From d7772609779901f72cbb0d6f15fbf34099b07624 Mon Sep 17 00:00:00 2001 From: guoapeng Date: Sun, 6 Jul 2025 13:00:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/audit/History.vue | 6 ++-- src/layouts/default.vue | 59 ++++++++++++++++++++-------------------- src/stores/systemStore.ts | 39 ++++++++++++++++++++------ src/views/login/index.vue | 8 ++++-- 4 files changed, 68 insertions(+), 44 deletions(-) diff --git a/src/components/audit/History.vue b/src/components/audit/History.vue index 761037d..bf21792 100644 --- a/src/components/audit/History.vue +++ b/src/components/audit/History.vue @@ -127,14 +127,16 @@ const deleteBtnVisible = computed(() => { - + diff --git a/src/layouts/default.vue b/src/layouts/default.vue index b3a1482..8ae5a73 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -3,7 +3,8 @@ import WifiConnSvg from 'assets/images/wifi-conn.svg' import WifiUnconnSvg from 'assets/images/wifi-unconn.svg' import ErrorEventsModal from 'components/system/ErrorEventsModal.vue' import NetReconnection from 'components/system/NetReconnection.vue' -import { formatDateTime, openFullscreen } from 'libs/utils' +import { delToken } from 'libs/token' +import { formatDateTime } from 'libs/utils' import { authRoutes } from 'router/routes' import { useDeviceStore } from 'stores/deviceStore' import { computed, onMounted, onUnmounted, ref, watch, watchEffect } from 'vue' @@ -38,12 +39,6 @@ const liquidDrainState = ref(liquidStore.liquidDrainWorkState) const deviceState = ref(deviceStore.deviceState) const sealInfo = ref(sealStore.sealInfo) const websocketConnected = ref(systemStore.websocketConnected) -let touchStartTime = 0 -let touchCount = 0 - -const userData = localStorage.getItem('user') -const userInfo = userData ? JSON.parse(userData) : {} -const userRole = userInfo.roleType || '' const deviceType = __DEVICE_TYPE__ @@ -57,31 +52,37 @@ const menuList = computed(() => { ) { return false } - return !(item.name === 'debug' && userRole !== 'admin') + return !(item.name === 'debug' && systemStore.systemUser?.name !== 'admin') }) }) + onMounted(() => { + runSystemTime(systemStore.systemTime) + console.log(systemStore.systemUser) // 连续3次点击任意地方,全屏显示 - onFullScreen() + // onFullScreen() }) -const onFullScreen = () => { - document.body.addEventListener('touchstart', (event) => { - const now = Date.now() - const timeDiff = now - touchStartTime - if (timeDiff < 300 && timeDiff > 0) { - touchCount++ - if (touchCount === 3) { - event.preventDefault() - openFullscreen() - } - } - else { - touchCount = 1 - } - touchStartTime = now - }) -} +// const touchStartTime = 0 +// const touchCount = 0 + +// const onFullScreen = () => { +// document.body.addEventListener('touchstart', (event) => { +// const now = Date.now() +// const timeDiff = now - touchStartTime +// if (timeDiff < 300 && timeDiff > 0) { +// touchCount++ +// if (touchCount === 3) { +// event.preventDefault() +// openFullscreen() +// } +// } +// else { +// touchCount = 1 +// } +// touchStartTime = now +// }) +// } const showDeviceStateName = () => { if (deviceState.value.state?.toLocaleLowerCase() !== 'idle') { @@ -103,10 +104,6 @@ const showDeviceStateName = () => { } } -onMounted(() => { - runSystemTime(systemStore.systemTime) -}) - watchEffect(() => { deviceInfo.value = deviceStore.deviceInfo websocketConnected.value = systemStore.websocketConnected @@ -158,6 +155,8 @@ const onLogout = () => { } FtMessageBox.warning('请确认是否退出登录?').then(() => { localStorage.removeItem('user') + delToken() + useSystemStore().updateUser(null) router.push('/login') }) } diff --git a/src/stores/systemStore.ts b/src/stores/systemStore.ts index 3fb6a99..8ff973d 100644 --- a/src/stores/systemStore.ts +++ b/src/stores/systemStore.ts @@ -7,9 +7,7 @@ import { sendCmd } from '@/apis/system' export const useSystemStore = defineStore('system', () => { const websocketConnected = ref(true) - const systemUser = ref({ - username: '', - }) + const systemUser = ref(null) const systemLogList = ref([]) const insertLog = (log: System.SystemLog) => { systemLogList.value.unshift(log) @@ -25,19 +23,37 @@ export const useSystemStore = defineStore('system', () => { uuids.clear() } uuids.add(item.uuid) - if (item.type === 'AppCheckPointCheckFailEvent' && item.errCheckPoints) { // 传感器检测失败弹窗事件 + if (item.type === 'AppCheckPointCheckFailEvent' && item.errCheckPoints) { + // 传感器检测失败弹窗事件 item.errCheckPoints.forEach((errCheckPoint) => { - const log: System.SystemLog = { name: `${errCheckPoint.ecodeInfo}(${errCheckPoint.ecode})`, status: 'check', time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), uuid: item.uuid } + const log: System.SystemLog = { + name: `${errCheckPoint.ecodeInfo}(${errCheckPoint.ecode})`, + status: 'check', + time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), + uuid: item.uuid, + } insertLog(log) }) } - if (item.type === 'AppWarningPromoptEvent') { // 报警事件 - const log: System.SystemLog = { name: item.description || '', status: 'warn', time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), uuid: item.uuid } + if (item.type === 'AppWarningPromoptEvent') { + // 报警事件 + const log: System.SystemLog = { + name: item.description || '', + status: 'warn', + time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), + uuid: item.uuid, + } ElMessage.warning(item.description) insertLog(log) } - if (item.type === 'AppPromoptEvent') { // 普通弹窗事件 - const log: System.SystemLog = { name: item.message || '', status: 'info', time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), uuid: item.uuid } + if (item.type === 'AppPromoptEvent') { + // 普通弹窗事件 + const log: System.SystemLog = { + name: item.message || '', + status: 'info', + time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), + uuid: item.uuid, + } insertLog(log) } }) @@ -76,6 +92,10 @@ export const useSystemStore = defineStore('system', () => { websocketConnected.value = isConnected } + const updateUser = (data: any) => { + systemUser.value = data + } + /** * @function subscribeDisinfectEvent * @desc 订阅消毒状态变更事件 @@ -136,6 +156,7 @@ export const useSystemStore = defineStore('system', () => { websocketConnected, systemTime, systemLogList, + updateUser, updateLoading, updateConnected, getSystemTime, diff --git a/src/views/login/index.vue b/src/views/login/index.vue index ae6652d..b0463d2 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -72,15 +72,17 @@ const loginHandle = async () => { className: 'UserMgrService', fnName: 'getLoginUser', } - syncSendCmd(params).then((res) => { + syncSendCmd(params).then(async (res) => { if (res.ackcode === 0) { + useSystemStore().updateUser(res.rely.loginUser) localStorage.setItem('user', JSON.stringify(res.rely.loginUser)) + setToken('111') deviceStore.setDeviceState(res.rely.loginUser) } + await router.push('/home') + loading.value = false }) - await router.push('/home') } - loading.value = false }) .catch(() => { loading.value = false