goview_vue/src/main.ts

60 lines
1.3 KiB
TypeScript
Raw Normal View History

import { createApp } from 'vue'
import App from './App.vue'
import router, { setupRouter } from '@/router'
import i18n from '@/i18n/index'
import { setupStore } from '@/store'
import { setupNaive, setupDirectives, setupCustomComponents, initFunction } from '@/plugins'
2022-04-14 10:05:57 +08:00
import { GoAppProvider } from '@/components/GoAppProvider/index'
2021-12-20 14:29:29 +08:00
import { setHtmlTheme } from '@/utils'
2022-03-15 17:49:02 +08:00
2022-07-15 00:11:42 +08:00
// 引入全局样式
import '@/styles/pages/index.scss'
2022-03-15 17:49:02 +08:00
// 引入动画
2022-01-13 16:20:25 +08:00
import 'animate.css/animate.min.css'
2022-03-15 17:49:02 +08:00
// 引入标尺
import 'vue3-sketch-ruler/lib/style.css'
2022-01-13 16:20:25 +08:00
async function appInit() {
2022-04-14 10:05:57 +08:00
const goAppProvider = createApp(GoAppProvider)
2021-12-10 14:11:49 +08:00
const app = createApp(App)
2021-12-10 14:11:49 +08:00
// 注册全局常用的 naive-ui 组件
setupNaive(app)
2021-12-10 14:11:49 +08:00
2021-12-19 19:19:46 +08:00
// 注册全局自定义指令
setupDirectives(app)
2021-12-10 14:11:49 +08:00
2021-12-19 19:19:46 +08:00
// 注册全局自定义组件
setupCustomComponents(app)
2021-12-10 14:11:49 +08:00
// 挂载状态管理
setupStore(app)
2021-12-10 14:11:49 +08:00
2022-01-09 19:22:55 +08:00
// 解决路由守卫Axios中可使用DialogMessage 等全局组件
2022-04-14 10:05:57 +08:00
goAppProvider.mount('#appProvider', true)
2021-12-10 14:11:49 +08:00
// 挂载路由
2022-01-09 19:22:55 +08:00
setupRouter(app)
2021-12-10 14:11:49 +08:00
// 路由准备就绪后挂载APP实例
await router.isReady()
// Store 准备就绪后处理主题色
setHtmlTheme()
// 语言注册
app.use(i18n)
2021-12-10 14:11:49 +08:00
// 挂载到页面
app.mount('#app', true)
// 挂载到 window
window['$vue'] = app
2021-12-10 14:11:49 +08:00
}
appInit().then(() => {
initFunction()
})