refactor: ♻️ 重构首页ws获取在线人数的代码

重构首页ws获取在线人数的代码
This commit is contained in:
Theo
2024-09-28 00:12:29 +08:00
parent b797acbb49
commit 463e5eb419
2 changed files with 3 additions and 3 deletions

View File

@@ -69,7 +69,7 @@ export const useUserStore = defineStore("user", () => {
// remove token // remove token
function resetToken() { function resetToken() {
return new Promise<void>((resolve) => { return new Promise<void>((resolve) => {
localStorage.setItem(TOKEN_KEY, ""); removeToken();
resetRouter(); resetRouter();
resolve(); resolve();
}); });

View File

@@ -188,7 +188,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import WebSocketManager from "@/api/socket"; import WebSocketManager from "@/utils/socket";
defineOptions({ defineOptions({
name: "Dashboard", name: "Dashboard",
@@ -390,7 +390,7 @@ const getNoticeLevelTag = (type: number) => {
}; };
function connectWebSocket() { function connectWebSocket() {
WebSocketManager.getWebSocketClient("/topic/onlineUserCount", (message) => { WebSocketManager.getOrCreateClient("/topic/onlineUserCount", (message) => {
onlineUserCount.value = JSON.parse(message); onlineUserCount.value = JSON.parse(message);
}); });
} }