From bdd4bfd582a5f587ab008b7f08ed2b971aeb5867 Mon Sep 17 00:00:00 2001 From: zhoulexin Date: Thu, 28 May 2026 14:39:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E5=90=8A=E8=88=B1?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/useKeepAlive.js | 55 +++++ src/stores/user.js | 11 - src/utils/request.js | 2 +- src/views/detail/index.vue | 197 ++++++++++++++---- .../components/CameraGrid.vue | 4 +- src/views/home/index.vue | 1 - src/views/login/index.vue | 35 ---- 7 files changed, 213 insertions(+), 92 deletions(-) create mode 100644 src/composables/useKeepAlive.js diff --git a/src/composables/useKeepAlive.js b/src/composables/useKeepAlive.js new file mode 100644 index 0000000..8ee67ea --- /dev/null +++ b/src/composables/useKeepAlive.js @@ -0,0 +1,55 @@ +import { ref } from 'vue' +import { newPodApi } from '@/api/user' + +// 模块级变量,确保所有组件实例共享同一个定时器状态 +let keepAliveTimer = null +const isRunning = ref(false) + +export function useKeepAlive() { + const callKeepAlive = async () => { + const session = localStorage.getItem('newPodSession') + if (!session) { + stopKeepAlive() + return + } + try { + await newPodApi({ + session: Number(session), + id: 2, + call: { + service: 'rpc', + method: 'keepAlive' + }, + params: { + timeout: 60 + } + }) + } catch (e) { + console.error('KeepAlive error:', e) + } + } + + const startKeepAlive = () => { + if (keepAliveTimer) return // 已启动,避免重复 + + const session = localStorage.getItem('newPodSession') + if (!session) return + isRunning.value = true + callKeepAlive() + keepAliveTimer = setInterval(callKeepAlive, 60000) + } + + const stopKeepAlive = () => { + if (keepAliveTimer) { + clearInterval(keepAliveTimer) + keepAliveTimer = null + } + isRunning.value = false + } + + return { + isRunning, + startKeepAlive, + stopKeepAlive + } +} diff --git a/src/stores/user.js b/src/stores/user.js index fb69ce3..a4d5a2c 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -36,25 +36,14 @@ export const useUserStore = defineStore('user', () => { const logout = async () => { if (isLoggingOut.value) return isLoggingOut.value = true - const params = { - "session": 2878481200, - "id": 2, - "call": { - "service": "rpc", - "method": "logout" - } - } try { await logoutApi() - // 退出后台吊舱登录 - await newPodApi(params) } catch (e) { // 忽略logout接口错误 } finally { token.value = '' userInfo.value = null localStorage.removeItem('token') - localStorage.removeItem('newPodSession') isLoggingOut.value = false } } diff --git a/src/utils/request.js b/src/utils/request.js index f26caba..becf0e0 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -7,7 +7,7 @@ function createService(baseURL) { const service = axios.create({ baseURL: baseURL, - timeout: 15000 + timeout: 120000 }) // 请求拦截器 diff --git a/src/views/detail/index.vue b/src/views/detail/index.vue index 6d86dd4..23e3b8b 100644 --- a/src/views/detail/index.vue +++ b/src/views/detail/index.vue @@ -59,9 +59,9 @@
- + 调焦 - +
@@ -72,9 +72,9 @@
- + 聚焦 - +
@@ -85,9 +85,9 @@
- + 光圈 - +
@@ -135,24 +135,46 @@ > {{ recordingStates[index] ? '停止' : '录屏' }} - 放大 + 放大 + + + +
+ +
+
@@ -640,4 +736,21 @@ onBeforeUnmount(() => { object-fit: contain; } } + +:deep(.el-dialog.is-fullscreen) { + .el-dialog__body { + padding: 0; + height: calc(100% - 56px); + background: #000; + } +} + +.enlarge-video-body { + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + background: #000; +} diff --git a/src/views/face-recognition/components/CameraGrid.vue b/src/views/face-recognition/components/CameraGrid.vue index 73e3cc7..71ae4b0 100644 --- a/src/views/face-recognition/components/CameraGrid.vue +++ b/src/views/face-recognition/components/CameraGrid.vue @@ -44,14 +44,14 @@ -
+
diff --git a/src/views/home/index.vue b/src/views/home/index.vue index bd6d80f..1c5bebb 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -129,7 +129,6 @@ const loading = ref(false) const showAddDialog = ref(false) const editData = ref(null) const isEdit = ref(false) - // 查看详情 const viewDetail = (item) => { router.push({ diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 04c908f..d05f0d9 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -108,8 +108,6 @@ import { useRouter, useRoute } from 'vue-router' import { ElMessage } from 'element-plus' import { useUserStore } from '@/stores/user' import { newPodApi } from '@/api/user' -import md5 from 'js-md5' -import sha256 from 'js-sha256' import AuthLogo from '@/components/AuthLogo.vue' import AuthBackground from '@/components/AuthBackground.vue' @@ -175,20 +173,6 @@ const loginRules = { { required: true, message: '请输入密码', trigger: 'blur' } ] } -const generateRandomString = (length = 6) => { - // 定义字符集:数字 + 大写字母 (去除了易混淆的 I, O 等,可根据需求调整) - const chars = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'; - - let result = ''; - const charsLength = chars.length; - - for (let i = 0; i < length; i++) { - const randomIndex = Math.floor(Math.random() * charsLength); - result += chars[randomIndex]; - } - - return result; -} const handleLogin = async () => { if (!loginFormRef.value) return @@ -198,25 +182,6 @@ const handleLogin = async () => { try { const res = await userStore.login(loginForm) if (res.success) { - // 登录后台吊舱管理 - const random = generateRandomString() - const podLogin = await newPodApi({ - "session": 0, - "id": 2, - "call": { - "service": "rpc", - "method": "login" - }, - "params": { - "userName": "admin", - "password": sha256(sha256('abcd1234') + random), - "random": random, - "ip": "127.0.0.1", - "port": 80, - "encryptType": 1 - } - }) - localStorage.setItem('newPodSession', podLogin.params.session) // 处理记住密码 if (rememberMe.value) { saveCredentials()