dsh-dock 0.9.6 → 0.9.7
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 +18 -18
- package/README.md +325 -325
- package/client.js +42 -8
- package/cordis.patch.yml +2 -2
- package/features/animation/host.js +660 -660
- package/features/animation/view.jsx +2247 -2247
- package/features/balance/host.js +494 -494
- package/features/balance/view.js +351 -351
- package/features/games/games/breakout.jsx +227 -227
- package/features/games/games/gomoku.jsx +244 -244
- package/features/games/games/racer.jsx +169 -169
- package/features/games/games/shared.jsx +118 -118
- package/features/games/games/snake.jsx +144 -144
- package/features/games/games/sokoban.jsx +180 -180
- package/features/games/games/tank.jsx +128 -128
- package/features/games/games/tetris.jsx +308 -308
- package/features/games/games/xiangqi.jsx +277 -277
- package/features/games/tank-core.js +152 -152
- package/features/games/view.jsx +639 -639
- package/features/games/xiangqi-core.js +299 -299
- package/features/heartbeat/view.js +35 -35
- package/features/mobile-relay/gateway.js +472 -472
- package/features/mobile-relay/host.js +570 -569
- package/features/mobile-relay/view.jsx +300 -300
- package/features/modelconfig/host.js +403 -403
- package/features/modelconfig/view.js +490 -490
- package/features/theme/view.js +61 -61
- package/features/tokenlog/host.js +678 -678
- package/features/tokenlog/view.jsx +561 -561
- package/features/visionproxy/host.js +315 -315
- package/index.js +175 -118
- package/package.json +59 -59
- package/src/client.jsx +668 -668
- package/src/host-core.js +98 -95
- package/src/shared.js +167 -130
package/features/theme/view.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
// dsh-dock · 功能模块【主题信息】· 客户端视图(纯 Client 功能,无宿主半部)
|
|
2
|
-
import react from "react";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
|
|
5
|
-
// dsh 客户端主题服务(@deepseek-ai/dsh-client-ui-theme 的 ctx.provide("theme", ...))快照结构:
|
|
6
|
-
// { preference: 'light'|'dark'|'system', active: { id, colorScheme, tokens }, themes, revision }
|
|
7
|
-
// preference 是用户偏好;active.id 是解析后的实际生效主题(preference 为 system 时落到 light/dark)。
|
|
8
|
-
// 注意:快照顶层没有 id/name 字段——直接读 snap.id 只会得到 undefined(曾导致本页显示"未知")。
|
|
9
|
-
const PREFERENCE_LABELS = { light: "亮色", dark: "暗色", system: "跟随系统" };
|
|
10
|
-
const THEME_LABELS = { light: "亮色", dark: "暗色" };
|
|
11
|
-
|
|
12
|
-
function readThemeInfo(ctx) {
|
|
13
|
-
const theme = ctx && ctx.get ? ctx.get("theme") : undefined;
|
|
14
|
-
if (!theme || typeof theme.getTheme !== "function") return { err: "theme 服务不可用" };
|
|
15
|
-
let snap = null;
|
|
16
|
-
try { snap = theme.getTheme(); } catch (err) { return { err: "读取失败:" + String((err && err.message) || err) }; }
|
|
17
|
-
const preference = snap && typeof snap.preference === "string" ? snap.preference : "";
|
|
18
|
-
const activeId = snap && snap.active && typeof snap.active.id === "string" ? snap.active.id : "";
|
|
19
|
-
// 偏好 → 中文;system 且实际主题与偏好不同名时补注实际生效值(跟随系统 = 亮色/暗色)
|
|
20
|
-
const label = (PREFERENCE_LABELS[preference] || preference || "未知")
|
|
21
|
-
+ (activeId && activeId !== preference && THEME_LABELS[activeId] ? "(实际" + THEME_LABELS[activeId] + ")" : "");
|
|
22
|
-
return { label };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function useThemeInfo(ctx) {
|
|
26
|
-
const [info, setInfo] = useState(() => readThemeInfo(ctx));
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
// 设置页「外观」行切换主题时实时刷新(快照 revision 递增,theme/change 事件广播)
|
|
29
|
-
let off = null;
|
|
30
|
-
try {
|
|
31
|
-
if (ctx && typeof ctx.on === "function") {
|
|
32
|
-
off = ctx.on("theme/change", () => setInfo(readThemeInfo(ctx)));
|
|
33
|
-
}
|
|
34
|
-
} catch { /* 无订阅能力时降级为静态显示 */ }
|
|
35
|
-
return () => { try { if (typeof off === "function") off(); } catch { /* 清理失败静默 */ } };
|
|
36
|
-
}, [ctx]);
|
|
37
|
-
return info;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function ThemeView(props) {
|
|
41
|
-
const r = useThemeInfo(props && props.ctx);
|
|
42
|
-
if (r.err) return react.createElement("div", null, r.err);
|
|
43
|
-
return react.createElement("div", null, "当前主题:" + r.label);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function ThemeStat(props) {
|
|
47
|
-
const r = useThemeInfo(props && props.ctx);
|
|
48
|
-
if (r.err) return react.createElement("span", null, r.err);
|
|
49
|
-
return react.createElement("span", null, "主题:" + r.label);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const feature = {
|
|
53
|
-
id: "theme",
|
|
54
|
-
name: "主题信息",
|
|
55
|
-
order: 150,
|
|
56
|
-
accent: "#a78bfa",
|
|
57
|
-
description: "读取当前主题快照:偏好与实际生效主题(纯 Client,主题切换实时刷新)",
|
|
58
|
-
defaultEnabled: false,
|
|
59
|
-
View: ThemeView,
|
|
60
|
-
HomeStat: ThemeStat,
|
|
61
|
-
};
|
|
1
|
+
// dsh-dock · 功能模块【主题信息】· 客户端视图(纯 Client 功能,无宿主半部)
|
|
2
|
+
import react from "react";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
|
|
5
|
+
// dsh 客户端主题服务(@deepseek-ai/dsh-client-ui-theme 的 ctx.provide("theme", ...))快照结构:
|
|
6
|
+
// { preference: 'light'|'dark'|'system', active: { id, colorScheme, tokens }, themes, revision }
|
|
7
|
+
// preference 是用户偏好;active.id 是解析后的实际生效主题(preference 为 system 时落到 light/dark)。
|
|
8
|
+
// 注意:快照顶层没有 id/name 字段——直接读 snap.id 只会得到 undefined(曾导致本页显示"未知")。
|
|
9
|
+
const PREFERENCE_LABELS = { light: "亮色", dark: "暗色", system: "跟随系统" };
|
|
10
|
+
const THEME_LABELS = { light: "亮色", dark: "暗色" };
|
|
11
|
+
|
|
12
|
+
function readThemeInfo(ctx) {
|
|
13
|
+
const theme = ctx && ctx.get ? ctx.get("theme") : undefined;
|
|
14
|
+
if (!theme || typeof theme.getTheme !== "function") return { err: "theme 服务不可用" };
|
|
15
|
+
let snap = null;
|
|
16
|
+
try { snap = theme.getTheme(); } catch (err) { return { err: "读取失败:" + String((err && err.message) || err) }; }
|
|
17
|
+
const preference = snap && typeof snap.preference === "string" ? snap.preference : "";
|
|
18
|
+
const activeId = snap && snap.active && typeof snap.active.id === "string" ? snap.active.id : "";
|
|
19
|
+
// 偏好 → 中文;system 且实际主题与偏好不同名时补注实际生效值(跟随系统 = 亮色/暗色)
|
|
20
|
+
const label = (PREFERENCE_LABELS[preference] || preference || "未知")
|
|
21
|
+
+ (activeId && activeId !== preference && THEME_LABELS[activeId] ? "(实际" + THEME_LABELS[activeId] + ")" : "");
|
|
22
|
+
return { label };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function useThemeInfo(ctx) {
|
|
26
|
+
const [info, setInfo] = useState(() => readThemeInfo(ctx));
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
// 设置页「外观」行切换主题时实时刷新(快照 revision 递增,theme/change 事件广播)
|
|
29
|
+
let off = null;
|
|
30
|
+
try {
|
|
31
|
+
if (ctx && typeof ctx.on === "function") {
|
|
32
|
+
off = ctx.on("theme/change", () => setInfo(readThemeInfo(ctx)));
|
|
33
|
+
}
|
|
34
|
+
} catch { /* 无订阅能力时降级为静态显示 */ }
|
|
35
|
+
return () => { try { if (typeof off === "function") off(); } catch { /* 清理失败静默 */ } };
|
|
36
|
+
}, [ctx]);
|
|
37
|
+
return info;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function ThemeView(props) {
|
|
41
|
+
const r = useThemeInfo(props && props.ctx);
|
|
42
|
+
if (r.err) return react.createElement("div", null, r.err);
|
|
43
|
+
return react.createElement("div", null, "当前主题:" + r.label);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function ThemeStat(props) {
|
|
47
|
+
const r = useThemeInfo(props && props.ctx);
|
|
48
|
+
if (r.err) return react.createElement("span", null, r.err);
|
|
49
|
+
return react.createElement("span", null, "主题:" + r.label);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const feature = {
|
|
53
|
+
id: "theme",
|
|
54
|
+
name: "主题信息",
|
|
55
|
+
order: 150,
|
|
56
|
+
accent: "#a78bfa",
|
|
57
|
+
description: "读取当前主题快照:偏好与实际生效主题(纯 Client,主题切换实时刷新)",
|
|
58
|
+
defaultEnabled: false,
|
|
59
|
+
View: ThemeView,
|
|
60
|
+
HomeStat: ThemeStat,
|
|
61
|
+
};
|