| | |
| | | import { computed, ref } from 'vue'; |
| | | import type { ChatRoomItem } from '../layout/component/sidebar/components/types'; |
| | | import { getSectionList } from '../api/ai/chat'; |
| | | |
| | | /** |
| | | * Room 关联的一些配置 |
| | | */ |
| | | export type RoomConfig = { |
| | | /** 是否直接调用大模型(通义千问)回答 */ |
| | | isAnswerByLLM: boolean; |
| | | /** @description 从首页进去获取的第一个回复,回调函数 */ |
| | | firstResCb: any; |
| | | /** @description 当前聊天室的 group_type */ |
| | | activeGroupType: string; |
| | | }; |
| | | |
| | | 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 (!roomId) return; |
| | | if (!roomConfig.value) { |
| | | roomConfig.value = {}; |
| | | } |
| | |
| | | }; |
| | | |
| | | export const getRoomConfig = <T extends RoomConfigKey>(roomId: string, key: T) => { |
| | | if (!roomId) return; |
| | | if (!roomConfig.value) { |
| | | return null; |
| | | } |
| | |
| | | export const activeSectionAId = ref(null); |
| | | export const activeLLMId = ref(null); |
| | | |
| | | |
| | | /** @description 当前聊天室 groupType */ |
| | | export const activeGroupType = computed({ |
| | | get: () => { |
| | | const result = getRoomConfig(activeRoomId.value, 'activeGroupType'); |
| | | return result; |
| | | }, |
| | | set: (value) => { |
| | | setRoomConfig(activeRoomId.value, 'activeGroupType', value); |
| | | }, |
| | | }); |
| | | |
| | | /** |
| | | * 全局使用的 ref |
| | | */ |
| | | export const sectionAList = ref([]); |
| | | export const sectionAList = ref([]); |
| | | |
| | | //#region ====================== 全局使用数据 ====================== |
| | | // group 列表 |
| | | export const sceneGroupList = ref([]); |
| | | // groupType 列表 |
| | | export const groupTypeList = computed(() => Array.from(new Set(sceneGroupList.value.map((item) => item.group_type)))); |
| | | |
| | | export const groupTypeMapIcon = { |
| | | 办公助手: 'ywicon-bangong', |
| | | 知识库: 'ywicon-changyonggongjuzhishisuoyin', |
| | | 业务场景: 'ywicon-yewu', |
| | | }; |
| | | |
| | | /** |
| | | * 获取全局所有数据 |
| | | */ |
| | | export const getAllData = async () => { |
| | | const res = await getSectionList(); |
| | | sceneGroupList.value = res?.groups ?? []; |
| | | }; |
| | | //#endregion |