Files
nxxmdata/government-admin/src/App.vue

48 lines
1.0 KiB
Vue
Raw Normal View History

2025-09-17 18:04:28 +08:00
<template>
<a-config-provider :locale="zhCN">
2025-09-17 18:04:28 +08:00
<router-view />
</a-config-provider>
2025-09-17 18:04:28 +08:00
</template>
<script setup>
import zhCN from 'ant-design-vue/es/locale/zh_CN'
2025-09-17 18:04:28 +08:00
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
2025-09-17 18:04:28 +08:00
const router = useRouter()
const userStore = useUserStore()
2025-09-17 18:04:28 +08:00
// 检查登录状态
onMounted(() => {
const token = userStore.token
2025-09-19 17:52:28 +08:00
// 如果没有token且当前不是登录页则跳转到登录页
if (!token && router.currentRoute.value.path !== '/login') {
router.push('/login')
}
// 如果有token且当前是登录页则跳转到首页
if (token && router.currentRoute.value.path === '/login') {
router.push('/')
2025-09-19 17:52:28 +08:00
}
2025-09-17 18:04:28 +08:00
})
</script>
<style>
2025-09-17 18:04:28 +08:00
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
background-color: #f5f5f5;
2025-09-17 18:04:28 +08:00
}
#app {
min-height: 100vh;
2025-09-17 18:04:28 +08:00
}
</style>