2021-12-10 14:11:49 +08:00
|
|
|
|
import { createApp } from 'vue';
|
|
|
|
|
import App from './App.vue';
|
|
|
|
|
import router, { setupRouter } from '@/router';
|
|
|
|
|
import { setupStore } from '@/store';
|
|
|
|
|
import { setupNaive, setupDirectives } from '@/plugins';
|
|
|
|
|
import { AppProvider } from '@/components/Application';
|
2021-12-15 22:16:16 +08:00
|
|
|
|
import { setHtmlTheme } from '@/utils/style'
|
2021-12-10 14:11:49 +08:00
|
|
|
|
|
2021-12-14 15:53:30 +08:00
|
|
|
|
async function appInit() {
|
2021-12-10 14:11:49 +08:00
|
|
|
|
const appProvider = createApp(AppProvider);
|
|
|
|
|
|
|
|
|
|
const app = createApp(App);
|
|
|
|
|
|
|
|
|
|
// 注册全局常用的 naive-ui 组件
|
|
|
|
|
setupNaive(app);
|
|
|
|
|
|
|
|
|
|
// 注册全局自定义指令,如:v-permission权限指令
|
|
|
|
|
setupDirectives(app);
|
|
|
|
|
|
|
|
|
|
// 挂载状态管理
|
|
|
|
|
setupStore(app);
|
|
|
|
|
|
2021-12-15 22:16:16 +08:00
|
|
|
|
// 处理主题色
|
|
|
|
|
setHtmlTheme()
|
|
|
|
|
|
2021-12-10 14:11:49 +08:00
|
|
|
|
//优先挂载一下 Provider 解决路由守卫,Axios中可使用,Dialog,Message 等之类组件
|
|
|
|
|
appProvider.mount('#appProvider', true);
|
|
|
|
|
|
|
|
|
|
// 挂载路由
|
|
|
|
|
await setupRouter(app);
|
|
|
|
|
|
|
|
|
|
// 路由准备就绪后挂载APP实例
|
|
|
|
|
await router.isReady();
|
|
|
|
|
|
|
|
|
|
app.mount('#app', true);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-14 15:53:30 +08:00
|
|
|
|
void appInit();
|