From 3a4e0e2208a48c43639cdd4a7ef883a11e747fbf Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期四, 02 十一月 2023 16:51:16 +0800
Subject: [PATCH] Merge branch 'dev' of http://192.168.5.5:10010/r/web/bulletin-board-style1 into wn

---
 src/stores/tasks.ts |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts
index 02f2694..92035a0 100644
--- a/src/stores/tasks.ts
+++ b/src/stores/tasks.ts
@@ -28,6 +28,11 @@
     return getTaskList(params)
       .then((res) => {
         channels.value = res.data
+
+        // 棣栨鑾峰彇閫氶亾鏁版嵁鏃惰嚜鍔ㄩ�変腑绗竴涓换鍔�
+        if (!activeTask?.value) {
+          selectFirstTask(channels.value)
+        }
       })
       .catch((err) => {
         console.error(err)
@@ -35,6 +40,19 @@
       })
   }
 
+  function selectFirstTask(channels: TasksGroupByChannel) {
+    const firstNotEmptyChannel = Object.entries(channels).find((ele) => {
+      const taskList = (ele[1] as TasksResponse)?.Tasks
+
+      return !!taskList.length
+    })
+
+    if (firstNotEmptyChannel) {
+      const channelNumber = +firstNotEmptyChannel[0]
+      activeTask.value = channels[channelNumber].Tasks[0]
+    }
+  }
+
   /**
    * 鏁版嵁鍔犺浇瀹屾垚鍚庤嚜鍔ㄩ�変腑涓�涓换鍔�
    */

--
Gitblit v1.8.0