xiaochan пре 1 година
родитељ
комит
f9cfc9f393

+ 3 - 0
src/App.vue

@@ -19,10 +19,13 @@ import {CyMessageBox} from "@/components/cy/message-box";
 import {useProgressBarStore} from "@/pinia/progress-bar-store";
 import {useUserStore} from "@/pinia/user-store";
 import {useSystemStore} from "@/pinia/system-store";
+import useChangeToken from "@/utils/cy-use/useChangeToken";
 
 const progressBarStore = useProgressBarStore()
 const systemStore = useSystemStore()
 
+useChangeToken()
+
 progressBarStore.initialize({
   title: '数据上传',
   isOpen: false,

+ 39 - 0
src/utils/cy-use/useChangeToken.ts

@@ -0,0 +1,39 @@
+import {useEventListener} from '@vueuse/core'
+import {onUnmounted} from "vue";
+import {CyMessageBox} from "@/components/cy/message-box";
+
+
+export enum documentVisibilityEnum {
+    hidden = 'hidden',
+    visible = 'visible'
+}
+
+function useChangeToken() {
+    const token = localStorage.token
+
+    function isChange() {
+        if (document.visibilityState === documentVisibilityEnum.hidden)
+            return
+        if (token !== localStorage.token)
+            CyMessageBox.alert({
+                message: '监测到账号不一致',
+                confirmButtonText: '刷新页面'
+            }).finally(() => {
+                window.location.reload()
+            })
+    }
+
+    const listener = useEventListener(document, "visibilitychange", () => {
+        isChange()
+    });
+
+    onMounted(() => {
+        isChange()
+    })
+
+    onUnmounted(() => {
+        listener()
+    })
+}
+
+export default useChangeToken

+ 0 - 1
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/EmrMain.vue

@@ -1329,7 +1329,6 @@ const watchVisibility = () => {
   }, {immediate: true})
 }
 
-
 const refreshSaveEmr = (): Promise<boolean> => {
   return new Promise((resolve, reject) => {
     const document = editor!.getDocument();