From be0b1a911b5e36faf8bcc61c452520e97f00cd16 Mon Sep 17 00:00:00 2001
From: yangyin <1850366751@qq.com>
Date: 星期一, 28 十月 2024 16:08:22 +0800
Subject: [PATCH] 默认应用场景选择第一个

---
 src/stores/chatRoom.ts |  101 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 89 insertions(+), 12 deletions(-)

diff --git a/src/stores/chatRoom.ts b/src/stores/chatRoom.ts
index 13421b5..3bc36f6 100644
--- a/src/stores/chatRoom.ts
+++ b/src/stores/chatRoom.ts
@@ -1,18 +1,95 @@
-import { computed, ref, watch } from 'vue';
-import type { ChatRoomItem } from '../layout/component/sidebar/waterLeftAside/types';
-import { Local } from '../utils/storage';
+import { computed, ref } from 'vue';
+import type { ChatRoomItem } from '../layout/component/sidebar/components/types';
+import { getSectionList } from '../api/ai/chat';
 
-export const chatRoomList = ref<ChatRoomItem[]>(Local.get('chatRoomList'));
+/**
+ * Room 鍏宠仈鐨勪竴浜涢厤缃�
+ */
+export type RoomConfig = {
+	/** 鏄惁鐩存帴璋冪敤澶фā鍨嬶紙閫氫箟鍗冮棶锛夊洖绛� */
+	isAnswerByLLM: boolean;
+	/** @description 浠庨椤佃繘鍘昏幏鍙栫殑绗竴涓洖澶嶏紝鍥炶皟鍑芥暟 */
+	firstResCb: any;
+	/** @description 褰撳墠鑱婂ぉ瀹ょ殑 group_type */
+	activeGroupType: string;
+};
 
-watch(
-	() => chatRoomList.value,
-	(val) => {
-		Local.set('chatRoomList', val);
-	},
-	{
-		deep: true,
+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 = {};
 	}
-);
+	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 (!roomId) return;
+	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 topGroupId = 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([]);
+
+//#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',
+};
+const getSceneGroupList = async () => {
+	const res = await getSectionList();
+	sceneGroupList.value = res?.groups ?? [];
+};
+/**
+ * 鑾峰彇鍏ㄥ眬鎵�鏈夋暟鎹�
+ */
+export const getAllData = async () => {
+	getSceneGroupList();
+
+};
+
+//#endregion

--
Gitblit v1.9.3