From a3f920c3aa61a1bbbdf042163ea194f092ae466d Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Wed, 11 Mar 2026 12:12:18 +0800
Subject: [PATCH] feat: 退出登录
---
applications/drone-command/src/utils/util.js | 63 ++++++++++++++++++++-----------
1 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/applications/drone-command/src/utils/util.js b/applications/drone-command/src/utils/util.js
index c149ad4..2525288 100644
--- a/applications/drone-command/src/utils/util.js
+++ b/applications/drone-command/src/utils/util.js
@@ -469,33 +469,50 @@
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 function logOutFun() {
+ // 延迟导入 store 和 router,避免循环依赖:
+ // auth.js → router → store → user.js → auth.js
+ const store = require('@/store').default
+ const router = require('@/router').default
+ const { VITE_APP_PARENT_SYSTEM, VITE_APP_ENV } = import.meta.env
+ store.dispatch('LogOut').then(() => {
+ const isDev = VITE_APP_ENV === 'development'
+ if (isDev) {
+ router.push({ path: '/login' })
+ setTimeout(() => location.reload())
+ } else {
+ window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`)
+ }
+ })
}
--
Gitblit v1.9.3