From 50b87568817be0d36a391284490fad17bcb16b01 Mon Sep 17 00:00:00 2001
From: yangyin <1850366751@qq.com>
Date: 星期三, 20 十一月 2024 13:15:27 +0800
Subject: [PATCH] 修改主场景和此场景先后执行问题

---
 src/stores/chatRoom.ts |   35 +++++++++--------------------------
 1 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/src/stores/chatRoom.ts b/src/stores/chatRoom.ts
index c2aa55f..fb0fd98 100644
--- a/src/stores/chatRoom.ts
+++ b/src/stores/chatRoom.ts
@@ -88,23 +88,8 @@
 	鐭ヨ瘑搴�: 'ywicon-changyonggongjuzhishisuoyin',
 	涓氬姟鍦烘櫙: 'ywicon-yewu',
 };
-//鑾峰彇鍦烘櫙閫夋嫨鍒楄〃
-const getSceneGroupList = () => {
-	return new Promise((resolve, reject) => {
-		getSectionList()
-			.then((res) => {
-				sceneGroupList.value = res?.groups ?? [];
-				resolve(true);
-			})
-			.catch((error) => {
-				reject(error);
-			});
-	});
-};
-
-const getSelectListSample = async () => {
+const getSelectListSample = async (res1, res2) => {
 	try {
-		const [res1, res2] = await Promise.all([getSelectSample({}), getUserTemplateList()]);
 		const samples = res1?.samples ?? [];
 		const templateSamples = (res2?.templates ?? []).map((item) => ({
 			group_id: item.template_group,
@@ -132,16 +117,14 @@
  * 鑾峰彇鍏ㄥ眬鎵�鏈夋暟鎹�
  */
 export const getAllData = async () => {
-	return new Promise(async (resolve, reject) => {
-		try {
-			await getSceneGroupList();
-			await getSelectListSample();
-			await getHistoryChatRooms();
-			resolve(true);
-		} catch (error) {
-			reject(error);
-		}
-	});
+	Promise.all([getSectionList(), getSelectSample({}), getUserTemplateList()])
+		.then((res) => {
+			let [sectionList, selectSample, userTemplateList] = res;
+			sceneGroupList.value = sectionList?.groups ?? [];
+			getSelectListSample(selectSample, userTemplateList);
+		})
+		.catch((err) => {});
+	getHistoryChatRooms();
 };
 
 //#endregion

--
Gitblit v1.9.3