feat: 班级小助手 阶段1-3(monorepo + 后端 REST/Socket.IO + Web 管理端)

This commit is contained in:
LoveChengke committed 2026-09-11 21:57:38 +08:00
commit 84ab49de10
102 files changed
+14751

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { onMounted, onUnmounted, watch } from 'vue';
import { useAuthStore } from '@/stores/auth';
import { useRealtimeStore } from '@/stores/realtime';
const auth = useAuthStore();
const realtime = useRealtimeStore();
/** 已登录时建立实时连接,退出登录时断开 */
function syncRealtime(token: string | null): void {
if (token) realtime.connect(token);
else realtime.disconnect();
}
onMounted(() => {
syncRealtime(auth.token);
});
watch(
() => auth.token,
(token) => syncRealtime(token),
);
onUnmounted(() => {
realtime.disconnect();
});
</script>
<template>
<router-view />
</template>