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

50 lines
1.2 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>
import mainHub from "@/hubs/mainHub.js";
import noticeSignalR from "@/hubs/noticeHub.js";
2024-05-23 23:40:55 +08:00
import bbsNoticeSignalR from "@/hubs/bbsNoticeHub.js";
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";
2024-01-15 12:08:31 +08:00
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-05-23 23:40:55 +08:00
//如果登录了,再连接消息通知
bbsNoticeSignalR();
noticeSignalR();
2024-05-23 23:40:55 +08:00
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) => {
//console.log("token发生改变");
2024-01-15 12:08:31 +08:00
if (val) {
mainHub();
2024-01-15 12:08:31 +08:00
}
},
{ immediate: true, deep: true }
2024-01-15 12:08:31 +08:00
);
2023-12-14 10:15:23 +08:00
</script>
2023-12-27 22:41:57 +08:00
<style scoped></style>