From a53ece5036c1fa61a63fe5f9e0cd3519210ab928 Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Fri, 07 Aug 2026 09:44:27 +0800
Subject: [PATCH] feat:兼容分辨率低不出现滚动条
---
applications/drone-command/src/utils/util.js | 97 ++++++++++++++++++++++++++++++------------------
1 files changed, 61 insertions(+), 36 deletions(-)
diff --git a/applications/drone-command/src/utils/util.js b/applications/drone-command/src/utils/util.js
index 57c3536..403dbe1 100644
--- a/applications/drone-command/src/utils/util.js
+++ b/applications/drone-command/src/utils/util.js
@@ -1,6 +1,8 @@
import { validatenull } from './validate'
import sha256 from 'crypto-js/sha256'
import Base64 from 'crypto-js/enc-base64'
+import { useRoute } from 'vue-router'
+
//表单序列化
export const serialize = data => {
let list = []
@@ -102,22 +104,21 @@
* esc监听全屏
*/
export const listenfullscreen = callback => {
- function listen () {
+ const handler = () => {
callback()
}
- document.addEventListener('fullscreenchange', function () {
- listen()
- })
- document.addEventListener('mozfullscreenchange', function () {
- listen()
- })
- document.addEventListener('webkitfullscreenchange', function () {
- listen()
- })
- document.addEventListener('msfullscreenchange', function () {
- listen()
- })
+ document.addEventListener('fullscreenchange', handler)
+ document.addEventListener('mozfullscreenchange', handler)
+ document.addEventListener('webkitfullscreenchange', handler)
+ document.addEventListener('msfullscreenchange', handler)
+
+ return () => {
+ document.removeEventListener('fullscreenchange', handler)
+ document.removeEventListener('mozfullscreenchange', handler)
+ document.removeEventListener('webkitfullscreenchange', handler)
+ document.removeEventListener('msfullscreenchange', handler)
+ }
}
/**
* 获取缩略图路径
@@ -470,33 +471,57 @@
return `${url.substring(0, lastDotIndex)}_show.jpeg`
}
// key驼峰转换为下划线
-export function camelToSnake (obj) {
- if (typeof obj !== 'object' || obj === null) {
- return obj
- }
+export function camelToSnake(obj) {
+ if (typeof obj !== 'object' || obj === null) {
+ return obj
+ }
- if (Array.isArray(obj)) {
- return obj.map(item => camelToSnake(item))
- }
+ if (Array.isArray(obj)) {
+ return obj.map(item => camelToSnake(item))
+ }
- const newObj = {}
- for (const key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
- const newKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()
- newObj[newKey] = camelToSnake(obj[key])
- }
- }
- return newObj
+ const newObj = {}
+ for (const key in obj) {
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
+ const newKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()
+ newObj[newKey] = camelToSnake(obj[key])
+ }
+ }
+ return newObj
}
// a链接直接下载
export const aLinkDownloadUtil = (url, name) => {
- let a = document.createElement('a')
- a.style.display = 'none'
- a.href = url
- a.download = name
- document.body.appendChild(a)
- a.click()
- document.body.removeChild(a)
- a = null
+ let a = document.createElement('a')
+ a.style.display = 'none'
+ a.href = url
+ a.download = name
+ document.body.appendChild(a)
+ a.click()
+ document.body.removeChild(a)
+ a = null
+}
+// 统一退出登录
+export async function logOutFun() {
+ // 延迟导入 store 和 router,避免循环依赖:
+ // auth.js → router → store → user.js → auth.js
+ const { default: store } = await import('@/store')
+ const { default: router } = await import('@/router')
+ const { VITE_APP_PARENT_SYSTEM, VITE_APP_ENV } = import.meta.env
+
+ const jumpFun = () => {
+ const urlParams = new URLSearchParams(window.location.search);
+ const openDev = urlParams.get('openDev');
+ const isDev = VITE_APP_ENV === 'development'
+ if (isDev || openDev) {
+ router.push({ path: '/login' })
+ // setTimeout(() => location.reload())
+ } else {
+ window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`)
+ }
+ }
+
+ store.dispatch('LogOut').then(() => {
+ jumpFun()
+ })
}
--
Gitblit v1.9.3