From 0e5850157c1a9f77390988acb61b6b8651a08f0b Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期一, 11 八月 2025 15:57:48 +0800
Subject: [PATCH] Merge branch 'ID1975-副屏自动更新' into test
---
src/views/mobile/bedsideAuxiliaryScreen/index.vue | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/src/views/mobile/bedsideAuxiliaryScreen/index.vue b/src/views/mobile/bedsideAuxiliaryScreen/index.vue
index 3154799..6bfef1c 100644
--- a/src/views/mobile/bedsideAuxiliaryScreen/index.vue
+++ b/src/views/mobile/bedsideAuxiliaryScreen/index.vue
@@ -18,13 +18,22 @@
</template>
<script lang="ts" setup>
-import { ref, watch, computed, onMounted, defineAsyncComponent } from "vue";
+import {
+ ref,
+ watch,
+ computed,
+ onMounted,
+ defineAsyncComponent,
+ onBeforeUnmount,
+} from "vue";
// @ts-ignore
import Header from "./components/Header.vue";
import { useBedsideAuxiliaryScreenStore } from "@/store/bedsideAuxiliaryScreen";
import { EPageType } from "@/store/type/bedsideAuxiliaryScreen.type";
-import { getAvailableHeightByClass } from "@/utils/utils";
+import { getAvailableHeightByClass, delay } from "@/utils/utils";
import { useWindowSize } from "@/composables/useWindowSize";
+import { getServiceVersionApi } from "@/utils/httpApi";
+import { ElMessage } from "element-plus";
// 未排班时的组件
const UnplannedSchedule = defineAsyncComponent(
() => import("./pages/UnplannedSchedule.vue")
@@ -47,6 +56,9 @@
const bedsideAuxiliaryScreenStore = useBedsideAuxiliaryScreenStore();
const cotentHeight = ref(0);
const { width, height } = useWindowSize();
+
+const versionTimer = 1000 * 60 * 5; // 五分钟请求一次 getServiceVersionApi 接口,防止副屏关屏的时候收不到推送的消息
+let timer: ReturnType<typeof setInterval> | null = null;
const backgroundColor = computed(() => {
let color = "#DAE5EC";
@@ -104,6 +116,36 @@
cotentHeight.value = getAvailableHeightByClass("content-position");
});
+// 版本更新/手动刷新场景
+// watch(
+// [
+// bedsideAuxiliaryScreenStore.version,
+// bedsideAuxiliaryScreenStore.deviceData.isRefresh,
+// ],
+// ([newVersion, newIsRefresh], [oldVersion, oldIsRefresh]) => {
+// // 如果远程版本号存在更新/设备列表页面进行了手动刷新
+// console.log('bedsideAuxiliaryScreenStore.version :', bedsideAuxiliaryScreenStore.version)
+// if (
+// newVersion !== oldVersion||
+// newIsRefresh === 1
+// ) {
+// refreshFun();
+// }
+// }
+// );
+
+const getServiceVersionFun = async () => {
+ try {
+ const { version } = await getServiceVersionApi();
+ if (version !== bedsideAuxiliaryScreenStore.version) {
+ bedsideAuxiliaryScreenStore.refreshVersion(version);
+ }
+ } catch (error) {
+ ElMessage.error("获取版本号失败,请联系管理员!");
+ }
+};
+
+
onMounted(() => {
if (bedsideAuxiliaryScreenStore.deviceCode) {
bedsideAuxiliaryScreenStore.connect(
@@ -112,8 +154,22 @@
}`
);
}
+ // 先立即执行一次
+ getServiceVersionFun();
+
+ // 再每 5 分钟执行一次
+ timer = setInterval(() => {
+ getServiceVersionFun();
+ }, versionTimer);
cotentHeight.value = getAvailableHeightByClass("content-position");
});
+
+onBeforeUnmount(() => {
+ // 把定时器清除掉
+ if (timer) {
+ clearInterval(timer);
+ }
+});
</script>
<style lang="less" scoped>
--
Gitblit v1.8.0