feat: 添加管理员可控的F12调试模式开关

## 功能说明
- 管理员登录后可在管理后台页面看到"调试模式"卡片
- 点击开关按钮可启用/禁用F12和开发者工具
- 调试模式状态保存在localStorage,页面刷新后保持
- 同时控制主应用(app.html)和分享页面(share.html)的调试权限

## 技术实现
1. app.js新增debugMode配置和toggleDebugMode方法
2. app.html添加调试模式开关UI,并修改防调试代码支持debugMode控制
3. share.html添加防调试代码,受localStorage中的debugMode控制

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-14 16:04:17 +08:00
parent 024e807f75
commit bce225ec5c
3 changed files with 145 additions and 13 deletions

View File

@@ -17,6 +17,7 @@ createApp({
isLogin: true,
fileViewMode: 'grid', // 文件显示模式: grid 大图标, list 列表
shareViewMode: 'list', // 分享显示模式: grid 大图标, list 列表
debugMode: false, // 调试模式(管理员可切换)
// 表单数据
loginForm: {
@@ -1973,9 +1974,37 @@ handleDragLeave(e) {
this.uploadingTool = false;
event.target.value = ''; // 清空input允许重复上传
}
} },
},
// ===== 调试模式管理 =====
// 切换调试模式
toggleDebugMode() {
this.debugMode = !this.debugMode;
// 保存到 localStorage
if (this.debugMode) {
localStorage.setItem('debugMode', 'true');
this.showToast('success', '调试模式已启用', 'F12和开发者工具快捷键已启用');
// 刷新页面以应用更改
setTimeout(() => {
window.location.reload();
}, 1000);
} else {
localStorage.removeItem('debugMode');
this.showToast('info', '调试模式已禁用', '页面将重新加载以应用更改');
// 刷新页面以应用更改
setTimeout(() => {
window.location.reload();
}, 1000);
}
}
},
mounted() {
// 初始化调试模式状态
this.debugMode = localStorage.getItem('debugMode') === 'true';
// 阻止全局拖拽默认行为(防止拖到区域外打开新页面)
window.addEventListener("dragover", (e) => {
e.preventDefault();