From 7e7424b2662e5b27dcc1c0d37f43e909e0b15ee1 Mon Sep 17 00:00:00 2001 From: songshankun <songshankun@foxmail.com> Date: 星期四, 02 十一月 2023 16:47:38 +0800 Subject: [PATCH] feat: 轮询plc/设备/调整集群状态组件/title组件加图标 --- 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