提交 aa97780b 作者: 毛细亚

Merge branch 'release' into 1.1

<template> <template>
<!-- 开发模式触发区域 - 隐藏的点击区域 --> <!-- 开发模式触发区域 - 隐藏的点击区域 -->
<div class="dev-mode-trigger" @click="handleDevModeClick" title="开发模式触发区域"></div> <div class="debug-container">
<div class="dev-mode-trigger" @click="handleDevModeClick" title="开发模式触发区域"></div>
<div class="dev-mode-cookie" @click="cleanCookie" title="清除所有 cookie"></div>
</div>
</template> </template>
<script> <script>
import devModeManager from '@/utils/devMode' import devModeManager from '@/utils/devMode'
import Cookies from 'js-cookie'
export default { export default {
name: 'Debug', name: 'Debug',
methods: { methods: {
handleDevModeClick() { handleDevModeClick() {
devModeManager.handleClick() devModeManager.handleClick()
},
cleanCookie() {
// 清除所有 cookie
Cookies.remove('token')
Cookies.remove('userid')
Cookies.remove('corp_id')
Cookies.remove('cser_id')
Cookies.remove('accountSelect')
Cookies.remove('signData')
this.$message.success('清除所有 cookie 成功')
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.debug-container{
width: 100%;
height: 5px;
position: absolute;
top: 0;
left: 0;
z-index: 999;
}
/* 开发模式触发区域 */ /* 开发模式触发区域 */
.dev-mode-trigger { .dev-mode-trigger {
position: absolute; position: absolute;
top: 5px; top: 0px;
left: 5px; left: 0px;
width: 50px; width: 50px;
height: 50px; height: 20px;
background: transparent; background: transparent;
cursor: pointer; cursor: pointer;
z-index: 999; z-index: 999;
...@@ -33,4 +55,15 @@ export default { ...@@ -33,4 +55,15 @@ export default {
background: rgba(0, 191, 138, 0.1); background: rgba(0, 191, 138, 0.1);
border-radius: 4px; border-radius: 4px;
} }
.dev-mode-cookie{
position: absolute;
top: 0px;
right: 0px;
width: 50px;
height: 20px;
}
.dev-mode-cookie:hover {
background: rgba(138, 2, 162, 0.1);
border-radius: 4px;
}
</style> </style>
\ No newline at end of file
...@@ -8,6 +8,7 @@ class DevModeManager { ...@@ -8,6 +8,7 @@ class DevModeManager {
this.maxClicks = 7 // 连续点击7次开启 this.maxClicks = 7 // 连续点击7次开启
this.resetTime = 3000 // 3秒内无点击则重置 this.resetTime = 3000 // 3秒内无点击则重置
this.isDevMode = this.getDevModeFromStorage() this.isDevMode = this.getDevModeFromStorage()
this.isDestroyingVConsole = false // 标记VConsole正在销毁中
// 自动初始化逻辑 // 自动初始化逻辑
this.autoInit() this.autoInit()
...@@ -44,6 +45,12 @@ class DevModeManager { ...@@ -44,6 +45,12 @@ class DevModeManager {
// 处理点击事件 // 处理点击事件
handleClick() { handleClick() {
// 如果正在销毁VConsole,忽略点击事件
if (this.isDestroyingVConsole) {
console.log('VConsole正在关闭中,请稍候...')
return
}
this.clickCount++ this.clickCount++
console.log(`开发模式激活进度: ${this.clickCount}/${this.maxClicks}`) console.log(`开发模式激活进度: ${this.clickCount}/${this.maxClicks}`)
...@@ -91,18 +98,26 @@ class DevModeManager { ...@@ -91,18 +98,26 @@ class DevModeManager {
try { try {
// 防止重复初始化 // 防止重复初始化
if (!this.vConsole) { if (!this.vConsole) {
// 如果上次销毁未完成,等待一段时间
if (this.isDestroyingVConsole) {
console.log('正在等待上次的VConsole销毁完成...')
setTimeout(() => this.enableDevMode(), 500)
return
}
this.vConsole = new VConsole() this.vConsole = new VConsole()
console.log('🎉 开发模式已开启!') console.log('🎉 开发模式已开启!')
console.log('💡 提示:再次连续点击7次可关闭开发模式') console.log('💡 提示:再次连续点击7次可关闭开发模式')
this.isDevMode = true
this.saveDevModeToStorage(true)
} else { } else {
console.log('📱 开发模式已经处于开启状态') console.log('📱 开发模式已经处于开启状态')
} }
this.isDevMode = true
this.saveDevModeToStorage(true)
} catch (error) { } catch (error) {
console.error('开启开发模式失败:', error) console.error('开启开发模式失败:', error)
this.vConsole = null this.vConsole = null
this.isDevMode = false this.isDevMode = false
this.isDestroyingVConsole = false
} }
} }
...@@ -110,17 +125,41 @@ class DevModeManager { ...@@ -110,17 +125,41 @@ class DevModeManager {
disableDevMode() { disableDevMode() {
try { try {
if (this.vConsole) { if (this.vConsole) {
this.vConsole.destroy() // 设置标志,表示正在销毁
this.vConsole = null this.isDestroyingVConsole = true
console.log('👋 开发模式已关闭!')
// 在销毁前保存引用
const vConsoleInstance = this.vConsole;
// 先将实例引用设置为null,防止后续调用
this.vConsole = null;
// 使用setTimeout延迟一点点销毁操作,以确保事件循环中的其他任务已完成
setTimeout(() => {
// 使用try-catch单独包装destroy调用,防止异常影响状态设置
try {
vConsoleInstance.destroy();
} catch (destroyError) {
console.error('VConsole销毁时出错:', destroyError);
}
// 销毁完成后,清除标志
this.isDestroyingVConsole = false;
console.log('👋 开发模式已关闭!');
}, 100);
this.isDevMode = false;
this.saveDevModeToStorage(false);
} else {
this.isDevMode = false;
this.isDestroyingVConsole = false;
this.saveDevModeToStorage(false);
} }
this.isDevMode = false
this.saveDevModeToStorage(false)
} catch (error) { } catch (error) {
console.error('关闭开发模式失败:', error) console.error('关闭开发模式失败:', error);
// 强制重置状态 // 强制重置状态
this.vConsole = null this.vConsole = null;
this.isDevMode = false this.isDevMode = false;
this.isDestroyingVConsole = false;
} }
} }
...@@ -136,7 +175,8 @@ class DevModeManager { ...@@ -136,7 +175,8 @@ class DevModeManager {
environment: process.env.NODE_ENV, environment: process.env.NODE_ENV,
clickCount: this.clickCount, clickCount: this.clickCount,
maxClicks: this.maxClicks, maxClicks: this.maxClicks,
hasVConsole: !!this.vConsole hasVConsole: !!this.vConsole,
isDestroyingVConsole: this.isDestroyingVConsole
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="loginContent"> <div class="loginContent">
<div v-if="!token"> <div v-if="!token">
<div> <div>
当前组织:<span class="current-org">{{ currentOrg.name }}</span> 当前选中组织:<span class="current-org">{{ currentOrg.name }}</span>
<el-button type="text" @click="showOrgDialog = true">切换组织</el-button> <el-button type="text" @click="showOrgDialog = true">切换组织</el-button>
</div> </div>
<div class="qr-contain"> <div class="qr-contain">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论