From 30b694341b49cfa01dfbb62448e87c6a88b0910b Mon Sep 17 00:00:00 2001 From: Aisland Date: Wed, 19 Aug 2026 23:54:26 +0800 Subject: [PATCH] feat: native DSH skin template (dshell.css/html served at /api/worktable/template) + knowledge pack mandates it for generated HTML --- 01_content/build.mjs | 1 + 01_content/src/client/index.tsx | 3 + 01_content/src/index.ts | 29 +++++++ 01_content/template/dshell.css | 74 ++++++++++++++++++ 01_content/template/dshell.html | 78 +++++++++++++++++++ .../worklogs/2026-08-16_worktable-v2.md | 14 ++++ AGENTS.md | 3 + 7 files changed, 202 insertions(+) create mode 100644 01_content/template/dshell.css create mode 100644 01_content/template/dshell.html diff --git a/01_content/build.mjs b/01_content/build.mjs index 77c8f33..263741c 100644 --- a/01_content/build.mjs +++ b/01_content/build.mjs @@ -29,6 +29,7 @@ await build({ format: 'esm', target: ['node22'], external: ['@deepseek-ai/*', 'node:*', 'ws', 'node-pty'], + loader: { '.css': 'text', '.html': 'text' }, // 原生皮肤模板以文本嵌入服务端 bundle }) await build({ diff --git a/01_content/src/client/index.tsx b/01_content/src/client/index.tsx index 36087e4..5f82f4e 100644 --- a/01_content/src/client/index.tsx +++ b/01_content/src/client/index.tsx @@ -428,6 +428,9 @@ const KNOWLEDGE_PACK = [ ' 窗内容还可放 iframe 网页与文件预览(.md/.txt/.tsx/.css/.html 等)。', '- 窗口可装载的形式:HTML 单文件(交互 UI,放项目文件夹后在资源管理器点击渲染)、网页 URL、', ' 文件预览(.md/.txt/.tsx/.css/.html/图片/.mp4 等);产出形式按任务类型选,不要一律 HTML。', + '- 产出 HTML 必须用工作台原生皮肤:在页面 加 ,', + ' 组件类参考 /api/worktable/template/dshell.html(卡片/按钮/状态徽标/标签页/列表/统计/进度/表格等),', + ' 界面即可与 DSH 原生风格一致;自造样式控制在最小范围。', '- 服务端能力:/api/worktable/fs(列目录)、/api/worktable/write(写文件)、/api/worktable/mkdir(建目录)、', ' /api/worktable/git(git 状态)、/api/worktable/site(静态托管)。', '- 改完插件在 01_content 目录执行 npm run build;重启 dsh web 或浏览器 F5 生效。', diff --git a/01_content/src/index.ts b/01_content/src/index.ts index deb40e0..4f34aea 100644 --- a/01_content/src/index.ts +++ b/01_content/src/index.ts @@ -38,6 +38,13 @@ const FILE_TYPES: Record = { const SITE_PREFIX = '/api/worktable/site' +// 原生皮肤模板(esbuild text loader 嵌入;/api/worktable/template 路由直接下发) +// @ts-ignore +import dshellCss from '../template/dshell.css' +// @ts-ignore +import dshellHtml from '../template/dshell.html' +const TEMPLATE_PREFIX = '/api/worktable/template' + /** * 从本插件模块位置向祖先方向查找并加载 node_modules 包(如 ws / node-pty)。 * 本包经 junction 链接进 profile,普通 import 可能解析不到 profile 级依赖; @@ -236,6 +243,28 @@ export function apply(ctx: Context) { // 本地站点(目录级静态托管):点开 index.html 时挂载整个所在目录, // 让 ./assets/... 等相对引用正常解析(前缀路由,余下路径 = /<相对路径>)。 + // 原生皮肤模板:HTML 骨架 + 设计系统样式表(随插件分发,主题自动适配) + webServer.register({ + kind: 'prefix', + path: TEMPLATE_PREFIX, + handler: (req: any, res: any) => { + try { + if (req.method !== 'GET') { res.writeHead(405); res.end(); return } + const pathname = new URL(req.url ?? '/', 'http://dsh.internal').pathname + const rel = pathname.slice(TEMPLATE_PREFIX.length) + if (rel === '/dshell.css') { + res.writeHead(200, { 'content-type': 'text/css; charset=utf-8', 'cache-control': 'no-store' }) + res.end(dshellCss) + } else { + res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store' }) + res.end(dshellHtml) + } + } catch (err) { + res.writeHead(404); res.end(String(err)) + } + }, + }) + webServer.register({ kind: 'prefix', path: SITE_PREFIX, diff --git a/01_content/template/dshell.css b/01_content/template/dshell.css new file mode 100644 index 0000000..d460833 --- /dev/null +++ b/01_content/template/dshell.css @@ -0,0 +1,74 @@ +/* dsh-worktable 原生皮肤 · DSH 设计系统组件库 + 用法: + 所有颜色走 DSH 主题变量(--dsw-alias-*),自动适配明暗主题。 */ +: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; +} +.dshell { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; min-height: 100%; } +/* 文字层级 */ +.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; } +/* 卡片 */ +.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; } +/* 按钮(绿色主按钮 / 幽灵按钮 / 危险) */ +.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; } +/* 状态徽标(圆点 + 文字;绿=已完成 黄=待办/待发布 灰=未开始) */ +.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; } +/* 标签页 */ +.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); } +/* 列表 */ +.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); } +/* 网格 / 统计 */ +.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; } +/* 进度条 */ +.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; } +/* 输入 */ +.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); } +/* 表格 */ +.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; } +/* 键值对 */ +.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; } +/* 分割线 */ +.dshell-divider { height: 1px; background: var(--dsw-alias-border-l1, #262b36); margin: 6px 0; } +/* 滚动条 */ +::-webkit-scrollbar { width: 10px; height: 10px; } +::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 5px; } +::-webkit-scrollbar-track { background: transparent; } diff --git a/01_content/template/dshell.html b/01_content/template/dshell.html new file mode 100644 index 0000000..25aa369 --- /dev/null +++ b/01_content/template/dshell.html @@ -0,0 +1,78 @@ + + + + + + + 我的窗口 + + + +
+ +

窗口标题

+

一句话说明这个窗口做什么。

+ + +
+ 已完成 + 进行中 + 未开始 +
+ + +
+ + + +
+ + +
+
+
总数
+
128
+
+12.4%
+
+
+
进行中
+
7
+
+
+
已完成
+
121
+
+
+ + +
+
+ 条目一:示例内容标题 + 昨天 +
+
+ 条目二:示例内容标题 + 已发布 +
+
+ + +
+

详情

+
+
字段 A值 A
+
字段 B值 B
+
+
+
+
+ + +
+ + +
+
+ + diff --git a/02_process/worklogs/2026-08-16_worktable-v2.md b/02_process/worklogs/2026-08-16_worktable-v2.md index 591711d..e0a393b 100644 --- a/02_process/worklogs/2026-08-16_worktable-v2.md +++ b/02_process/worklogs/2026-08-16_worktable-v2.md @@ -964,6 +964,20 @@ ERROR_COUNT: 0(终端窗不在回归范围内,视觉部分请用户重启后确认)。 - 备注:-NoProfile 为服务端改动,需重启 dsh web 生效;字体/换行转义为客户端改动,F5 生效。 +## 补记(原生皮肤模板 + 知识包接入) + +- 用户目标:参照「Oil Creator」爆改 DSH 的效果,让自定义窗口内容与 DSH 原生风格一致。 +- 实现:① 新增 01_content/template/dshell.css(设计系统:全部走 --dsw-alias-* 主题变量, + 含卡片/按钮(绿pill+幽灵)/状态徽标(绿黄点)/标签页/列表/统计/进度/输入/表格/键值对/滚动条) + 与 dshell.html(起始骨架示例);② esbuild text loader 把两者嵌入服务端 bundle, + 新增前缀路由 /api/worktable/template 下发;③ 窗口任务知识包新增:产出 HTML 必须 + ,组件类参考模板——界面自动原生质感。 +- 验证:lib/index.js 含 dshell.css/.html 与路由 ✓;lib/client.js 知识包含模板引用 ✓; + functional-diag 全 20 STEP ERROR_COUNT: 0。 +- 备注:模板路由为服务端改动,需重启 dsh web 后生效(重启后浏览器可直开 + /api/worktable/template/dshell.html 预览模板)。 + + diff --git a/AGENTS.md b/AGENTS.md index 2b01210..a1faca7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -46,6 +46,9 @@ node --check lib/index.js 放进该文件夹」指令——用户要求项目产出文件不得落到默认位置。 - **窗口任务提示词**:buildWindowTaskText 统一组装(窗口身份「项目+窗口N」+ 项目文件夹 + 插件知识包);知识包注明「不要重新侦察插件源码」,改提示词时保持这个原则。 +- **原生皮肤模板**:01_content/template/dshell.css + dshell.html(esbuild text loader 嵌入服务端 + bundle,/api/worktable/template 路由下发);知识包要求产出 HTML 一律引用该样式表,组件类 + 参考模板。新增组件样式只加到 dshell.css,保持单一来源。 - **提示词零泄漏(硬约束)**:所有对外生成的提示词(buildWindowTaskText 窗口任务提示词、 buildCustomLayoutPrompt 剪贴板布局提示词)禁止写入用户的个人工作区分组名(如 Projects / DeepseekHarness)、其他用户的项目名与私人路径。剪贴板提示词会发给别人的 DSH,必须只含