dsh-theme-customizer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/PATCH-CORDIS-BUTTON.md +67 -0
- package/README.en.md +89 -0
- package/README.md +89 -0
- package/apply-patch.cjs +102 -0
- package/cordis.patch.yml +9 -0
- package/lib/client.js +3102 -0
- package/lib/index.js +8 -0
- package/package.json +50 -0
- package//345/257/271/350/257/235/345/214/272/346/265/213/350/257/225/346/214/207/344/273/244.md +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lxxz1918
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# 官方 Cordis 按钮常驻补丁说明(dsh-client-ui-cordis)
|
|
2
|
+
|
|
3
|
+
> 验证通过(2026-08-19,临时静态测试插件 v3 确认:无插件活动时按钮常驻、开关即时显隐、刷新持久)。
|
|
4
|
+
> **推荐直接用随包脚本一键安装**:`node apply-patch.cjs`(自动备份 / `--check` 查状态 / `--undo` 撤销)。本文档记录补丁内容与手动重打方法。
|
|
5
|
+
|
|
6
|
+
## 为什么需要补丁
|
|
7
|
+
|
|
8
|
+
官方 `CordisPanel` 在**没有任何动态插件活动**时 `return null`(按钮隐藏)。
|
|
9
|
+
需求:侧边栏底部的官方 Cordis 按钮**常驻**(无插件时也显示),并由主题插件开关控制。
|
|
10
|
+
|
|
11
|
+
## 补丁文件
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
<home>\.dsh\profiles\node_modules\@deepseek-ai\dsh-client-ui-cordis\lib\client.js
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
原始备份:同目录 `client.js.bak-theme-customizer`
|
|
18
|
+
⚠️ DSH 升级会覆盖此文件 → 需按下面内容重打(或重跑 `node apply-patch.cjs`)。
|
|
19
|
+
|
|
20
|
+
## 补丁内容(两处)
|
|
21
|
+
|
|
22
|
+
### 1. 常驻条件(原约 712 行,组件内)
|
|
23
|
+
|
|
24
|
+
**原代码**:
|
|
25
|
+
```js
|
|
26
|
+
if (all.length === 0) return null;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**补丁后**:
|
|
30
|
+
```js
|
|
31
|
+
if (all.length === 0 && window.__TCZ_HIDE_OFFICIAL_CORDIS) return null; /* [dsh-theme-customizer] Cordis按钮常驻补丁 */
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
⚠️ 千万不要加 `!`!历史上写反过一次(`!window.__TCZ_HIDE_OFFICIAL_CORDIS`),
|
|
35
|
+
导致 flag=false(常驻)时反而隐藏。语义:
|
|
36
|
+
- `window.__TCZ_HIDE_OFFICIAL_CORDIS = false` → 常驻(无插件也显示)
|
|
37
|
+
- `window.__TCZ_HIDE_OFFICIAL_CORDIS = true` → 官方原逻辑(无插件隐藏)
|
|
38
|
+
|
|
39
|
+
### 2. 即时响应 hook(原约 688 行后,组件顶部 hooks 区,必须在条件 return 之前)
|
|
40
|
+
|
|
41
|
+
在 `}, [onRefresh, open]);` 之后、`const byPlugin = ...` 之前插入:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const [, tczForce] = (0, react.useState)(0);
|
|
45
|
+
(0, react.useEffect)(() => {
|
|
46
|
+
const tczFn = () => tczForce((n) => n + 1);
|
|
47
|
+
window.addEventListener('tcz:cordis-visibility', tczFn);
|
|
48
|
+
return () => window.removeEventListener('tcz:cordis-visibility', tczFn);
|
|
49
|
+
}, []);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
效果:切换开关后按钮**立即**显隐(无需刷新页面)。
|
|
53
|
+
|
|
54
|
+
## 触发端约定
|
|
55
|
+
|
|
56
|
+
设置 flag 的插件(动态 thmcz-1 / 静态 dsh-theme-customizer 的 `applyCordisEntryFlag`):
|
|
57
|
+
```js
|
|
58
|
+
window.__TCZ_HIDE_OFFICIAL_CORDIS = !cordisEntry;
|
|
59
|
+
window.dispatchEvent(new Event('tcz:cordis-visibility'));
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 验证记录
|
|
63
|
+
|
|
64
|
+
- 2026-08-19:临时静态插件 `dsh-theme-customizer-test`(plugin-test/,v3 非受控 checkbox)验证通过。
|
|
65
|
+
- 教训:受控 checkbox + React force 重渲染在静态插件环境不可靠(第二次切换后 UI 不更新),
|
|
66
|
+
测试插件改用**非受控 checkbox + 手动 DOM 同步**后完全正常。
|
|
67
|
+
- ✅ 2026-08-19 已清理:`plugin-test/` 目录、junction、`web/package.json` 两行均已移除(设置里"主题测试"入口随重启消失)。
|
package/README.en.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# dsh-theme-customizer
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-theme-customizer)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://github.com/topics/dsh-plugin)
|
|
6
|
+
[](https://github.com/lxxz1918/dsh-theme-customizer/stargazers)
|
|
7
|
+
|
|
8
|
+
**English** | [中文](README.md)
|
|
9
|
+
|
|
10
|
+
> A theme customizer plugin for the DeepSeek Harness (DSH) web UI. Backgrounds, text colors, borders and details — all adjustable visually, persisted across restarts.
|
|
11
|
+
> Config is stored in localStorage; presets can be exported as `.tczp` files (images included) and shared with any machine.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Interface module (7 background areas)**: Main / Sidebar / Conversation / Composer / Settings panel / Floating panel / Cordis panel
|
|
16
|
+
- Each area: None / Solid color / Image (with crop & selection) + opacity (**larger value = more transparent**) + base color (independent layer)
|
|
17
|
+
- Main background supports "include sidebar / exclude sidebar" display area toggle
|
|
18
|
+
- Sidebar image fades out directly via mask — never covers the top UI or the settings panel
|
|
19
|
+
- **Borders module**: color + opacity for all default UI borders/dividers, independently for 5 areas (Main incl. sidebar / Cordis / Composer / Settings / Floating panel)
|
|
20
|
+
- **Text colors module**: 5 categories (Body / Process / Auxiliary / Faded / Accent), shared across light & dark themes, restorable to official defaults
|
|
21
|
+
- **Brand color**: color + opacity for the top-left DeepSeek Harness logo; the "Harness" wordmark can be tinted separately
|
|
22
|
+
- **Conversation details**: user bubble / inline code / code block background / code block scrollbar / conversation scrollbar / todo panel collapsed & expanded / "scroll to bottom" button background
|
|
23
|
+
- **Composer**: background, fixed input height (1–10 rows), stats line takeover (9 independent toggles + full expand), command button & menu backgrounds
|
|
24
|
+
- **New session button**: None/Solid/Image style + show text/icon toggles + independent icon/text colors + base color
|
|
25
|
+
- **Layout**: draggable settings panel (drag its header; position persisted; one-click reset)
|
|
26
|
+
- **Floating panel**: a draggable mini settings panel (choose which modules to show), always on top
|
|
27
|
+
- **Presets**: save/apply/rename/delete/export/import (`.tczp`, images included, up to 10) + drag-to-reorder
|
|
28
|
+
- **Global reset**: one click to restore all defaults (3-step confirm to prevent accidents)
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Option 1: npm (published package)
|
|
34
|
+
npm install -g dsh-theme-customizer
|
|
35
|
+
dsh plugin --profile web add dsh-theme-customizer
|
|
36
|
+
|
|
37
|
+
# Option 2: local directory (after cloning this repo)
|
|
38
|
+
dsh plugin --profile web add <path-to-this-repo>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Then **restart dsh web** for it to take effect. Verify: Settings → Theme should appear.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
1. Open **Settings → Theme** and adjust by module; changes apply instantly and save automatically (the bottom of the page shows "last saved" time)
|
|
46
|
+
2. For quick tweaks, click "↗ Open float panel" at the top right — the panel is draggable
|
|
47
|
+
3. To verify the conversation-area options, use the test text in [对话区测试指令.md](对话区测试指令.md)
|
|
48
|
+
|
|
49
|
+
## Persistent Cordis button (optional)
|
|
50
|
+
|
|
51
|
+
The "Cordis button always visible" toggle in Theme settings **requires a patch to the official dsh-client-ui-cordis package**; without the patch the toggle has no effect. One-click install:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
node apply-patch.cjs # apply patch (auto backup)
|
|
55
|
+
node apply-patch.cjs --check # check status
|
|
56
|
+
node apply-patch.cjs --undo # revert
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
⚠️ **DSH upgrades overwrite the official package** — re-run `apply-patch.cjs` after upgrading. Details in [PATCH-CORDIS-BUTTON.md](PATCH-CORDIS-BUTTON.md).
|
|
60
|
+
|
|
61
|
+
## Build from source (developers)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# 1. Concatenate source fragments (optimized/src/ → optimized/dist/, with syntax check + line map/symbols)
|
|
65
|
+
node optimized\build.cjs
|
|
66
|
+
|
|
67
|
+
# 2. Generate the static client bundle (dist/p3_2_client.js → lib/client.js)
|
|
68
|
+
node build_static.cjs optimized\dist\p3_2_client.js lib\client.js
|
|
69
|
+
|
|
70
|
+
# 3. Syntax check + install for testing
|
|
71
|
+
node --check lib\client.js
|
|
72
|
+
dsh plugin --profile web add <path-to-this-repo>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Source layout: `optimized/src/` contains 16 fragments (`00_*`~`15_*` + `host.js`) concatenated in filename order into the plugin function body. Look up features in `optimized/INDEX.md`.
|
|
76
|
+
|
|
77
|
+
## Preset files (.tczp)
|
|
78
|
+
|
|
79
|
+
Presets panel → "📥 Import preset" and pick a `.tczp` file to restore a whole config (images included — no original files needed). Export each preset via "📤 Export" in the same panel.
|
|
80
|
+
|
|
81
|
+
## Uninstall
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
dsh plugin --profile web remove dsh-theme-customizer
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
[MIT](LICENSE)
|
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# dsh-theme-customizer
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-theme-customizer)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://github.com/topics/dsh-plugin)
|
|
6
|
+
[](https://github.com/lxxz1918/dsh-theme-customizer/stargazers)
|
|
7
|
+
|
|
8
|
+
**中文** | [English](README.en.md)
|
|
9
|
+
|
|
10
|
+
> DeepSeek Harness(DSH)Web 界面自定义主题插件:背景、文字、框线、细节全部可视化设置,刷新/重启不丢。
|
|
11
|
+
> 配置存 localStorage,预设可导出 `.tczp` 文件(含图片)分享到任意电脑。
|
|
12
|
+
|
|
13
|
+
## 功能一览
|
|
14
|
+
|
|
15
|
+
- **界面板块(7 区域背景)**:主界面 / 侧边栏 / 对话区 / 输入区 / 设置界面 / 浮窗面板 / Cordis 插件界面
|
|
16
|
+
- 每区域:无 / 纯色 / 图片(选区裁剪)+ 透明度(**数值越大越透明**)+ 底色(独立层)
|
|
17
|
+
- 主界面支持「包含侧边栏 / 不包含侧边栏」显示区域切换
|
|
18
|
+
- 侧边栏图片用 mask 直接淡出,不盖顶部 UI、不挡设置面板
|
|
19
|
+
- **框线板块**:所有界面默认边框/分隔线颜色 + 透明度,主界面(含侧边栏)/ Cordis / 输入区 / 设置界面 / 浮窗 5 区域独立
|
|
20
|
+
- **字体颜色板块**:正文 / 过程 / 辅助 / 弱化 / 强调 5 类文字颜色(亮暗主题共用,可恢复官方默认)
|
|
21
|
+
- **标志调色**:左上角 DeepSeek Harness 标志颜色 + 透明度;「Harness」文字部分可单独调色
|
|
22
|
+
- **对话区细节**:用户发言气泡 / 行内代码 / 代码块背景 / 代码块滚动条 / 对话区滚动条 / 任务栏收起展开 / 「一键到底」按钮背景
|
|
23
|
+
- **输入区**:背景、输入框固定高度(1~10 行)、统计条接管渲染(9 项独立开关 + 完全展开)、命令按钮/菜单背景
|
|
24
|
+
- **新会话按钮**:无/纯色/图片样式 + 显示文本/图标开关 + 图标/文本颜色独立设置 + 底色
|
|
25
|
+
- **布局调整**:设置界面面板可拖动(拖 header 移动 + 位置持久化 + 一键复位)
|
|
26
|
+
- **浮动主题面板**:可拖动的迷你设置面板(勾选显示内容),顶层不遮挡
|
|
27
|
+
- **预设**:保存/应用/重命名/删除/导出/导入(`.tczp` 含图,最多 10 个)+ 拖拽排序
|
|
28
|
+
- **全局恢复默认**:一键重置所有设置(三级确认防误触)
|
|
29
|
+
|
|
30
|
+
## 安装
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# 方式一:npm 安装(发布包)
|
|
34
|
+
npm install -g dsh-theme-customizer
|
|
35
|
+
dsh plugin --profile web add dsh-theme-customizer
|
|
36
|
+
|
|
37
|
+
# 方式二:本地目录安装(GitHub clone 后)
|
|
38
|
+
dsh plugin --profile web add <本仓库路径>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
装完**重启 dsh web** 生效。验证:设置 → 主题 出现即可。
|
|
42
|
+
|
|
43
|
+
## 使用
|
|
44
|
+
|
|
45
|
+
1. 打开 **设置 → 主题**,按板块调整;改动即时生效、自动保存(页面底部显示「最近保存」时间)
|
|
46
|
+
2. 需要快速调整时可点右上「↗ 打开浮窗」,浮窗可拖动
|
|
47
|
+
3. 装完想验证对话区各选项效果,可用 [对话区测试指令.md](对话区测试指令.md) 里的测试文本
|
|
48
|
+
|
|
49
|
+
## Cordis 按钮常驻(可选)
|
|
50
|
+
|
|
51
|
+
主题设置里「Cordis 按钮常驻」开关**依赖官方 dsh-client-ui-cordis 补丁**,未打补丁时开关不生效。一键安装:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
node apply-patch.cjs # 打补丁(自动备份)
|
|
55
|
+
node apply-patch.cjs --check # 查看状态
|
|
56
|
+
node apply-patch.cjs --undo # 撤销
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
⚠️ **DSH 升级会覆盖官方包**,升级后需重跑 `apply-patch.cjs`。细节见 [PATCH-CORDIS-BUTTON.md](PATCH-CORDIS-BUTTON.md)。
|
|
60
|
+
|
|
61
|
+
## 从源码构建(开发者)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# 1. 拼接源码片段(optimized/src/ → optimized/dist/,自动语法校验 + 行号映射/符号表)
|
|
65
|
+
node optimized\build.cjs
|
|
66
|
+
|
|
67
|
+
# 2. 生成静态 client bundle(dist/p3_2_client.js → lib/client.js)
|
|
68
|
+
node build_static.cjs optimized\dist\p3_2_client.js lib\client.js
|
|
69
|
+
|
|
70
|
+
# 3. 语法校验 + 安装测试
|
|
71
|
+
node --check lib\client.js
|
|
72
|
+
dsh plugin --profile web add <本仓库路径>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
源码结构:`optimized/src/` 16 个片段(`00_*`~`15_*` + `host.js`)按文件名拼接为插件函数体,功能定位查 `optimized/INDEX.md`。
|
|
76
|
+
|
|
77
|
+
## 预设文件(.tczp)
|
|
78
|
+
|
|
79
|
+
预设面板 → 「📥 导入预设」选择 `.tczp` 文件即可恢复整套配置(含图片,无需原图)。导出同样在预设面板逐条「📤 导出」。
|
|
80
|
+
|
|
81
|
+
## 卸载
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
dsh plugin --profile web remove dsh-theme-customizer
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
[MIT](LICENSE)
|
package/apply-patch.cjs
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// apply-patch.cjs —— 官方 Cordis 按钮常驻补丁一键安装/撤销(dsh-theme-customizer 随包脚本)
|
|
2
|
+
// 背景:官方 dsh-client-ui-cordis 在"没有任何动态插件活动"时 return null(按钮隐藏)。
|
|
3
|
+
// 本补丁让按钮显隐受 window.__TCZ_HIDE_OFFICIAL_CORDIS 控制(主题插件「Cordis 按钮常驻」开关使用)。
|
|
4
|
+
// ⚠️ DSH 升级会覆盖官方包 → 升级后需重跑本脚本。
|
|
5
|
+
//
|
|
6
|
+
// 用法(任意目录):
|
|
7
|
+
// node apply-patch.cjs # 打补丁(首次自动备份 client.js.bak-theme-customizer)
|
|
8
|
+
// node apply-patch.cjs --check # 只检查补丁状态,不修改任何文件
|
|
9
|
+
// node apply-patch.cjs --undo # 撤销:从备份恢复官方原文件
|
|
10
|
+
//
|
|
11
|
+
// 细节与验证记录见 PATCH-CORDIS-BUTTON.md
|
|
12
|
+
const fs = require('fs')
|
|
13
|
+
const path = require('path')
|
|
14
|
+
|
|
15
|
+
const MARK = '[dsh-theme-customizer] Cordis按钮常驻补丁'
|
|
16
|
+
const BAK = 'client.js.bak-theme-customizer'
|
|
17
|
+
|
|
18
|
+
// ── 定位官方包 client.js ──
|
|
19
|
+
function findTarget() {
|
|
20
|
+
const bases = []
|
|
21
|
+
if (process.env.APPDATA) bases.push(path.join(process.env.APPDATA, '.dsh'))
|
|
22
|
+
if (process.env.USERPROFILE) bases.push(path.join(process.env.USERPROFILE, '.dsh'))
|
|
23
|
+
for (const base of bases) {
|
|
24
|
+
const p = path.join(base, 'profiles', 'node_modules', '@deepseek-ai', 'dsh-client-ui-cordis', 'lib', 'client.js')
|
|
25
|
+
if (fs.existsSync(p)) return p
|
|
26
|
+
}
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ── 两处替换 ──
|
|
31
|
+
function apply(content) {
|
|
32
|
+
// 1. 常驻条件:无插件活动时也渲染(flag=true 时恢复官方原逻辑)。
|
|
33
|
+
// ⚠️ 语义(PATCH-CORDIS-BUTTON.md 历史教训,勿加 !):
|
|
34
|
+
// window.__TCZ_HIDE_OFFICIAL_CORDIS = false/未设置 → 常驻(无插件也显示)
|
|
35
|
+
// window.__TCZ_HIDE_OFFICIAL_CORDIS = true → 官方原逻辑(无插件隐藏)
|
|
36
|
+
const re1 = /if\s*\(\s*all\.length\s*===\s*0\s*\)\s*return\s+null\s*;/
|
|
37
|
+
// 2. 即时响应 hook:监听 tcz:cordis-visibility 事件强制重渲染(切换开关立即显隐)
|
|
38
|
+
const re2 = /(\},\s*\[onRefresh,\s*open\]\);)/
|
|
39
|
+
|
|
40
|
+
if (!re1.test(content)) throw new Error('未找到锚点 1:`if (all.length === 0) return null;`(官方代码已变化?)')
|
|
41
|
+
if (!re2.test(content)) throw new Error('未找到锚点 2:`}, [onRefresh, open]);`(官方代码已变化?)')
|
|
42
|
+
|
|
43
|
+
const hook = [
|
|
44
|
+
'const [, tczForce] = (0, react.useState)(0); /* ' + MARK + ' */',
|
|
45
|
+
'(0, react.useEffect)(() => {',
|
|
46
|
+
' const tczFn = () => tczForce((n) => n + 1);',
|
|
47
|
+
" window.addEventListener('tcz:cordis-visibility', tczFn);",
|
|
48
|
+
" return () => window.removeEventListener('tcz:cordis-visibility', tczFn);",
|
|
49
|
+
'}, []);',
|
|
50
|
+
].join('\n')
|
|
51
|
+
|
|
52
|
+
return content
|
|
53
|
+
.replace(re1, 'if (all.length === 0 && window.__TCZ_HIDE_OFFICIAL_CORDIS) return null; /* ' + MARK + ' */')
|
|
54
|
+
.replace(re2, '$1\n' + hook)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const arg = process.argv[2] || ''
|
|
58
|
+
const target = findTarget()
|
|
59
|
+
if (!target) {
|
|
60
|
+
console.error('✗ 找不到官方包:<home>/.dsh/profiles/node_modules/@deepseek-ai/dsh-client-ui-cordis/lib/client.js')
|
|
61
|
+
console.error(' 请确认 dsh 已安装且路径正确。')
|
|
62
|
+
process.exit(1)
|
|
63
|
+
}
|
|
64
|
+
console.log('目标文件: ' + target)
|
|
65
|
+
|
|
66
|
+
const content = fs.readFileSync(target, 'utf8')
|
|
67
|
+
const patched = content.includes(MARK)
|
|
68
|
+
const bakPath = path.join(path.dirname(target), BAK)
|
|
69
|
+
|
|
70
|
+
if (arg === '--check') {
|
|
71
|
+
console.log(patched
|
|
72
|
+
? '✅ 已打补丁(' + MARK + ' 标记存在)'
|
|
73
|
+
: '⏹ 未打补丁')
|
|
74
|
+
console.log(fs.existsSync(bakPath) ? '备份存在: ' + BAK : '无备份')
|
|
75
|
+
process.exit(0)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (arg === '--undo') {
|
|
79
|
+
if (!patched) { console.log('⏹ 未打补丁,无需撤销'); process.exit(0) }
|
|
80
|
+
if (!fs.existsSync(bakPath)) { console.error('✗ 没有备份文件,无法撤销(请手动恢复或重装官方包)'); process.exit(1) }
|
|
81
|
+
fs.copyFileSync(bakPath, target)
|
|
82
|
+
console.log('✅ 已从备份恢复官方原文件')
|
|
83
|
+
process.exit(0)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (patched) {
|
|
87
|
+
console.log('⏹ 已经打过补丁(跳过)。撤销用: node apply-patch.cjs --undo')
|
|
88
|
+
process.exit(0)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 首次打补丁前备份(已存在则不覆盖,保留最早的原版)
|
|
92
|
+
if (!fs.existsSync(bakPath)) fs.copyFileSync(target, bakPath)
|
|
93
|
+
try {
|
|
94
|
+
const next = apply(content)
|
|
95
|
+
fs.writeFileSync(target, next, 'utf8')
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error('✗ ' + e.message)
|
|
98
|
+
console.error(' 官方包代码已变化,请参照 PATCH-CORDIS-BUTTON.md 手动处理。')
|
|
99
|
+
process.exit(1)
|
|
100
|
+
}
|
|
101
|
+
console.log('✅ 补丁完成(已备份 ' + BAK + ')')
|
|
102
|
+
console.log(' 生效方式:刷新/重启 dsh web。主题设置 → Cordis 插件界面 → 「Cordis 按钮常驻」开关即时显隐。')
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# dsh-theme-customizer bundle layer: applied automatically when the package
|
|
2
|
+
# is installed (package.json declares dsh.bundle.patch). The insert row makes
|
|
3
|
+
# the package a Cordis plugin row; because the package declares dsh.client,
|
|
4
|
+
# the same row also enters the browser roster (window.__DSH_BOOT__) and its
|
|
5
|
+
# ./client export is served as a client bundle.
|
|
6
|
+
|
|
7
|
+
- insert:
|
|
8
|
+
- id: theme-customizer
|
|
9
|
+
name: dsh-theme-customizer
|