feat: 完成在线人数store改造

This commit is contained in:
陈淳
2024-01-15 12:08:31 +08:00
parent e64b12097a
commit 40195ea993
4 changed files with 860 additions and 41 deletions

View File

@@ -7,15 +7,15 @@
</template>
<script setup>
import signalR from "@/utils/signalR";
import useAuths from "@/hooks/useAuths";
import useConfigStore from "@/stores/config";
import { ElConfigProvider } from "element-plus";
import { onMounted,watch } from "vue";
const { tokenValue } = useAuths();
import useUserStore from "@/stores/user.js";
import { onMounted,watch,computed } from "vue";
const userStore = useUserStore();
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
const locale = zhCn;
const configStore = useConfigStore();
const token = computed(() => useUserStore().token);
// 判断是否有loading有的话去掉
const loading = document.getElementById("Loading");
if (loading !== null) {
@@ -31,16 +31,16 @@ onMounted(async () => {
});
// watch(
// () => tokenValue,
// (val,oldValue) => {
// console.log("token发生改变");
// if (val) {
// signalR.close();
// signalR.init(`main`);
// }
// },
// { deep:true }
// );
watch(
() => token,
(val,oldValue) => {
console.log("token发生改变");
if (val) {
signalR.close();
signalR.init(`main`);
}
},
{immediate:true,deep:true}
);
</script>
<style scoped></style>