22 lines
938 B
TypeScript
22 lines
938 B
TypeScript
import { createApp } from 'vue'
|
|
import { createPinia } from 'pinia'
|
|
import ElementPlus from 'element-plus'
|
|
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
|
import 'element-plus/dist/index.css'
|
|
import './styles/tokens.css'
|
|
import App from './App.vue'
|
|
import { router } from './router'
|
|
import { useAuth } from './stores/auth'
|
|
import { usePlatform } from './stores/platform'
|
|
|
|
async function start() {
|
|
if (import.meta.env.DEV && import.meta.env.VITE_API_MODE === 'mock') {
|
|
const { worker } = await import('./mocks/browser')
|
|
await worker.start({ onUnhandledRequest: 'bypass' })
|
|
}
|
|
const app = createApp(App); app.use(createPinia()); app.use(router); app.use(ElementPlus, { locale: zhCn })
|
|
window.addEventListener('vdi:unauthorized', () => { useAuth().clear(); usePlatform().clear(); if (router.currentRoute.value.path !== '/login') void router.replace('/login') })
|
|
await router.isReady(); app.mount('#app')
|
|
}
|
|
void start()
|