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

48 lines
1.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<a-config-provider :locale="zhCN">
<router-view />
</a-config-provider>
</template>
<script setup>
import zhCN from 'ant-design-vue/es/locale/zh_CN'
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
const router = useRouter()
const userStore = useUserStore()
// 检查登录状态
onMounted(() => {
const token = userStore.token
// 如果没有token且当前不是登录页则跳转到登录页
if (!token && router.currentRoute.value.path !== '/login') {
router.push('/login')
}
// 如果有token且当前是登录页则跳转到首页
if (token && router.currentRoute.value.path === '/login') {
router.push('/')
}
})
</script>
<style>
* {
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;
}
#app {
min-height: 100vh;
}
</style>