- 工作台大版本升级:hash 路由 + 6 数据功能页(周榜/热门账号/账号详情/视频详情/AI写脚本/AI写作复盘),只读复用 dsh 库副本 + 抖音榜单 JSON - 数据库隔离:复制 dsh 库到 mcn-work-shop/,与 dsh 原库各访问各的(已 gitignore) - 图标全面扁平化:Lucide 线性 SVG,功能图标亮色区分,文字标题去图标 - 首页重构:功能入口卡 + AI写剧本快捷卡片(2列/8个/5行预览) + 独立帮助页 + header 精简 - 新增设计技能 impeccable + taste-skill(生成网页时参考) - 修复:fmtTime 跨 script 全局冲突(P0)、弹窗关闭、外链新标签打开等
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
export const LIVE_BROWSER_SCRIPT_PARTS = Object.freeze([
|
|
Object.freeze({ name: 'session-state', file: 'live-browser-session.js' }),
|
|
Object.freeze({ name: 'dom-helpers', file: 'live-browser-dom.js' }),
|
|
Object.freeze({ name: 'browser-ui', file: 'live-browser.js' }),
|
|
]);
|
|
|
|
export function resolveLiveBrowserScriptParts(scriptsDir, parts = LIVE_BROWSER_SCRIPT_PARTS) {
|
|
if (!scriptsDir) throw new Error('scriptsDir is required');
|
|
return parts.map((part, index) => ({
|
|
...part,
|
|
index,
|
|
path: path.join(scriptsDir, part.file),
|
|
}));
|
|
}
|
|
|
|
export function assertLiveBrowserScriptParts(parts, exists = fs.existsSync) {
|
|
for (const part of parts) {
|
|
if (!exists(part.path)) {
|
|
throw new Error(`Live browser script part missing: ${part.name} (${part.path})`);
|
|
}
|
|
}
|
|
return parts;
|
|
}
|
|
|
|
export function readLiveBrowserScriptParts(parts, readFile = (filePath) => fs.readFileSync(filePath, 'utf-8')) {
|
|
return parts.map((part) => ({
|
|
...part,
|
|
source: readFile(part.path),
|
|
}));
|
|
}
|
|
|
|
export function assembleLiveBrowserScript({ token, port, vocabulary, commandPrefix = '/', parts }) {
|
|
const prelude =
|
|
`window.__IMPECCABLE_TOKEN__ = '${token}';\n` +
|
|
`window.__IMPECCABLE_PORT__ = ${port};\n` +
|
|
`window.__IMPECCABLE_COMMAND_PREFIX__ = ${JSON.stringify(commandPrefix)};\n` +
|
|
// Canonical command vocabulary (values + labels + icons). live-browser.js
|
|
// builds its action picker from this instead of an inline copy.
|
|
`window.__IMPECCABLE_VOCAB__ = ${JSON.stringify(vocabulary)};\n`;
|
|
|
|
const body = parts.map((part) => {
|
|
const file = part.file || path.basename(part.path || '');
|
|
return `// --- impeccable live script part: ${part.name} (${file}) ---\n${part.source}`;
|
|
}).join('\n');
|
|
|
|
return prelude + body;
|
|
}
|