wujingjing
2025-03-03 26e2d14957500f4f738945d4c71d1288a72c85cb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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';
 
/**
 * 连接消息同步服务
 * @returns
 */
const connectMsgSyncService = () => {
    if (!Local.get(accessSessionKey)) return;
    if (!SSE_URL) return;
    // 创建实例
    const sseClient = new SSEClient(
        // `https://widev.cpolar.top/sse/chat/connect_broadcast_chat`,
        // `${MAIN_URL}events`
        SSE_URL
    );
    sseClient.connect({
        websessionid: Local.get(accessSessionKey),
    });
    return sseClient;
};
 
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 ?? {};
};