45 changed files with 280 additions and 114 deletions
@ -0,0 +1,5 @@ |
|||||
|
<template> |
||||
|
<w-platform-page></w-platform-page> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"></script> |
@ -0,0 +1,46 @@ |
|||||
|
import packageJson from '../package.json'; |
||||
|
import { createApp } from 'vue'; |
||||
|
import platform from 'platform-core'; |
||||
|
import { ApplicationInitializer, ComponentManager } from 'platform-core'; |
||||
|
import localMocks from './mock'; |
||||
|
import localI18nMessages from './i18n'; |
||||
|
import localMenus from './menus/menus.json'; |
||||
|
import localRoutes from './routes/routes.json'; |
||||
|
import localComponents from './components'; |
||||
|
import App from './App.vue'; |
||||
|
|
||||
|
import 'platform-core/dist/css/platform-core.css'; |
||||
|
import './css/tailwind.css'; |
||||
|
|
||||
|
// 设置远程组件加载器
|
||||
|
// 覆盖 platform-core 包中的 remoteComponentLoader 函数
|
||||
|
// 只有在主前端项目中编写如下的 remoteComponentLoader 函数才能实现 webpack MF 的 shared 功能
|
||||
|
ComponentManager.setRemoteComponentLoader((moduleName: string, componentName: string): any => { |
||||
|
return async () => { |
||||
|
await __webpack_init_sharing__('default'); |
||||
|
const container = window[moduleName]; |
||||
|
if (container) { |
||||
|
await container.init(__webpack_share_scopes__.default); |
||||
|
const factory = await window[moduleName].get(componentName); |
||||
|
return factory(); |
||||
|
} else { |
||||
|
throw new Error('window["' + moduleName + '"] is undefined!'); |
||||
|
} |
||||
|
}; |
||||
|
}); |
||||
|
|
||||
|
//初始化平台
|
||||
|
ApplicationInitializer.initialize({ |
||||
|
moduleName: packageJson.name, |
||||
|
moduleVersion: packageJson.version, |
||||
|
localMocks: localMocks, |
||||
|
localI18nMessages: localI18nMessages, |
||||
|
localMenus: localMenus, |
||||
|
localRoutes: localRoutes, |
||||
|
localComponents: localComponents, |
||||
|
callback: () => { |
||||
|
const app = createApp(App); |
||||
|
app.use(platform); |
||||
|
app.mount('#app'); |
||||
|
}, |
||||
|
}); |
@ -0,0 +1,7 @@ |
|||||
|
/** |
||||
|
* 引入 tailwind.css |
||||
|
*/ |
||||
|
|
||||
|
@tailwind base; |
||||
|
@tailwind components; |
||||
|
@tailwind utilities; |
@ -0,0 +1,18 @@ |
|||||
|
/** |
||||
|
* 本文件用于定义前端多语言消息 |
||||
|
* 多语言消息文件可以为1个或多个 |
||||
|
*/ |
||||
|
|
||||
|
import messages from './messages.json'; |
||||
|
import messages_tw_CN from './messages_tw_CN.json'; |
||||
|
import messages_zh_CN from './messages_zh_CN.json'; |
||||
|
|
||||
|
const localI18nMessages = [ |
||||
|
{ |
||||
|
en: messages, |
||||
|
tw_CN: messages_tw_CN, |
||||
|
zh_CN: messages_zh_CN, |
||||
|
}, |
||||
|
]; |
||||
|
|
||||
|
export default localI18nMessages; |
@ -0,0 +1 @@ |
|||||
|
import('./boostrap'); |
@ -0,0 +1,20 @@ |
|||||
|
/** |
||||
|
* 本文件用于定义前端 mock, 采用 json 文件定义 mock, 单个 mock 配置说明: |
||||
|
{ |
||||
|
"enable": true, |
||||
|
"url": "/api/sample/action1", |
||||
|
"method": "get", |
||||
|
"response": { |
||||
|
"code": 200, |
||||
|
"messageI18nKey": "success", |
||||
|
"message": "success", |
||||
|
"data": { |
||||
|
"message": "This is a message for Action 1" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
const localMocks = []; |
||||
|
|
||||
|
export default localMocks; |
@ -0,0 +1,33 @@ |
|||||
|
import type { AppType } from 'platform-core/types'; |
||||
|
|
||||
|
declare global { |
||||
|
interface Window { |
||||
|
APP: AppType; |
||||
|
__webpack_init_sharing__: any; |
||||
|
__webpack_share_scopes__: any; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
declare module '*.vue' { |
||||
|
import type { App, DefineComponent } from 'vue'; |
||||
|
|
||||
|
const component: DefineComponent<{}, {}, any> & { |
||||
|
install(app: App): void; |
||||
|
}; |
||||
|
|
||||
|
export default component; |
||||
|
} |
||||
|
|
||||
|
declare module 'vue/types/vue' { |
||||
|
interface VueConstructor { |
||||
|
$t: any; |
||||
|
$fc: any; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
declare module '@vue/runtime-core' { |
||||
|
interface ComponentCustomProperties { |
||||
|
$t: any; |
||||
|
$fc: any; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue