提交 650c4fd3 作者: 毛细亚

123

上级 c71ffb5a
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>company_app</title><script src="https://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script><script defer="defer" src="static/js/chunk-vendors.037127e5.js"></script><script defer="defer" src="static/js/app.0988f45b.js"></script><link href="static/css/chunk-vendors.34a02360.css" rel="stylesheet"><link href="static/css/app.da449827.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but company_app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html> <!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>company_app</title><script src="https://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script><script defer="defer" src="static/js/chunk-vendors.c5338b55.js"></script><script defer="defer" src="static/js/app.493a4164.js"></script><link href="static/css/chunk-vendors.34a02360.css" rel="stylesheet"><link href="static/css/app.da449827.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but company_app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
\ No newline at end of file \ 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论