Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
468b0cebec | ||
|
|
f2ef7655dd | ||
|
|
6aa0d3dce4 | ||
|
|
b917f0e0ed | ||
|
|
1b053e5577 | ||
|
|
6b8349073d | ||
|
|
65b99b8cf3 | ||
|
|
071507e53f | ||
|
|
f65694516f | ||
|
|
a25a23fcdb | ||
|
|
73f1ce439e | ||
|
|
61711299ec | ||
|
|
b567701fa1 | ||
|
|
2d25e4ec39 | ||
|
|
4dd3a8c785 |
@@ -2,6 +2,7 @@
|
||||
|
||||
- [README](../README.md) — 项目概述与目录结构
|
||||
- [PRD](../02_process/PRD.md) — 需求与设计(含接手分界线 §11)
|
||||
- [本地改造记录](../02_process/LOCAL-CHANGES.md) — 相对上游的全部本地定制(改侧栏/状态/二级页面前先读)
|
||||
- [兼容与安全](../docs/compatibility-and-security.md) — 当前 0.5.1 范围、接口与隔离限制
|
||||
- [AGENTS](../AGENTS.md) — 项目规则
|
||||
- [01_content](../01_content) — 插件包
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "dsh-worktable",
|
||||
"description": "工作台:DSH 侧边栏的 agent 级项目容器,收纳如 TravelAtlas 等自装项目",
|
||||
"version": "0.5.3-local.3",
|
||||
"version": "0.5.3-local.10",
|
||||
"entry": {
|
||||
"name": "dsh-worktable",
|
||||
"inject": []
|
||||
|
||||
+212
-66
@@ -7986,7 +7986,10 @@ var css = xterm_default + "\n" + [
|
||||
".dsh-wt_layout:hover{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}",
|
||||
".dsh-wt_layout[data-on=true]{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}",
|
||||
".dsh-wt_layout[data-on=true] .dsh-wt_layoutName{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}",
|
||||
".dsh-wt_layoutIcon{flex:none;font-size:15px}",
|
||||
".dsh-wt_layoutIcon{flex:none;font-size:15px;display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px}",
|
||||
// 内联 SVG 图标:跟随文字色,两平台渲染一致(emoji 依赖系统字体,形状/配色不统一)
|
||||
".dsh-wt_layoutSvg{width:15px;height:15px;display:block;flex:none;color:var(--dsw-alias-label-secondary,#9aa4b2)}",
|
||||
".dsh-wt_layout[data-on=true] .dsh-wt_layoutSvg{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}",
|
||||
".dsh-wt_layoutText{flex:1;min-width:0;display:flex;flex-direction:column;gap:0}",
|
||||
".dsh-wt_layoutName{font-size:12px;font-weight:400;line-height:17px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
||||
// 箭头与项目名同一行高 + 字面中心对齐;› 墨迹在字面框内偏下,整体上移 1px 使视觉居中
|
||||
@@ -8404,7 +8407,11 @@ var css = xterm_default + "\n" + [
|
||||
".dsh-wt_updateBtn svg{width:12px;height:12px;flex:none}",
|
||||
".dsh-wt_updateBadge svg{width:12px;height:12px;flex:none}",
|
||||
".dsh-wt_updateBtn:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}",
|
||||
".dsh-wt_updateBtnCopy{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:rgba(79,142,247,.18);color:#cfe0ff}",
|
||||
// 「复制 AI 提示词」主按钮:原来用 rgba(...,.18) 半透明底 + 浅蓝字,在实际主题上
|
||||
// 对比度极低(截图里几乎看不见)。改为实心强调色 + 白字,hover/active 明确反馈。
|
||||
".dsh-wt_updateBtnCopy{border-color:transparent;background:var(--dsw-alias-state-accent-primary,#4f8ef7);color:#fff;font-weight:600}",
|
||||
".dsh-wt_updateBtnCopy:hover{background:var(--dsw-alias-state-accent-primary-hover,#3f7de0);color:#fff}",
|
||||
".dsh-wt_updateBtnCopy:active{transform:translateY(.5px)}",
|
||||
".dsh-wt_updateHint{font-size:10.5px;color:var(--dsw-alias-label-tertiary,#7d8aa5)}",
|
||||
".dsh-wt_versionRow{margin-top:8px;padding-top:8px;border-top:1px solid var(--dsw-alias-border-l1,#262b36);display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--dsw-alias-label-tertiary,#7d8aa5)}",
|
||||
".dsh-wt_updateToggle{display:flex;align-items:center;gap:6px;cursor:pointer;user-select:none}",
|
||||
@@ -8412,7 +8419,25 @@ var css = xterm_default + "\n" + [
|
||||
".dsh-wt_updateSwitch{position:relative;width:26px;height:14px;border-radius:999px;background:var(--dsw-alias-state-accent-primary,#4f8ef7);cursor:pointer}",
|
||||
'.dsh-wt_updateSwitch::after{content:"";position:absolute;top:2px;right:2px;width:10px;height:10px;border-radius:50%;background:#fff;transition:right .15s}',
|
||||
".dsh-wt_updateSwitch[data-off=true]{background:var(--dsw-alias-border-l1,#333a48)}",
|
||||
".dsh-wt_updateSwitch[data-off=true]::after{right:14px}"
|
||||
".dsh-wt_updateSwitch[data-off=true]::after{right:14px}",
|
||||
// 二级页面:缩进 + 左侧引导折线
|
||||
".dsh-wt_layoutSub{margin-left:20px;border-style:dashed;position:relative;height:30px!important}",
|
||||
".dsh-wt_layoutSub .dsh-wt_layoutName{font-size:11.5px;color:var(--dsw-alias-label-secondary,#9aa4b2)}",
|
||||
'.dsh-wt_layoutSub::before{content:"";position:absolute;left:-12px;top:-11px;bottom:50%;width:9px;border-left:1.5px solid var(--dsw-alias-border-l2,#3a4150);border-bottom:1.5px solid var(--dsw-alias-border-l2,#3a4150);border-bottom-left-radius:6px;pointer-events:none}',
|
||||
// 折叠按钮:固定在最右(› 箭头右侧),无边框无底色;所有项目卡都占这个位置(无子页面的用 ghost 占位)
|
||||
".dsh-wt_foldBtn{position:absolute;right:0px;top:50%;transform:translateY(-50%);z-index:3;display:inline-flex;align-items:center;justify-content:center;width:16px;height:18px;border-radius:4px;font-size:11px;line-height:1;cursor:pointer;color:var(--dsw-alias-label-secondary,#9aa4b2)}",
|
||||
".dsh-wt_foldBtn:hover{color:var(--dsw-alias-label-primary,#e6e8eb)}",
|
||||
".dsh-wt_foldBtnGhost{cursor:default;pointer-events:none}",
|
||||
".dsh-wt_layoutHasKids .dsh-wt_layoutArrow{margin-right:0}",
|
||||
".dsh-wt_manageRowSub{margin-left:20px}",
|
||||
// DS Bot 侧栏元素隐藏(迁移自「改 ds-bot/client.js 插 return null」的做法)。
|
||||
// 动机:ds-bot 是随应用升级的 .bundled-plugins tgz 安装,升级/重装必丢改;
|
||||
// 改为由本插件注入 CSS,只要工作台装着,ds-bot 随便升级都不丢。
|
||||
// 注意:nav.bt-home-nav 必须带 nav 标签选择器 —— BotHome 错误面板有同名 div,不能误伤。
|
||||
// 「返回 bot」按钮([data-slot="sidebar.footer.action"] .bt-return)按用户要求保留显示,不隐藏。
|
||||
'[data-testid="duet-transcript-toggle"]{display:none!important}',
|
||||
"nav.bt-home-nav{display:none!important}",
|
||||
".bt-connect-wrap{display:none!important}"
|
||||
].join("\n");
|
||||
|
||||
// src/client/locales.ts
|
||||
@@ -8471,6 +8496,9 @@ var zh = {
|
||||
"manage.deleteLayout": "\u5220\u9664\u5E03\u5C40",
|
||||
"manage.deleteProject": "\u5220\u9664\u9879\u76EE",
|
||||
"manage.changeView": "\u53D8\u66F4\u89C6\u56FE",
|
||||
"manage.addPage": "\u65B0\u589E\u4E8C\u7EA7\u9875\u9762",
|
||||
"tree.fold": "\u6298\u53E0\u4E8C\u7EA7\u9875\u9762",
|
||||
"tree.expand": "\u5C55\u5F00\u4E8C\u7EA7\u9875\u9762",
|
||||
"viewPick.title": "\u9009\u62E9\u65B0\u89C6\u56FE\uFF08\u5185\u5BB9\u7A97\u81EA\u52A8\u8FC1\u5165\uFF09",
|
||||
"confirm.title": "\u5220\u9664\u9879\u76EE",
|
||||
"confirm.cancel": "\u53D6\u6D88",
|
||||
@@ -8638,6 +8666,7 @@ var zh = {
|
||||
"update.available": "\u65B0\u7248\u672C\u53EF\u7528",
|
||||
"update.current": "\u5F53\u524D\u7248\u672C",
|
||||
"update.copyAi": "\u590D\u5236 AI \u63D0\u793A\u8BCD",
|
||||
"update.copyFailed": "\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u4E2D\u547D\u4EE4",
|
||||
"update.skip": "\u5FFD\u7565\u6B64\u7248\u672C",
|
||||
"update.autoCheck": "\u81EA\u52A8\u68C0\u67E5\u66F4\u65B0",
|
||||
"update.checkNow": "\u7ACB\u5373\u68C0\u67E5",
|
||||
@@ -8705,6 +8734,9 @@ var en = {
|
||||
"manage.deleteLayout": "Delete layout",
|
||||
"manage.deleteProject": "Delete project",
|
||||
"manage.changeView": "Change layout",
|
||||
"manage.addPage": "Add sub page",
|
||||
"tree.fold": "Collapse sub pages",
|
||||
"tree.expand": "Expand sub pages",
|
||||
"viewPick.title": "Pick a new layout (panes migrate automatically)",
|
||||
"confirm.title": "Delete project",
|
||||
"confirm.cancel": "Cancel",
|
||||
@@ -8872,6 +8904,7 @@ var en = {
|
||||
"update.available": "New version available",
|
||||
"update.current": "Current version",
|
||||
"update.copyAi": "Copy AI prompt",
|
||||
"update.copyFailed": "Copy failed, select the command manually",
|
||||
"update.skip": "Skip this version",
|
||||
"update.autoCheck": "Auto-check updates",
|
||||
"update.checkNow": "Check now",
|
||||
@@ -8943,9 +8976,17 @@ function hostPreviewUrl(path, surface = {
|
||||
if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("Unsupported Host preview protocol");
|
||||
return url.href;
|
||||
}
|
||||
function worktableUpgrade(protocol = typeof location === "undefined" ? "http:" : location.protocol) {
|
||||
var UPDATE_BASE = "https://gitea.ququclean.com/xiaoqu/dsh-worktable/releases/download";
|
||||
function upgradeCommandFor(tag, protocol = typeof location === "undefined" ? "http:" : location.protocol) {
|
||||
const desktop = protocol === "dsh-app:";
|
||||
const command = "dsh plugin --profile " + (desktop ? "desktop" : "web") + ' add "https://github.com/Aisland-SJL/dsh-worktable/releases/latest/download/dsh-worktable.tgz"';
|
||||
const clean = String(tag || "").trim().replace(/^v/, "");
|
||||
const t = clean ? "v" + clean : "";
|
||||
const url = t ? UPDATE_BASE + "/" + t + "/dsh-worktable.tgz" : UPDATE_BASE + "/";
|
||||
return "dsh plugin --profile " + (desktop ? "desktop" : "web") + ' add "' + url + '"';
|
||||
}
|
||||
function worktableUpgrade(tag, protocol = typeof location === "undefined" ? "http:" : location.protocol) {
|
||||
const desktop = protocol === "dsh-app:";
|
||||
const command = upgradeCommandFor(tag, protocol);
|
||||
const prompt = desktop ? "\u5E2E\u6211\u5347\u7EA7 dsh-worktable\u3002\u6211\u5F53\u524D\u4F7F\u7528\u5B98\u65B9\u684C\u9762\u7AEF\uFF1A\u5148\u5B9A\u4F4D\u8BE5\u684C\u9762\u7AEF\u81EA\u5E26\u7684 dsh CLI \u5E76\u51C6\u5907\u66F4\u65B0\uFF0C\u518D\u63D0\u9192\u6211\u5B8C\u6574\u9000\u51FA\u684C\u9762\u7AEF\u3002\u786E\u8BA4\u9000\u51FA\u540E\u4F7F\u7528\u8BE5 CLI \u6267\u884C " + command + "\u3002\u4E0D\u8981\u4F7F\u7528\u7F51\u9875\u7AEF CLI\uFF0C\u4E0D\u8981\u4FEE\u6539 web profile\uFF0C\u4E0D\u8981\u81EA\u52A8\u6740\u8FDB\u7A0B\u6216\u91CD\u542F\uFF1B\u5B8C\u6210\u540E\u63D0\u9192\u6211\u624B\u52A8\u91CD\u65B0\u6253\u5F00\u684C\u9762\u7AEF\u3002" : "\u5E2E\u6211\u5347\u7EA7 dsh-worktable\uFF1A\u6267\u884C " + command + "\uFF0C\u5B8C\u6210\u540E\u63D0\u9192\u6211\u91CD\u542F dsh web \u5E76\u5237\u65B0\u9875\u9762";
|
||||
return { command, prompt, desktop };
|
||||
}
|
||||
@@ -9175,8 +9216,8 @@ var CHANGELOG_V030 = `\u66F4\u65B0\u516C\u544A \xB7 v0.5.1
|
||||
\u30103.1 \u6587\u5B57\u4E0E\u7EC6\u8282\u6253\u78E8\u3011\u5168\u5C40\u5B57\u4F53\u4E0E\u5B57\u53F7\u7EDF\u4E00\u4F18\u5316\u3001\u4E0B\u62C9\u9762\u677F\u73BB\u7483\u5316\u4E0E\u5BF9\u9F50\u3001\u83DC\u5355\u70B9\u9009\u540E\u4FDD\u6301\u6253\u5F00\u4FBF\u4E8E\u8FDE\u7EED\u9884\u89C8\u3001\u6309\u94AE\u63CF\u8FB9\u4E0E\u60AC\u505C\u53CD\u9988\u7B49\u4EA4\u4E92\u7EC6\u8282\uFF1B\u540C\u65F6\u4FEE\u590D\u4E86\u591A\u9879\u4F53\u9A8C\u95EE\u9898\uFF08\u7167\u7247\u4E0A\u4F20\u6E05\u6670\u5EA6\u3001\u80CC\u666F\u7F51\u683C\u7EBF\u5728\u7167\u7247\u6A21\u5F0F\u4E0B\u4E0D\u751F\u6548\u3001\u6D45\u8272\u4E3B\u9898\u4E0B\u5DE5\u4F5C\u72B6\u6001\u5149\u6548\u4E0D\u53EF\u89C1\u7B49\uFF09\u3002`;
|
||||
|
||||
// src/client/updateCheck.ts
|
||||
var LOCAL_VERSION = false ? "dev" : "0.5.3-local.3";
|
||||
var UPDATE_REPO = "Aisland-SJL/dsh-worktable";
|
||||
var LOCAL_VERSION = false ? "dev" : "0.5.3-local.10";
|
||||
var UPDATE_API = "/api/worktable/update-check";
|
||||
var K_UPDATE_CHECK = "dsh.worktable.updateCheck.v1";
|
||||
var K_LAST_CHECK = "dsh.worktable.lastUpdateCheck.v1";
|
||||
var K_SKIP = "dsh.worktable.skipVersion.v1";
|
||||
@@ -9280,7 +9321,7 @@ async function checkUpdate(force = false) {
|
||||
const ctrl = new AbortController();
|
||||
const timer2 = setTimeout(() => ctrl.abort(), 8e3);
|
||||
try {
|
||||
const r = await fetch("https://api.github.com/repos/" + UPDATE_REPO + "/releases/latest", { headers: { Accept: "application/vnd.github+json" }, cache: "no-store", signal: ctrl.signal });
|
||||
const r = await fetch(UPDATE_API, { headers: { Accept: "application/json" }, cache: "no-store", signal: ctrl.signal });
|
||||
if (r.ok) d = await r.json();
|
||||
else if (r.status === 403 || r.status === 404) break;
|
||||
} catch {
|
||||
@@ -17336,7 +17377,6 @@ function boxPayload(x0, y0, x1, y1) {
|
||||
}
|
||||
return { primary, line, candidates, limited, src };
|
||||
}
|
||||
var { prompt: UPGRADE_AI } = worktableUpgrade();
|
||||
async function copyTextSafe(text2) {
|
||||
try {
|
||||
if (navigator.clipboard?.writeText) {
|
||||
@@ -18617,7 +18657,8 @@ function ConsolePane() {
|
||||
};
|
||||
const [updCopied, setUpdCopied] = (0, import_react2.useState)(false);
|
||||
const onCopyUpgrade = async () => {
|
||||
const ok = await copyTextSafe(UPGRADE_AI);
|
||||
const { prompt } = worktableUpgrade(updInfo?.latest ?? LOCAL_VERSION);
|
||||
const ok = await copyTextSafe(prompt);
|
||||
if (ok) {
|
||||
setUpdCopied(true);
|
||||
window.setTimeout(() => setUpdCopied(false), 2200);
|
||||
@@ -19460,7 +19501,7 @@ function FileViewer(props) {
|
||||
const ext = (props.path.split(".").pop() || "").toLowerCase();
|
||||
const fileUrl = "/api/worktable/file?path=" + encodeURIComponent(props.path);
|
||||
if (ext === "pdf") {
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("iframe", { className: "dsh-wt_paneFrame", src: fileUrl, title: basenameOf2(props.path) });
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("iframe", { className: "dsh-wt_paneFrame", src: fileUrl, title: basenameOf2(props.path), allowFullScreen: true });
|
||||
}
|
||||
if (IMAGE_EXTS.test("." + ext)) {
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-wt_imgView", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { src: fileUrl, alt: basenameOf2(props.path) }) });
|
||||
@@ -20845,8 +20886,8 @@ function flushHostSave() {
|
||||
|
||||
// src/client/index.tsx
|
||||
var import_jsx_runtime3 = require("react/jsx-runtime");
|
||||
var UPDATE_REPO2 = "Aisland-SJL/dsh-worktable";
|
||||
var { command: UPGRADE_CMD, prompt: UPGRADE_AI2, desktop: DESKTOP_HOST } = worktableUpgrade();
|
||||
var UPDATE_API2 = "/api/worktable/update-check";
|
||||
var DESKTOP_HOST = typeof location !== "undefined" && location.protocol === "dsh-app:";
|
||||
var ICON_SYNC = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { viewBox: "0 0 16 16", "aria-hidden": true, children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", d: "M1.5 8a6.5 6.5 0 0 1 11.1-4.6L14.5 5" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", d: "M14.5 1.5V5h-3.5" }),
|
||||
@@ -20858,6 +20899,26 @@ var ICON_SPARK = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { viewBox:
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12.6 11.2l.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5z", fill: "currentColor" })
|
||||
] });
|
||||
async function copyText(text2) {
|
||||
try {
|
||||
if (navigator.clipboard?.writeText && window.isSecureContext !== false) {
|
||||
await navigator.clipboard.writeText(text2);
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
try {
|
||||
const ta = document.createElement("textarea");
|
||||
ta.value = text2;
|
||||
ta.setAttribute("readonly", "");
|
||||
ta.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none";
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
ta.setSelectionRange(0, ta.value.length);
|
||||
const ok = typeof document.execCommand === "function" ? document.execCommand("copy") : false;
|
||||
document.body.removeChild(ta);
|
||||
if (ok) return true;
|
||||
} catch {
|
||||
}
|
||||
try {
|
||||
if (navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(text2);
|
||||
@@ -21052,6 +21113,7 @@ function normalizeView(raw) {
|
||||
orderBy,
|
||||
dock: p.dock === "float" ? "float" : "footer",
|
||||
floatTop: typeof p.floatTop === "number" ? p.floatTop : null,
|
||||
foldedProjects: Array.isArray(p.foldedProjects) ? p.foldedProjects.filter((x) => typeof x === "string") : [],
|
||||
consoleTheme: p.consoleTheme === "dark" || p.consoleTheme === "light" || p.consoleTheme === "system" ? p.consoleTheme : "system",
|
||||
consoleCols: typeof p.consoleCols === "number" && p.consoleCols >= 1 && p.consoleCols <= 5 ? Math.round(p.consoleCols) : 3,
|
||||
consoleShape: p.consoleShape === "circle" ? "circle" : "square",
|
||||
@@ -21262,6 +21324,11 @@ async function ensureSessionModel(sessionId) {
|
||||
}
|
||||
var CONSOLE_ID = "wt-console";
|
||||
var CONSOLE_ICON = "\u{1F5A5}\uFE0F";
|
||||
var ICON_CONSOLE = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { className: "dsh-wt_layoutSvg", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { x: "1.6", y: "2.2", width: "12.8", height: "8.6", rx: "1.5", stroke: "currentColor", strokeWidth: "1.3" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M5.2 13.4h5.6", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M8 10.8v2.6", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
|
||||
] });
|
||||
function specHasConsoleTab(spec) {
|
||||
return !!spec?.main?.[0]?.tabs?.some((t) => t.content?.kind === "builtin" && t.content.type === "console");
|
||||
}
|
||||
@@ -21744,6 +21811,7 @@ function WorktableSection(props) {
|
||||
const updateInfo = newerUpdateInfo(rawUpdateInfo);
|
||||
const [updateCheckOn, setUpdateCheckOn] = (0, import_react3.useState)(() => localStorage.getItem("dsh.worktable.updateCheck.v1") !== "0");
|
||||
const [updateCopied, setUpdateCopied] = (0, import_react3.useState)(false);
|
||||
const [updateCopyFailed, setUpdateCopyFailed] = (0, import_react3.useState)(false);
|
||||
const [updateStatus, setUpdateStatus] = (0, import_react3.useState)("idle");
|
||||
const updateCheckingRef = (0, import_react3.useRef)(false);
|
||||
const updateAliveRef = (0, import_react3.useRef)(true);
|
||||
@@ -21768,7 +21836,7 @@ function WorktableSection(props) {
|
||||
const ctrl = new AbortController();
|
||||
const timer2 = setTimeout(() => ctrl.abort(), 8e3);
|
||||
try {
|
||||
const r = await fetch("https://api.github.com/repos/" + UPDATE_REPO2 + "/releases/latest", { headers: { Accept: "application/vnd.github+json" }, cache: "no-store", signal: ctrl.signal });
|
||||
const r = await fetch(UPDATE_API2, { headers: { Accept: "application/json" }, cache: "no-store", signal: ctrl.signal });
|
||||
if (r.ok) d = await r.json();
|
||||
else if (r.status === 403 || r.status === 404) break;
|
||||
} catch {
|
||||
@@ -21804,11 +21872,19 @@ function WorktableSection(props) {
|
||||
(0, import_react3.useEffect)(() => {
|
||||
if (updateCheckOn) void checkUpdates();
|
||||
}, [updateCheckOn, checkUpdates]);
|
||||
const upgrade = (0, import_react3.useMemo)(
|
||||
() => worktableUpgrade(updateInfo?.latest ?? LOCAL_VERSION),
|
||||
[updateInfo?.latest]
|
||||
);
|
||||
const copyUpgradeAi = async () => {
|
||||
const ok = await copyText(UPGRADE_AI2);
|
||||
const ok = await copyText(upgrade.prompt);
|
||||
if (ok) {
|
||||
setUpdateCopyFailed(false);
|
||||
setUpdateCopied(true);
|
||||
setTimeout(() => setUpdateCopied(false), 2200);
|
||||
} else {
|
||||
setUpdateCopyFailed(true);
|
||||
setTimeout(() => setUpdateCopyFailed(false), 3e3);
|
||||
}
|
||||
};
|
||||
const skipUpdate = () => {
|
||||
@@ -22938,7 +23014,28 @@ function WorktableSection(props) {
|
||||
};
|
||||
const removeLayout = (id) => {
|
||||
invalidateWidgetProject(id);
|
||||
persistProjects((prev) => ({ ...prev, layouts: prev.layouts.filter((l) => l.id !== id) }));
|
||||
persistProjects((prev) => ({
|
||||
...prev,
|
||||
layouts: prev.layouts.filter((l) => l.id !== id).map((l) => l.parentId === id ? { ...l, parentId: void 0 } : l)
|
||||
}));
|
||||
};
|
||||
const addSubPage = (parent) => {
|
||||
const parentName = projects.nameOverrides[parent.id] ?? parent.title;
|
||||
const child = buildLayout("2h", parentName + " \xB7 \u65B0\u9875\u9762");
|
||||
child.parentId = parent.id;
|
||||
const folder = projects.folders[parent.id];
|
||||
persistProjects((prev) => ({
|
||||
...prev,
|
||||
layouts: [...prev.layouts, child],
|
||||
folders: folder ? { ...prev.folders, [child.id]: folder } : prev.folders
|
||||
}));
|
||||
invalidatePickState();
|
||||
openSplit(child);
|
||||
reportUsed(child.id);
|
||||
};
|
||||
const toggleFold = (id) => {
|
||||
const folded = view.foldedProjects ?? [];
|
||||
persistView({ foldedProjects: folded.includes(id) ? folded.filter((x) => x !== id) : [...folded, id] });
|
||||
};
|
||||
const applyLayoutChange = (id, presetId) => {
|
||||
invalidateWidgetProject(id);
|
||||
@@ -23146,6 +23243,28 @@ function WorktableSection(props) {
|
||||
const paneTitles = [...l.top ?? [], ...l.main].map((p) => p.title).join(" ");
|
||||
return (l.title + " " + paneTitles).toLowerCase().includes(queryLower);
|
||||
});
|
||||
const layoutTree = (0, import_react3.useMemo)(() => {
|
||||
const visIds = new Set(visibleLayouts.map((l) => l.id));
|
||||
const kids = /* @__PURE__ */ new Map();
|
||||
const roots = [];
|
||||
for (const l of visibleLayouts) {
|
||||
if (l.parentId && visIds.has(l.parentId)) {
|
||||
const arr = kids.get(l.parentId) ?? [];
|
||||
arr.push(l);
|
||||
kids.set(l.parentId, arr);
|
||||
} else roots.push(l);
|
||||
}
|
||||
const ord = (a, b) => effectiveOrder.indexOf(a.id) - effectiveOrder.indexOf(b.id);
|
||||
const out = [];
|
||||
for (const r of [...roots].sort(ord)) {
|
||||
const cs = (kids.get(r.id) ?? []).sort(ord);
|
||||
out.push({ node: r, depth: 0, hasKids: cs.length > 0 });
|
||||
if (!(view.foldedProjects ?? []).includes(r.id)) {
|
||||
for (const c of cs) out.push({ node: c, depth: 1, hasKids: false });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}, [visibleLayouts, effectiveOrder, view.foldedProjects]);
|
||||
const isFloat = float != null;
|
||||
const floatStyle = isFloat ? {
|
||||
position: "fixed",
|
||||
@@ -23394,9 +23513,9 @@ function WorktableSection(props) {
|
||||
updateInfo.latest
|
||||
] }),
|
||||
updateInfo.notes && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-wt_updateNotes", children: updateInfo.notes }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-wt_updateCmd", children: UPGRADE_CMD }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-wt_updateCmd", children: upgrade.command }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-wt_updateBtns", children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "dsh-wt_updateBtn dsh-wt_updateBtnCopy", onClick: () => void copyUpgradeAi(), children: updateCopied ? "\u2713 " + t("update.copied") : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "dsh-wt_updateBtn dsh-wt_updateBtnCopy", onClick: () => void copyUpgradeAi(), children: updateCopied ? "\u2713 " + t("update.copied") : updateCopyFailed ? "\u26A0 " + t("update.copyFailed") : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
||||
ICON_SPARK,
|
||||
" ",
|
||||
t("update.copyAi")
|
||||
@@ -23488,6 +23607,16 @@ function WorktableSection(props) {
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RenameInput, { initial: display, placeholder: t("manage.renamePh"), onCommit: (v) => renameProject(id, v) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "dsh-wt_manageBtn", title: isHidden ? t("manage.show") : t("manage.hide"), onClick: () => toggleHidden(id), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(EyeIcon, { closed: isHidden }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "dsh-wt_manageBtn", title: t("manage.changeView"), onClick: () => setViewPickFor(id), children: "\u{1F9E9}" }),
|
||||
layout && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
||||
"button",
|
||||
{
|
||||
type: "button",
|
||||
className: "dsh-wt_manageBtn",
|
||||
title: t("manage.addPage"),
|
||||
onClick: () => addSubPage(layout),
|
||||
children: "\uFF0B"
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
||||
"button",
|
||||
{
|
||||
@@ -23967,7 +24096,7 @@ function WorktableSection(props) {
|
||||
title: t("console.name"),
|
||||
onClick: (e) => clickConsoleCard(e.currentTarget),
|
||||
children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutIcon", children: CONSOLE_ICON }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutIcon", children: ICON_CONSOLE }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutText", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutName", children: t("console.name") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
||||
"span",
|
||||
@@ -23990,54 +24119,71 @@ function WorktableSection(props) {
|
||||
}
|
||||
),
|
||||
renderProjectSlot ? renderProjectSlot("sidebar.worktable.project", ownerProps) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-wt_empty", children: t("empty") }),
|
||||
visibleLayouts.map((l) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
||||
"button",
|
||||
{
|
||||
type: "button",
|
||||
className: "dsh-wt_layout",
|
||||
"data-on": activeSplitId === l.id ? "true" : "false",
|
||||
style: { order: effectiveOrder.indexOf(l.id) + 1e3, position: "relative" },
|
||||
onClick: () => {
|
||||
openSplit(l);
|
||||
reportUsed(l.id);
|
||||
layoutTree.map(({ node: l, depth, hasKids }, ti) => {
|
||||
const folded = (view.foldedProjects ?? []).includes(l.id);
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
||||
"button",
|
||||
{
|
||||
type: "button",
|
||||
className: "dsh-wt_layout" + (depth === 1 ? " dsh-wt_layoutSub" : "") + (hasKids ? " dsh-wt_layoutHasKids" : ""),
|
||||
"data-on": activeSplitId === l.id ? "true" : "false",
|
||||
style: { order: ti + 1e3, position: "relative" },
|
||||
onClick: () => {
|
||||
openSplit(l);
|
||||
reportUsed(l.id);
|
||||
},
|
||||
children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
||||
"span",
|
||||
{
|
||||
className: "dsh-wt_layoutIcon dsh-wt_iconPick",
|
||||
role: "button",
|
||||
tabIndex: 0,
|
||||
title: t("icons.change"),
|
||||
onClick: (e) => {
|
||||
e.stopPropagation();
|
||||
openIconPick("layout", l.id, e.currentTarget);
|
||||
},
|
||||
children: l.icon ?? "\u{1F9F1}"
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutText", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutName", children: projects.nameOverrides[l.id] ?? l.title }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
||||
"span",
|
||||
{
|
||||
className: "dsh-wt_bindBtn",
|
||||
role: "button",
|
||||
tabIndex: 0,
|
||||
"data-bound": bindNotifyMap[l.id] ?? (projects.bindings[l.id] ? "true" : "false"),
|
||||
"data-tip": projects.bindings[l.id] ? t("bind.tipBound", { name: boundSessionTitle(projects.bindings[l.id]) }) + (bindNotifyMap[l.id] === "busy" ? t("bind.tipBusy") : bindNotifyMap[l.id] === "done" ? t("bind.tipDone") : bindNotifyMap[l.id] === "need" ? t("bind.tipNeed") : "") : t("bind.tipUnbound"),
|
||||
"aria-label": projects.bindings[l.id] ? t("bind.tipBound", { name: boundSessionTitle(projects.bindings[l.id]) }) : t("bind.tipUnbound"),
|
||||
onClick: (e) => {
|
||||
e.stopPropagation();
|
||||
openBindPick(l.id, e.currentTarget);
|
||||
},
|
||||
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_bindCircles", "aria-hidden": true })
|
||||
}
|
||||
),
|
||||
hasKids ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
||||
"span",
|
||||
{
|
||||
className: "dsh-wt_foldBtn" + (folded ? " dsh-wt_foldBtnOff" : ""),
|
||||
role: "button",
|
||||
tabIndex: 0,
|
||||
title: folded ? t("tree.expand") : t("tree.fold"),
|
||||
onClick: (e) => {
|
||||
e.stopPropagation();
|
||||
toggleFold(l.id);
|
||||
},
|
||||
children: folded ? "\u25B8" : "\u25BE"
|
||||
}
|
||||
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_foldBtn dsh-wt_foldBtnGhost", "aria-hidden": true }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutArrow", "aria-hidden": true, children: "\u203A" })
|
||||
]
|
||||
},
|
||||
children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
||||
"span",
|
||||
{
|
||||
className: "dsh-wt_layoutIcon dsh-wt_iconPick",
|
||||
role: "button",
|
||||
tabIndex: 0,
|
||||
title: t("icons.change"),
|
||||
onClick: (e) => {
|
||||
e.stopPropagation();
|
||||
openIconPick("layout", l.id, e.currentTarget);
|
||||
},
|
||||
children: l.icon ?? "\u{1F9F1}"
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutText", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutName", children: projects.nameOverrides[l.id] ?? l.title }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
||||
"span",
|
||||
{
|
||||
className: "dsh-wt_bindBtn",
|
||||
role: "button",
|
||||
tabIndex: 0,
|
||||
"data-bound": bindNotifyMap[l.id] ?? (projects.bindings[l.id] ? "true" : "false"),
|
||||
"data-tip": projects.bindings[l.id] ? t("bind.tipBound", { name: boundSessionTitle(projects.bindings[l.id]) }) + (bindNotifyMap[l.id] === "busy" ? t("bind.tipBusy") : bindNotifyMap[l.id] === "done" ? t("bind.tipDone") : bindNotifyMap[l.id] === "need" ? t("bind.tipNeed") : "") : t("bind.tipUnbound"),
|
||||
"aria-label": projects.bindings[l.id] ? t("bind.tipBound", { name: boundSessionTitle(projects.bindings[l.id]) }) : t("bind.tipUnbound"),
|
||||
onClick: (e) => {
|
||||
e.stopPropagation();
|
||||
openBindPick(l.id, e.currentTarget);
|
||||
},
|
||||
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_bindCircles", "aria-hidden": true })
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-wt_layoutArrow", "aria-hidden": true, children: "\u203A" })
|
||||
]
|
||||
},
|
||||
l.id
|
||||
))
|
||||
l.id
|
||||
);
|
||||
})
|
||||
] }),
|
||||
visibleShortcuts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-wt_shortcuts", children: visibleShortcuts.map((s) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
||||
"a",
|
||||
|
||||
+292
-88
@@ -117,85 +117,242 @@ function createPreviewFiles(now = () => Date.now()) {
|
||||
};
|
||||
}
|
||||
|
||||
// template/dshell.css
|
||||
var dshell_default = `/* dsh-worktable \u539F\u751F\u76AE\u80A4 \xB7 DSH \u8BBE\u8BA1\u7CFB\u7EDF\u7EC4\u4EF6\u5E93
|
||||
\u7528\u6CD5\uFF1A<link rel="stylesheet" href="/api/worktable/template/dshell.css">
|
||||
\u6240\u6709\u989C\u8272\u8D70 DSH \u4E3B\u9898\u53D8\u91CF\uFF08--dsw-alias-*\uFF09\uFF0C\u81EA\u52A8\u9002\u914D\u660E\u6697\u4E3B\u9898\u3002 */
|
||||
:root { color-scheme: dark; }
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
body {
|
||||
background: var(--dsw-alias-bg-base, #0b0e14);
|
||||
color: var(--dsw-alias-label-primary, #e6e8eb);
|
||||
font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
// src/theme.ts
|
||||
var THEME_VAR_PREFIXES = ["--dsw-", "--dsh-", "--ds-"];
|
||||
var THEME_BRIDGE_ID = "wt-theme-bridge";
|
||||
var THEME_JS_PATH = "/api/worktable/template/theme.js";
|
||||
var THEME_BRIDGE_JS = `(function () {
|
||||
var PREFIXES = ${JSON.stringify(THEME_VAR_PREFIXES)};
|
||||
if (window.__wtThemeBridgeInstalled) return;
|
||||
window.__wtThemeBridgeInstalled = true;
|
||||
function ok(name) {
|
||||
if (!name || name.slice(0, 2) !== '--') return false;
|
||||
for (var i = 0; i < PREFIXES.length; i++) if (name.slice(0, PREFIXES[i].length) === PREFIXES[i]) return true;
|
||||
return false;
|
||||
}
|
||||
/** \u5411\u4E0A\u627E\u5230\u6700\u5916\u5C42\u540C\u6E90\u7956\u5148\u7A97\u53E3\uFF1B\u8DE8\u57DF\u6216\u5230\u9876\u5C31\u505C\u3002 */
|
||||
function hostWindow() {
|
||||
var w = window;
|
||||
try {
|
||||
for (var i = 0; i < 12; i++) {
|
||||
var p = w.parent;
|
||||
if (!p || p === w) break;
|
||||
if (!p.document || !p.document.documentElement) break;
|
||||
w = p;
|
||||
}
|
||||
} catch (e) { /* \u8DE8\u57DF\uFF1A\u505C\u5728\u5F53\u524D\u5C42 */ }
|
||||
return w === window ? null : w;
|
||||
}
|
||||
function hostVars(host) {
|
||||
var out = [];
|
||||
try {
|
||||
var el = host.document.body || host.document.documentElement;
|
||||
if (!el) return out;
|
||||
var cs = host.getComputedStyle(el);
|
||||
for (var i = 0; i < cs.length; i++) {
|
||||
var n = cs[i];
|
||||
if (!ok(n)) continue;
|
||||
var v = cs.getPropertyValue(n);
|
||||
if (v && v.trim()) out.push([n, v.trim()]);
|
||||
}
|
||||
out.dark = el.hasAttribute && el.hasAttribute('data-ds-dark-theme');
|
||||
} catch (e) { /* \u8BFB\u4E0D\u5230\u5C31\u9000\u56DE\u7CFB\u7EDF\u504F\u597D */ }
|
||||
return out;
|
||||
}
|
||||
function systemDark() {
|
||||
try { return !!(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches); } catch (e) { return false; }
|
||||
}
|
||||
/** \u9875\u9762\u81EA\u5E26\u4E3B\u9898\u5F00\u5173\uFF1F\uFF08\u9875\u9762\u4F18\u5148\uFF0C\u6865\u4E0D\u62A2\uFF09
|
||||
* 1) \u8FD0\u884C\u65F6\u663E\u5F0F\uFF1Awindow.__wtThemeBridgeManual = true
|
||||
* 2) \u6807\u8BB0\uFF1A<html data-wt-theme-mode="manual">
|
||||
* 3) \u8001\u5DE5\u4F5C\u53F0\u9875\u517C\u5BB9\uFF1A<html data-wb-theme> \u6216 localStorage['dwb.theme']\uFF08\u65E5\u8BB0\u5DE5\u4F5C\u53F0 / ai\u9012\u5F52\u5B66\u4E60\u7528\u8FD9\u5957\uFF09
|
||||
* \u663E\u5F0F\u8DDF\u968F\uFF1A<html data-wt-theme-mode="auto">\uFF08\u6216 <html data-wt-theme-key="\u81EA\u5DF1\u7684\u952E">\uFF09\uFF1D**\u5FFD\u7565**\u4E0A\u9762 3) \u7684
|
||||
* legacy \u5224\u5B9A\uFF0C\u5F3A\u5236\u8DDF\u5BBF\u4E3B\u2014\u2014\u540C\u6E90\u9875\u9762\u5171\u7528\u4E00\u4E2A localStorage \u952E\u65F6\uFF0C\u8FD9\u6761\u662F"\u6211\u53EA\u60F3\u8DDF\u5BBF\u4E3B"\u7684\u552F\u4E00\u529E\u6CD5\u3002 */
|
||||
function pageManual() {
|
||||
try {
|
||||
if (window.__wtThemeBridgeManual) return true;
|
||||
var el = document.documentElement;
|
||||
if (el) {
|
||||
var mode = el.getAttribute && el.getAttribute('data-wt-theme-mode');
|
||||
if (mode === 'manual') return true;
|
||||
if (mode === 'auto' || mode === 'host') return false;
|
||||
if (el.hasAttribute && el.hasAttribute('data-wt-theme-key')) return false;
|
||||
if (el.hasAttribute && el.hasAttribute('data-wb-theme')) return true;
|
||||
}
|
||||
var v = null;
|
||||
try { v = localStorage.getItem('dwb.theme'); } catch (e) { v = null; }
|
||||
if (v === 'dark' || v === 'light') return true;
|
||||
} catch (e) { /* \u8BFB\u4E0D\u5230\u5C31\u6309\u975E\u624B\u52A8\u5904\u7406 */ }
|
||||
return false;
|
||||
}
|
||||
var applied = [];
|
||||
/** \u6E05\u6389\u6865\u5199\u8FC7\u7684\u5185\u8054 token\uFF1A\u5207\u5230\u624B\u52A8\u4E3B\u9898\u65F6\u5FC5\u987B\u8BA9\u4F4D\u7ED9\u9875\u9762\u81EA\u5DF1\u7684\u6837\u5F0F\u8868\u503C\u3002 */
|
||||
function clearApplied() {
|
||||
var root = document.documentElement;
|
||||
for (var i = 0; i < applied.length; i++) {
|
||||
try { root.style.removeProperty(applied[i]); } catch (e) {}
|
||||
try { if (document.body) document.body.style.removeProperty(applied[i]); } catch (e) {}
|
||||
}
|
||||
applied = [];
|
||||
}
|
||||
function apply() {
|
||||
if (pageManual()) { clearApplied(); return; }
|
||||
var host = hostWindow();
|
||||
var vars = host ? hostVars(host) : [];
|
||||
var dark = host ? !!vars.dark : systemDark();
|
||||
var root = document.documentElement;
|
||||
for (var i = 0; i < vars.length; i++) root.style.setProperty(vars[i][0], vars[i][1]);
|
||||
root.style.colorScheme = dark ? 'dark' : 'light';
|
||||
if (document.body) {
|
||||
for (var j = 0; j < vars.length; j++) document.body.style.setProperty(vars[j][0], vars[j][1]);
|
||||
if (dark) document.body.setAttribute('data-ds-dark-theme', '');
|
||||
else document.body.removeAttribute('data-ds-dark-theme');
|
||||
}
|
||||
applied = vars.map(function (p) { return p[0]; });
|
||||
}
|
||||
apply();
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', apply, { once: true });
|
||||
// \u9875\u9762\u81EA\u5DF1\u5207\u4E3B\u9898\uFF08data-wb-theme / data-wt-theme-mode\uFF09\u65F6\u7ACB\u523B\u91CD\u65B0\u5224\u5B9A\uFF0C\u522B\u7B49\u8F6E\u8BE2
|
||||
try {
|
||||
var MO0 = window.MutationObserver;
|
||||
if (MO0) new MO0(function () { apply(); }).observe(document.documentElement, { attributes: true, attributeFilter: ['data-wb-theme', 'data-wt-theme-mode'] });
|
||||
} catch (e) { /* \u5FFD\u7565 */ }
|
||||
var host = hostWindow();
|
||||
if (host) {
|
||||
try {
|
||||
var MO = host.MutationObserver || window.MutationObserver;
|
||||
var mo = new MO(function () { apply(); });
|
||||
var opts = { attributes: true, attributeFilter: ['style', 'class', 'data-ds-dark-theme'] };
|
||||
mo.observe(host.document.documentElement, opts);
|
||||
if (host.document.body) mo.observe(host.document.body, opts);
|
||||
host.document.addEventListener('DOMContentLoaded', function () { try { mo.observe(host.document.body, opts); } catch (e) {} apply(); });
|
||||
} catch (e) { /* \u89C2\u6D4B\u5931\u8D25\u9760\u4E0B\u9762\u7684\u515C\u5E95\u8F6E\u8BE2 */ }
|
||||
}
|
||||
try {
|
||||
var mq = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)');
|
||||
if (mq) { if (mq.addEventListener) mq.addEventListener('change', apply); else if (mq.addListener) mq.addListener(apply); }
|
||||
} catch (e) { /* \u5FFD\u7565 */ }
|
||||
window.__wtThemeBridgeApply = apply;
|
||||
setInterval(apply, 5000); // \u515C\u5E95\uFF1A\u5BBF\u4E3B\u6362\u4E3B\u9898\u4E5F\u53EF\u80FD\u53EA\u6362\u6837\u5F0F\u8868\u3001\u4E0D\u52A8\u5C5E\u6027
|
||||
})();`;
|
||||
function injectThemeBridge(html, external = false) {
|
||||
const src = String(html ?? "");
|
||||
if (!src || src.includes(THEME_BRIDGE_ID)) return src;
|
||||
const tag = external ? `<script id="${THEME_BRIDGE_ID}" data-wt-theme-bridge src="${THEME_JS_PATH}"></script>` : `<script id="${THEME_BRIDGE_ID}" data-wt-theme-bridge>${THEME_BRIDGE_JS}</script>`;
|
||||
const head = /<\/head\s*>/i.exec(src);
|
||||
if (head) return src.slice(0, head.index) + tag + src.slice(head.index);
|
||||
const body = /<\/body\s*>/i.exec(src);
|
||||
if (body) return src.slice(0, body.index) + tag + src.slice(body.index);
|
||||
return tag + src;
|
||||
}
|
||||
.dshell { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; min-height: 100%; }
|
||||
/* \u6587\u5B57\u5C42\u7EA7 */
|
||||
.dshell-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--dsw-alias-label-primary, #e6e8eb); }
|
||||
.dshell-sub { margin: 0; font-size: 12px; color: var(--dsw-alias-label-secondary, #9aa4b2); }
|
||||
.dshell-muted { color: var(--dsw-alias-label-tertiary, #6b7280); font-size: 11.5px; }
|
||||
/* \u5361\u7247 */
|
||||
.dshell-card { border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 10px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); padding: 12px 14px; }
|
||||
.dshell-card + .dshell-card { margin-top: 10px; }
|
||||
/* \u6309\u94AE\uFF08\u7EFF\u8272\u4E3B\u6309\u94AE / \u5E7D\u7075\u6309\u94AE / \u5371\u9669\uFF09 */
|
||||
.dshell-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 1px solid transparent; background: #3fb950; color: #0b0e14; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
|
||||
.dshell-btn:hover { filter: brightness(1.08); }
|
||||
.dshell-btnGhost { background: transparent; border-color: var(--dsw-alias-border-l1, #262b36); color: var(--dsw-alias-label-secondary, #9aa4b2); }
|
||||
.dshell-btnGhost:hover { color: var(--dsw-alias-label-primary, #e6e8eb); border-color: var(--dsw-alias-border-l2, #3a4150); }
|
||||
.dshell-btnDanger { background: transparent; border-color: #f85149; color: #f85149; }
|
||||
/* \u72B6\u6001\u5FBD\u6807\uFF08\u5706\u70B9 + \u6587\u5B57\uFF1B\u7EFF=\u5DF2\u5B8C\u6210 \u9EC4=\u5F85\u529E/\u5F85\u53D1\u5E03 \u7070=\u672A\u5F00\u59CB\uFF09 */
|
||||
.dshell-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l1, #262b36); font-size: 11.5px; color: var(--dsw-alias-label-secondary, #9aa4b2); background: var(--dsw-alias-fill-l1, rgba(255,255,255,.03)); }
|
||||
.dshell-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-label-tertiary, #6b7280); }
|
||||
.dshell-badgeDone { color: #3fb950; border-color: rgba(63,185,80,.4); }
|
||||
.dshell-badgeDone::before { background: #3fb950; box-shadow: 0 0 5px #3fb950; }
|
||||
.dshell-badgeWait { color: #d29922; border-color: rgba(210,153,34,.4); }
|
||||
.dshell-badgeWait::before { background: #d29922; box-shadow: 0 0 5px #d29922; }
|
||||
.dshell-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dsw-alias-label-tertiary, #6b7280); }
|
||||
.dshell-dotDone { background: #3fb950; box-shadow: 0 0 5px #3fb950; }
|
||||
.dshell-dotWait { background: #d29922; box-shadow: 0 0 5px #d29922; }
|
||||
/* \u6807\u7B7E\u9875 */
|
||||
.dshell-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--dsw-alias-border-l1, #262b36); }
|
||||
.dshell-tab { padding: 7px 12px; font-size: 12.5px; color: var(--dsw-alias-label-secondary, #9aa4b2); cursor: pointer; border: none; background: none; font: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; }
|
||||
.dshell-tabOn { color: var(--dsw-alias-label-primary, #e6e8eb); border-bottom-color: var(--dsw-alias-state-accent-primary, #4f8ef7); }
|
||||
/* \u5217\u8868 */
|
||||
.dshell-list { display: flex; flex-direction: column; gap: 6px; }
|
||||
.dshell-listItem { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 8px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); cursor: pointer; }
|
||||
.dshell-listItem:hover { border-color: var(--dsw-alias-border-l2, #3a4150); background: var(--dsw-alias-fill-l1, rgba(255,255,255,.05)); }
|
||||
.dshell-listItemTitle { font-size: 12.5px; color: var(--dsw-alias-label-primary, #e6e8eb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.dshell-listItemMeta { flex: none; font-size: 11px; color: var(--dsw-alias-label-tertiary, #6b7280); }
|
||||
/* \u7F51\u683C / \u7EDF\u8BA1 */
|
||||
.dshell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
|
||||
.dshell-stat { padding: 10px 12px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 10px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); }
|
||||
.dshell-statLabel { font-size: 11px; color: var(--dsw-alias-label-secondary, #9aa4b2); }
|
||||
.dshell-statValue { font-size: 20px; font-weight: 600; color: var(--dsw-alias-label-primary, #e6e8eb); }
|
||||
.dshell-statDelta { font-size: 11px; color: #3fb950; }
|
||||
/* \u8FDB\u5EA6\u6761 */
|
||||
.dshell-progress { height: 6px; border-radius: 3px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.06)); overflow: hidden; }
|
||||
.dshell-progressBar { height: 100%; border-radius: 3px; background: #3fb950; }
|
||||
/* \u8F93\u5165 */
|
||||
.dshell-input, .dshell-textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 8px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.03)); color: var(--dsw-alias-label-primary, #e6e8eb); font: inherit; font-size: 12.5px; outline: none; }
|
||||
.dshell-input:focus, .dshell-textarea:focus { border-color: var(--dsw-alias-state-accent-primary, #4f8ef7); }
|
||||
/* \u8868\u683C */
|
||||
.dshell-table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
||||
.dshell-table th, .dshell-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--dsw-alias-border-l1, #262b36); }
|
||||
.dshell-table th { color: var(--dsw-alias-label-secondary, #9aa4b2); font-weight: 500; }
|
||||
/* \u952E\u503C\u5BF9 */
|
||||
.dshell-kv { display: flex; flex-direction: column; gap: 6px; }
|
||||
.dshell-kvRow { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
|
||||
.dshell-kvKey { color: var(--dsw-alias-label-secondary, #9aa4b2); }
|
||||
.dshell-kvValue { color: var(--dsw-alias-label-primary, #e6e8eb); text-align: right; }
|
||||
/* \u5206\u5272\u7EBF */
|
||||
.dshell-divider { height: 1px; background: var(--dsw-alias-border-l1, #262b36); margin: 6px 0; }
|
||||
/* \u6EDA\u52A8\u6761 */
|
||||
::-webkit-scrollbar { width: 10px; height: 10px; }
|
||||
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 5px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
|
||||
// template/dshell.css
|
||||
var dshell_default = `/* dsh-worktable \u539F\u751F\u76AE\u80A4 \xB7 DSH \u8BBE\u8BA1\u7CFB\u7EDF\u7EC4\u4EF6\u5E93\r
|
||||
\u7528\u6CD5\uFF1A<link rel="stylesheet" href="/api/worktable/template/dshell.css">\r
|
||||
\u989C\u8272\u4E00\u5F8B\u8D70 DSH \u4E3B\u9898\u53D8\u91CF\uFF08--dsw-alias-*\uFF09\uFF0C\u81EA\u52A8\u9002\u914D\u660E\u6697\u4E3B\u9898\u3002\r
|
||||
\u4E3B\u9898\u6765\u6E90\u4F18\u5148\u7EA7\uFF1A\r
|
||||
1) \u5DE5\u4F5C\u53F0\u5185\uFF1A\u4E3B\u9898\u6865\uFF08\u7AD9\u70B9\u8DEF\u7531\u81EA\u52A8\u6CE8\u5165\uFF0C\u6216\u663E\u5F0F\u5F15 /api/worktable/template/theme.js\uFF09\r
|
||||
\u628A\u5BBF\u4E3B body \u4E0A\u7684 --dsw-*/--dsh-*/--ds-* \u955C\u50CF\u6210\u9875\u9762\u5185\u8054\u6837\u5F0F \u2192 \u8DDF\u968F DSH \u7684 \u6D45\u8272/\u6DF1\u8272/\u8DDF\u968F\u7CFB\u7EDF\uFF1B\r
|
||||
2) \u72EC\u7ACB\u6253\u5F00\uFF1A\u7528\u4E0B\u9762 :root \u7684\u515C\u5E95\uFF0C\u5E76\u6309\u7CFB\u7EDF\u6DF1\u6D45\u8272\u5207\u6362\u3002\r
|
||||
\u6CE8\u610F\uFF1A\u4E0D\u8981\u5728\u8FD9\u91CC\u5199\u6B7B\u6DF1\u8272\uFF08\u65E7\u7248 :root{color-scheme:dark} \u4F1A\u8BA9\u6240\u6709\u9875\u9762\u9501\u6B7B\u6DF1\u8272\uFF0C\r
|
||||
2026-11 \u4ECE 0.5.x \u7EBF\u6062\u590D\u65F6\u518D\u6B21\u8E29\u5230\uFF0CREQ-20261117-0013 \u4E00\u5E76\u4FEE\u6389\uFF09\u3002 */\r
|
||||
:root {\r
|
||||
color-scheme: light dark;\r
|
||||
--dsw-alias-bg-base: #ffffff;\r
|
||||
--dsw-alias-fill-l1: rgba(16, 24, 40, .03);\r
|
||||
--dsw-alias-border-l1: #e4e7ec;\r
|
||||
--dsw-alias-border-l2: #d0d5dd;\r
|
||||
--dsw-alias-label-primary: #101828;\r
|
||||
--dsw-alias-label-secondary: #475467;\r
|
||||
--dsw-alias-label-tertiary: #98a2b3;\r
|
||||
--dsw-alias-state-accent-primary: #2f6feb;\r
|
||||
}\r
|
||||
@media (prefers-color-scheme: dark) {\r
|
||||
:root {\r
|
||||
--dsw-alias-bg-base: #0b0e14;\r
|
||||
--dsw-alias-fill-l1: rgba(255, 255, 255, .02);\r
|
||||
--dsw-alias-border-l1: #262b36;\r
|
||||
--dsw-alias-border-l2: #3a4150;\r
|
||||
--dsw-alias-label-primary: #e6e8eb;\r
|
||||
--dsw-alias-label-secondary: #9aa4b2;\r
|
||||
--dsw-alias-label-tertiary: #6b7280;\r
|
||||
--dsw-alias-state-accent-primary: #4f8ef7;\r
|
||||
}\r
|
||||
}\r
|
||||
* { box-sizing: border-box; }\r
|
||||
html, body { margin: 0; padding: 0; }\r
|
||||
body {\r
|
||||
background: var(--dsw-alias-bg-base, #0b0e14);\r
|
||||
color: var(--dsw-alias-label-primary, #e6e8eb);\r
|
||||
font-family: var(--dsw-font-family, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif);\r
|
||||
font-size: 13px;\r
|
||||
line-height: 1.6;\r
|
||||
}\r
|
||||
.dshell { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; min-height: 100%; }\r
|
||||
/* \u6587\u5B57\u5C42\u7EA7 */\r
|
||||
.dshell-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--dsw-alias-label-primary, #e6e8eb); }\r
|
||||
.dshell-sub { margin: 0; font-size: 12px; color: var(--dsw-alias-label-secondary, #9aa4b2); }\r
|
||||
.dshell-muted { color: var(--dsw-alias-label-tertiary, #6b7280); font-size: 11.5px; }\r
|
||||
/* \u5361\u7247 */\r
|
||||
.dshell-card { border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 10px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); padding: 12px 14px; }\r
|
||||
.dshell-card + .dshell-card { margin-top: 10px; }\r
|
||||
/* \u6309\u94AE\uFF08\u7EFF\u8272\u4E3B\u6309\u94AE / \u5E7D\u7075\u6309\u94AE / \u5371\u9669\uFF09 */\r
|
||||
.dshell-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 1px solid transparent; background: #3fb950; color: #0b0e14; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }\r
|
||||
.dshell-btn:hover { filter: brightness(1.08); }\r
|
||||
.dshell-btnGhost { background: transparent; border-color: var(--dsw-alias-border-l1, #262b36); color: var(--dsw-alias-label-secondary, #9aa4b2); }\r
|
||||
.dshell-btnGhost:hover { color: var(--dsw-alias-label-primary, #e6e8eb); border-color: var(--dsw-alias-border-l2, #3a4150); }\r
|
||||
.dshell-btnDanger { background: transparent; border-color: #f85149; color: #f85149; }\r
|
||||
/* \u72B6\u6001\u5FBD\u6807\uFF08\u5706\u70B9 + \u6587\u5B57\uFF1B\u7EFF=\u5DF2\u5B8C\u6210 \u9EC4=\u5F85\u529E/\u5F85\u53D1\u5E03 \u7070=\u672A\u5F00\u59CB\uFF09 */\r
|
||||
.dshell-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l1, #262b36); font-size: 11.5px; color: var(--dsw-alias-label-secondary, #9aa4b2); background: var(--dsw-alias-fill-l1, rgba(255,255,255,.03)); }\r
|
||||
.dshell-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-label-tertiary, #6b7280); }\r
|
||||
.dshell-badgeDone { color: #3fb950; border-color: rgba(63,185,80,.4); }\r
|
||||
.dshell-badgeDone::before { background: #3fb950; box-shadow: 0 0 5px #3fb950; }\r
|
||||
.dshell-badgeWait { color: #d29922; border-color: rgba(210,153,34,.4); }\r
|
||||
.dshell-badgeWait::before { background: #d29922; box-shadow: 0 0 5px #d29922; }\r
|
||||
.dshell-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dsw-alias-label-tertiary, #6b7280); }\r
|
||||
.dshell-dotDone { background: #3fb950; box-shadow: 0 0 5px #3fb950; }\r
|
||||
.dshell-dotWait { background: #d29922; box-shadow: 0 0 5px #d29922; }\r
|
||||
/* \u6807\u7B7E\u9875 */\r
|
||||
.dshell-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--dsw-alias-border-l1, #262b36); }\r
|
||||
.dshell-tab { padding: 7px 12px; font-size: 12.5px; color: var(--dsw-alias-label-secondary, #9aa4b2); cursor: pointer; border: none; background: none; font: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; }\r
|
||||
.dshell-tabOn { color: var(--dsw-alias-label-primary, #e6e8eb); border-bottom-color: var(--dsw-alias-state-accent-primary, #4f8ef7); }\r
|
||||
/* \u5217\u8868 */\r
|
||||
.dshell-list { display: flex; flex-direction: column; gap: 6px; }\r
|
||||
.dshell-listItem { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 8px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); cursor: pointer; }\r
|
||||
.dshell-listItem:hover { border-color: var(--dsw-alias-border-l2, #3a4150); background: var(--dsw-alias-fill-l1, rgba(255,255,255,.05)); }\r
|
||||
.dshell-listItemTitle { font-size: 12.5px; color: var(--dsw-alias-label-primary, #e6e8eb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\r
|
||||
.dshell-listItemMeta { flex: none; font-size: 11px; color: var(--dsw-alias-label-tertiary, #6b7280); }\r
|
||||
/* \u7F51\u683C / \u7EDF\u8BA1 */\r
|
||||
.dshell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }\r
|
||||
.dshell-stat { padding: 10px 12px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 10px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); }\r
|
||||
.dshell-statLabel { font-size: 11px; color: var(--dsw-alias-label-secondary, #9aa4b2); }\r
|
||||
.dshell-statValue { font-size: 20px; font-weight: 600; color: var(--dsw-alias-label-primary, #e6e8eb); }\r
|
||||
.dshell-statDelta { font-size: 11px; color: #3fb950; }\r
|
||||
/* \u8FDB\u5EA6\u6761 */\r
|
||||
.dshell-progress { height: 6px; border-radius: 3px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.06)); overflow: hidden; }\r
|
||||
.dshell-progressBar { height: 100%; border-radius: 3px; background: #3fb950; }\r
|
||||
/* \u8F93\u5165 */\r
|
||||
.dshell-input, .dshell-textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 8px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.03)); color: var(--dsw-alias-label-primary, #e6e8eb); font: inherit; font-size: 12.5px; outline: none; }\r
|
||||
.dshell-input:focus, .dshell-textarea:focus { border-color: var(--dsw-alias-state-accent-primary, #4f8ef7); }\r
|
||||
/* \u8868\u683C */\r
|
||||
.dshell-table { width: 100%; border-collapse: collapse; font-size: 12px; }\r
|
||||
.dshell-table th, .dshell-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--dsw-alias-border-l1, #262b36); }\r
|
||||
.dshell-table th { color: var(--dsw-alias-label-secondary, #9aa4b2); font-weight: 500; }\r
|
||||
/* \u952E\u503C\u5BF9 */\r
|
||||
.dshell-kv { display: flex; flex-direction: column; gap: 6px; }\r
|
||||
.dshell-kvRow { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }\r
|
||||
.dshell-kvKey { color: var(--dsw-alias-label-secondary, #9aa4b2); }\r
|
||||
.dshell-kvValue { color: var(--dsw-alias-label-primary, #e6e8eb); text-align: right; }\r
|
||||
/* \u5206\u5272\u7EBF */\r
|
||||
.dshell-divider { height: 1px; background: var(--dsw-alias-border-l1, #262b36); margin: 6px 0; }\r
|
||||
/* \u6EDA\u52A8\u6761 */\r
|
||||
::-webkit-scrollbar { width: 10px; height: 10px; }\r
|
||||
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 5px; }\r
|
||||
::-webkit-scrollbar-track { background: transparent; }\r
|
||||
`;
|
||||
|
||||
// template/dshell.html
|
||||
var dshell_default2 = '<!doctype html>\n<!-- dsh-worktable \u539F\u751F\u76AE\u80A4\u6A21\u677F\uFF1A\u65B0\u9875\u9762\u4EE5\u6B64\u4E3A\u57FA\u7840\uFF0C\u66FF\u6362\u4E0B\u9762\u793A\u4F8B\u5185\u5BB9\u5373\u53EF\u3002\n \u6837\u5F0F\u8868\u7531\u63D2\u4EF6\u63D0\u4F9B\uFF08\u968F\u4E3B\u9898\u81EA\u52A8\u9002\u914D\uFF09\uFF0C\u4E0D\u8981\u590D\u5236\u6216\u6539\u5199\u5B83\u3002 -->\n<html lang="zh-CN">\n<head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <title>\u6211\u7684\u7A97\u53E3</title>\n <link rel="stylesheet" href="/api/worktable/template/dshell.css" />\n</head>\n<body>\n <div class="dshell">\n <!-- \u6807\u9898\u533A -->\n <h1 class="dshell-title">\u7A97\u53E3\u6807\u9898</h1>\n <p class="dshell-sub">\u4E00\u53E5\u8BDD\u8BF4\u660E\u8FD9\u4E2A\u7A97\u53E3\u505A\u4EC0\u4E48\u3002</p>\n\n <!-- \u72B6\u6001\u5FBD\u6807\uFF1A\u5DF2\u5B8C\u6210 dshell-badgeDone / \u8FDB\u884C\u4E2D dshell-badgeWait / \u9ED8\u8BA4 -->\n <div>\n <span class="dshell-badge dshell-badgeDone">\u5DF2\u5B8C\u6210</span>\n <span class="dshell-badge dshell-badgeWait">\u8FDB\u884C\u4E2D</span>\n <span class="dshell-badge">\u672A\u5F00\u59CB</span>\n </div>\n\n <!-- \u6807\u7B7E\u9875 -->\n <div class="dshell-tabs">\n <button class="dshell-tab dshell-tabOn">\u6982\u89C8</button>\n <button class="dshell-tab">\u8BE6\u60C5</button>\n <button class="dshell-tab">\u8BBE\u7F6E</button>\n </div>\n\n <!-- \u7EDF\u8BA1\u5361\u7247\u7F51\u683C -->\n <div class="dshell-grid">\n <div class="dshell-stat">\n <div class="dshell-statLabel">\u603B\u6570</div>\n <div class="dshell-statValue">128</div>\n <div class="dshell-statDelta">+12.4%</div>\n </div>\n <div class="dshell-stat">\n <div class="dshell-statLabel">\u8FDB\u884C\u4E2D</div>\n <div class="dshell-statValue">7</div>\n </div>\n <div class="dshell-stat">\n <div class="dshell-statLabel">\u5DF2\u5B8C\u6210</div>\n <div class="dshell-statValue">121</div>\n </div>\n </div>\n\n <!-- \u5217\u8868 -->\n <div class="dshell-list">\n <div class="dshell-listItem">\n <span class="dshell-listItemTitle">\u6761\u76EE\u4E00\uFF1A\u793A\u4F8B\u5185\u5BB9\u6807\u9898</span>\n <span class="dshell-listItemMeta">\u6628\u5929</span>\n </div>\n <div class="dshell-listItem">\n <span class="dshell-listItemTitle">\u6761\u76EE\u4E8C\uFF1A\u793A\u4F8B\u5185\u5BB9\u6807\u9898</span>\n <span class="dshell-badge dshell-badgeDone">\u5DF2\u53D1\u5E03</span>\n </div>\n </div>\n\n <!-- \u5361\u7247 + \u952E\u503C\u5BF9 -->\n <div class="dshell-card">\n <h2 class="dshell-sub" style="margin:0 0 8px">\u8BE6\u60C5</h2>\n <div class="dshell-kv">\n <div class="dshell-kvRow"><span class="dshell-kvKey">\u5B57\u6BB5 A</span><span class="dshell-kvValue">\u503C A</span></div>\n <div class="dshell-kvRow"><span class="dshell-kvKey">\u5B57\u6BB5 B</span><span class="dshell-kvValue">\u503C B</span></div>\n </div>\n <div class="dshell-divider"></div>\n <div class="dshell-progress"><div class="dshell-progressBar" style="width:72%"></div></div>\n </div>\n\n <!-- \u64CD\u4F5C\u533A -->\n <div style="display:flex;gap:8px">\n <button class="dshell-btn">\u4E3B\u8981\u64CD\u4F5C</button>\n <button class="dshell-btn dshell-btnGhost">\u6B21\u8981\u64CD\u4F5C</button>\n </div>\n </div>\n</body>\n</html>\n';
|
||||
var dshell_default2 = '<!doctype html>\r\n<!-- dsh-worktable \u539F\u751F\u76AE\u80A4\u6A21\u677F\uFF1A\u65B0\u9875\u9762\u4EE5\u6B64\u4E3A\u57FA\u7840\uFF0C\u66FF\u6362\u4E0B\u9762\u793A\u4F8B\u5185\u5BB9\u5373\u53EF\u3002\r\n \u6837\u5F0F\u8868\u7531\u63D2\u4EF6\u63D0\u4F9B\uFF08\u968F\u4E3B\u9898\u81EA\u52A8\u9002\u914D\uFF09\uFF0C\u4E0D\u8981\u590D\u5236\u6216\u6539\u5199\u5B83\u3002 -->\r\n<html lang="zh-CN">\r\n<head>\r\n <!-- \u4E3B\u9898\u8DDF\u968F\uFF1A\u7AD9\u70B9\u8DEF\u7531\uFF08/api/worktable/site/**\uFF09\u5DF2\u81EA\u52A8\u6CE8\u5165\u4E3B\u9898\u6865\uFF0C\u65E0\u9700\u624B\u5199\uFF1B\r\n \u72EC\u7ACB\u6253\u5F00 / \u5D4C\u5957 iframe \u65F6\u663E\u5F0F\u5F15\u5165\u4E0B\u9762\u8FD9\u4E00\u884C\u5373\u53EF\uFF1A\r\n <script src="/api/worktable/template/theme.js"></script> -->\r\n <meta charset="utf-8" />\r\n <meta name="viewport" content="width=device-width, initial-scale=1" />\r\n <title>\u6211\u7684\u7A97\u53E3</title>\r\n <link rel="stylesheet" href="/api/worktable/template/dshell.css" />\r\n</head>\r\n<body>\r\n <div class="dshell">\r\n <!-- \u6807\u9898\u533A -->\r\n <h1 class="dshell-title">\u7A97\u53E3\u6807\u9898</h1>\r\n <p class="dshell-sub">\u4E00\u53E5\u8BDD\u8BF4\u660E\u8FD9\u4E2A\u7A97\u53E3\u505A\u4EC0\u4E48\u3002</p>\r\n\r\n <!-- \u72B6\u6001\u5FBD\u6807\uFF1A\u5DF2\u5B8C\u6210 dshell-badgeDone / \u8FDB\u884C\u4E2D dshell-badgeWait / \u9ED8\u8BA4 -->\r\n <div>\r\n <span class="dshell-badge dshell-badgeDone">\u5DF2\u5B8C\u6210</span>\r\n <span class="dshell-badge dshell-badgeWait">\u8FDB\u884C\u4E2D</span>\r\n <span class="dshell-badge">\u672A\u5F00\u59CB</span>\r\n </div>\r\n\r\n <!-- \u6807\u7B7E\u9875 -->\r\n <div class="dshell-tabs">\r\n <button class="dshell-tab dshell-tabOn">\u6982\u89C8</button>\r\n <button class="dshell-tab">\u8BE6\u60C5</button>\r\n <button class="dshell-tab">\u8BBE\u7F6E</button>\r\n </div>\r\n\r\n <!-- \u7EDF\u8BA1\u5361\u7247\u7F51\u683C -->\r\n <div class="dshell-grid">\r\n <div class="dshell-stat">\r\n <div class="dshell-statLabel">\u603B\u6570</div>\r\n <div class="dshell-statValue">128</div>\r\n <div class="dshell-statDelta">+12.4%</div>\r\n </div>\r\n <div class="dshell-stat">\r\n <div class="dshell-statLabel">\u8FDB\u884C\u4E2D</div>\r\n <div class="dshell-statValue">7</div>\r\n </div>\r\n <div class="dshell-stat">\r\n <div class="dshell-statLabel">\u5DF2\u5B8C\u6210</div>\r\n <div class="dshell-statValue">121</div>\r\n </div>\r\n </div>\r\n\r\n <!-- \u5217\u8868 -->\r\n <div class="dshell-list">\r\n <div class="dshell-listItem">\r\n <span class="dshell-listItemTitle">\u6761\u76EE\u4E00\uFF1A\u793A\u4F8B\u5185\u5BB9\u6807\u9898</span>\r\n <span class="dshell-listItemMeta">\u6628\u5929</span>\r\n </div>\r\n <div class="dshell-listItem">\r\n <span class="dshell-listItemTitle">\u6761\u76EE\u4E8C\uFF1A\u793A\u4F8B\u5185\u5BB9\u6807\u9898</span>\r\n <span class="dshell-badge dshell-badgeDone">\u5DF2\u53D1\u5E03</span>\r\n </div>\r\n </div>\r\n\r\n <!-- \u5361\u7247 + \u952E\u503C\u5BF9 -->\r\n <div class="dshell-card">\r\n <h2 class="dshell-sub" style="margin:0 0 8px">\u8BE6\u60C5</h2>\r\n <div class="dshell-kv">\r\n <div class="dshell-kvRow"><span class="dshell-kvKey">\u5B57\u6BB5 A</span><span class="dshell-kvValue">\u503C A</span></div>\r\n <div class="dshell-kvRow"><span class="dshell-kvKey">\u5B57\u6BB5 B</span><span class="dshell-kvValue">\u503C B</span></div>\r\n </div>\r\n <div class="dshell-divider"></div>\r\n <div class="dshell-progress"><div class="dshell-progressBar" style="width:72%"></div></div>\r\n </div>\r\n\r\n <!-- \u64CD\u4F5C\u533A -->\r\n <div style="display:flex;gap:8px">\r\n <button class="dshell-btn">\u4E3B\u8981\u64CD\u4F5C</button>\r\n <button class="dshell-btn dshell-btnGhost">\u6B21\u8981\u64CD\u4F5C</button>\r\n </div>\r\n </div>\r\n</body>\r\n</html>\r\n';
|
||||
|
||||
// src/index.ts
|
||||
function baseDshHome() {
|
||||
@@ -225,7 +382,7 @@ function resolveDshHomeSafe() {
|
||||
cachedDshHome = baseDshHome();
|
||||
return cachedDshHome;
|
||||
}
|
||||
var PLUGIN_VERSION = false ? "dev" : "0.5.3-local.3";
|
||||
var PLUGIN_VERSION = false ? "dev" : "0.5.3-local.10";
|
||||
var name = "dsh-worktable";
|
||||
var inject = ["webServer", "sessions"];
|
||||
var HEALTH_PATH = "/api/worktable/health";
|
||||
@@ -494,20 +651,35 @@ function apply(ctx) {
|
||||
}
|
||||
})();
|
||||
};
|
||||
const register = (route, publicAsset = false) => ctx.effect(() => webServer.register({
|
||||
...route,
|
||||
handler: async (req, res) => {
|
||||
if (!publicAsset && route.path !== HEALTH_PATH) {
|
||||
const rejected = await requestRejection(ctx, req);
|
||||
if (rejected !== void 0) {
|
||||
if (route.path === "/api/worktable/state") stateLog("REJECT " + req.method + " -> " + rejected);
|
||||
json(res, rejected, { error: rejectionText(rejected) });
|
||||
return;
|
||||
const register = (route, publicAsset = false) => {
|
||||
let dispose;
|
||||
try {
|
||||
dispose = webServer.register({
|
||||
...route,
|
||||
handler: async (req, res) => {
|
||||
if (!publicAsset && route.path !== HEALTH_PATH) {
|
||||
const rejected = await requestRejection(ctx, req);
|
||||
if (rejected !== void 0) {
|
||||
if (route.path === "/api/worktable/state") stateLog("REJECT " + req.method + " -> " + rejected);
|
||||
json(res, rejected, { error: rejectionText(rejected) });
|
||||
return;
|
||||
}
|
||||
}
|
||||
return route.handler(req, res);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
if (String(err).includes("duplicate")) {
|
||||
ctx.logger?.warn("[dsh-worktable] \u8DEF\u7531\u5DF2\u88AB\u5360\u7528\uFF08\u70ED\u91CD\u8F7D\u6CC4\u6F0F\u81EA\u4FDD\uFF09\uFF0C\u8DF3\u8FC7: " + route?.path);
|
||||
return;
|
||||
}
|
||||
return route.handler(req, res);
|
||||
throw err;
|
||||
}
|
||||
}), "dsh-worktable: " + route.path);
|
||||
try {
|
||||
ctx.effect(() => dispose, "dsh-worktable: " + route.path);
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
register({
|
||||
kind: "exact",
|
||||
path: "/api/worktable/preview",
|
||||
@@ -571,6 +743,35 @@ function apply(ctx) {
|
||||
json(res, 200, { plugin: "dsh-worktable", version: PLUGIN_VERSION, ok: true });
|
||||
}
|
||||
});
|
||||
register({
|
||||
kind: "exact",
|
||||
path: "/api/worktable/update-check",
|
||||
handler: async (_req, res) => {
|
||||
const upstream = "https://gitea.ququclean.com/api/v1/repos/xiaoqu/dsh-worktable/releases/latest";
|
||||
const ctrl = new AbortController();
|
||||
const timer = setTimeout(() => ctrl.abort(), 8e3);
|
||||
try {
|
||||
const r = await fetch(upstream, {
|
||||
headers: { Accept: "application/json", "user-agent": "dsh-worktable/" + PLUGIN_VERSION },
|
||||
signal: ctrl.signal
|
||||
});
|
||||
if (!r.ok) {
|
||||
json(res, 502, { error: "upstream status " + r.status });
|
||||
return;
|
||||
}
|
||||
const d = await r.json();
|
||||
json(res, 200, {
|
||||
tag_name: typeof d?.tag_name === "string" ? d.tag_name : "",
|
||||
body: typeof d?.body === "string" ? d.body : "",
|
||||
html_url: typeof d?.html_url === "string" ? d.html_url : ""
|
||||
});
|
||||
} catch (err) {
|
||||
json(res, 502, { error: "upstream unreachable: " + String(err?.message ?? err) });
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
}
|
||||
});
|
||||
register({
|
||||
kind: "exact",
|
||||
path: "/api/worktable/file",
|
||||
@@ -638,6 +839,9 @@ function apply(ctx) {
|
||||
if (rel === "/dshell.css") {
|
||||
res.writeHead(200, { "content-type": "text/css; charset=utf-8", "cache-control": "no-store" });
|
||||
res.end(dshell_default);
|
||||
} else if (rel === "/theme.js") {
|
||||
res.writeHead(200, { "content-type": "text/javascript; charset=utf-8", "cache-control": "no-store" });
|
||||
res.end(THEME_BRIDGE_JS);
|
||||
} else {
|
||||
res.writeHead(200, { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" });
|
||||
res.end(dshell_default2);
|
||||
@@ -701,7 +905,7 @@ function apply(ctx) {
|
||||
"referrer-policy": "no-referrer",
|
||||
"x-content-type-options": "nosniff"
|
||||
});
|
||||
res.end(data);
|
||||
res.end(ext === "html" || ext === "htm" ? Buffer.from(injectThemeBridge(data.toString("utf8")), "utf8") : data);
|
||||
} catch (err) {
|
||||
json(res, 404, { error: String(err) });
|
||||
}
|
||||
|
||||
Generated
+3
-3
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "dsh-worktable",
|
||||
"version": "0.5.1",
|
||||
"version": "0.5.3-local.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "dsh-worktable",
|
||||
"version": "0.5.1",
|
||||
"version": "0.5.3-local.4",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
@@ -15,7 +15,7 @@
|
||||
"xterm": "^5.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"dsh": "0.2.0-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.5",
|
||||
"dsh": "0.2.0-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.5 || 0.2.2-alpha.2",
|
||||
"node": ">=22"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "dsh-worktable",
|
||||
"description": "工作台 Worktable:DeepSeek Harness 侧边栏的 agent 级项目容器(应用抽屉)",
|
||||
"version": "0.5.3-local.3",
|
||||
"version": "0.5.3-local.10",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Aisland-SJL/dsh-worktable.git",
|
||||
|
||||
@@ -110,7 +110,9 @@ const tgz = join(work, 'pack', packedName)
|
||||
console.log('[release-prep] packed: ' + packedName)
|
||||
|
||||
// ---------- 4. 结构清单断言(精确到文件,不含源码/映射) ----------
|
||||
const listTar = spawnSync('tar', ['-tzf', tgz], { encoding: 'utf8' })
|
||||
// Windows: GNU tar 会把 "C:\..." 的盘符当成 rsh 远端主机(Cannot connect to C),
|
||||
// 必须 --force-local 才能在 win32 上列包;POSIX 上该选项也有,可无条件传。
|
||||
const listTar = spawnSync('tar', ['--force-local', '-tzf', tgz], { encoding: 'utf8' })
|
||||
if (listTar.status !== 0) { console.error('[release-prep] FAIL: tar -tzf'); process.exit(1) }
|
||||
const entries = listTar.stdout.split(/\r?\n/).filter(Boolean)
|
||||
const EXPECTED = [
|
||||
|
||||
@@ -36,9 +36,22 @@ export function hostPreviewUrl(
|
||||
}
|
||||
|
||||
/** Keep update instructions on the active profile; Desktop must use its bundled CLI. */
|
||||
export function worktableUpgrade(protocol = typeof location === 'undefined' ? 'http:' : location.protocol) {
|
||||
// 本仓发布在自建 Gitea:它不支持 GitHub 的 /releases/latest/download 简写,
|
||||
// 安装命令必须带具体 tag。tag 由调用方传入(等于检查到的新版本),
|
||||
// 不再写死当前版本——否则「有新版本」提示里给的却是自己这一版的地址。
|
||||
const UPDATE_BASE = 'https://gitea.ququclean.com/xiaoqu/dsh-worktable/releases/download'
|
||||
|
||||
export function upgradeCommandFor(tag: string, protocol = typeof location === 'undefined' ? 'http:' : location.protocol): string {
|
||||
const desktop = protocol === 'dsh-app:'
|
||||
const command = 'dsh plugin --profile ' + (desktop ? 'desktop' : 'web') + ' add "https://github.com/Aisland-SJL/dsh-worktable/releases/latest/download/dsh-worktable.tgz"'
|
||||
const clean = String(tag || '').trim().replace(/^v/, '')
|
||||
const t = clean ? 'v' + clean : ''
|
||||
const url = t ? UPDATE_BASE + '/' + t + '/dsh-worktable.tgz' : UPDATE_BASE + '/'
|
||||
return 'dsh plugin --profile ' + (desktop ? 'desktop' : 'web') + ' add "' + url + '"'
|
||||
}
|
||||
|
||||
export function worktableUpgrade(tag: string, protocol = typeof location === 'undefined' ? 'http:' : location.protocol) {
|
||||
const desktop = protocol === 'dsh-app:'
|
||||
const command = upgradeCommandFor(tag, protocol)
|
||||
const prompt = desktop
|
||||
? '帮我升级 dsh-worktable。我当前使用官方桌面端:先定位该桌面端自带的 dsh CLI 并准备更新,再提醒我完整退出桌面端。确认退出后使用该 CLI 执行 ' + command + '。不要使用网页端 CLI,不要修改 web profile,不要自动杀进程或重启;完成后提醒我手动重新打开桌面端。'
|
||||
: '帮我升级 dsh-worktable:执行 ' + command + ',完成后提醒我重启 dsh web 并刷新页面'
|
||||
|
||||
+146
-15
@@ -30,9 +30,14 @@ import { loadHostState, queueHostSave, markHydrated, staysReadOnly, flushHostSav
|
||||
type OrderBy = 'manual' | 'recent'
|
||||
type DockMode = 'footer' | 'float'
|
||||
|
||||
// ── 更新检查(客户端直连 GitHub Releases API,只读 GET;失败静默)──
|
||||
const UPDATE_REPO = 'Aisland-SJL/dsh-worktable'
|
||||
const { command: UPGRADE_CMD, prompt: UPGRADE_AI, desktop: DESKTOP_HOST } = worktableUpgrade()
|
||||
// ── 更新检查(客户端直连本仓 Gitea Releases API,只读 GET;失败静默)──
|
||||
// 本仓是内部补丁分发仓:上游只发官方版(无本地补丁),
|
||||
// 查上游既看不到本仓版本,国内网络也常失败。
|
||||
// 走宿主中转:页面来源是随机端口 127.0.0.1,直连 Gitea 跨源且无 CORS 头会被拦截
|
||||
const UPDATE_API = '/api/worktable/update-check'
|
||||
// 升级命令必须在「检测到新版本」后按该版本生成(见下方 upgrade 系列 useMemo),
|
||||
// 不能用模块级常量——否则提示里给的是当前已装版本的地址。
|
||||
const DESKTOP_HOST = typeof location !== 'undefined' && location.protocol === 'dsh-app:'
|
||||
// 更新提示图标(手绘 SVG,避免 emoji 跨平台渲染差异)
|
||||
const ICON_SYNC = (
|
||||
<svg viewBox="0 0 16 16" aria-hidden>
|
||||
@@ -48,10 +53,33 @@ const ICON_SPARK = (
|
||||
<path d="M12.6 11.2l.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5z" fill="currentColor" />
|
||||
</svg>
|
||||
)
|
||||
/**
|
||||
* 复制文案:优先 Clipboard API;不可用(webview 非安全上下文、权限未授予、
|
||||
* 或 API 存在但调用被拒)时回退到 execCommand('copy'),再不行用隐藏 textarea + 选区。
|
||||
* 只返回 true 表示「文本确实进了剪贴板」,避免按钮显示 ✓ 却什么都没复制。
|
||||
*/
|
||||
async function copyText(text: string): Promise<boolean> {
|
||||
try {
|
||||
if (navigator.clipboard?.writeText && window.isSecureContext !== false) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
return true
|
||||
}
|
||||
} catch { /* 继续降级 */ }
|
||||
try {
|
||||
const ta = document.createElement('textarea')
|
||||
ta.value = text
|
||||
ta.setAttribute('readonly', '')
|
||||
ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none'
|
||||
document.body.appendChild(ta)
|
||||
ta.select()
|
||||
ta.setSelectionRange(0, ta.value.length)
|
||||
const ok = typeof document.execCommand === 'function' ? document.execCommand('copy') : false
|
||||
document.body.removeChild(ta)
|
||||
if (ok) return true
|
||||
} catch { /* 继续降级 */ }
|
||||
try {
|
||||
if (navigator.clipboard?.writeText) { await navigator.clipboard.writeText(text); return true }
|
||||
} catch { /* fallthrough */ }
|
||||
} catch { /* 全部失败 */ }
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -61,6 +89,8 @@ type ViewState = {
|
||||
orderBy: OrderBy
|
||||
dock: DockMode
|
||||
floatTop: number | null
|
||||
/** 折叠中的项目 id(这些项目不展开显示其二级页面;缺省 = 全部展开)*/
|
||||
foldedProjects?: string[]
|
||||
/** 控制室面板主题:dark/light/system(system = 跟随宿主 color-scheme,即 DSH 深色/白色/跟随系统设置) */
|
||||
consoleTheme?: 'dark' | 'light' | 'system'
|
||||
/** 控制室每行显示项目数(1-5,默认 3)*/
|
||||
@@ -328,6 +358,7 @@ function normalizeView(raw: any): ViewState {
|
||||
orderBy,
|
||||
dock: p.dock === 'float' ? 'float' : 'footer',
|
||||
floatTop: typeof p.floatTop === 'number' ? p.floatTop : null,
|
||||
foldedProjects: Array.isArray(p.foldedProjects) ? p.foldedProjects.filter((x: unknown): x is string => typeof x === 'string') : [],
|
||||
consoleTheme: p.consoleTheme === 'dark' || p.consoleTheme === 'light' || p.consoleTheme === 'system' ? p.consoleTheme : 'system',
|
||||
consoleCols: typeof p.consoleCols === 'number' && p.consoleCols >= 1 && p.consoleCols <= 5 ? Math.round(p.consoleCols) : 3,
|
||||
consoleShape: p.consoleShape === 'circle' ? 'circle' : 'square',
|
||||
@@ -560,6 +591,20 @@ async function ensureSessionModel(sessionId: string): Promise<void> {
|
||||
const CONSOLE_ID = 'wt-console'
|
||||
const CONSOLE_ICON = '🖥️'
|
||||
|
||||
/**
|
||||
* 控制室图标:内联 SVG 替代 emoji。
|
||||
* emoji 的渲染完全取决于系统字体(Windows Segoe UI Emoji / macOS Apple Color Emoji
|
||||
* 形状与配色都不同),同一份代码在不同机器上长得不一样,看起来也偏旧。
|
||||
* 用 currentColor 描边图标可跟随主题色,两平台一致。
|
||||
*/
|
||||
const ICON_CONSOLE = (
|
||||
<svg className="dsh-wt_layoutSvg" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
||||
<rect x="1.6" y="2.2" width="12.8" height="8.6" rx="1.5" stroke="currentColor" strokeWidth="1.3" />
|
||||
<path d="M5.2 13.4h5.6" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" />
|
||||
<path d="M8 10.8v2.6" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" />
|
||||
</svg>
|
||||
)
|
||||
|
||||
/** 控制室布局是否健全:主窗格首格存在 console 类型标签(旧版关标签的坏存档没有它) */
|
||||
function specHasConsoleTab(spec: LayoutSpec | undefined): boolean {
|
||||
return !!spec?.main?.[0]?.tabs?.some((t) => t.content?.kind === 'builtin' && t.content.type === 'console')
|
||||
@@ -1072,6 +1117,7 @@ function WorktableSection(props: any) {
|
||||
const updateInfo = newerUpdateInfo(rawUpdateInfo)
|
||||
const [updateCheckOn, setUpdateCheckOn] = useState<boolean>(() => localStorage.getItem('dsh.worktable.updateCheck.v1') !== '0')
|
||||
const [updateCopied, setUpdateCopied] = useState(false)
|
||||
const [updateCopyFailed, setUpdateCopyFailed] = useState(false)
|
||||
const [updateStatus, setUpdateStatus] = useState<'idle' | 'checking' | 'uptodate' | 'failed'>('idle')
|
||||
const updateCheckingRef = useRef(false)
|
||||
const updateAliveRef = useRef(true)
|
||||
@@ -1091,7 +1137,7 @@ function WorktableSection(props: any) {
|
||||
const ctrl = new AbortController()
|
||||
const timer = setTimeout(() => ctrl.abort(), 8000) // 单次 8s 超时,计入下一轮重试
|
||||
try {
|
||||
const r = await fetch('https://api.github.com/repos/' + UPDATE_REPO + '/releases/latest', { headers: { Accept: 'application/vnd.github+json' }, cache: 'no-store', signal: ctrl.signal })
|
||||
const r = await fetch(UPDATE_API, { headers: { Accept: 'application/json' }, cache: 'no-store', signal: ctrl.signal })
|
||||
if (r.ok) d = await r.json() as { tag_name?: string; body?: string; html_url?: string }
|
||||
else if (r.status === 403 || r.status === 404) break // 限流/不存在:不再重试
|
||||
} catch { /* 网络抖动/超时:下一轮重试 */ }
|
||||
@@ -1111,9 +1157,22 @@ function WorktableSection(props: any) {
|
||||
}
|
||||
}, [])
|
||||
useEffect(() => { if (updateCheckOn) void checkUpdates() }, [updateCheckOn, checkUpdates])
|
||||
// 升级命令/提示按「检测到的新版本」生成:给出的是要装的版本,而不是当前已装版本。
|
||||
const upgrade = useMemo(
|
||||
() => worktableUpgrade(updateInfo?.latest ?? LOCAL_VERSION),
|
||||
[updateInfo?.latest],
|
||||
)
|
||||
const copyUpgradeAi = async () => {
|
||||
const ok = await copyText(UPGRADE_AI)
|
||||
if (ok) { setUpdateCopied(true); setTimeout(() => setUpdateCopied(false), 2200) }
|
||||
const ok = await copyText(upgrade.prompt)
|
||||
if (ok) {
|
||||
setUpdateCopyFailed(false)
|
||||
setUpdateCopied(true)
|
||||
setTimeout(() => setUpdateCopied(false), 2200)
|
||||
} else {
|
||||
// 复制失败要让用户看见,否则就是「点了没反应」
|
||||
setUpdateCopyFailed(true)
|
||||
setTimeout(() => setUpdateCopyFailed(false), 3000)
|
||||
}
|
||||
}
|
||||
const skipUpdate = () => {
|
||||
if (updateInfo) {
|
||||
@@ -2242,7 +2301,35 @@ function buildCustomLayoutPrompt(req: string): string {
|
||||
|
||||
const removeLayout = (id: string) => {
|
||||
invalidateWidgetProject(id)
|
||||
persistProjects((prev) => ({ ...prev, layouts: prev.layouts.filter((l) => l.id !== id) }))
|
||||
// 二级页面:删父项目不级联删子页面 —— 子页面提升为顶级,避免误删用户内容
|
||||
persistProjects((prev) => ({
|
||||
...prev,
|
||||
layouts: prev.layouts
|
||||
.filter((l) => l.id !== id)
|
||||
.map((l) => (l.parentId === id ? { ...l, parentId: undefined } : l)),
|
||||
}))
|
||||
}
|
||||
|
||||
// ── 二级页面:挂在某个项目下的独立布局页(仅一级)──
|
||||
const addSubPage = (parent: LayoutSpec) => {
|
||||
const parentName = projects.nameOverrides[parent.id] ?? parent.title
|
||||
const child = buildLayout('2h', parentName + ' · 新页面')
|
||||
child.parentId = parent.id
|
||||
const folder = projects.folders[parent.id]
|
||||
persistProjects((prev) => ({
|
||||
...prev,
|
||||
layouts: [...prev.layouts, child],
|
||||
folders: folder ? { ...prev.folders, [child.id]: folder } : prev.folders,
|
||||
}))
|
||||
invalidatePickState()
|
||||
openSplit(child)
|
||||
reportUsed(child.id)
|
||||
}
|
||||
|
||||
/** 折叠/展开某个项目的二级页面列表 */
|
||||
const toggleFold = (id: string) => {
|
||||
const folded = view.foldedProjects ?? []
|
||||
persistView({ foldedProjects: folded.includes(id) ? folded.filter((x) => x !== id) : [...folded, id] })
|
||||
}
|
||||
|
||||
// ── 变更视图:所有项目通用。布局项目 = 重建其布局条目;入驻项目 = 建立/更新视图覆盖。
|
||||
@@ -2476,6 +2563,30 @@ function buildCustomLayoutPrompt(req: string): string {
|
||||
const paneTitles = [...(l.top ?? []), ...l.main].map((p) => p.title).join(' ')
|
||||
return (l.title + ' ' + paneTitles).toLowerCase().includes(queryLower)
|
||||
})
|
||||
/** 侧栏树:父项目 + 其二级页面(仅一级嵌套;父项目不可见时子页面按顶级显示)*/
|
||||
const layoutTree = useMemo(() => {
|
||||
const visIds = new Set(visibleLayouts.map((l) => l.id))
|
||||
const kids = new Map<string, LayoutSpec[]>()
|
||||
const roots: LayoutSpec[] = []
|
||||
for (const l of visibleLayouts) {
|
||||
if (l.parentId && visIds.has(l.parentId)) {
|
||||
const arr = kids.get(l.parentId) ?? []
|
||||
arr.push(l)
|
||||
kids.set(l.parentId, arr)
|
||||
} else roots.push(l)
|
||||
}
|
||||
const ord = (a: LayoutSpec, b: LayoutSpec) => effectiveOrder.indexOf(a.id) - effectiveOrder.indexOf(b.id)
|
||||
const out: { node: LayoutSpec; depth: 0 | 1; hasKids: boolean }[] = []
|
||||
for (const r of [...roots].sort(ord)) {
|
||||
const cs = (kids.get(r.id) ?? []).sort(ord)
|
||||
out.push({ node: r, depth: 0, hasKids: cs.length > 0 })
|
||||
if (!(view.foldedProjects ?? []).includes(r.id)) {
|
||||
for (const c of cs) out.push({ node: c, depth: 1, hasKids: false })
|
||||
}
|
||||
}
|
||||
return out
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [visibleLayouts, effectiveOrder, view.foldedProjects])
|
||||
|
||||
const isFloat = float != null
|
||||
const floatStyle = isFloat
|
||||
@@ -2677,10 +2788,10 @@ function buildCustomLayoutPrompt(req: string): string {
|
||||
<div className="dsh-wt_updateHead"><span className="dsh-wt_updateDot" />{t('update.available')} · v{updateInfo.latest}</div>
|
||||
<div className="dsh-wt_updateVers">{t('update.current')} v{LOCAL_VERSION} → v{updateInfo.latest}</div>
|
||||
{updateInfo.notes && <div className="dsh-wt_updateNotes">{updateInfo.notes}</div>}
|
||||
<div className="dsh-wt_updateCmd">{UPGRADE_CMD}</div>
|
||||
<div className="dsh-wt_updateCmd">{upgrade.command}</div>
|
||||
<div className="dsh-wt_updateBtns">
|
||||
<button type="button" className="dsh-wt_updateBtn dsh-wt_updateBtnCopy" onClick={() => void copyUpgradeAi()}>
|
||||
{updateCopied ? '✓ ' + t('update.copied') : <>{ICON_SPARK} {t('update.copyAi')}</>}
|
||||
{updateCopied ? '✓ ' + t('update.copied') : updateCopyFailed ? '⚠ ' + t('update.copyFailed') : <>{ICON_SPARK} {t('update.copyAi')}</>}
|
||||
</button>
|
||||
<button type="button" className="dsh-wt_updateBtn" onClick={skipUpdate}>{t('update.skip')}</button>
|
||||
</div>
|
||||
@@ -2740,6 +2851,14 @@ function buildCustomLayoutPrompt(req: string): string {
|
||||
<EyeIcon closed={isHidden} />
|
||||
</button>
|
||||
<button type="button" className="dsh-wt_manageBtn" title={t('manage.changeView')} onClick={() => setViewPickFor(id)}>🧩</button>
|
||||
{layout && (
|
||||
<button
|
||||
type="button"
|
||||
className="dsh-wt_manageBtn"
|
||||
title={t('manage.addPage')}
|
||||
onClick={() => addSubPage(layout)}
|
||||
>+</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="dsh-wt_manageBtn"
|
||||
@@ -3175,7 +3294,7 @@ function buildCustomLayoutPrompt(req: string): string {
|
||||
title={t('console.name')}
|
||||
onClick={(e) => clickConsoleCard(e.currentTarget as HTMLElement)}
|
||||
>
|
||||
<span className="dsh-wt_layoutIcon">{CONSOLE_ICON}</span>
|
||||
<span className="dsh-wt_layoutIcon">{ICON_CONSOLE}</span>
|
||||
<span className="dsh-wt_layoutText">
|
||||
<span className="dsh-wt_layoutName">{t('console.name')}</span>
|
||||
</span>
|
||||
@@ -3197,13 +3316,15 @@ function buildCustomLayoutPrompt(req: string): string {
|
||||
{renderProjectSlot
|
||||
? renderProjectSlot('sidebar.worktable.project', ownerProps)
|
||||
: <div className="dsh-wt_empty">{t('empty')}</div>}
|
||||
{visibleLayouts.map((l) => (
|
||||
{layoutTree.map(({ node: l, depth, hasKids }, ti) => {
|
||||
const folded = (view.foldedProjects ?? []).includes(l.id)
|
||||
return (
|
||||
<button
|
||||
key={l.id}
|
||||
type="button"
|
||||
className="dsh-wt_layout"
|
||||
className={'dsh-wt_layout' + (depth === 1 ? ' dsh-wt_layoutSub' : '') + (hasKids ? ' dsh-wt_layoutHasKids' : '')}
|
||||
data-on={activeSplitId === l.id ? 'true' : 'false'}
|
||||
style={{ order: effectiveOrder.indexOf(l.id) + 1000, position: 'relative' }}
|
||||
style={{ order: ti + 1000, position: 'relative' }}
|
||||
onClick={() => { openSplit(l); reportUsed(l.id) }}
|
||||
>
|
||||
<span
|
||||
@@ -3227,9 +3348,19 @@ function buildCustomLayoutPrompt(req: string): string {
|
||||
aria-label={projects.bindings[l.id] ? t('bind.tipBound', { name: boundSessionTitle(projects.bindings[l.id]) }) : t('bind.tipUnbound')}
|
||||
onClick={(e) => { e.stopPropagation(); openBindPick(l.id, e.currentTarget as HTMLElement) }}
|
||||
><span className="dsh-wt_bindCircles" aria-hidden /></span>
|
||||
{hasKids ? (
|
||||
<span
|
||||
className={'dsh-wt_foldBtn' + (folded ? ' dsh-wt_foldBtnOff' : '')}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
title={folded ? t('tree.expand') : t('tree.fold')}
|
||||
onClick={(e) => { e.stopPropagation(); toggleFold(l.id) }}
|
||||
>{folded ? '▸' : '▾'}</span>
|
||||
) : <span className="dsh-wt_foldBtn dsh-wt_foldBtnGhost" aria-hidden />}
|
||||
<span className="dsh-wt_layoutArrow" aria-hidden>›</span>
|
||||
</button>
|
||||
))}
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
{visibleShortcuts.length > 0 && (
|
||||
|
||||
@@ -60,6 +60,9 @@ export const zh = {
|
||||
'manage.deleteLayout': '删除布局',
|
||||
'manage.deleteProject': '删除项目',
|
||||
'manage.changeView': '变更视图',
|
||||
'manage.addPage': '新增二级页面',
|
||||
'tree.fold': '折叠二级页面',
|
||||
'tree.expand': '展开二级页面',
|
||||
'viewPick.title': '选择新视图(内容窗自动迁入)',
|
||||
'confirm.title': '删除项目',
|
||||
'confirm.cancel': '取消',
|
||||
@@ -227,6 +230,7 @@ export const zh = {
|
||||
'update.available': '新版本可用',
|
||||
'update.current': '当前版本',
|
||||
'update.copyAi': '复制 AI 提示词',
|
||||
'update.copyFailed': '复制失败,请手动选中命令',
|
||||
'update.skip': '忽略此版本',
|
||||
'update.autoCheck': '自动检查更新',
|
||||
'update.checkNow': '立即检查',
|
||||
@@ -299,6 +303,9 @@ export const en = {
|
||||
'manage.deleteLayout': 'Delete layout',
|
||||
'manage.deleteProject': 'Delete project',
|
||||
'manage.changeView': 'Change layout',
|
||||
'manage.addPage': 'Add sub page',
|
||||
'tree.fold': 'Collapse sub pages',
|
||||
'tree.expand': 'Expand sub pages',
|
||||
'viewPick.title': 'Pick a new layout (panes migrate automatically)',
|
||||
'confirm.title': 'Delete project',
|
||||
'confirm.cancel': 'Cancel',
|
||||
@@ -466,6 +473,7 @@ export const en = {
|
||||
'update.available': 'New version available',
|
||||
'update.current': 'Current version',
|
||||
'update.copyAi': 'Copy AI prompt',
|
||||
'update.copyFailed': 'Copy failed, select the command manually',
|
||||
'update.skip': 'Skip this version',
|
||||
'update.autoCheck': 'Auto-check updates',
|
||||
'update.checkNow': 'Check now',
|
||||
|
||||
@@ -70,6 +70,8 @@ export type LayoutSpec = {
|
||||
chatFullHeight?: boolean
|
||||
/** 顶行首次打开时高度占可用高度比例(0~1;0.5 = 上下等分);拖动后由存档值覆盖 */
|
||||
topHeightRatio?: number
|
||||
/** 二级页面:挂在某项目下的独立布局页(仅一级嵌套;缺省 = 顶级项目) */
|
||||
parentId?: string
|
||||
}
|
||||
|
||||
type Geom = { left: number; top: number; right: number; bottom: number }
|
||||
@@ -490,8 +492,8 @@ function boxPayload(x0: number, y0: number, x1: number, y1: number): { primary:
|
||||
return { primary, line, candidates, limited, src }
|
||||
}
|
||||
|
||||
/** 更新方法:复制给 AI 的升级指令(插件不自更新;升级由用户或其 Agent 执行 + 重启) */
|
||||
const { prompt: UPGRADE_AI } = worktableUpgrade()
|
||||
/** 更新方法:复制给 AI 的升级指令(插件不自更新;升级由用户或其 Agent 执行 + 重启)。
|
||||
* 命令按「检测到的新版本」生成 —— 见下方 onCopyUpgrade 里的 worktableUpgrade(tag)。 */
|
||||
|
||||
async function copyTextSafe(text: string): Promise<boolean> {
|
||||
try { if (navigator.clipboard?.writeText) { await navigator.clipboard.writeText(text); return true } } catch {}
|
||||
@@ -1762,7 +1764,9 @@ function ConsolePane() {
|
||||
}
|
||||
const [updCopied, setUpdCopied] = useState(false)
|
||||
const onCopyUpgrade = async () => {
|
||||
const ok = await copyTextSafe(UPGRADE_AI)
|
||||
// 按检测到的新版本生成命令;没有新版本时退回当前版本(保持原有可复制行为)
|
||||
const { prompt } = worktableUpgrade(updInfo?.latest ?? LOCAL_VERSION)
|
||||
const ok = await copyTextSafe(prompt)
|
||||
if (ok) { setUpdCopied(true); window.setTimeout(() => setUpdCopied(false), 2200) }
|
||||
}
|
||||
const onSkipVersion = () => {
|
||||
@@ -2479,7 +2483,7 @@ function FileViewer(props: { path: string }) {
|
||||
const ext = (props.path.split('.').pop() || '').toLowerCase()
|
||||
const fileUrl = '/api/worktable/file?path=' + encodeURIComponent(props.path)
|
||||
if (ext === 'pdf') {
|
||||
return <iframe className="dsh-wt_paneFrame" src={fileUrl} title={basenameOf(props.path)} />
|
||||
return <iframe className="dsh-wt_paneFrame" src={fileUrl} title={basenameOf(props.path)} allowFullScreen />
|
||||
}
|
||||
if (IMAGE_EXTS.test('.' + ext)) {
|
||||
return (
|
||||
|
||||
@@ -234,7 +234,10 @@ export const css = xtermCss + '\n' + [
|
||||
'.dsh-wt_layout:hover{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}',
|
||||
'.dsh-wt_layout[data-on=true]{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05))}',
|
||||
'.dsh-wt_layout[data-on=true] .dsh-wt_layoutName{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}',
|
||||
'.dsh-wt_layoutIcon{flex:none;font-size:15px}',
|
||||
'.dsh-wt_layoutIcon{flex:none;font-size:15px;display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px}',
|
||||
// 内联 SVG 图标:跟随文字色,两平台渲染一致(emoji 依赖系统字体,形状/配色不统一)
|
||||
'.dsh-wt_layoutSvg{width:15px;height:15px;display:block;flex:none;color:var(--dsw-alias-label-secondary,#9aa4b2)}',
|
||||
'.dsh-wt_layout[data-on=true] .dsh-wt_layoutSvg{color:var(--dsw-alias-state-accent-primary,#4f8ef7)}',
|
||||
'.dsh-wt_layoutText{flex:1;min-width:0;display:flex;flex-direction:column;gap:0}',
|
||||
'.dsh-wt_layoutName{font-size:12px;font-weight:400;line-height:17px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
||||
// 箭头与项目名同一行高 + 字面中心对齐;› 墨迹在字面框内偏下,整体上移 1px 使视觉居中
|
||||
@@ -653,7 +656,11 @@ export const css = xtermCss + '\n' + [
|
||||
'.dsh-wt_updateBtn svg{width:12px;height:12px;flex:none}',
|
||||
'.dsh-wt_updateBadge svg{width:12px;height:12px;flex:none}',
|
||||
'.dsh-wt_updateBtn:hover{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.06))}',
|
||||
'.dsh-wt_updateBtnCopy{border-color:var(--dsw-alias-state-accent-primary,#4f8ef7);background:rgba(79,142,247,.18);color:#cfe0ff}',
|
||||
// 「复制 AI 提示词」主按钮:原来用 rgba(...,.18) 半透明底 + 浅蓝字,在实际主题上
|
||||
// 对比度极低(截图里几乎看不见)。改为实心强调色 + 白字,hover/active 明确反馈。
|
||||
'.dsh-wt_updateBtnCopy{border-color:transparent;background:var(--dsw-alias-state-accent-primary,#4f8ef7);color:#fff;font-weight:600}',
|
||||
'.dsh-wt_updateBtnCopy:hover{background:var(--dsw-alias-state-accent-primary-hover,#3f7de0);color:#fff}',
|
||||
'.dsh-wt_updateBtnCopy:active{transform:translateY(.5px)}',
|
||||
'.dsh-wt_updateHint{font-size:10.5px;color:var(--dsw-alias-label-tertiary,#7d8aa5)}',
|
||||
'.dsh-wt_versionRow{margin-top:8px;padding-top:8px;border-top:1px solid var(--dsw-alias-border-l1,#262b36);display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--dsw-alias-label-tertiary,#7d8aa5)}',
|
||||
'.dsh-wt_updateToggle{display:flex;align-items:center;gap:6px;cursor:pointer;user-select:none}',
|
||||
@@ -662,4 +669,22 @@ export const css = xtermCss + '\n' + [
|
||||
'.dsh-wt_updateSwitch::after{content:"";position:absolute;top:2px;right:2px;width:10px;height:10px;border-radius:50%;background:#fff;transition:right .15s}',
|
||||
'.dsh-wt_updateSwitch[data-off=true]{background:var(--dsw-alias-border-l1,#333a48)}',
|
||||
'.dsh-wt_updateSwitch[data-off=true]::after{right:14px}',
|
||||
// 二级页面:缩进 + 左侧引导折线
|
||||
'.dsh-wt_layoutSub{margin-left:20px;border-style:dashed;position:relative;height:30px!important}',
|
||||
'.dsh-wt_layoutSub .dsh-wt_layoutName{font-size:11.5px;color:var(--dsw-alias-label-secondary,#9aa4b2)}',
|
||||
'.dsh-wt_layoutSub::before{content:"";position:absolute;left:-12px;top:-11px;bottom:50%;width:9px;border-left:1.5px solid var(--dsw-alias-border-l2,#3a4150);border-bottom:1.5px solid var(--dsw-alias-border-l2,#3a4150);border-bottom-left-radius:6px;pointer-events:none}',
|
||||
// 折叠按钮:固定在最右(› 箭头右侧),无边框无底色;所有项目卡都占这个位置(无子页面的用 ghost 占位)
|
||||
'.dsh-wt_foldBtn{position:absolute;right:0px;top:50%;transform:translateY(-50%);z-index:3;display:inline-flex;align-items:center;justify-content:center;width:16px;height:18px;border-radius:4px;font-size:11px;line-height:1;cursor:pointer;color:var(--dsw-alias-label-secondary,#9aa4b2)}',
|
||||
'.dsh-wt_foldBtn:hover{color:var(--dsw-alias-label-primary,#e6e8eb)}',
|
||||
'.dsh-wt_foldBtnGhost{cursor:default;pointer-events:none}',
|
||||
'.dsh-wt_layoutHasKids .dsh-wt_layoutArrow{margin-right:0}',
|
||||
'.dsh-wt_manageRowSub{margin-left:20px}',
|
||||
// DS Bot 侧栏元素隐藏(迁移自「改 ds-bot/client.js 插 return null」的做法)。
|
||||
// 动机:ds-bot 是随应用升级的 .bundled-plugins tgz 安装,升级/重装必丢改;
|
||||
// 改为由本插件注入 CSS,只要工作台装着,ds-bot 随便升级都不丢。
|
||||
// 注意:nav.bt-home-nav 必须带 nav 标签选择器 —— BotHome 错误面板有同名 div,不能误伤。
|
||||
// 「返回 bot」按钮([data-slot="sidebar.footer.action"] .bt-return)按用户要求保留显示,不隐藏。
|
||||
'[data-testid="duet-transcript-toggle"]{display:none!important}',
|
||||
'nav.bt-home-nav{display:none!important}',
|
||||
'.bt-connect-wrap{display:none!important}',
|
||||
].join('\n')
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
/** 更新检查核心(控制室公告页使用;设置面板保留自身实现,后续版本统一去重)。键与设置面板共用。 */
|
||||
declare const __WT_VERSION__: string
|
||||
export const LOCAL_VERSION = typeof __WT_VERSION__ === 'undefined' ? 'dev' : __WT_VERSION__
|
||||
const UPDATE_REPO = 'Aisland-SJL/dsh-worktable'
|
||||
// 本仓是内部补丁分发仓,更新源必须是自己的 Gitea,而不是上游 GitHub:
|
||||
// 上游只发布官方版(无本地补丁),查它既看不到本仓版本,国内网络也常失败。
|
||||
// 走宿主中转(/api/worktable/update-check):页面来源是随机端口的 127.0.0.1,
|
||||
// 直连 Gitea 属跨源且 Gitea 无 CORS 头,浏览器会拦截请求。
|
||||
const UPDATE_API = '/api/worktable/update-check'
|
||||
|
||||
export type UpdateStatus = 'idle' | 'checking' | 'uptodate' | 'failed'
|
||||
export type UpdateInfo = { latest: string; notes: string; url: string }
|
||||
@@ -92,7 +96,7 @@ export async function checkUpdate(force = false): Promise<{ status: UpdateStatus
|
||||
const ctrl = new AbortController()
|
||||
const timer = setTimeout(() => ctrl.abort(), 8000)
|
||||
try {
|
||||
const r = await fetch('https://api.github.com/repos/' + UPDATE_REPO + '/releases/latest', { headers: { Accept: 'application/vnd.github+json' }, cache: 'no-store', signal: ctrl.signal })
|
||||
const r = await fetch(UPDATE_API, { headers: { Accept: 'application/json' }, cache: 'no-store', signal: ctrl.signal })
|
||||
if (r.ok) d = (await r.json()) as { tag_name?: string; body?: string; html_url?: string }
|
||||
else if (r.status === 403 || r.status === 404) break
|
||||
} catch { /* 网络抖动/超时:下一轮重试 */ }
|
||||
|
||||
+69
-13
@@ -8,6 +8,7 @@ import { homedir } from 'node:os'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
import { requestRejection, rejectionText } from './requestAuth'
|
||||
import { createPreviewFiles, PREVIEW_PREFIX, PREVIEW_CSP } from './previewFiles'
|
||||
import { injectThemeBridge, THEME_BRIDGE_JS } from './theme'
|
||||
|
||||
/**
|
||||
* 基础数据目录解析:不加载任何官方包(loadPkg 的兜底只能用它,禁止反向调用包加载函数——否则成环)。
|
||||
@@ -294,19 +295,34 @@ export function apply(ctx: Context) {
|
||||
})()
|
||||
}
|
||||
// Direct WebServer routes do NOT inherit the host's /api authentication route.
|
||||
const register = (route: any, publicAsset = false) => ctx.effect(() => webServer.register({
|
||||
...route,
|
||||
handler: async (req: any, res: any) => {
|
||||
if (!publicAsset && route.path !== HEALTH_PATH) {
|
||||
const rejected = await requestRejection(ctx, req)
|
||||
if (rejected !== undefined) {
|
||||
if (route.path === '/api/worktable/state') stateLog('REJECT ' + req.method + ' -> ' + rejected)
|
||||
json(res, rejected, { error: rejectionText(rejected) }); return
|
||||
}
|
||||
// REQ: 容忍热重载期重复路由 —— 旧 fiber 尚未释放时再次注册会抛 duplicate,
|
||||
// 若直接抛出会让新 fiber 激活失败、客户端贡献(侧边栏抽屉)整体消失。
|
||||
// 此时跳过注册即可:路由仍由存活 fiber 服务,下次重启自然收敛回单 fiber。
|
||||
const register = (route: any, publicAsset = false) => {
|
||||
let dispose: (() => void) | undefined
|
||||
try {
|
||||
dispose = webServer.register({
|
||||
...route,
|
||||
handler: async (req: any, res: any) => {
|
||||
if (!publicAsset && route.path !== HEALTH_PATH) {
|
||||
const rejected = await requestRejection(ctx, req)
|
||||
if (rejected !== undefined) {
|
||||
if (route.path === '/api/worktable/state') stateLog('REJECT ' + req.method + ' -> ' + rejected)
|
||||
json(res, rejected, { error: rejectionText(rejected) }); return
|
||||
}
|
||||
}
|
||||
return route.handler(req, res)
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
if (String(err).includes('duplicate')) {
|
||||
ctx.logger?.warn('[dsh-worktable] 路由已被占用(热重载泄漏自保),跳过: ' + route?.path)
|
||||
return
|
||||
}
|
||||
return route.handler(req, res)
|
||||
},
|
||||
}), 'dsh-worktable: ' + route.path)
|
||||
throw err
|
||||
}
|
||||
try { ctx.effect(() => dispose, 'dsh-worktable: ' + route.path) } catch {}
|
||||
}
|
||||
|
||||
register({
|
||||
kind: 'exact', path: '/api/worktable/preview',
|
||||
@@ -352,6 +368,36 @@ export function apply(ctx: Context) {
|
||||
},
|
||||
})
|
||||
|
||||
// 更新检查中转:客户端页面来源是 http://127.0.0.1:<随机端口>,直接 fetch
|
||||
// 自建 Gitea 属跨源请求;Gitea 不返回 Access-Control-Allow-Origin,浏览器会拦截
|
||||
// (表现为「立即检查」无反应 / 「上次检查未成功」)。改由宿主服务端代取,同源无 CORS。
|
||||
register({
|
||||
kind: 'exact',
|
||||
path: '/api/worktable/update-check',
|
||||
handler: async (_req: any, res: any) => {
|
||||
const upstream = 'https://gitea.ququclean.com/api/v1/repos/xiaoqu/dsh-worktable/releases/latest'
|
||||
const ctrl = new AbortController()
|
||||
const timer = setTimeout(() => ctrl.abort(), 8000)
|
||||
try {
|
||||
const r = await fetch(upstream, {
|
||||
headers: { Accept: 'application/json', 'user-agent': 'dsh-worktable/' + PLUGIN_VERSION },
|
||||
signal: ctrl.signal,
|
||||
})
|
||||
if (!r.ok) { json(res, 502, { error: 'upstream status ' + r.status }); return }
|
||||
const d: any = await r.json()
|
||||
json(res, 200, {
|
||||
tag_name: typeof d?.tag_name === 'string' ? d.tag_name : '',
|
||||
body: typeof d?.body === 'string' ? d.body : '',
|
||||
html_url: typeof d?.html_url === 'string' ? d.html_url : '',
|
||||
})
|
||||
} catch (err: any) {
|
||||
json(res, 502, { error: 'upstream unreachable: ' + String(err?.message ?? err) })
|
||||
} finally {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// 本地文件读取(资源管理器点击 .html 后浏览器标签内打开)
|
||||
register({
|
||||
kind: 'exact',
|
||||
@@ -397,6 +443,11 @@ export function apply(ctx: Context) {
|
||||
if (rel === '/dshell.css') {
|
||||
res.writeHead(200, { 'content-type': 'text/css; charset=utf-8', 'cache-control': 'no-store' })
|
||||
res.end(dshellCss)
|
||||
} else if (rel === '/theme.js') {
|
||||
// REQ-20261117-0013:主题桥显式引用入口(站点路由已自动注入内联版;
|
||||
// 独立打开 / 嵌套 iframe 时手动引这一份)。移植自 qiudl 0.4.x 分支。
|
||||
res.writeHead(200, { 'content-type': 'text/javascript; charset=utf-8', 'cache-control': 'no-store' })
|
||||
res.end(THEME_BRIDGE_JS)
|
||||
} else {
|
||||
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store' })
|
||||
res.end(dshellHtml)
|
||||
@@ -433,7 +484,12 @@ export function apply(ctx: Context) {
|
||||
const ext = (abs.split('.').pop() || '').toLowerCase()
|
||||
res.writeHead(200, { 'content-type': FILE_TYPES[ext] ?? 'application/octet-stream', 'cache-control': 'no-store',
|
||||
'content-security-policy': PREVIEW_CSP, 'referrer-policy': 'no-referrer', 'x-content-type-options': 'nosniff' })
|
||||
res.end(data)
|
||||
// REQ-20261117-0013:产物 HTML 自动挂主题桥,让所有工作台页跟随 DSH 主题
|
||||
// (浅色/深色/跟随系统)。幂等:已含 data-wt-theme-bridge 标记则原样返回;
|
||||
// 非 HTML 不受影响。移植自 qiudl 0.4.x 分支(0.5.x 线缺失该能力)。
|
||||
res.end(ext === 'html' || ext === 'htm'
|
||||
? Buffer.from(injectThemeBridge(data.toString('utf8')), 'utf8')
|
||||
: data)
|
||||
} catch (err) {
|
||||
json(res, 404, { error: String(err) })
|
||||
}
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
/**
|
||||
* 工作台主题桥(theme bridge)。
|
||||
*
|
||||
* 问题:产物页是**独立的 document**,DSH 宿主写在 `body` / `body[data-ds-dark-theme]` 上的
|
||||
* `--dsw-*` token 不会跨文档继承;`dshell.css` 只能靠 `var(--x, 兜底)` 兜底,
|
||||
* 于是所有工作台页在浅色主题下依旧渲染成深色(2026-10-15 用户报"页面缺少主题跟随")。
|
||||
*
|
||||
* 方案(同源 iframe 直接读宿主文档的 computed style,实测可枚举自定义属性):
|
||||
* 1) **站点路由自动注入**(`injectThemeBridge`):`/api/worktable/site/**` 下所有 `.html`
|
||||
* 响应都会带上一段内联桥,页面作者零改动,嵌套 iframe 也各拿一份;
|
||||
* 2) **显式引入**:`/api/worktable/template/theme.js`(同一份脚本),供独立打开、
|
||||
* 或经 file/其它托管方式打开的页面使用;
|
||||
* 3) 纯函数 `shouldMirrorVar` / `pickThemeVars` 同时给测试与浏览器脚本用,避免判定漂移。
|
||||
*
|
||||
* 桥的行为:把宿主 body 上 `--dsw-* / --dsh-* / --ds-*` 的自定义属性镜像到自己的
|
||||
* `html`/`body` 内联样式(内联优先级高于 dshell.css 的 `:root` 兜底),并同步
|
||||
* `color-scheme` 与 `data-ds-dark-theme` 标记;跟随宿主属性变化(MutationObserver)、
|
||||
* 系统深浅色变化(matchMedia)与低频轮询兜底。拿不到宿主(独立打开)时退回系统偏好。
|
||||
*
|
||||
* **页面优先**:页面自带主题开关时不抢——`window.__wtThemeBridgeManual = true`、
|
||||
* `<html data-wt-theme-mode="manual">`,或老工作台页的 `<html data-wb-theme>` /
|
||||
* `localStorage['dwb.theme']`(日记工作台、ai递归学习用这套)。判定为手动时会**清掉**
|
||||
* 桥写过的内联 token,让页面自己的样式表值生效;页面切回跟随(清掉标记)后调
|
||||
* `window.__wtThemeBridgeApply()` 即可恢复镜像。
|
||||
*/
|
||||
|
||||
/** 需要镜像的自定义属性前缀:颜色/材质 token(--dsw-)、字体与字号 token(--dsh-)、代码字体(--ds-)。 */
|
||||
export const THEME_VAR_PREFIXES = ['--dsw-', '--dsh-', '--ds-'] as const
|
||||
|
||||
/** 桥脚本的 DOM 标记(幂等注入与测试断言共用)。 */
|
||||
export const THEME_BRIDGE_ID = 'wt-theme-bridge'
|
||||
|
||||
/** 主题脚本路由(显式引入用)。 */
|
||||
export const THEME_JS_PATH = '/api/worktable/template/theme.js'
|
||||
|
||||
export type ThemeVar = [name: string, value: string]
|
||||
|
||||
/** 该自定义属性是否属于需要镜像的主题 token。 */
|
||||
export function shouldMirrorVar(name: string): boolean {
|
||||
const n = String(name ?? '').trim()
|
||||
if (!n.startsWith('--')) return false
|
||||
return THEME_VAR_PREFIXES.some((p) => n.startsWith(p))
|
||||
}
|
||||
|
||||
/** 从 [名, 值] 列表里挑出要镜像的 token(去空值、去非法名)。 */
|
||||
export function pickThemeVars(pairs: ReadonlyArray<ThemeVar> | null | undefined): ThemeVar[] {
|
||||
const out: ThemeVar[] = []
|
||||
for (const pair of pairs ?? []) {
|
||||
if (!Array.isArray(pair) || pair.length < 2) continue
|
||||
const name = String(pair[0] ?? '').trim()
|
||||
const value = String(pair[1] ?? '').trim()
|
||||
if (!shouldMirrorVar(name) || !value) continue
|
||||
out.push([name, value])
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** 浏览器端桥脚本(单份真相:内联注入与 /template/theme.js 都用它)。 */
|
||||
export const THEME_BRIDGE_JS = `(function () {
|
||||
var PREFIXES = ${JSON.stringify(THEME_VAR_PREFIXES)};
|
||||
if (window.__wtThemeBridgeInstalled) return;
|
||||
window.__wtThemeBridgeInstalled = true;
|
||||
function ok(name) {
|
||||
if (!name || name.slice(0, 2) !== '--') return false;
|
||||
for (var i = 0; i < PREFIXES.length; i++) if (name.slice(0, PREFIXES[i].length) === PREFIXES[i]) return true;
|
||||
return false;
|
||||
}
|
||||
/** 向上找到最外层同源祖先窗口;跨域或到顶就停。 */
|
||||
function hostWindow() {
|
||||
var w = window;
|
||||
try {
|
||||
for (var i = 0; i < 12; i++) {
|
||||
var p = w.parent;
|
||||
if (!p || p === w) break;
|
||||
if (!p.document || !p.document.documentElement) break;
|
||||
w = p;
|
||||
}
|
||||
} catch (e) { /* 跨域:停在当前层 */ }
|
||||
return w === window ? null : w;
|
||||
}
|
||||
function hostVars(host) {
|
||||
var out = [];
|
||||
try {
|
||||
var el = host.document.body || host.document.documentElement;
|
||||
if (!el) return out;
|
||||
var cs = host.getComputedStyle(el);
|
||||
for (var i = 0; i < cs.length; i++) {
|
||||
var n = cs[i];
|
||||
if (!ok(n)) continue;
|
||||
var v = cs.getPropertyValue(n);
|
||||
if (v && v.trim()) out.push([n, v.trim()]);
|
||||
}
|
||||
out.dark = el.hasAttribute && el.hasAttribute('data-ds-dark-theme');
|
||||
} catch (e) { /* 读不到就退回系统偏好 */ }
|
||||
return out;
|
||||
}
|
||||
function systemDark() {
|
||||
try { return !!(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches); } catch (e) { return false; }
|
||||
}
|
||||
/** 页面自带主题开关?(页面优先,桥不抢)
|
||||
* 1) 运行时显式:window.__wtThemeBridgeManual = true
|
||||
* 2) 标记:<html data-wt-theme-mode="manual">
|
||||
* 3) 老工作台页兼容:<html data-wb-theme> 或 localStorage['dwb.theme'](日记工作台 / ai递归学习用这套)
|
||||
* 显式跟随:<html data-wt-theme-mode="auto">(或 <html data-wt-theme-key="自己的键">)=**忽略**上面 3) 的
|
||||
* legacy 判定,强制跟宿主——同源页面共用一个 localStorage 键时,这条是"我只想跟宿主"的唯一办法。 */
|
||||
function pageManual() {
|
||||
try {
|
||||
if (window.__wtThemeBridgeManual) return true;
|
||||
var el = document.documentElement;
|
||||
if (el) {
|
||||
var mode = el.getAttribute && el.getAttribute('data-wt-theme-mode');
|
||||
if (mode === 'manual') return true;
|
||||
if (mode === 'auto' || mode === 'host') return false;
|
||||
if (el.hasAttribute && el.hasAttribute('data-wt-theme-key')) return false;
|
||||
if (el.hasAttribute && el.hasAttribute('data-wb-theme')) return true;
|
||||
}
|
||||
var v = null;
|
||||
try { v = localStorage.getItem('dwb.theme'); } catch (e) { v = null; }
|
||||
if (v === 'dark' || v === 'light') return true;
|
||||
} catch (e) { /* 读不到就按非手动处理 */ }
|
||||
return false;
|
||||
}
|
||||
var applied = [];
|
||||
/** 清掉桥写过的内联 token:切到手动主题时必须让位给页面自己的样式表值。 */
|
||||
function clearApplied() {
|
||||
var root = document.documentElement;
|
||||
for (var i = 0; i < applied.length; i++) {
|
||||
try { root.style.removeProperty(applied[i]); } catch (e) {}
|
||||
try { if (document.body) document.body.style.removeProperty(applied[i]); } catch (e) {}
|
||||
}
|
||||
applied = [];
|
||||
}
|
||||
function apply() {
|
||||
if (pageManual()) { clearApplied(); return; }
|
||||
var host = hostWindow();
|
||||
var vars = host ? hostVars(host) : [];
|
||||
var dark = host ? !!vars.dark : systemDark();
|
||||
var root = document.documentElement;
|
||||
for (var i = 0; i < vars.length; i++) root.style.setProperty(vars[i][0], vars[i][1]);
|
||||
root.style.colorScheme = dark ? 'dark' : 'light';
|
||||
if (document.body) {
|
||||
for (var j = 0; j < vars.length; j++) document.body.style.setProperty(vars[j][0], vars[j][1]);
|
||||
if (dark) document.body.setAttribute('data-ds-dark-theme', '');
|
||||
else document.body.removeAttribute('data-ds-dark-theme');
|
||||
}
|
||||
applied = vars.map(function (p) { return p[0]; });
|
||||
}
|
||||
apply();
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', apply, { once: true });
|
||||
// 页面自己切主题(data-wb-theme / data-wt-theme-mode)时立刻重新判定,别等轮询
|
||||
try {
|
||||
var MO0 = window.MutationObserver;
|
||||
if (MO0) new MO0(function () { apply(); }).observe(document.documentElement, { attributes: true, attributeFilter: ['data-wb-theme', 'data-wt-theme-mode'] });
|
||||
} catch (e) { /* 忽略 */ }
|
||||
var host = hostWindow();
|
||||
if (host) {
|
||||
try {
|
||||
var MO = host.MutationObserver || window.MutationObserver;
|
||||
var mo = new MO(function () { apply(); });
|
||||
var opts = { attributes: true, attributeFilter: ['style', 'class', 'data-ds-dark-theme'] };
|
||||
mo.observe(host.document.documentElement, opts);
|
||||
if (host.document.body) mo.observe(host.document.body, opts);
|
||||
host.document.addEventListener('DOMContentLoaded', function () { try { mo.observe(host.document.body, opts); } catch (e) {} apply(); });
|
||||
} catch (e) { /* 观测失败靠下面的兜底轮询 */ }
|
||||
}
|
||||
try {
|
||||
var mq = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)');
|
||||
if (mq) { if (mq.addEventListener) mq.addEventListener('change', apply); else if (mq.addListener) mq.addListener(apply); }
|
||||
} catch (e) { /* 忽略 */ }
|
||||
window.__wtThemeBridgeApply = apply;
|
||||
setInterval(apply, 5000); // 兜底:宿主换主题也可能只换样式表、不动属性
|
||||
})();`
|
||||
|
||||
/**
|
||||
* 给产物 HTML 注入主题桥(幂等)。
|
||||
* 优先插到 `</head>` 前;没有 head 就插到 `</body>` 前;都没有就前置。
|
||||
* @param html 原始 HTML 文本
|
||||
* @param external true = 用 `<script src>` 引 /template/theme.js;默认内联(少一次请求,离线可用)
|
||||
*/
|
||||
export function injectThemeBridge(html: string, external = false): string {
|
||||
const src = String(html ?? '')
|
||||
if (!src || src.includes(THEME_BRIDGE_ID)) return src
|
||||
const tag = external
|
||||
? `<script id="${THEME_BRIDGE_ID}" data-wt-theme-bridge src="${THEME_JS_PATH}"></script>`
|
||||
: `<script id="${THEME_BRIDGE_ID}" data-wt-theme-bridge>${THEME_BRIDGE_JS}</script>`
|
||||
const head = /<\/head\s*>/i.exec(src)
|
||||
if (head) return src.slice(0, head.index) + tag + src.slice(head.index)
|
||||
const body = /<\/body\s*>/i.exec(src)
|
||||
if (body) return src.slice(0, body.index) + tag + src.slice(body.index)
|
||||
return tag + src
|
||||
}
|
||||
@@ -1,13 +1,41 @@
|
||||
/* dsh-worktable 原生皮肤 · DSH 设计系统组件库
|
||||
用法:<link rel="stylesheet" href="/api/worktable/template/dshell.css">
|
||||
所有颜色走 DSH 主题变量(--dsw-alias-*),自动适配明暗主题。 */
|
||||
:root { color-scheme: dark; }
|
||||
颜色一律走 DSH 主题变量(--dsw-alias-*),自动适配明暗主题。
|
||||
主题来源优先级:
|
||||
1) 工作台内:主题桥(站点路由自动注入,或显式引 /api/worktable/template/theme.js)
|
||||
把宿主 body 上的 --dsw-*/--dsh-*/--ds-* 镜像成页面内联样式 → 跟随 DSH 的 浅色/深色/跟随系统;
|
||||
2) 独立打开:用下面 :root 的兜底,并按系统深浅色切换。
|
||||
注意:不要在这里写死深色(旧版 :root{color-scheme:dark} 会让所有页面锁死深色,
|
||||
2026-11 从 0.5.x 线恢复时再次踩到,REQ-20261117-0013 一并修掉)。 */
|
||||
:root {
|
||||
color-scheme: light dark;
|
||||
--dsw-alias-bg-base: #ffffff;
|
||||
--dsw-alias-fill-l1: rgba(16, 24, 40, .03);
|
||||
--dsw-alias-border-l1: #e4e7ec;
|
||||
--dsw-alias-border-l2: #d0d5dd;
|
||||
--dsw-alias-label-primary: #101828;
|
||||
--dsw-alias-label-secondary: #475467;
|
||||
--dsw-alias-label-tertiary: #98a2b3;
|
||||
--dsw-alias-state-accent-primary: #2f6feb;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--dsw-alias-bg-base: #0b0e14;
|
||||
--dsw-alias-fill-l1: rgba(255, 255, 255, .02);
|
||||
--dsw-alias-border-l1: #262b36;
|
||||
--dsw-alias-border-l2: #3a4150;
|
||||
--dsw-alias-label-primary: #e6e8eb;
|
||||
--dsw-alias-label-secondary: #9aa4b2;
|
||||
--dsw-alias-label-tertiary: #6b7280;
|
||||
--dsw-alias-state-accent-primary: #4f8ef7;
|
||||
}
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
body {
|
||||
background: var(--dsw-alias-bg-base, #0b0e14);
|
||||
color: var(--dsw-alias-label-primary, #e6e8eb);
|
||||
font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
|
||||
font-family: var(--dsw-font-family, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
样式表由插件提供(随主题自动适配),不要复制或改写它。 -->
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<!-- 主题跟随:站点路由(/api/worktable/site/**)已自动注入主题桥,无需手写;
|
||||
独立打开 / 嵌套 iframe 时显式引入下面这一行即可:
|
||||
<script src="/api/worktable/template/theme.js"></script> -->
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>我的窗口</title>
|
||||
|
||||
@@ -26,7 +26,7 @@ function npmCliPath() {
|
||||
return c[0] ?? 'npm'
|
||||
}
|
||||
|
||||
const REPO = 'Aisland-SJL/dsh-worktable'
|
||||
const REPO = process.env.SLARK_WT_REPO || 'Aisland-SJL/dsh-worktable'
|
||||
// 参数严格解析:--expect-sha <64位hex> [tag];缺值/非 hex/重复参数/多余 tag 一律拒绝
|
||||
const args = process.argv.slice(2)
|
||||
let EXPECT_SHA = null
|
||||
@@ -49,7 +49,9 @@ for (let i = 0; i < args.length; i++) {
|
||||
sawTag = true
|
||||
}
|
||||
// latest 用特殊路径 /releases/latest/download/<asset>;具体 tag 用 /releases/download/<tag>/<asset>(tag 保留 v 前缀)
|
||||
const assetBase = TAG === '' ? 'https://github.com/' + REPO + '/releases/latest/download/' : 'https://github.com/' + REPO + '/releases/download/' + TAG + '/'
|
||||
// SLARK_WT_HOST 可指向自建 Gitea(默认 GitHub 上游)
|
||||
const HOST = process.env.SLARK_WT_HOST || 'https://github.com'
|
||||
const assetBase = TAG === '' ? HOST + '/' + REPO + '/releases/latest/download/' : HOST + '/' + REPO + '/releases/download/' + TAG + '/'
|
||||
|
||||
function httpGet(url, outFile) {
|
||||
// PowerShell Invoke-WebRequest:走 WinINET 系统代理(本机网络环境需要);-L 行为由 IWR 自动跟随重定向
|
||||
@@ -69,7 +71,8 @@ console.log('[verify-remote] GET ' + fixedUrl)
|
||||
if (!httpGet(fixedUrl, fixedFile)) { console.error('[verify-remote] FAIL: download fixed-name asset'); process.exit(1) }
|
||||
|
||||
// 2. 解包读版本,拼版本化 URL 并下载
|
||||
const listTar = spawnSync('tar', ['-tzf', fixedFile], { encoding: 'utf8' })
|
||||
// Windows: GNU tar 会把 "C:\..." 的盘符当成 rsh 主机,必须 --force-local
|
||||
const listTar = spawnSync('tar', ['--force-local', '-tzf', fixedFile], { encoding: 'utf8' })
|
||||
if (listTar.status !== 0) { console.error('[verify-remote] FAIL: tar -tzf'); process.exit(1) }
|
||||
const entries = listTar.stdout.split(/\r?\n/).filter(Boolean)
|
||||
const EXPECTED = ['package/LICENSE','package/README.md','package/cordis.patch.yml','package/dsh.plugin.json','package/lib/client.js','package/lib/index.js','package/package.json']
|
||||
@@ -77,7 +80,7 @@ const okStruct = entries.length === EXPECTED.length && EXPECTED.every((e) => ent
|
||||
if (!okStruct) { console.error('[verify-remote] FAIL: structure mismatch: ' + entries.join(',')); process.exit(1) }
|
||||
console.log('[verify-remote] structure ok (7 files)')
|
||||
const ext = join(work, 'ext'); mkdirSync(ext, { recursive: true })
|
||||
const x = spawnSync('tar', ['-xzf', fixedFile, '-C', ext])
|
||||
const x = spawnSync('tar', ['--force-local', '-xzf', fixedFile, '-C', ext])
|
||||
if (x.status !== 0) { console.error('[verify-remote] FAIL: tar extract'); process.exit(1) }
|
||||
const pkg = JSON.parse(readFileSync(join(ext, 'package', 'package.json'), 'utf8'))
|
||||
const manifest = JSON.parse(readFileSync(join(ext, 'package', 'dsh.plugin.json'), 'utf8'))
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
# 本地改造记录
|
||||
|
||||
> 本文件记录相对上游 dsh-worktable 的**全部本地改造**,供交接、复用与回归。
|
||||
> 每条标注日期、动机、落点与验证方式。改动在 `01_content/src/`,经 `npm run build`
|
||||
> 产出 `lib/`;发布物由 `npm run pack`(`01_content/release-prep.mjs`)生成。
|
||||
|
||||
当前版本:**0.5.3-local.10**(2026-12-02)
|
||||
产物:`01_content/dist/v0.5.3-local.10/dsh-worktable.tgz`,486219 字节,
|
||||
sha256 `2ff7d45a3ea1d0d2344a72f313439be7dacdf52a9e4c9317ba11b54e1f58945f`
|
||||
|
||||
---
|
||||
|
||||
## 一、桌面端状态持久化(0.5.2-local 线,上游已有补丁)
|
||||
|
||||
**动机**:桌面端宿主每次启动带 `--port 0`(随机端口),页面来源随之变化;工作台把
|
||||
项目/布局存在 localStorage,浏览器按来源隔离 → 换端口等于空库,重启就丢。
|
||||
|
||||
**做法**:`src/client/hostState.ts` 把「项目 + 视图」镜像到宿主侧文件
|
||||
(`/api/worktable/state`)。localStorage 仍是第一落点,宿主文件是跨重启兜底。
|
||||
|
||||
**两条保险**(一次真实事故的产物:空状态把宿主文件冲掉):
|
||||
|
||||
1. `hydrated` 标记 —— 读完宿主之前禁止写入;`markHydrated()` 放行,
|
||||
`staysReadOnly()` 整场禁写。读失败宁可只用本地,也不拿空值覆盖镜像。
|
||||
2. `parts` 按 key 合并 —— POST 只带最新值,服务端再按 key 合并,
|
||||
半截写入不会丢另一半。
|
||||
|
||||
**重试**:`RETRY_DELAYS = [0, 300, 700, 1200, 2000, 3000]`,共 6 次退避。
|
||||
宿主 web 服务就绪慢于面板加载时,不会误判为「旧宿主」。
|
||||
|
||||
覆盖范围:项目、布局、绑定、项目文件夹、视图与外观设置。
|
||||
不覆盖:图库媒体(仍在 IndexedDB,换端口照样丢)。
|
||||
|
||||
---
|
||||
|
||||
## 二、孤儿路由防护(0.5.3-local.5,2026-12-02)
|
||||
|
||||
**现象**:安装/升级其他插件触发 profile 热重载后,侧边栏工作台抽屉整个消失,
|
||||
日志报 `webserver: duplicate exact route "/api/worktable/health"`。
|
||||
|
||||
**根因**:热替换时旧 fiber 尚未释放已注册路由 → 新 fiber 激活失败 →
|
||||
客户端贡献随之卸载。
|
||||
|
||||
**改动**:`src/index.ts` 的 `register` 包一层 try/catch:
|
||||
|
||||
```ts
|
||||
const register = (route: any, publicAsset = false) => {
|
||||
let dispose: (() => void) | undefined
|
||||
try {
|
||||
dispose = webServer.register({ ...route, handler: /* 鉴权包装 */ })
|
||||
} catch (err) {
|
||||
if (String(err).includes('duplicate')) {
|
||||
ctx.logger?.warn('[dsh-worktable] 路由已被占用(热重载泄漏自保),跳过: ' + route?.path)
|
||||
return // 跳过注册,但插件照常激活
|
||||
}
|
||||
throw err
|
||||
}
|
||||
try { ctx.effect(() => dispose, 'dsh-worktable: ' + route.path) } catch {}
|
||||
}
|
||||
```
|
||||
|
||||
**要点**:
|
||||
- `register` 必须**直接调用**(`server-home` 测试夹具的 `effect` 是空实现,不执行回调)
|
||||
- `effect` 只负责挂 disposer(本 fiber dispose 时释放路由)
|
||||
|
||||
**效果**:泄漏发生时侧边栏不再消失,API 由旧 fiber 继续服务,下次重启收敛回单 fiber。
|
||||
|
||||
---
|
||||
|
||||
## 三、iframe 全屏(0.5.3-local.5,2026-12-02)
|
||||
|
||||
**动机**:项目窗格里的看板(HTML 单文件)自带全屏按钮,缺 `allowFullScreen`
|
||||
会被浏览器拒绝。
|
||||
|
||||
**改动**:`src/client/split.tsx` 的 `IframePane` 加 `allowFullScreen`。
|
||||
|
||||
```tsx
|
||||
return <iframe className="dsh-wt_paneFrame" src={fileUrl} title={basenameOf(props.path)} allowFullScreen />
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 四、二级页面(父子项目树,0.5.3-local.5,2026-12-02)
|
||||
|
||||
**能力**:项目下可挂独立布局页,侧栏按树形展示(仅一级嵌套)。
|
||||
|
||||
**数据模型**:`src/client/split.tsx` 的 `LayoutSpec.parentId?: string`——缺省 = 顶级项目。
|
||||
|
||||
**核心实现**:
|
||||
|
||||
| 位置 | 内容 |
|
||||
|---|---|
|
||||
| `src/client/index.tsx` `addSubPage` | 管理面板「新增二级页面」(`+` 按钮):`buildLayout('2h', 父名 + ' · 新页面')`,继承父项目文件夹,建完即打开 |
|
||||
| `src/client/index.tsx` `toggleFold` | 折叠/展开某项目的子页面,状态存 `view.foldedProjects` |
|
||||
| `src/client/index.tsx` `layoutTree` | 侧栏树构建:父项目 + 子页面(仅一级;父项目不可见时子页面按顶级显示) |
|
||||
| `src/client/index.tsx` 渲染段 | `depth === 1` 加 `.dsh-wt_layoutSub`,有子页面时显示折叠箭头(`▾`/`▸`) |
|
||||
| `src/client/styles.ts` | `.dsh-wt_layoutSub`(缩进 20px + 虚线边框 + 左侧引导折线)、`.dsh-wt_foldBtn`、`.dsh-wt_foldBtnGhost` |
|
||||
| `src/client/locales.ts` | `manage.addPage` / `tree.fold` / `tree.expand` 中英双语文案 |
|
||||
|
||||
**设计取舍**:
|
||||
- **仅一级嵌套**:子页面不能再挂子页面
|
||||
- **删除父项目不级联删子页面**:`removeLayout` 把 `parentId === id` 的子页面提升为顶级,
|
||||
避免误删用户内容
|
||||
- 父项目隐藏时,子页面按顶级显示,不跟着消失
|
||||
|
||||
---
|
||||
|
||||
## 五、DS Bot 侧栏元素隐藏(0.5.3-local.5,2026-12-02)
|
||||
|
||||
**背景**:原先通过改 `ds-bot/client.js`(组件开头插 `return null`)实现隐藏。
|
||||
ds-bot 是随应用升级的 `.bundled-plugins` tgz 安装,**升级/重装必丢**。
|
||||
|
||||
**方案**:改为本插件注入 CSS 隐藏。只要 worktable 装着,ds-bot 随便升级都不丢。
|
||||
|
||||
**改动**:`src/client/styles.ts` 末尾四条:
|
||||
|
||||
```css
|
||||
[data-testid="duet-transcript-toggle"]{display:none!important} /* duet 语音记录开关 */
|
||||
nav.bt-home-nav{display:none!important} /* 首页/消息/待办 */
|
||||
.bt-connect-wrap{display:none!important} /* 连接插件 */
|
||||
```
|
||||
|
||||
**0.5.3-local.7 起**:侧栏底部的「返回 bot」按钮(`[data-slot="sidebar.footer.action"] .bt-return`)
|
||||
按用户要求**恢复显示**,不再隐藏。
|
||||
|
||||
**注意**:`nav.bt-home-nav` 必须带 `nav` 标签选择器 —— BotHome 错误面板有同名
|
||||
`div.bt-home-nav`,不能误伤。
|
||||
|
||||
---
|
||||
|
||||
## 六、更新检查改指本仓 Gitea(0.5.3-local.6,2026-12-02)
|
||||
|
||||
**现象**:控制室/设置里点「立即检查」,查不到本仓新发布的版本,还常显示「上次检查未成功」。
|
||||
|
||||
**根因**:本仓从上游 fork 后,更新检查仍查上游 GitHub:
|
||||
|
||||
```ts
|
||||
fetch('https://api.github.com/repos/Aisland-SJL/dsh-worktable/releases/latest')
|
||||
```
|
||||
|
||||
三重问题:
|
||||
1. 上游只发**官方版**(无本地补丁),本仓的 `-local.*` 版本它根本不知道
|
||||
2. 国内网络访问 `api.github.com` 常失败 → 「检查未成功」
|
||||
3. 安装命令也指向上游 `github.com/.../releases/latest/download/`
|
||||
|
||||
**改动**(三处):
|
||||
|
||||
| 文件 | 改动 |
|
||||
|---|---|
|
||||
| `src/client/updateCheck.ts` | 控制室用:`UPDATE_HOST` + Gitea API `/api/v1/repos/xiaoqu/dsh-worktable/releases/latest` |
|
||||
| `src/client/index.tsx` | 设置面板用(独立实现):同样改 Gitea API |
|
||||
| `src/client/hostTransport.ts` | `worktableUpgrade()` 的安装命令改为带具体 tag 的本仓 tgz |
|
||||
|
||||
**注意**:Gitea **不支持** GitHub 的 `/releases/latest/download/<asset>` 简写(实测 404),
|
||||
安装命令必须带具体 tag,所以 `UPDATE_TGZ` 是固定 URL,每次发版要同步更新。
|
||||
|
||||
**测试**:`04_test/sidebar-popup.test.mjs` 的 `releaseUrl` 断言同步改为新 API 地址。
|
||||
|
||||
**0.5.3-local.8 修正(2026-12-02)**:直连 Gitea API 仍不通 —— 页面来源是
|
||||
`http://127.0.0.1:<随机端口>`,请求 `https://gitea.ququclean.com/api/...` 属跨源,
|
||||
而 **Gitea 不返回 `Access-Control-Allow-Origin`**,浏览器直接拦截 fetch
|
||||
(表现为「立即检查」无反应、长期显示「上次检查未成功」)。
|
||||
|
||||
改为**宿主中转**:`src/index.ts` 新增 `/api/worktable/update-check` 路由,
|
||||
由服务端(Node,无 CORS 约束)代取 Gitea 的 `releases/latest`,客户端只请求同源路径。
|
||||
该路由沿既有约定**需要鉴权**(`request-auth.test.mjs` 要求除 health/preview-static 外
|
||||
所有路由都必须拒绝未鉴权请求)。
|
||||
|
||||
**版本比较无需改动**:`cmpVer('v0.5.2-local.6', '0.5.3-local.5') = -1`,
|
||||
core 段 0.5.2 < 0.5.3 已能正确判定「有新版」。
|
||||
|
||||
---
|
||||
|
||||
## 七、工具链修复(0.5.3-local.5,2026-12-02)
|
||||
|
||||
三个 Windows 兼容缺陷,不修则 `npm run pack` 门禁过不去:
|
||||
|
||||
1. **`01_content/release-prep.mjs`** `tar -tzf` → 加 `--force-local`。
|
||||
GNU tar 把 `C:\...` 的盘符当成 rsh 远端主机,报 `Cannot connect to C: resolve failed`。
|
||||
2. **`04_test/preview-files.test.mjs`** `rmSync` 删 Windows junction 失败
|
||||
(`ERR_FS_EISDIR`)→ 加 `unlinkSync` 兜底。
|
||||
3. **`04_test/widget-mount.test.mjs`** 提取段起点是 `function loadProjects()`,
|
||||
不含其依赖的 `normalizeProjects`,运行时 ReferenceError 被 `catch` 吞掉,
|
||||
返回 `DEFAULT_PROJECTS` 导致断言 `undefined`。起点前移到
|
||||
`function normalizeProjects(raw: any)`。
|
||||
|
||||
---
|
||||
|
||||
## 八、安装 / 重启
|
||||
|
||||
- 发布版安装:`dsh plugin --profile web add "<release tgz URL>"`
|
||||
- **桌面端:先完全退出 Slark,再执行命令**,装完手动重开。
|
||||
- `--profile` 按实际 profile 名改。
|
||||
- bundle 启动时组合:网页重启 `dsh web` 并刷新;桌面完整退出/手动重开。
|
||||
- 宿主不在 `engines.dsh` 声明列表内时,安装会被兼容性检查拒绝并回滚。
|
||||
|
||||
---
|
||||
|
||||
## 九、回归入口
|
||||
|
||||
```bash
|
||||
cd 01_content
|
||||
npm run build # 构建(必须 cd 到 01_content,否则 lib 写错位置)
|
||||
npm run check # node --check 两个 bundle
|
||||
npm run pack # 发布打包:139 项兼容回归 + 结构/安装/工厂/锚点/服务端断言
|
||||
npm run test:gate # 客户端工厂门禁(10 用例)
|
||||
npm run verify:remote -- --expect-sha <pack 输出的 SHA> [tag] # 发布后远端只读核对
|
||||
```
|
||||
|
||||
`pack` 门禁链路:身份结构断言 → 版本一致性 → 会话/输入/传输/挂载回归(139 项)→
|
||||
构建 → `node --check` → `npm pack` → 结构清单(精确 7 文件,无 `src/`、无 `.map`)→
|
||||
独立临时目录 `npm install` + `import()` → 客户端工厂求值 → 分栏锚点 DOM(14 场景)→
|
||||
sidebar/control-room/update 呈现 → 真实 Chromium 分栏边距(5 场景)→
|
||||
服务端数据目录解析(3 场景)→ `dist/v<版本>/` 双资产同源。
|
||||
|
||||
---
|
||||
|
||||
## 十、已知边界
|
||||
|
||||
1. **同 tag 资产不可覆盖**:坏包处理 = 发新版本号 + 旧 Release 正文标注问题。
|
||||
2. 平台边界:Windows 网页端为已测范围;macOS 为核心路径已做跨平台适配、
|
||||
尚未真机端到端验证。
|
||||
3. 路径拼接必须走 `src/client/pathutil.ts` 或 Node `path` API,不手写分隔符。
|
||||
@@ -38,14 +38,19 @@ test('Unknown stream protocols are rejected', () => {
|
||||
})
|
||||
|
||||
test('Web update instructions retain the web profile', () => {
|
||||
const { command, prompt, desktop } = worktableUpgrade('https:')
|
||||
const { command, prompt, desktop } = worktableUpgrade('0.5.3-local.10', 'https:')
|
||||
assert.equal(desktop, false)
|
||||
assert.match(command, /--profile web add/)
|
||||
assert.match(prompt, /重启 dsh web/)
|
||||
// 命令必须指向「要装的版本」,不能是当前已装版本(否则提示与命令自相矛盾)
|
||||
assert.match(command, /\/releases\/download\/v0\.5\.3-local\.10\/dsh-worktable\.tgz/)
|
||||
const older = worktableUpgrade('0.5.3-local.9', 'https:').command
|
||||
assert.match(older, /v0\.5\.3-local\.9/)
|
||||
assert.doesNotMatch(older, /v0\.5\.3-local\.10/)
|
||||
})
|
||||
|
||||
test('Desktop update instructions require its bundled CLI and manual restart', () => {
|
||||
const { command, prompt, desktop } = worktableUpgrade('dsh-app:')
|
||||
const { command, prompt, desktop } = worktableUpgrade('0.5.3-local.10', 'dsh-app:')
|
||||
assert.equal(desktop, true)
|
||||
assert.match(command, /--profile desktop add/)
|
||||
assert.doesNotMatch(command, /--profile web/)
|
||||
|
||||
@@ -39,7 +39,7 @@ test('Preview reads only its canonical root, including directory indexes',async(
|
||||
for(const parts of [['..','outside','outside.txt'],['..\\outside\\outside.txt'],['/outside'],['bad\0']]) assert.equal(await store.file(token,parts),null)
|
||||
symlinkSync(outside,join(root,'escape'),process.platform==='win32'?'junction':'dir')
|
||||
assert.equal(await store.file(token,['escape','outside.txt']),null)
|
||||
rmSync(join(root,'escape'))
|
||||
try { rmSync(join(root,'escape')) } catch { try { unlinkSync(join(root,'escape')) } catch {} }
|
||||
})
|
||||
test('Capabilities expire after idle time; revocation and disposal remove them',async()=>{
|
||||
let now=0;const store=createPreviewFiles(()=>now),a=await store.mount(root)
|
||||
|
||||
@@ -304,7 +304,8 @@ function testConsolePresentation() {
|
||||
}
|
||||
|
||||
async function testUpdatePresentation() {
|
||||
const releaseUrl = 'https://api.github.com/repos/Aisland-SJL/dsh-worktable/releases/latest'
|
||||
// 更新源是本仓 Gitea(内部补丁分发仓),不是上游 GitHub
|
||||
const releaseUrl = '/api/worktable/update-check'
|
||||
for (const outcome of ['older', 'same', 'forbidden', 'invalid', 'invalid-prefix', 'skip']) {
|
||||
let response = { status: 200, tag: 'v9.0.0' }
|
||||
let requests = 0
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
// 工作台主题桥回归:
|
||||
// 1) 纯函数(前缀判定 / 取值清洗)行为正确
|
||||
// 2) 注入幂等、有 head 插 head、无 head 退 body、再退前置;支持 external 模式
|
||||
// 3) 浏览器脚本含关键接线(宿主镜像、深色标记、变化跟随、兜底轮询)
|
||||
// 4) 站点路由 / 模板路由 / dshell.css / dshell.html 的接线必须都在(防"改了桥但没接上")
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { createRequire } from 'node:module'
|
||||
import { runInNewContext } from 'node:vm'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const require = createRequire(new URL('../01_content/package.json', import.meta.url))
|
||||
const { buildSync } = require('esbuild')
|
||||
const code = buildSync({
|
||||
entryPoints: [fileURLToPath(new URL('../01_content/src/theme.ts', import.meta.url))],
|
||||
bundle: true, write: false, platform: 'node', format: 'cjs',
|
||||
}).outputFiles[0].text
|
||||
const module = { exports: {} }
|
||||
runInNewContext(code, { module, exports: module.exports, setInterval: () => 0, setTimeout: () => 0, clearTimeout: () => {} })
|
||||
const { THEME_VAR_PREFIXES, THEME_BRIDGE_ID, THEME_JS_PATH, shouldMirrorVar, pickThemeVars, injectThemeBridge, THEME_BRIDGE_JS } = module.exports
|
||||
|
||||
const read = (rel) => readFileSync(fileURLToPath(new URL(rel, import.meta.url)), 'utf8')
|
||||
const indexSrc = read('../01_content/src/index.ts')
|
||||
const cssSrc = read('../01_content/template/dshell.css')
|
||||
const htmlSrc = read('../01_content/template/dshell.html')
|
||||
|
||||
test('shouldMirrorVar 只认主题 token 前缀', () => {
|
||||
assert.deepEqual([...THEME_VAR_PREFIXES], ['--dsw-', '--dsh-', '--ds-'])
|
||||
for (const ok of ['--dsw-alias-bg-base', '--dsh-content-font-size', '--ds-font-family-code']) {
|
||||
assert.ok(shouldMirrorVar(ok), '应镜像:' + ok)
|
||||
}
|
||||
for (const no of ['color', '--x', '--dsw', 'dsw-alias-bg-base', '', null, undefined]) {
|
||||
assert.ok(!shouldMirrorVar(no), '不应镜像:' + String(no))
|
||||
}
|
||||
})
|
||||
|
||||
test('pickThemeVars 去空值、去非法名、保留顺序', () => {
|
||||
const got = pickThemeVars([
|
||||
['--dsw-alias-bg-base', ' #fff '],
|
||||
['color', '#000'],
|
||||
['--dsh-content-font-size', ''],
|
||||
['--ds-font-family-code', 'Menlo, monospace'],
|
||||
['--dsw-alias-label-primary', ' '],
|
||||
])
|
||||
// 跨 vm 上下文,数组原型不同,逐项按字符串比较
|
||||
assert.equal(got.length, 2)
|
||||
assert.deepEqual([String(got[0][0]), String(got[0][1])], ['--dsw-alias-bg-base', '#fff'])
|
||||
assert.deepEqual([String(got[1][0]), String(got[1][1])], ['--ds-font-family-code', 'Menlo, monospace'])
|
||||
assert.equal(pickThemeVars(null).length, 0)
|
||||
assert.equal(pickThemeVars([null, [], ['--dsw-a']]).length, 0)
|
||||
})
|
||||
|
||||
test('injectThemeBridge:插 head、幂等、退化到 body/前置、external 模式', () => {
|
||||
const page = '<!doctype html><html><head><title>t</title></head><body>hi</body></html>'
|
||||
const out = injectThemeBridge(page)
|
||||
assert.ok(out.includes(THEME_BRIDGE_ID), '应写入桥标记')
|
||||
assert.ok(out.indexOf(THEME_BRIDGE_ID) < out.indexOf('</head>'), '应插在 </head> 之前')
|
||||
assert.ok(out.includes('window.__wtThemeBridgeInstalled'), '应内联脚本本体')
|
||||
assert.equal(injectThemeBridge(out), out, '二次注入必须原样返回(幂等)')
|
||||
|
||||
const noHead = '<html><body>hi</body></html>'
|
||||
const out2 = injectThemeBridge(noHead)
|
||||
assert.ok(out2.indexOf(THEME_BRIDGE_ID) < out2.indexOf('</body>'), '无 head 时插在 </body> 前')
|
||||
const bare = 'just text'
|
||||
assert.ok(injectThemeBridge(bare).startsWith('<script'), '都没有时前置注入')
|
||||
assert.equal(injectThemeBridge(''), '')
|
||||
|
||||
const ext = injectThemeBridge(page, true)
|
||||
assert.ok(ext.includes('src="' + THEME_JS_PATH + '"'), 'external 模式应引模板路由')
|
||||
assert.ok(!ext.includes('__wtThemeBridgeInstalled'), 'external 模式不内联脚本本体')
|
||||
})
|
||||
|
||||
test('浏览器脚本含主题跟随的关键接线', () => {
|
||||
for (const needle of [
|
||||
'window.__wtThemeBridgeInstalled',
|
||||
'w.parent',
|
||||
'getComputedStyle',
|
||||
'getPropertyValue',
|
||||
"setAttribute('data-ds-dark-theme'",
|
||||
"style.colorScheme",
|
||||
'MutationObserver',
|
||||
'matchMedia',
|
||||
'prefers-color-scheme: dark',
|
||||
'setInterval',
|
||||
]) {
|
||||
assert.ok(THEME_BRIDGE_JS.includes(needle), '桥脚本缺少:' + needle)
|
||||
}
|
||||
assert.ok(THEME_BRIDGE_JS.includes(JSON.stringify(THEME_VAR_PREFIXES)), '桥脚本应内联同一份前缀表')
|
||||
})
|
||||
|
||||
test('页面优先:自带主题开关时桥必须让位(并清掉自己写过的内联 token)', () => {
|
||||
for (const needle of [
|
||||
'function pageManual()',
|
||||
'__wtThemeBridgeManual',
|
||||
"getAttribute('data-wt-theme-mode')",
|
||||
"mode === 'auto' || mode === 'host'",
|
||||
"hasAttribute('data-wt-theme-key')",
|
||||
"hasAttribute('data-wb-theme')",
|
||||
"localStorage.getItem('dwb.theme')",
|
||||
'function clearApplied()',
|
||||
'style.removeProperty',
|
||||
'if (pageManual()) { clearApplied(); return; }',
|
||||
"attributeFilter: ['data-wb-theme', 'data-wt-theme-mode']",
|
||||
]) {
|
||||
assert.ok(THEME_BRIDGE_JS.includes(needle), '页面优先逻辑缺少:' + needle)
|
||||
}
|
||||
// 「显式跟随宿主」必须排在 legacy dwb.theme 判定之前:同源页面共用一个键时,
|
||||
// 否则任何一个页面点过 ◐,所有页面都会被判成手动,想跟宿主的页面就被劫持了。
|
||||
const autoIdx = THEME_BRIDGE_JS.indexOf("mode === 'auto' || mode === 'host'")
|
||||
const legacyIdx = THEME_BRIDGE_JS.indexOf("localStorage.getItem('dwb.theme')")
|
||||
assert.ok(autoIdx > -1 && legacyIdx > -1 && autoIdx < legacyIdx, 'auto/host 短路必须早于 legacy 键判定')
|
||||
// 兼容老工作台页:apply() 里必须先判定「页面自带主题」,再镜像宿主
|
||||
const callManual = THEME_BRIDGE_JS.indexOf('if (pageManual()) { clearApplied(); return; }')
|
||||
const callHost = THEME_BRIDGE_JS.indexOf('host ? hostVars(host) : []')
|
||||
assert.ok(callManual > -1 && callHost > -1, 'apply() 应同时含两处调用')
|
||||
assert.ok(callManual < callHost, '应先判定手动再镜像宿主')
|
||||
})
|
||||
|
||||
test('站点路由与模板路由接线齐全(产物 HTML 自动跟随主题)', () => {
|
||||
assert.ok(indexSrc.includes("import { injectThemeBridge, THEME_BRIDGE_JS } from './theme'"), '服务端应导入主题桥')
|
||||
assert.ok(/ext === 'html' \|\| ext === 'htm'[\s\S]{0,120}injectThemeBridge\(/.test(indexSrc), '站点路由应对 html 响应注入主题桥')
|
||||
assert.ok(/rel === '\/theme\.js'/.test(indexSrc), '模板路由应下发 /theme.js')
|
||||
assert.ok(/text\/javascript; charset=utf-8/.test(indexSrc), 'theme.js 的 content-type 应为 JS')
|
||||
})
|
||||
|
||||
test('dshell.css 不再写死深色,深/浅两套兜底与主题桥分工明确', () => {
|
||||
const css = cssSrc.replace(/\/\*[\s\S]*?\*\//g, '') // 去掉注释(注释里会引用旧写法)
|
||||
assert.ok(!/:root\s*\{\s*color-scheme:\s*dark\s*;/.test(css), '不应再写死 color-scheme: dark')
|
||||
assert.ok(css.includes('color-scheme: light dark'), '应声明 light dark 让独立打开时跟随系统')
|
||||
assert.ok(css.includes('@media (prefers-color-scheme: dark)'), '应有系统深色兜底')
|
||||
assert.ok(css.includes('--dsw-alias-bg-base: #ffffff'), '应有浅色兜底 token')
|
||||
assert.ok(css.includes('--dsw-alias-bg-base: #0b0e14'), '应有深色兜底 token')
|
||||
assert.ok(/font-family:\s*var\(--dsw-font-family/.test(css), '正文字体应跟随主题字体 token')
|
||||
assert.ok(htmlSrc.includes('theme.js'), '模板应说明显式引入主题桥的方式')
|
||||
})
|
||||
@@ -226,7 +226,9 @@ test('loading legacy project state preserves its saved windows without using old
|
||||
const saved = specOf('old')
|
||||
saved.top[0].tabs = [{ id: 'old-tab', content: { kind: 'iframe', url: 'old.html' } }]
|
||||
const store = storage({ 'dsh.worktable.projects.v1': JSON.stringify({ layouts: [saved], folders: { old: 'C:/shared' } }), 'dsh.worktable.pendingMount.v1': JSON.stringify({ fresh: { content: 'old.html' } }) })
|
||||
const load = evaluate(section(indexSource, 'function loadProjects()', '\nconst clamp') + '\nexport { loadProjects }', { localStorage: store, PROJECTS_KEY: 'dsh.worktable.projects.v1', DEFAULT_PROJECTS: {} }).loadProjects
|
||||
// 提取段必须包含 normalizeProjects:loadProjects 依赖它解析 layouts,
|
||||
// 否则运行时 ReferenceError 被 catch 吞掉,返回 DEFAULT_PROJECTS,断言随之为 undefined。
|
||||
const load = evaluate(section(indexSource, 'function normalizeProjects(raw: any)', '\nconst clamp') + '\nexport { loadProjects }', { localStorage: store, PROJECTS_KEY: 'dsh.worktable.projects.v1', DEFAULT_PROJECTS: {} }).loadProjects
|
||||
assert.equal(load().layouts[0].top[0].tabs[0].content.url, 'old.html')
|
||||
assert.equal(new WidgetMountRegistry(store).entries().length, 0)
|
||||
assert.ok(!indexSource.includes("getItem('dsh.worktable.pendingMount.v1')"))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 本地补丁:工作台状态镜像到宿主侧
|
||||
|
||||
基于上游 `Aisland-SJL/dsh-worktable` **v0.5.1**,本地版本号 `0.5.3-local.3`。
|
||||
基于上游 `Aisland-SJL/dsh-worktable` **v0.5.1**,本地版本号 `0.5.3-local.4`。
|
||||
|
||||
## 为什么打这个补丁
|
||||
|
||||
@@ -88,3 +88,4 @@ dsh plugin --profile web add "https://gitea.ququclean.com/xiaoqu/dsh-worktable/r
|
||||
| 0.5.3-local.1 | REQ-20261117-0013:单标签窗格隐藏标签栏(原只对控制室生效),关闭入口移到窗格标题条,标题改显示当前标签名 |
|
||||
| 0.5.3-local.2 | REQ-20261117-0013:收起态 rail 限制 8 个图标,其余进「⋯」菜单(原先四类全平铺无上限) |
|
||||
| 0.5.3-local.3 | REQ-20261117-0013:状态文件路径改为优先取本机 `03_local/local.json` 的 `cloudStatePath`(指向独立 git 仓),恢复「云状态 + git 历史」;客户端兼容旧 ISO 串形态的 updatedAt |
|
||||
| 0.5.3-local.4 | REQ-20261117-0013:恢复主题桥(0.5.x 线缺失 `src/theme.ts`、`/theme.js` 路由与产物 HTML 自动注入);修 dshell.css 写死 `color-scheme: dark`;正文字体改走 `--dsw-font-family` |
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
> ## 📦 本仓库是内部补丁分发仓,不是上游源码仓
|
||||
>
|
||||
> 上游:<https://github.com/Aisland-SJL/dsh-worktable> | 本仓 = 上游 **v0.5.1** + 桌面端状态持久化补丁(`0.5.2-local.6`)。
|
||||
> 下面从「Screenshots」开始的全部内容是上游 README 原文;本次改动说明见 [PATCH.md](PATCH.md)。
|
||||
> 上游:<https://github.com/Aisland-SJL/dsh-worktable> | 本仓 = 上游 **v0.5.1** + 桌面端状态持久化补丁 + 本项目自用的若干增强(`0.5.3-local.10`)。
|
||||
> 下面从「Screenshots」开始的全部内容是上游 README 原文;本地改动逐条记录见 [LOCAL-CHANGES.md](02_process/LOCAL-CHANGES.md)。
|
||||
|
||||
### 要不要装
|
||||
|
||||
@@ -16,16 +16,16 @@
|
||||
|
||||
### 安装
|
||||
|
||||
当前版本 **v0.5.2-local.6**:
|
||||
当前版本 **v0.5.3-local.10**:
|
||||
|
||||
```bash
|
||||
dsh plugin --profile web add "https://gitea.ququclean.com/xiaoqu/dsh-worktable/releases/download/v0.5.2-local.6/dsh-worktable.tgz"
|
||||
dsh plugin --profile web add "https://gitea.ququclean.com/xiaoqu/dsh-worktable/releases/download/v0.5.3-local.10/dsh-worktable.tgz"
|
||||
```
|
||||
|
||||
- **桌面端:先完全退出 Slark,再执行命令**,装完手动重开;不要在宿主运行时安装。
|
||||
- `--profile web` 按你自己的 profile 名字改。
|
||||
- 资产 `dsh-worktable.tgz`,478462 字节,sha256:
|
||||
`421bca6e48689cf96af38a6703c4b1c31435b5e476209c575c6faccce650d07a`
|
||||
- 资产 `dsh-worktable.tgz`,486219 字节,sha256:
|
||||
`2ff7d45a3ea1d0d2344a72f313439be7dacdf52a9e4c9317ba11b54e1f58945f`
|
||||
(下载后可 `Get-FileHash dsh-worktable.tgz -Algorithm SHA256` 核对)
|
||||
- 声明兼容的 DSH 版本:`0.2.0-rc.2` / `0.2.1-rc.3` / `0.2.1-rc.5` / `0.2.2-alpha.2`。
|
||||
宿主不在这个列表里时,安装会被兼容性检查直接拒绝并回滚。
|
||||
@@ -44,14 +44,14 @@ dsh plugin --profile web add "https://gitea.ququclean.com/xiaoqu/dsh-worktable/r
|
||||
- **覆盖**:项目、布局、绑定、项目文件夹、视图与外观设置 → 镜像到 `<DSH_HOME>/worktable-state.json`
|
||||
- **不覆盖**:图库媒体(照片仍存在 IndexedDB),换端口照样丢
|
||||
- 状态文件是宿主侧的,跨重启、跨端口稳定;localStorage 仍保留为第一落点
|
||||
- **不丢数据的两条保险**(0.5.2-local.6 起):
|
||||
- **不丢数据的两条保险**(0.5.2-local.6 起,0.5.3 继续沿用):
|
||||
- 写入按 key 合并 —— 只改了外观时,`projects` 不会被半截写入抹掉
|
||||
- 启动时读不到宿主状态就整场不写 —— 宁可这次只在本地,也不拿空状态覆盖镜像
|
||||
|
||||
### 升级与回退
|
||||
|
||||
- 装上 `0.5.2-local.6` 后,插件不会提示升级到 0.5.1。
|
||||
- 上游发布 0.5.2 及以上时插件会提示升级;**一旦升级就回到没有补丁的状态**,重启又会丢数据。新版本需要把补丁重新合并(改动只有三处,见 [PATCH.md](PATCH.md))。
|
||||
- 装上 `0.5.3-local.10` 后,插件不会提示升级到 0.5.1。
|
||||
- 上游发布 0.5.2 及以上时插件会提示升级;**一旦升级就回到没有补丁的状态**,重启又会丢数据。新版本需要把补丁重新合并(改动清单见 [LOCAL-CHANGES.md](02_process/LOCAL-CHANGES.md))。
|
||||
- 回退官方版:
|
||||
```bash
|
||||
dsh plugin --profile web add "https://github.com/Aisland-SJL/dsh-worktable/releases/latest/download/dsh-worktable.tgz"
|
||||
|
||||
Reference in New Issue
Block a user