mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-12 11:00:16 +08:00
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { createApp } from 'vue'
|
|
import '@/@iconify/icons-bundle'
|
|
import ToastPlugin from 'vue-toast-notification'
|
|
import VuetifyUseDialog from 'vuetify-use-dialog'
|
|
import { configureNProgress, doneNProgress, startNProgress } from '@/api/nprogress'
|
|
import App from '@/App.vue'
|
|
import vuetify from '@/plugins/vuetify'
|
|
import { loadFonts } from '@/plugins/webfontloader'
|
|
import router from '@/router'
|
|
import store from '@/store'
|
|
import '@core/scss/template/index.scss'
|
|
import '@layouts/styles/index.scss'
|
|
import '@styles/styles.scss'
|
|
import 'vue-toast-notification/dist/theme-default.css'
|
|
|
|
loadFonts()
|
|
|
|
// Nprogress
|
|
configureNProgress()
|
|
|
|
// Create vue app
|
|
const app = createApp(App)
|
|
|
|
// Use plugins Mount vue app
|
|
app.use(vuetify)
|
|
.use(router)
|
|
.use(store)
|
|
.use(ToastPlugin, {
|
|
position: 'bottom-right',
|
|
})
|
|
.use(VuetifyUseDialog).mount('#app')
|
|
|
|
// 导航守卫
|
|
router.beforeEach((to, from, next) => {
|
|
// 通过 Vuex Store 检查用户是否已登录
|
|
const isAuthenticated = store.state.auth.token !== null
|
|
if (to.meta.requiresAuth && !isAuthenticated) {
|
|
// 如果路由需要登录权限且用户未登录,则跳转到登录页面
|
|
next('/login')
|
|
}
|
|
else {
|
|
// 否则,允许继续进行路由导航
|
|
startNProgress()
|
|
next()
|
|
}
|
|
})
|
|
|
|
router.afterEach(() => {
|
|
doneNProgress()
|
|
})
|