| | |
| | | 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'; |
| | | |
| | | /** |
| | | * 连接消息同步服务 |
| | |
| | | */ |
| | | 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), |
| | |
| | | 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 ?? {}; |
| | | }; |