wujingjing
2025-03-12 3b86eca19001658c91213b05f4b03414f791f414
src/stores/global.ts
@@ -1,7 +1,11 @@
import { MAIN_URL } from '../constants';
import type { Ref } from 'vue';
import { ref } from 'vue';
import { GetSystemGlobalConfig } from '../api/system';
import { SSE_URL } from '../constants';
import { accessSessionKey } from '../utils/request';
import { SSEClient } from '../utils/sse/SSEClient';
import { Local } from '../utils/storage';
import type { SystemGlobalConfig } from '../views/types';
/**
 * 连接消息同步服务
@@ -9,10 +13,12 @@
 */
const connectMsgSyncService = () => {
   if (!Local.get(accessSessionKey)) return;
   if (!SSE_URL) return;
   // 创建实例
   const sseClient = new SSEClient(
      `${MAIN_URL}chat/connect_broadcast_chat`,
      // `https://widev.cpolar.top/sse/chat/connect_broadcast_chat`,
      // `${MAIN_URL}events`
      SSE_URL
   );
   sseClient.connect({
      websessionid: Local.get(accessSessionKey),
@@ -20,6 +26,18 @@
   return sseClient;
};
// export const sseClient = connectMsgSyncService();
export const sseClient = null;
export const sseClient = connectMsgSyncService();
/** @description 系统全局配置 */
export const systemGlobalConfig: Ref<SystemGlobalConfig> = ref({} as SystemGlobalConfig);
/**
 * 获取系统全局配置
 * @returns
 */
export const getSystemGlobalConfig = async () => {
   const res = await GetSystemGlobalConfig({
      config_key_list: ['ui.project_city'].join(','),
   });
   systemGlobalConfig.value = res.values ?? {};
};