fix(MCN工作台): 修复刷新回首页(P0) + 周榜页全面对齐首页交互

- 根因: app.js 先于 data-pages.js 加载,boot 立即 router() 时 DataPages 未定义 → 数据页路由被当未知路由 → location.hash='#/' 回首页
- 修复: boot 改 DOMContentLoaded + 50ms 轮询等 DataPages 就绪再路由;router 兜底保护(数据页名+DataPages未定义不跳首页)
- 验证: browser-harness 真实验证(独立Chrome 9223调试实例) 直接访问/刷新/切换全部通过
- 首页周榜: 新增板块(前10+赛道日期筛选)、综合得分倒序排序、9列(新增粉丝/点赞/评论/分享+功能列)、导入按钮、去分页
- 完整周榜页(#/ranking): 对齐首页(赛道列前置、工具栏/分页右对齐、综合得分倒序+橙色、功能列居中、导入/查看按钮区分)
- 路由记忆: localStorage+cookie 双写,刷新后恢复上次页面
- 其他: AI写剧本→AI生成脚本、全部字体按比例放大+2(取整无小数)、外链新标签打开、btn-import/btn-view 样式
This commit is contained in:
maogeigei committed 2026-08-27 20:43:39 +08:00
1 parent 9248cbe776
commit 7f84c3b54d
9 files changed
+325 -102

No files matched your search

@@ -289,6 +289,37 @@ const server = http.createServer((req, res) => {
} catch (e) { return sendErr(500, e.message); }
}
// ---------- 提交 AI 任务(Automation 一次性任务,WorkBuddy 自动执行,左侧会话栏可见)----------
if (p === '/api/run' && req.method === 'POST') {
let body = '';
req.on('data', (c) => { body += c; if (body.length > 1e6) req.destroy(); });
req.on('end', () => {
try {
const { prompt, name } = JSON.parse(body || '{}');
if (!prompt || typeof prompt !== 'string' || !prompt.trim()) return sendErr(400, 'prompt 不能为空');
const { DatabaseSync } = require('node:sqlite');
const db = new DatabaseSync(process.env.WORKBUDDY_DB || path.join(os.homedir(), '.workbuddy', 'workbuddy.db'));
const now = Date.now();
const id = 'automation-' + now;
const cwd = 'D:\\AgentSkill\\mcn-workshop'; // 工作台触发的会话归入 mcn-workshop 空间分组
const d = new Date();
const pad = (n) => String(n).padStart(2, '0');
const scheduledAt = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
const uidRow = db.prepare("SELECT user_id FROM sessions WHERE user_id IS NOT NULL AND user_id <> '' ORDER BY created_at DESC LIMIT 1").get();
const ownerUserId = uidRow ? uidRow.user_id : '';
db.prepare(`INSERT INTO automations (id,name,prompt,status,schedule_type,next_run_at,scheduled_at,rrule,cwds,created_at,updated_at,skills_json,connector_ids_json,model_id,permission_mode,owner_user_id,owner_status)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`)
.run(id, name || '工作台任务', prompt.trim(), 'ACTIVE', 'once', now, scheduledAt, '', JSON.stringify([cwd]), now, now, '[]', '[]', 'deepseek-v4-flash', 'fullAccess', ownerUserId, 'confirmed');
db.close();
log('已提交 AI 任务: ' + id + (name ? ' (' + name + ')' : ''));
return sendJSON(200, { ok: true, id, message: '任务已提交,请在左侧会话栏查看执行' });
} catch (e) {
return sendErr(500, '任务提交失败: ' + e.message);
}
});
return;
}
// ---------- 静态文件 ----------
let filePath = path.join(PUBLIC_DIR, p === '/' ? 'index.html' : p);
// 防穿越