feat: v3.1 - 统一规约视图、项目树导航、移动端支持

主要更新:
- 统一规约管理视图(全局/项目规约共享表格)
- 项目树形导航(看板/项目规约子菜单)
- 智能高亮与状态持久化
- 移动端响应式支持(汉堡菜单)
- 规约类型更新为7个专业分类
- 文件清理(85→15文件,减少82%)

修复问题:
- 修复创建项目功能(JavaScript语法错误)
- 修复协作规约错误高亮
- 修复看板需要点击2次才高亮
- 修复项目树自动收起问题

新增工具:
- debug.html(项目创建测试)
- test.html(移动端测试)
- status.html(系统诊断)

技术改进:
- 上下文状态管理(currentRuleContext)
- 展开状态持久化(projectExpandedState)
- 触摸事件支持
- 移除console.log提升兼容性
This commit is contained in:
work-1
2026-02-24 15:04:25 +08:00
parent b32ebb017a
commit 01f43d8da5
25 changed files with 14287 additions and 4637 deletions
+128
View File
@@ -0,0 +1,128 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>系统状态</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
background: #f5f5f5;
}
.status-card {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
.status-ok { color: #4caf50; }
.status-error { color: #f44336; }
h1 { color: #667eea; }
.info { margin: 10px 0; padding: 10px; background: #f9f9f9; border-radius: 5px; }
button {
padding: 10px 20px;
background: #667eea;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
button:hover { opacity: 0.9; }
#log { font-family: monospace; font-size: 12px; white-space: pre-wrap; }
</style>
</head>
<body>
<div class="status-card">
<h1>🚀 系统状态检查</h1>
<div class="info">
<strong>服务器:</strong> <span id="server-status" class="status-ok">✅ 运行中</span><br>
<strong>时间:</strong> <span id="current-time"></span><br>
<strong>浏览器:</strong> <span id="browser"></span>
</div>
<h3>功能测试</h3>
<button onclick="testAPI()">测试 API</button>
<button onclick="testProjects()">测试项目列表</button>
<button onclick="testRules()">测试规约</button>
<button onclick="clearCache()">清除缓存</button>
<button onclick="location.href='/'">返回主页</button>
<div id="log" class="info" style="margin-top: 20px; max-height: 300px; overflow-y: auto;">
等待测试...
</div>
</div>
<script>
const log = (msg, isError = false) => {
const logDiv = document.getElementById('log');
const time = new Date().toLocaleTimeString();
const prefix = isError ? '❌' : '✅';
logDiv.innerHTML += `\n${time} ${prefix} ${msg}`;
logDiv.scrollTop = logDiv.scrollHeight;
};
document.getElementById('current-time').textContent = new Date().toLocaleString('zh-CN');
document.getElementById('browser').textContent = navigator.userAgent.split(' ').pop();
async function testAPI() {
log('测试 /api/stats ...');
try {
const res = await fetch('/api/stats');
const data = await res.json();
log(`API 正常 - 项目:${data.projects} 任务:${data.tasks}`);
} catch (e) {
log('API 错误: ' + e.message, true);
}
}
async function testProjects() {
log('测试 /api/projects ...');
try {
const res = await fetch('/api/projects');
const data = await res.json();
log(`获取到 ${data.length} 个项目`);
data.forEach(p => log(` - ${p.name}`));
} catch (e) {
log('项目列表错误: ' + e.message, true);
}
}
async function testRules() {
log('测试 /api/rules/global ...');
try {
const res = await fetch('/api/rules/global');
const data = await res.json();
log(`获取到 ${data.length} 条全局规约`);
} catch (e) {
log('规约错误: ' + e.message, true);
}
}
function clearCache() {
log('清除缓存...');
if ('caches' in window) {
caches.keys().then(names => {
names.forEach(name => caches.delete(name));
});
}
localStorage.clear();
sessionStorage.clear();
log('缓存已清除,请刷新页面');
}
// 自动运行基础测试
window.addEventListener('load', () => {
setTimeout(() => {
log('=== 自动测试开始 ===');
testAPI();
}, 500);
});
</script>
</body>
</html>