| | |
| | | import { computed, ref, watch } from 'vue'; |
| | | import { computed, ref } from 'vue'; |
| | | import type { ChatRoomItem } from '../layout/component/sidebar/components/types'; |
| | | import { Local } from '../utils/storage'; |
| | | |
| | | 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); |
| | | export const activeSectionAId = ref(null); |
| | | export const activeLLMId = ref(null); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 全局使用的 ref |
| | | */ |
| | | export const sectionAList = ref([]); |