Files
Yi.Admin/Yi.Bbs.Vue3/src/App.vue

47 lines
1.1 KiB
Vue
Raw Normal View History

2023-12-27 22:41:57 +08:00
<script setup></script>
2023-12-14 10:15:23 +08:00
<template>
2023-12-27 22:41:57 +08:00
<el-config-provider :locale="locale">
<RouterView />
</el-config-provider>
2023-12-14 10:15:23 +08:00
</template>
<script setup>
2024-01-15 00:25:25 +08:00
import signalR from "@/utils/signalR";
2023-12-14 10:15:23 +08:00
import useConfigStore from "@/stores/config";
2023-12-27 22:41:57 +08:00
import { ElConfigProvider } from "element-plus";
2024-01-15 12:08:31 +08:00
import useUserStore from "@/stores/user.js";
import { onMounted,watch,computed } from "vue";
const userStore = useUserStore();
2023-12-27 22:41:57 +08:00
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
const locale = zhCn;
2023-12-14 10:15:23 +08:00
const configStore = useConfigStore();
2024-01-15 12:08:31 +08:00
const token = computed(() => useUserStore().token);
2023-12-27 22:41:57 +08:00
// 判断是否有loading有的话去掉
const loading = document.getElementById("Loading");
if (loading !== null) {
document.body.removeChild(Loading);
}
2023-12-14 10:15:23 +08:00
2023-12-27 22:41:57 +08:00
//加载全局信息
onMounted(async () => {
await configStore.getConfig();
2024-01-15 00:25:25 +08:00
// setInterval(() => {
// console.log("token的值"+tokenValue.value);
// }, 1000); // 1000毫秒即1秒
2023-12-27 22:41:57 +08:00
});
2024-01-15 00:25:25 +08:00
2024-01-15 12:08:31 +08:00
watch(
() => token,
(val,oldValue) => {
2024-01-17 16:31:01 +08:00
//console.log("token发生改变");
2024-01-15 12:08:31 +08:00
if (val) {
signalR.close();
signalR.init(`main`);
}
},
{immediate:true,deep:true}
);
2023-12-14 10:15:23 +08:00
</script>
2023-12-27 22:41:57 +08:00
<style scoped></style>