单应用项目,可以创建很多独立工具类页面 ,不用登录 初始化的页面
zhangchen
2025-07-26 0c23337e68270f9d5de011b56564448d76a5164a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<template>
  <div
    class="bedside-auxiliary-screen-container"
    :style="{ backgroundColor: backgroundColor }"
  >
    <Header />
    <div class="bedside-auxiliary-screen-content">
      <div class="content-position"></div>
      <transition name="fade" mode="out-in">
        <component
          v-if="cotentHeight > 0"
          :is="currentComponent"
          :height="cotentHeight"
        />
      </transition>
    </div>
  </div>
</template>
 
<script lang="ts" setup>
import { ref, watch, computed, onMounted, defineAsyncComponent } 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 { useWindowSize } from "@/composables/useWindowSize";
// 未排班时的组件
const UnplannedSchedule = defineAsyncComponent(
  () => import("./pages/UnplannedSchedule.vue")
);
// 未签到时的组件
const NotSignedIn = defineAsyncComponent(
  () => import("./pages/NotSignedIn.vue")
);
// 已签到时的组件
const SignedIn = defineAsyncComponent(() => import("./pages/SignedIn.vue"));
// 治疗中的组件
const UnderTreatment = defineAsyncComponent(
  () => import("./pages/UnderTreatment.vue")
);
// 血压计的组件
const Sphygmomanometer = defineAsyncComponent(
  () => import("./pages/Sphygmomanometer.vue")
);
 
const bedsideAuxiliaryScreenStore = useBedsideAuxiliaryScreenStore();
const cotentHeight = ref(0);
const { width, height } = useWindowSize();
 
const backgroundColor = computed(() => {
  let color = "#DAE5EC";
  // 如果是未排班、加载中或未签到页面,背景色为白色
  if (
    [
      EPageType.NOT_INIT,
      EPageType.LOADING,
      EPageType.UNPLANNED_SCHEDULE,
    ].includes(bedsideAuxiliaryScreenStore.deviceData.pageType)
  ) {
    color = "#fff";
  }
  return color;
});
 
const currentComponent = computed(() => {
  let name: any = UnplannedSchedule;
 
  // 血压计
  if (
    bedsideAuxiliaryScreenStore.deviceData.pageType ===
    EPageType.SPHYGMOMANOMETER
  ) {
    name = Sphygmomanometer;
  } else if (
    [
      EPageType.NOT_INIT,
      EPageType.LOADING,
      EPageType.UNPLANNED_SCHEDULE,
    ].includes(bedsideAuxiliaryScreenStore.deviceData.pageType)
  ) {
    name = UnplannedSchedule;
  }
  // 未签到
  else if (
    bedsideAuxiliaryScreenStore.deviceData.pageType === EPageType.NOT_SIGNED_IN
  ) {
    name = NotSignedIn;
  }
  // 已签到
  else if (
    bedsideAuxiliaryScreenStore.deviceData.pageType === EPageType.SIGNED_IN
  ) {
    name = SignedIn;
  }
  // 透析中
  else {
    name = UnderTreatment;
  }
  return name;
});
 
watch([width, height], () => {
  cotentHeight.value = getAvailableHeightByClass("content-position");
});
 
onMounted(() => {
  if (bedsideAuxiliaryScreenStore.deviceCode) {
    bedsideAuxiliaryScreenStore.connect(
      `${import.meta.env.VITE_SSE_BASE_URL}${
        bedsideAuxiliaryScreenStore.deviceCode
      }`
    );
  }
  cotentHeight.value = getAvailableHeightByClass("content-position");
});
</script>
 
<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.bedside-auxiliary-screen-container {
  background-color: #409eff;
  .bedside-auxiliary-screen-content {
    padding: 6px 12px 0;
  }
}
</style>
<style scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>