From 6ecaed01cf576560a31ae960d0cdf1473e03c6b8 Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期一, 11 八月 2025 15:40:26 +0800
Subject: [PATCH] ID1975-自动更新流程zancun

---
 src/store/bedsideAuxiliaryScreen.ts |   34 +++++++++++++++-------------------
 1 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/store/bedsideAuxiliaryScreen.ts b/src/store/bedsideAuxiliaryScreen.ts
index 1424463..fbcd79c 100644
--- a/src/store/bedsideAuxiliaryScreen.ts
+++ b/src/store/bedsideAuxiliaryScreen.ts
@@ -1,7 +1,6 @@
 import { defineStore } from "pinia";
 import { ref } from "vue";
 import dayjs from "dayjs";
-import cache from "../utils/cache";
 import { EventSourcePolyfill } from "event-source-polyfill";
 import type { BedsideAuxiliaryScreen, SseMsgData } from "./type/bedsideAuxiliaryScreen.type";
 import type { Task } from "./type/task.type";
@@ -11,12 +10,16 @@
   formatDeviceData,
 } from "./type/bedsideAuxiliaryScreen.type";
 import { ElMessage } from "element-plus/es";
+import { Local } from "@/utils/storage";
 
 export const useBedsideAuxiliaryScreenStore = defineStore(
   "bedsideAuxiliaryScreen",
   () => {
     /** 设备编号 */
-    const deviceCode = ref<string>(cache.get("devcieCode") || "");
+    const deviceCode = ref<string>(Local.get("devcieCode") || "");
+
+    /** 副屏版本号 */
+    const version = ref<string>(Local.get("version") || "0.0.0");
 
     /** 设备信息数据 */
     const deviceData = ref<BedsideAuxiliaryScreen>(defaultDeviceData());
@@ -24,13 +27,19 @@
     /** 任务列表 */
     const taskData = ref<Task[]>([]);
 
+    /** 设置副屏版本号 */
+    const setVersion = (val: string) => {
+      version.value = val;
+      Local.set("version", val);
+    }
+
     /**
      * 设置设备编号
      * @param code
      */
     const setDeviceCode = (code: string) => {
       deviceCode.value = code;
-      cache.set("devcieCode", code);
+      Local.set("devcieCode", code);
     };
 
     /**
@@ -47,22 +56,6 @@
     const pushTask = (taskItem: Task) => {
       taskData.value.push(taskItem);
     };
-
-    /**
-     * 是否将当前任务设置为已过期
-     * @param i
-     */
-    // const deleteTask = (i: number) => {
-    //   const task = taskData.value[i];
-    //   if (task) {
-    //     // 二次判断,判断任务时间是否早于或等于当前时间
-    //     const taskTime = dayjs(task.taskDate).second(0).millisecond(0);
-    //     const now = dayjs().second(0).millisecond(0); // 秒和毫秒都去掉
-    //     if (!taskTime.isAfter(now)) {
-    //       taskData.value[i].overdue = true
-    //     }
-    //   }
-    // };
 
     /** 设置当前定时任务 */
     const setSyncTask = (taskItem: Task) => {
@@ -154,6 +147,7 @@
           }
 
           deviceData.value = formatDeviceData(deviceData.value, dataBody);
+          setDeviceCode(dataBody.服务端版本号);
         }
       };
     };
@@ -180,6 +174,7 @@
     };
 
     return {
+      version,
       deviceCode,
       deviceData,
       setDeviceCode,
@@ -193,6 +188,7 @@
       pushTask,
       setSyncTask,
       clearTask,
+      setVersion,
     };
   }
 );

--
Gitblit v1.8.0