jiangchengfeiyi-Web/src/App.vue

48 lines
1017 B
Vue
Raw Normal View History

2024-10-23 09:55:22 +00:00
<template>
2024-12-08 02:40:37 +00:00
<el-config-provider :locale="zhCn">
<RouterView v-if="isRouterActive"></RouterView>
</el-config-provider>
2024-10-23 09:55:22 +00:00
</template>
<script setup lang="ts">
2024-11-05 12:19:45 +00:00
// 引入组件刷新功能
2024-12-19 10:55:48 +00:00
import { provide , nextTick , ref , onMounted } from 'vue'
2024-12-08 02:40:37 +00:00
import { ElConfigProvider } from 'element-plus'
2024-12-19 10:55:48 +00:00
import router from './router';
2024-12-08 02:40:37 +00:00
import zhCn from 'element-plus/es/locale/lang/zh-cn' //引入ElemenetPlus中文
2024-12-19 10:55:48 +00:00
import myAxios from './api/myAxios';
2024-11-05 12:19:45 +00:00
const isRouterActive = ref(true)
2024-12-19 10:55:48 +00:00
provide('reload', () => { //页面刷新
2024-11-05 12:19:45 +00:00
isRouterActive.value = false
nextTick(() => {
isRouterActive.value = true
})
})
2024-12-19 10:55:48 +00:00
onMounted(()=>{
checkLoginState()
})
const checkLoginState = async ()=>{ //监测登陆状态
2025-02-18 06:06:06 +00:00
console.log("start")
2024-12-19 10:55:48 +00:00
const res = await myAxios.get('/user/get/login')
2025-02-18 06:06:06 +00:00
console.log("end")
2024-12-19 10:55:48 +00:00
if(res.data.code != 1) {
router.push('/')
}
}
2024-10-23 09:55:22 +00:00
</script>
<style scoped>
2024-10-23 11:47:37 +00:00
html{
padding:0;
margin: 0;
}
body{
padding: 0;
margin: 0;
overflow: auto;
2024-10-23 11:47:37 +00:00
width: 100%;
min-width: 1200px;
2024-10-23 11:47:37 +00:00
}
2024-10-23 09:55:22 +00:00
</style>