本提交为 dsh_mcn_workshop 仓库的首个提交(旧仓 dsh_MCNProject 已停用), 完整固化 C:/Users/Administrator/.dsh 当前磁盘状态。 1) 临时数据清理:移出 sessions/(81M)、logs/、skill-backup-20260906/(14M)、 scripts/__pycache__、storages/workspace.json.bak —— 合计 94M(.dsh 162M → 68M) 2) 凭据脱敏:.credentials.yaml(含明文 DEEPSEEK_API_KEY)移出 git 跟踪并加入 .gitignore;mcn-data-insight/scripts/setup_redfox_key.py 中真实 key 示例改为占位符 3) .gitignore 增补 logs/、skill-backup-*/ 规则 4) 技能结构以当前磁盘状态为准:skills/ = mcn-short-video / impeccable / taste-skill / dsh-multi-user-migration;旧技能目录(mcn-dou-analysis、storyboard-prompt、 short-video-script、browser-harness、mcn-data-insight)与 profiles/web/node_modules/dsh-vision-router 本地已不存在,本提交记为删除
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
// dsh-plugin-mcn HTTP 路由工具(拆分自 index.js)
|
||
|
||
function parseQuery(url) {
|
||
const u = new URL(url, "http://localhost");
|
||
const out = {};
|
||
for (const [k, v] of u.searchParams) out[k] = v;
|
||
return out;
|
||
}
|
||
|
||
function json(res, status, body) {
|
||
res.writeHead(status, { "Content-Type": "application/json; charset=utf-8" });
|
||
res.end(JSON.stringify(body));
|
||
}
|
||
|
||
function readBody(req) {
|
||
return new Promise((resolvePromise, reject) => {
|
||
// 收集 Buffer 后一次性按 UTF-8 解码:逐 chunk 直接拼字符串会独立解码各 chunk,
|
||
// 多字节字符横跨 chunk 边界时被损坏为 U+FFFD(大体积 data 导入必现)
|
||
const chunks = [];
|
||
req.on("data", (c) => { chunks.push(c); });
|
||
req.on("end", () => {
|
||
try {
|
||
const data = Buffer.concat(chunks).toString("utf8");
|
||
resolvePromise(data ? JSON.parse(data) : {});
|
||
} catch (e) {
|
||
reject(new Error("请求体 JSON 解析失败:请以 UTF-8 发送 JSON。若用 PowerShell 调用,勿用 Invoke-RestMethod 直接传含中文的 -Body 字符串(Windows PowerShell 5.1 会按 GBK 编码导致此错误),请改用 curl.exe --data-binary @文件 或 [System.Text.Encoding]::UTF8.GetBytes() 字节体"));
|
||
}
|
||
});
|
||
req.on("error", reject);
|
||
});
|
||
}
|
||
|
||
export { parseQuery, json, readBody };
|