54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
import { createApp } from 'vue'
|
|
import App from '@/App.vue'
|
|
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|
import 'element-plus/dist/index.css'
|
|
import 'element-plus/theme-chalk/dark/css-vars.css'
|
|
import 'viewerjs/dist/viewer.css'
|
|
import VueViewer from 'v-viewer'
|
|
import '@/assets/less/index.less'
|
|
import '@/assets/css/all.min.css'
|
|
import '@/assets/js/all.min.js'
|
|
import router from './router'
|
|
import { loadAndAddDynamicRoutes } from './router'
|
|
import { createPinia } from 'pinia'
|
|
import { useAuthStore } from './stores/auth'
|
|
import { redirectToAuthorize, isAuthHandoff } from '@/utils/authClient'
|
|
import UmoEditor from '@/views/components/UmoEditor.vue';
|
|
|
|
if (typeof window !== 'undefined' && !window.global) {
|
|
window.global = window;
|
|
}
|
|
|
|
const app = createApp(App)
|
|
const pinia = createPinia()
|
|
app.component('UmoEditor', UmoEditor);
|
|
|
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|
app.component(key, component)
|
|
}
|
|
|
|
app.use(pinia)
|
|
app.use(router)
|
|
app.use(VueViewer)
|
|
|
|
const authStore = useAuthStore()
|
|
if (!isAuthHandoff()) {
|
|
authStore.checkAuth()
|
|
|
|
if (authStore.isLoggedIn) {
|
|
loadAndAddDynamicRoutes()
|
|
.catch(err => {
|
|
console.error('应用启动时加载动态路由失败:', err);
|
|
})
|
|
.then(() => {
|
|
const token = localStorage.getItem('token');
|
|
if (!token) {
|
|
redirectToAuthorize().catch((err) => {
|
|
console.error('跳转统一认证失败:', err);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
app.mount('#app') |