wujingjing
2024-07-22 bc4ab46fb5c4cb4435efabfe4b316be4ace5b026
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
44
45
46
47
48
49
50
51
import { computed, ref } from 'vue';
import type { ChatRoomItem } from '../layout/component/sidebar/components/types';
 
export type RoomConfig = {
    /** 是否直接调用大模型(通义千问)回答 */
    isAnswerByLLM: boolean;
    /** @description 从首页进去获取的第一个回复,回调函数 */
    firstResCb: any;
};
 
export type RoomConfigKey = keyof RoomConfig;
export const roomConfig = ref<Record<string, RoomConfig>>(null);
 
export const setRoomConfig = <T extends RoomConfigKey>(roomId: string, key: T, value: RoomConfig[T]) => {
    if (!roomConfig.value) {
        roomConfig.value = {};
    }
    if (!roomConfig.value[roomId]) {
        roomConfig.value[roomId] = {
            [key]: value,
        } as any;
    } else {
        roomConfig.value[roomId][key] = value;
    }
};
 
export const getRoomConfig = <T extends RoomConfigKey>(roomId: string, key: T) => {
    if (!roomConfig.value) {
        return null;
    }
    if (!roomConfig.value[roomId]) {
        return null;
    } else {
        return roomConfig.value[roomId][key];
    }
};
 
export const chatRoomList = ref<ChatRoomItem[]>([]);
 
export const activeRoomId = ref(null);
export const activeChatRoom = computed(() => chatRoomList.value?.find((item) => item.id === activeRoomId.value));
export const activeSampleId = ref(null);
export const activeSectionAId = ref(null);
export const activeLLMId = ref(null);
 
 
 
/**
 * 全局使用的 ref
 */
export const sectionAList = ref([]);