gerson
2024-07-07 d5f17f079d4af2a173015dc86a4d6d472731fac6
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
import { computed, ref, watch } from 'vue';
import type { ChatRoomItem } from '../layout/component/sidebar/components/types';
import { Local } from '../utils/storage';
 
export type RoomConfig = {
    /** 是否直接调用大模型(通义千问)回答 */
    isAnswerByLLM: boolean;
};
 
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 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);