@moonsand/dsh-ui-optimize 0.9.30 → 0.9.31
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/README.md +3 -3
- package/README.zh.md +3 -3
- package/client.js +83 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,8 +24,8 @@ Celadon, Linen, Cream, Graphite, Indigo, Slate, Sage, Rose. Picking a card recol
|
|
|
24
24
|
|
|
25
25
|
Two switches control the sidebar-foot buttons:
|
|
26
26
|
|
|
27
|
-
- **Reload UI** — reloads the page and client plugins only; the Host and running tasks keep going
|
|
28
|
-
- **Restart app** — restarts the whole app including its Host; interrupts the current conversation. **Desktop app only
|
|
27
|
+
- **Reload UI** — reloads the page and client plugins only; the Host and running tasks keep going. **Desktop app only**: browser shells such as fnOS already ship their own refresh entry, so this switch stays off there and cannot be turned on
|
|
28
|
+
- **Restart app** — restarts the whole app including its Host; interrupts the current conversation. **Desktop app only**: a browser session does not own the process that would have to be restarted
|
|
29
29
|
|
|
30
30
|
### Sidebar
|
|
31
31
|
|
|
@@ -40,7 +40,7 @@ The launcher follows the pattern of the community plugin [dsh-sidebar-shelf](htt
|
|
|
40
40
|
## Known limitations
|
|
41
41
|
|
|
42
42
|
- The theme choice lives in browser `localStorage`; it is lost with the browser profile or site data
|
|
43
|
-
- Restart
|
|
43
|
+
- Reload and Restart are **desktop-app only**: in a browser both switches are disabled and the sidebar-foot buttons are not rendered at all — the fnOS shell already provides its own refresh and restart entries
|
|
44
44
|
- The restart action is a process-level operation that cannot be verified automatically
|
|
45
45
|
- The **More** row is not folded; it stays in the native rail
|
|
46
46
|
- The launcher keeps the shell's own panel order — it does not sort, pin or reorder
|
package/README.zh.md
CHANGED
|
@@ -39,8 +39,8 @@ dsh plugin 或 GUI 插件管理:安装 @moonsand/dsh-ui-optimize
|
|
|
39
39
|
|
|
40
40
|
两个开关分别控制侧栏底部的「刷新界面」与「重启应用」按钮:
|
|
41
41
|
|
|
42
|
-
- **刷新界面**:只重新加载页面与客户端插件,Host
|
|
43
|
-
- **重启应用**:重启整个应用(含 Host
|
|
42
|
+
- **刷新界面**:只重新加载页面与客户端插件,Host 与正在跑的任务不受影响。**仅桌面端**:飞牛这类网页外壳自带刷新入口,网页端这个开关保持关闭且无法开启
|
|
43
|
+
- **重启应用**:重启整个应用(含 Host),会中断当前对话。**仅桌面端**:网页会话没有可重启的进程
|
|
44
44
|
|
|
45
45
|
### 侧栏
|
|
46
46
|
|
|
@@ -55,7 +55,7 @@ dsh plugin 或 GUI 插件管理:安装 @moonsand/dsh-ui-optimize
|
|
|
55
55
|
## 已知限制
|
|
56
56
|
|
|
57
57
|
- 主题选择保存在浏览器 `localStorage`,换机器或清站点数据会丢失
|
|
58
|
-
-
|
|
58
|
+
- 刷新与重启都是**桌面端专属**:网页端两个开关都会被禁用,侧栏底部也不会渲染这组按钮——飞牛外壳本身就带刷新与重启入口
|
|
59
59
|
- 重启动作为进程级操作,无法在自动化测试中验证,只能人工点一次确认
|
|
60
60
|
- 「更多」没有收进弹层,仍在原生竖栏里
|
|
61
61
|
- 弹层沿用宿主自己的面板顺序,不排序、不置顶、不重排
|
package/client.js
CHANGED
|
@@ -85,6 +85,7 @@ window.__ModuleLoader__.load({
|
|
|
85
85
|
'desktop.restartSwitch': 'Show the Restart app button',
|
|
86
86
|
'desktop.restartSwitchHint': 'Sidebar foot. Restarts the whole app including its Host; the current conversation is interrupted. Desktop app only',
|
|
87
87
|
'desktop.restartNotDesktop': 'This is a browser session, so restart is unavailable — clicking it would only reload the page. The feature works only inside the desktop app.',
|
|
88
|
+
'desktop.reloadNotDesktop': 'This is a browser session, so the reload button is not offered — this shell already has its own refresh entry. The switch works only inside the desktop app.',
|
|
88
89
|
'legacy.title': '@moonsand/dsh-desktop-restart is still installed',
|
|
89
90
|
'legacy.body': 'Both plugins draw reload/restart buttons, so the sidebar foot will show two sets. Uninstall dsh-desktop-restart under Settings → Plugins and keep only this one.',
|
|
90
91
|
storageNote: 'Storage unavailable — the choice lasts until this page reloads.',
|
|
@@ -142,6 +143,7 @@ window.__ModuleLoader__.load({
|
|
|
142
143
|
'desktop.restartSwitch': '显示「重启应用」按钮',
|
|
143
144
|
'desktop.restartSwitchHint': '侧栏底部。重启整个应用(含 Host),当前对话会中断;仅桌面端可用',
|
|
144
145
|
'desktop.restartNotDesktop': '当前是网页端,重启不可用——点了只会刷新页面。此功能仅在桌面应用里有效。',
|
|
146
|
+
'desktop.reloadNotDesktop': '当前是网页端,刷新按钮不提供——这个外壳已经自带刷新入口。此开关仅在桌面应用里可开。',
|
|
145
147
|
'legacy.title': '检测到 @moonsand/dsh-desktop-restart 仍在安装',
|
|
146
148
|
'legacy.body': '两个插件都会提供刷新/重启按钮,侧栏底部会出现两套。请到「设置 → 插件」卸载 dsh-desktop-restart,只保留本插件。',
|
|
147
149
|
storageNote: '浏览器存储不可用——选择的主题只在本次页面加载内有效。',
|
|
@@ -458,7 +460,10 @@ window.__ModuleLoader__.load({
|
|
|
458
460
|
* each switch inventing its own check. */
|
|
459
461
|
const FEATURES = {
|
|
460
462
|
theme: { envs: ['desktop', 'web'] },
|
|
461
|
-
reload
|
|
463
|
+
/* The fnOS shell has its own reload and restart entries, so these two stay
|
|
464
|
+
* desktop-only: in a browser session they would duplicate what the shell
|
|
465
|
+
* already offers, and the switch must not be turnable on there. */
|
|
466
|
+
reload: { envs: ['desktop'], reason: 'desktop.reloadNotDesktop' },
|
|
462
467
|
restart: { envs: ['desktop'], reason: 'desktop.restartNotDesktop' },
|
|
463
468
|
sidebar: { envs: ['desktop', 'web'], reason: 'sidebar.unavailable' },
|
|
464
469
|
}
|
|
@@ -506,7 +511,22 @@ window.__ModuleLoader__.load({
|
|
|
506
511
|
if (value !== 'desktop' && value !== 'web') return
|
|
507
512
|
if (store.env === value) return
|
|
508
513
|
store.env = value
|
|
509
|
-
|
|
514
|
+
/* Anything this shell cannot run is forced off the moment the probe
|
|
515
|
+
* answers: a `true` stored by a desktop session must not survive into a
|
|
516
|
+
* browser session, where `setFlag` refuses to turn the switch back on
|
|
517
|
+
* and the stored value would otherwise keep the button visible. */
|
|
518
|
+
const next = Object.assign({}, store.state, { version: 3 })
|
|
519
|
+
let dirty = false
|
|
520
|
+
const names = Object.keys(FEATURES)
|
|
521
|
+
for (let i = 0; i < names.length; i += 1) {
|
|
522
|
+
const name = names[i]
|
|
523
|
+
if (next[name] === true && !featureGate(name, value).available) {
|
|
524
|
+
next[name] = false
|
|
525
|
+
dirty = true
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (dirty) publish(next)
|
|
529
|
+
else store.notify()
|
|
510
530
|
},
|
|
511
531
|
setTheme(key) {
|
|
512
532
|
publish(
|
|
@@ -722,6 +742,7 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
|
|
|
722
742
|
const [state, setState] = React.useState(store.state)
|
|
723
743
|
const [legacyPresent, setLegacyPresent] = React.useState(false)
|
|
724
744
|
const env = store.env
|
|
745
|
+
const reloadGate = featureGate('reload', env)
|
|
725
746
|
const restartGate = featureGate('restart', env)
|
|
726
747
|
/* The shelf also needs the slot API: without it the switch stays off and
|
|
727
748
|
* says why, instead of offering something that cannot work. */
|
|
@@ -743,9 +764,7 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
|
|
|
743
764
|
let alive = true
|
|
744
765
|
void readStatus().then(function (status) {
|
|
745
766
|
if (!alive) return
|
|
746
|
-
|
|
747
|
-
store.setEnv(status.desktop === true ? 'desktop' : 'web')
|
|
748
|
-
}
|
|
767
|
+
store.setEnv(shellEnv(status))
|
|
749
768
|
})
|
|
750
769
|
return function () {
|
|
751
770
|
alive = false
|
|
@@ -835,10 +854,18 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
|
|
|
835
854
|
'div',
|
|
836
855
|
{ className: 'dsuik-rowtext' },
|
|
837
856
|
h('span', { className: 'dsuik-rowname' }, translate('desktop.reloadSwitch')),
|
|
838
|
-
h(
|
|
857
|
+
h(
|
|
858
|
+
'span',
|
|
859
|
+
{ className: 'dsuik-rowhint' + (reloadGate.available ? '' : ' is-warn') },
|
|
860
|
+
reloadGate.available
|
|
861
|
+
? translate('desktop.reloadSwitchHint')
|
|
862
|
+
: reloadGate.reason,
|
|
863
|
+
),
|
|
839
864
|
),
|
|
840
865
|
h(Switch, {
|
|
841
866
|
checked: state.reload === true,
|
|
867
|
+
disabled: !reloadGate.available,
|
|
868
|
+
title: reloadGate.reason,
|
|
842
869
|
label: translate('desktop.reloadSwitch'),
|
|
843
870
|
onChange: function (next) {
|
|
844
871
|
store.setFlag('reload', next)
|
|
@@ -1035,20 +1062,52 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
|
|
|
1035
1062
|
)
|
|
1036
1063
|
}
|
|
1037
1064
|
|
|
1065
|
+
/* The Host route lives on the DSH web server, but a shell may serve the page
|
|
1066
|
+
* under a path prefix and answer every other path with a text body (fnOS
|
|
1067
|
+
* answers `invalid token` with HTTP 200) — so a successful status still has
|
|
1068
|
+
* to be JSON carrying `desktop` before it counts. Try the page-relative URL
|
|
1069
|
+
* first, then the root. */
|
|
1038
1070
|
async function readStatus() {
|
|
1071
|
+
const candidates = []
|
|
1039
1072
|
try {
|
|
1040
|
-
|
|
1041
|
-
method: 'GET',
|
|
1042
|
-
headers: { accept: 'application/json' },
|
|
1043
|
-
credentials: 'same-origin',
|
|
1044
|
-
cache: 'no-store',
|
|
1045
|
-
signal: AbortSignal.timeout(6000),
|
|
1046
|
-
})
|
|
1047
|
-
if (!response.ok) return undefined
|
|
1048
|
-
return await response.json()
|
|
1073
|
+
candidates.push(new URL('ui-optimize/desktop/status', document.baseURI).href)
|
|
1049
1074
|
} catch (err) {
|
|
1050
|
-
|
|
1075
|
+
/* malformed baseURI: fall through to the root-relative URL */
|
|
1051
1076
|
}
|
|
1077
|
+
candidates.push('/ui-optimize/desktop/status')
|
|
1078
|
+
for (let i = 0; i < candidates.length; i += 1) {
|
|
1079
|
+
try {
|
|
1080
|
+
const response = await fetch(candidates[i], {
|
|
1081
|
+
method: 'GET',
|
|
1082
|
+
headers: { accept: 'application/json' },
|
|
1083
|
+
credentials: 'same-origin',
|
|
1084
|
+
cache: 'no-store',
|
|
1085
|
+
signal: AbortSignal.timeout(6000),
|
|
1086
|
+
})
|
|
1087
|
+
if (!response.ok) continue
|
|
1088
|
+
const data = await response.json()
|
|
1089
|
+
if (data && typeof data.desktop === 'boolean') return data
|
|
1090
|
+
} catch (err) {
|
|
1091
|
+
/* try the next candidate */
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
return undefined
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/* Which shell this is. The Host probe is authoritative. When it cannot be
|
|
1098
|
+
* read at all, the user agent still separates the Electron desktop app from
|
|
1099
|
+
* any browser, and anything unrecognised counts as web: a browser session
|
|
1100
|
+
* must never be offered a button it cannot honour. */
|
|
1101
|
+
function shellEnv(status) {
|
|
1102
|
+
if (status && typeof status.desktop === 'boolean') {
|
|
1103
|
+
return status.desktop === true ? 'desktop' : 'web'
|
|
1104
|
+
}
|
|
1105
|
+
try {
|
|
1106
|
+
if (/electron/i.test(navigator.userAgent || '')) return 'desktop'
|
|
1107
|
+
} catch (err) {
|
|
1108
|
+
/* no navigator: treat as web */
|
|
1109
|
+
}
|
|
1110
|
+
return 'web'
|
|
1052
1111
|
}
|
|
1053
1112
|
|
|
1054
1113
|
/**
|
|
@@ -1305,21 +1364,19 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
|
|
|
1305
1364
|
})
|
|
1306
1365
|
}, [])
|
|
1307
1366
|
const wide = props.wide !== false
|
|
1308
|
-
const
|
|
1309
|
-
const showRestart = state.restart === true
|
|
1367
|
+
const reloadGate = featureGate('reload', store.env)
|
|
1310
1368
|
const restartGate = featureGate('restart', store.env)
|
|
1369
|
+
/* The stored preference and the shell's ability are two different things:
|
|
1370
|
+
* a browser session must not draw a button it cannot honour, whatever the
|
|
1371
|
+
* preference says. */
|
|
1372
|
+
const showReload = state.reload === true && reloadGate.available
|
|
1373
|
+
const showRestart = state.restart === true && restartGate.available
|
|
1311
1374
|
if (!showReload && !showRestart) return null
|
|
1312
1375
|
return h(
|
|
1313
1376
|
'div',
|
|
1314
1377
|
{ className: 'dsuik-dsr-group' },
|
|
1315
1378
|
showReload ? h(RefreshButton, { wide: wide }) : null,
|
|
1316
|
-
showRestart
|
|
1317
|
-
? h(RestartButton, {
|
|
1318
|
-
wide: wide,
|
|
1319
|
-
unavailable: !restartGate.available,
|
|
1320
|
-
reason: restartGate.reason,
|
|
1321
|
-
})
|
|
1322
|
-
: null,
|
|
1379
|
+
showRestart ? h(RestartButton, { wide: wide }) : null,
|
|
1323
1380
|
)
|
|
1324
1381
|
}
|
|
1325
1382
|
|
|
@@ -1838,9 +1895,7 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
|
|
|
1838
1895
|
let alive = true
|
|
1839
1896
|
void readStatus().then(function (status) {
|
|
1840
1897
|
if (!alive) return
|
|
1841
|
-
|
|
1842
|
-
store.setEnv(status.desktop === true ? 'desktop' : 'web')
|
|
1843
|
-
}
|
|
1898
|
+
store.setEnv(shellEnv(status))
|
|
1844
1899
|
})
|
|
1845
1900
|
return function () {
|
|
1846
1901
|
alive = false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonsand/dsh-ui-optimize",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Switches that tune how DeepSeek Harness looks and behaves across the whole interface, not just a few screens — each works on its own and more arrive as the shell grows: an eight-theme minimalist gallery, sidebar panel folding, and reload/restart buttons at the sidebar foot. · 调 DeepSeek Harness 整体观感与操作的开关集合,管的是整套界面而不只是某几块;每个开关独立生效,随宿主能力增长继续增加:8 套极简主题画廊、侧栏面板收纳,以及侧栏底部的刷新界面与重启应用按钮。",
|
|
6
6
|
"license": "MIT",
|