refactor: ♻️ stomp 连接管理器优化,添加指数退避重连策略,调整 WebSocket 服务的目录结构

This commit is contained in:
Ray.Hao
2025-04-25 18:39:26 +08:00
parent 152789001a
commit f3576d51f2
11 changed files with 287 additions and 202 deletions

View File

@@ -324,10 +324,10 @@ import { useUserStore } from "@/store/modules/user.store";
import { formatGrowthRate } from "@/utils";
import { useTransition, useDateFormat } from "@vueuse/core";
import { Connection, Failed } from "@element-plus/icons-vue";
import { useWebSocketOnlineUsers } from "@/hooks/useWebSocketOnlineUsers";
import { useOnlineCount } from "@/hooks/websocket/services/useOnlineCount";
// 在线用户数量组件相关
const { onlineUserCount, lastUpdateTime, isConnected } = useWebSocketOnlineUsers();
const { onlineUserCount, lastUpdateTime, isConnected } = useOnlineCount();
// 记录上一次的用户数量用于计算趋势
const previousCount = ref(0);

View File

@@ -142,7 +142,7 @@
import { useDictStoreHook } from "@/store/modules/dict.store";
import { useDateFormat } from "@vueuse/core";
import DictAPI, { DictItemForm } from "@/api/system/dict.api";
import { useWebSocketDict, DictMessage } from "@/hooks/useWebSocketDict";
import { useDictSync, DictMessage } from "@/hooks/websocket/services/useDictSync";
// 性别字典编码
const DICT_CODE = "gender";
@@ -161,7 +161,7 @@ const dictForm = ref<DictItemForm | null>(null);
const selectedGender = ref("");
// 初始化WebSocket
const dictWebSocket = useWebSocketDict();
const dictWebSocket = useDictSync();
// 获取连接状态
const wsConnected = computed(() => dictWebSocket.isConnected);

View File

@@ -97,7 +97,7 @@
</template>
<script setup lang="ts">
import { useStomp } from "@/hooks/useStomp";
import { useStomp } from "@/hooks/websocket/core/useStomp";
import { useUserStoreHook } from "@/store/modules/user.store";
const userStore = useUserStoreHook();