zcode-pro 1.6.1 → 1.7.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/README.en.md +31 -21
- package/README.md +20 -12
- package/dist/inject.js +10431 -8836
- package/package.json +2 -1
- package/src/host/cdp.mjs +13 -3
- package/src/host/helper.mjs +1287 -488
- package/src/host/main.mjs +368 -30
- package/src/host/paths.mjs +17 -9
- package/src/host/pickFolder.mjs +11 -4
- package/src/host/settings.mjs +15 -2
- package/src/host/setup.mjs +54 -15
- package/src/host/skill-stats.mjs +6 -1
- package/src/host/taskIndex.mjs +464 -66
- package/src/host/taskOrder.mjs +128 -57
- package/src/host/version.mjs +15 -7
- package/src/host/wallpaper.mjs +76 -59
- package/src/host/webdav.mjs +66 -10
- package/src/inject/core.js +228 -103
- package/src/inject/features/alias-migration.js +5 -1
- package/src/inject/features/auto-rename.js +166 -0
- package/src/inject/features/file-menu.js +6 -2
- package/src/inject/features/idle-reclaim.js +31 -8
- package/src/inject/features/newtab-panels.js +11 -1
- package/src/inject/features/pinned-collapse.js +11 -3
- package/src/inject/features/plugin-card-retry.js +18 -8
- package/src/inject/features/plugin-updates.js +58 -0
- package/src/inject/features/sandbox-reclaim.js +17 -1
- package/src/inject/features/session-link.js +202 -0
- package/src/inject/features/session-switch.js +67 -30
- package/src/inject/features/settings-dialog.js +323 -124
- package/src/inject/features/status-bar.js +150 -28
- package/src/inject/features/subagent-icon.js +473 -0
- package/src/inject/features/table-copy.js +18 -2
- package/src/inject/features/task-order.js +47 -13
- package/src/inject/features/theme.js +88 -31
- package/src/inject/features/title-gen.js +5 -4
- package/src/inject/features/title-lock.js +13 -8
- package/src/inject/features/turn-usage.js +99 -47
- package/src/inject/features/ws-running.js +28 -13
- package/src/inject/index.js +7 -0
- package/src/inject/provider-fields.js +2 -2
- package/src/inject/ui.js +14 -0
|
@@ -8,6 +8,7 @@ import { migrationCard } from './alias-migration.js';
|
|
|
8
8
|
import { applyStyles, STYLE_DEFAULTS, showStyleHighlight, hideStyleHighlight } from './styles.js';
|
|
9
9
|
import { THEME_SKINS, CUSTOM_DEFAULTS } from './theme.js';
|
|
10
10
|
import { copyToClipboard, hCopyIcon } from './copy-path.js';
|
|
11
|
+
import { claimAutoUpdateRun } from './plugin-updates.js';
|
|
11
12
|
|
|
12
13
|
// 调宿主桥在系统浏览器打开外链;宿主没暴露该能力时静默忽略
|
|
13
14
|
function openExternal(url) {
|
|
@@ -287,13 +288,13 @@ export function openSettingsDialog() {
|
|
|
287
288
|
showToast(pluginsStatusLine.textContent, 'success');
|
|
288
289
|
};
|
|
289
290
|
void (async () => {
|
|
290
|
-
//
|
|
291
|
-
//
|
|
291
|
+
// 打开设置弹窗时,只有本次 ZCode 启动还没自动更新过才直接更:
|
|
292
|
+
// 同一次启动里反复开关弹窗不再重复下载/更新。开关关闭时只显示可更新数
|
|
292
293
|
const cfg = await getConfig(true).catch(() => null);
|
|
293
294
|
const res = await rpc('/plugins/status');
|
|
294
|
-
if (!res.ok) { setPluginsStatus(
|
|
295
|
+
if (!res.ok) { setPluginsStatus(errText(res)); return; }
|
|
295
296
|
const n = (res.updates || []).length;
|
|
296
|
-
if (cfg && (cfg.features || {}).autoUpdatePlugins === true && n > 0) {
|
|
297
|
+
if (cfg && (cfg.features || {}).autoUpdatePlugins === true && n > 0 && claimAutoUpdateRun()) {
|
|
297
298
|
void runPluginsUpdate();
|
|
298
299
|
return;
|
|
299
300
|
}
|
|
@@ -384,6 +385,11 @@ export function openSettingsDialog() {
|
|
|
384
385
|
if (await setFeature('tableCopy', next)) f.tableCopy = next;
|
|
385
386
|
refreshRows();
|
|
386
387
|
}),
|
|
388
|
+
settingRow(L.featureSessionLink, L.featureSessionLinkDesc, f.sessionLink !== false, async () => {
|
|
389
|
+
const next = !(f.sessionLink !== false);
|
|
390
|
+
if (await setFeature('sessionLink', next)) f.sessionLink = next;
|
|
391
|
+
refreshRows();
|
|
392
|
+
}),
|
|
387
393
|
settingRow(L.featureComposerProvider, L.featureComposerProviderDesc, f.composerProvider !== false, async () => {
|
|
388
394
|
const next = !(f.composerProvider !== false);
|
|
389
395
|
if (await setFeature('composerProvider', next)) f.composerProvider = next;
|
|
@@ -404,6 +410,11 @@ export function openSettingsDialog() {
|
|
|
404
410
|
if (await setFeature('wsRunningSpin', next)) f.wsRunningSpin = next;
|
|
405
411
|
refreshRows();
|
|
406
412
|
}),
|
|
413
|
+
settingRow(L.featureSubagentIcon, L.featureSubagentIconDesc, f.subagentIcon !== false, async () => {
|
|
414
|
+
const next = !(f.subagentIcon !== false);
|
|
415
|
+
if (await setFeature('subagentIcon', next)) f.subagentIcon = next;
|
|
416
|
+
refreshRows();
|
|
417
|
+
}),
|
|
407
418
|
settingRow(L.featureNewtabPanels, L.featureNewtabPanelsDesc, f.newtabPanels !== false, async () => {
|
|
408
419
|
const next = !(f.newtabPanels !== false);
|
|
409
420
|
if (await setFeature('newtabPanels', next)) f.newtabPanels = next;
|
|
@@ -630,10 +641,15 @@ export function openSettingsDialog() {
|
|
|
630
641
|
// 数字框滚轮/手输调节,改完即存即生效
|
|
631
642
|
const savedStyles = config.styles || {};
|
|
632
643
|
let saveTimer = null;
|
|
644
|
+
let pendingStyles = {};
|
|
633
645
|
const persistStyles = (partial) => {
|
|
646
|
+
// 防抖期间的多次改动合并提交:150ms 内连调两个字段时前一个不能丢
|
|
647
|
+
Object.assign(pendingStyles, partial);
|
|
634
648
|
clearTimeout(saveTimer);
|
|
635
649
|
saveTimer = setTimeout(async () => {
|
|
636
|
-
const
|
|
650
|
+
const body = pendingStyles;
|
|
651
|
+
pendingStyles = {};
|
|
652
|
+
const res = await rpc('/config', { method: 'POST', body: { styles: body } });
|
|
637
653
|
clearConfigCache();
|
|
638
654
|
if (res.ok) applyStyles((res.config && res.config.styles) || savedStyles);
|
|
639
655
|
else showToast(L.failed + ': ' + errText(res), 'error');
|
|
@@ -779,12 +795,12 @@ export function openSettingsDialog() {
|
|
|
779
795
|
renderToolbarSwitch();
|
|
780
796
|
// “外观”标签页的二级结构:样式(原内容)/ 状态栏(统计项顺序与显隐)/
|
|
781
797
|
// 主题(皮肤与自定义主题)/ 背景图(图库、文件夹轮换、网址)
|
|
782
|
-
const paneStylesSub1 = h('div', { class: 'mt-2' });
|
|
798
|
+
const paneStylesSub1 = h('div', { class: 'mt-2', style: 'display:none' });
|
|
783
799
|
const paneStylesSub2 = h('div', { class: 'mt-2', style: 'display:none' });
|
|
784
800
|
const paneStylesSub3 = h('div', { class: 'mt-2', style: 'display:none' });
|
|
785
|
-
const paneStylesSub4 = h('div', { class: 'mt-2'
|
|
801
|
+
const paneStylesSub4 = h('div', { class: 'mt-2' }); // 默认子页是壁纸,初始显示它
|
|
786
802
|
const ITEM_NAMES = {
|
|
787
|
-
ctx: 'sbItemCtx', questions: 'sbItemQuestions',
|
|
803
|
+
ctx: 'sbItemCtx', tokRate: 'sbItemTokRate', questions: 'sbItemQuestions',
|
|
788
804
|
todayTokens: 'sbItemTodayTokens', totalTokens: 'sbItemTotalTokens', tasks: 'sbItemTasks',
|
|
789
805
|
};
|
|
790
806
|
// 读取并归一化:会话组项在前、全局组项在后(组内保持保存的顺序),
|
|
@@ -792,9 +808,13 @@ export function openSettingsDialog() {
|
|
|
792
808
|
const sbItems = () => {
|
|
793
809
|
const saved = config.statusBar && Array.isArray(config.statusBar.items) ? config.statusBar.items : null;
|
|
794
810
|
if (!saved) return DEFAULT_STATUS_ITEMS.map((x) => ({ ...x }));
|
|
795
|
-
const byId = new Map(saved.map((x) => [x.id, x]));
|
|
796
811
|
const list = saved.filter((x) => ITEM_NAMES[x.id]).map((x) => ({ on: x.on !== false, id: x.id }));
|
|
797
|
-
|
|
812
|
+
// 新默认项按默认位插入(同 status-bar.js 的归一化),不补到组末尾;
|
|
813
|
+
// 缺失判定用过滤后的清单,防止默认项被过滤“藏起来”
|
|
814
|
+
const known = new Set(list.map((x) => x.id));
|
|
815
|
+
for (const d of DEFAULT_STATUS_ITEMS) {
|
|
816
|
+
if (!known.has(d.id)) list.splice(Math.min(DEFAULT_STATUS_ITEMS.indexOf(d), list.length), 0, { ...d });
|
|
817
|
+
}
|
|
798
818
|
return [
|
|
799
819
|
...list.filter((x) => STATUS_SESSION_IDS.has(x.id)),
|
|
800
820
|
...list.filter((x) => STATUS_GLOBAL_IDS.has(x.id)),
|
|
@@ -816,7 +836,7 @@ export function openSettingsDialog() {
|
|
|
816
836
|
const sbList = h('div', { class: 'divide-y divide-border rounded-xl border border-border' });
|
|
817
837
|
const sbGlobalList = h('div', { class: 'divide-y divide-border rounded-xl border border-border' });
|
|
818
838
|
// 每轮统计节(输入/输出/缓存,只开关不排序——显示顺序固定)
|
|
819
|
-
const TURN_NAMES = { turnIn: 'sbLabelIn', turnOut: 'sbLabelOut', turnCache: 'sbLabelCache' };
|
|
839
|
+
const TURN_NAMES = { turnIn: 'sbLabelIn', turnOut: 'sbLabelOut', turnTps: 'sbLabelTps', turnCache: 'sbLabelCache' };
|
|
820
840
|
const turnItems = () => {
|
|
821
841
|
const saved = config.statusBar && Array.isArray(config.statusBar.turnItems) ? config.statusBar.turnItems : null;
|
|
822
842
|
if (!saved) return DEFAULT_TURN_ITEMS.map((x) => ({ ...x }));
|
|
@@ -883,6 +903,7 @@ export function openSettingsDialog() {
|
|
|
883
903
|
const res = await rpc('/config', { method: 'POST', body: { features: { statusBar: to } } });
|
|
884
904
|
clearConfigCache();
|
|
885
905
|
if (res.ok) { config.features = { ...(config.features || {}), statusBar: to }; }
|
|
906
|
+
else showToast(L.failed + ': ' + errText(res), 'error'); // 失败提示;下面 renderMaster 按配置重画,开关自己弹回
|
|
886
907
|
window.dispatchEvent(new CustomEvent('zcodepro:config-changed'));
|
|
887
908
|
renderMaster();
|
|
888
909
|
});
|
|
@@ -922,20 +943,24 @@ export function openSettingsDialog() {
|
|
|
922
943
|
let bgLoading = false;
|
|
923
944
|
let folderInfo = { count: 0, dir: '' };
|
|
924
945
|
const themeInputCls = 'h-8 w-full rounded-lg border border-border bg-input px-2.5 text-ui-sm text-foreground outline-none transition-shadow placeholder:text-foreground-subtle focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40';
|
|
925
|
-
const numField = (val, min, max, commit, title) => {
|
|
946
|
+
const numField = (val, min, max, commit, title, step = 1) => {
|
|
926
947
|
const n = h('input', {
|
|
927
|
-
type: 'number', min: String(min), max: String(max), step:
|
|
928
|
-
|
|
948
|
+
type: 'number', min: String(min), max: String(max), step: String(step), title,
|
|
949
|
+
inputmode: step < 1 ? 'decimal' : 'numeric',
|
|
950
|
+
class: 'h-7 w-24 rounded-lg border border-border bg-input px-2 text-right text-ui-sm tabular-nums text-foreground outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40',
|
|
929
951
|
});
|
|
930
952
|
n.value = String(val);
|
|
931
953
|
n.addEventListener('change', () => {
|
|
932
|
-
|
|
954
|
+
// 按步进精度取整;step 带小数时(倍速)取两位小数并限制范围
|
|
955
|
+
const d = String(step).includes('.') ? String(step).split('.')[1].length : 0;
|
|
956
|
+
const raw = Number(n.value);
|
|
957
|
+
const v = Math.max(min, Math.min(max, Number.isFinite(raw) ? Number(raw.toFixed(d)) : min));
|
|
933
958
|
n.value = String(v);
|
|
934
959
|
commit(v);
|
|
935
960
|
});
|
|
936
961
|
return n;
|
|
937
962
|
};
|
|
938
|
-
const bgUrl = (name) => `${HELPER_URL}/bg/file/${encodeURIComponent(name)}`;
|
|
963
|
+
const bgUrl = (name) => `${HELPER_URL}/bg/file/${encodeURIComponent(name)}?t=${encodeURIComponent(liveBoot().token || '')}`; // 媒体路由认 URL 上的 token
|
|
939
964
|
const saveTheme = async (patch) => {
|
|
940
965
|
themeCfg = {
|
|
941
966
|
skin: patch.skin !== undefined ? patch.skin : themeCfg.skin,
|
|
@@ -973,7 +998,7 @@ export function openSettingsDialog() {
|
|
|
973
998
|
&& !bgFiles.some((f) => sameName(f.name, themeCfg.bg.file))) {
|
|
974
999
|
themeCfg = { ...themeCfg, bg: { ...themeCfg.bg, file: '' } };
|
|
975
1000
|
await saveTheme({ bg: { file: '' } });
|
|
976
|
-
showToast(L.themeBgDeletedActive, '
|
|
1001
|
+
showToast(L.themeBgDeletedActive, 'warning');
|
|
977
1002
|
return;
|
|
978
1003
|
}
|
|
979
1004
|
}
|
|
@@ -1083,7 +1108,10 @@ export function openSettingsDialog() {
|
|
|
1083
1108
|
...CUSTOM_FIELDS.map(([k, key]) => customInput(mode, k, L[key])))))),
|
|
1084
1109
|
);
|
|
1085
1110
|
};
|
|
1086
|
-
//
|
|
1111
|
+
// 分区背景行:默认(全局壁纸)/ 图库(下拉选图)/ 文件夹 / 网址
|
|
1112
|
+
// regionMaskTimers 记各分区遮罩滑杆的防抖提交(按行分开,互不误撤);
|
|
1113
|
+
// 只有"跟随全局"胶囊撤本行在途提交(它写 null 与拖动值直接冲突)
|
|
1114
|
+
const regionMaskTimers = {};
|
|
1087
1115
|
const setRegion = (region, value) => {
|
|
1088
1116
|
void saveTheme({ bg: { regions: { ...themeCfg.bg.regions, [region]: value } } });
|
|
1089
1117
|
};
|
|
@@ -1096,47 +1124,104 @@ export function openSettingsDialog() {
|
|
|
1096
1124
|
onClick: () => {
|
|
1097
1125
|
if (id === null) { setRegion(region, null); return; }
|
|
1098
1126
|
const keep = themeCfg.bg.regions[region];
|
|
1099
|
-
setRegion(region, {
|
|
1127
|
+
setRegion(region, {
|
|
1128
|
+
mode: id, file: keep && keep.file || '', folder: keep && keep.folder || '', url: keep && keep.url || '',
|
|
1129
|
+
fit: (keep && keep.fit) || null, maskOpacity: keep && keep.maskOpacity != null ? keep.maskOpacity : null,
|
|
1130
|
+
});
|
|
1100
1131
|
},
|
|
1101
1132
|
}, text);
|
|
1102
1133
|
let valueCtrl = null;
|
|
1103
1134
|
if (mode === 'library') {
|
|
1104
|
-
const sel = h('select', { class: 'h-7 max-w-40 rounded-lg border border-border bg-input px-1.5 text-ui-
|
|
1135
|
+
const sel = h('select', { class: 'h-7 max-w-40 rounded-lg border border-border bg-input px-1.5 text-ui-sm text-foreground outline-none' });
|
|
1105
1136
|
sel.append(h('option', { value: '' }, '—'));
|
|
1106
1137
|
for (const f of bgFiles) {
|
|
1107
1138
|
if (/\.(mp4|webm|mov)$/i.test(f.name)) continue; // 分区是 CSS 铺图,视频播不了
|
|
1108
1139
|
sel.append(h('option', { value: f.name }, f.name));
|
|
1109
1140
|
}
|
|
1110
1141
|
sel.value = (cur && cur.file) || '';
|
|
1111
|
-
sel.addEventListener('change', () =>
|
|
1142
|
+
sel.addEventListener('change', () => {
|
|
1143
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1144
|
+
if (fresh) setRegion(region, { ...fresh, file: sel.value });
|
|
1145
|
+
});
|
|
1112
1146
|
valueCtrl = sel;
|
|
1113
1147
|
} else if (mode === 'folder') {
|
|
1114
1148
|
const inp = h('input', { type: 'text', value: (cur && cur.folder) || '', class: themeInputCls.replace('h-8', 'h-7'), placeholder: '/path/to/wallpapers' });
|
|
1115
|
-
inp.addEventListener('change', () => {
|
|
1149
|
+
inp.addEventListener('change', () => { // 空值 = 清空目录,应用侧会撤掉旧图规则
|
|
1150
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1151
|
+
if (fresh) setRegion(region, { ...fresh, folder: inp.value.trim() });
|
|
1152
|
+
});
|
|
1116
1153
|
valueCtrl = inp;
|
|
1117
1154
|
} else if (mode === 'url') {
|
|
1118
1155
|
const inp = h('input', { type: 'url', value: (cur && cur.url) || '', class: themeInputCls.replace('h-8', 'h-7'), placeholder: 'https://...' });
|
|
1119
1156
|
inp.addEventListener('change', () => {
|
|
1120
1157
|
const v = inp.value.trim();
|
|
1121
|
-
if (
|
|
1122
|
-
|
|
1158
|
+
if (!/^https?:\/\/\S+$/.test(v) || /[<>"'\\]/.test(v)) { showToast(L.themeBgUrlInvalid, 'warning'); renderThemeBg(); return; } // 非法网址不保存:提示并回显已存值
|
|
1159
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1160
|
+
if (fresh) setRegion(region, { ...fresh, url: v });
|
|
1123
1161
|
});
|
|
1124
1162
|
valueCtrl = inp;
|
|
1125
1163
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1164
|
+
// 分区缩放/遮罩:与"画面"同款组件、分两列一行;跟随态由"跟随全局"胶囊表示
|
|
1165
|
+
const fitChip = (id, text) => h('button', {
|
|
1166
|
+
type: 'button', class: 'zcodepro-tab',
|
|
1167
|
+
'data-state': (cur && cur.fit ? cur.fit === id : id === '') ? 'active' : 'inactive',
|
|
1168
|
+
onClick: () => {
|
|
1169
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1170
|
+
if (fresh) setRegion(region, { ...fresh, fit: id || null });
|
|
1171
|
+
},
|
|
1172
|
+
}, text);
|
|
1173
|
+
const maskFollow = !(cur && cur.maskOpacity != null);
|
|
1174
|
+
const maskVal = Math.round((maskFollow ? themeCfg.bg.maskOpacity : cur.maskOpacity) * 100);
|
|
1175
|
+
const maskValLabel = h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm tabular-nums text-foreground-subtle' }, maskVal + '%');
|
|
1176
|
+
// 跟随中滑杆仍可拖:一拖就自动退出跟随(变淡只是视觉提示,不禁用)
|
|
1177
|
+
const maskRange = h('input', {
|
|
1178
|
+
type: 'range', min: '0', max: '99', step: '1', value: String(maskVal),
|
|
1179
|
+
class: 'zcodepro-range', 'aria-label': L.themeBgMask, style: 'flex:1' + (maskFollow ? ';opacity:0.55' : ''),
|
|
1180
|
+
});
|
|
1181
|
+
maskRange.addEventListener('input', () => {
|
|
1182
|
+
const v = Number(maskRange.value);
|
|
1183
|
+
maskValLabel.textContent = v + '%';
|
|
1184
|
+
clearTimeout(regionMaskTimers[region]);
|
|
1185
|
+
regionMaskTimers[region] = setTimeout(() => {
|
|
1186
|
+
// 调用时读取分区当前值再合并:防抖期间点过胶囊/换过来源时不拿旧对象盖回去
|
|
1187
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1188
|
+
if (fresh) setRegion(region, { ...fresh, maskOpacity: v / 100 });
|
|
1189
|
+
}, 300);
|
|
1190
|
+
});
|
|
1191
|
+
const maskChip = h('button', {
|
|
1192
|
+
type: 'button', class: 'zcodepro-tab',
|
|
1193
|
+
'data-state': maskFollow ? 'active' : 'inactive',
|
|
1194
|
+
// 与缩放的"跟随全局"钮同为"回到跟随":跟随中点按无操作,退出跟随拖滑杆
|
|
1195
|
+
onClick: () => {
|
|
1196
|
+
if (maskFollow) return;
|
|
1197
|
+
clearTimeout(regionMaskTimers[region]);
|
|
1198
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1199
|
+
if (fresh) setRegion(region, { ...fresh, maskOpacity: null });
|
|
1200
|
+
},
|
|
1201
|
+
}, L.themeBgFollowGlobal);
|
|
1202
|
+
return h('div', { class: 'flex flex-col gap-1' },
|
|
1203
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
1204
|
+
h('span', { class: 'w-16 shrink-0 text-ui-sm text-foreground' }, label),
|
|
1205
|
+
h('div', { class: 'flex flex-wrap gap-1' },
|
|
1206
|
+
rBtn(null, L.themeBgRegionFollow), rBtn('library', L.themeBgModeLibrary),
|
|
1207
|
+
rBtn('folder', L.themeBgModeFolder), rBtn('url', L.themeBgModeUrl)),
|
|
1208
|
+
valueCtrl || h('span', { class: 'text-ui-xs text-foreground-subtle' }, '')),
|
|
1209
|
+
cur ? h('div', { class: 'grid grid-cols-2 gap-x-6 gap-y-2' },
|
|
1210
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
1211
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, L.themeBgFit),
|
|
1212
|
+
fitChip('', L.themeBgFollowGlobal), fitChip('cover', L.themeBgFitCover), fitChip('contain', L.themeBgFitContain),
|
|
1213
|
+
fitChip('fill', L.themeBgFitFill), fitChip('tile', L.themeBgFitTile)),
|
|
1214
|
+
h('div', { class: 'flex items-center gap-2' },
|
|
1215
|
+
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, L.themeBgMask),
|
|
1216
|
+
maskRange, maskValLabel, maskChip)) : null);
|
|
1132
1217
|
};
|
|
1133
1218
|
const renderThemeBg = () => {
|
|
1134
1219
|
// 三个调节参数(滑杆行构造器:label + 范围 + 单位 + 提示 + 防抖保存)
|
|
1135
1220
|
const sliderRow = (label, title, min, max, step, val, unit, commit, hint) => {
|
|
1136
1221
|
// 标签列固定宽(容最长标签六字;内联样式——应用的 Tailwind 按需编译
|
|
1137
1222
|
// 不包含 w-[72px] 这类任意值类):多行滑杆的轨道起点对齐同一竖线
|
|
1138
|
-
const lab = h('span', { class: 'shrink-0 whitespace-nowrap text-ui-
|
|
1139
|
-
const valLabel = h('span', { class: '
|
|
1223
|
+
const lab = h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm font-medium text-foreground-subtle', title, style: 'width:72px' }, label);
|
|
1224
|
+
const valLabel = h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm tabular-nums text-foreground-subtle' }, val + unit);
|
|
1140
1225
|
const range = h('input', {
|
|
1141
1226
|
type: 'range', min: String(min), max: String(max), step: String(step), value: String(val),
|
|
1142
1227
|
class: 'zcodepro-range', 'aria-label': label, style: 'flex:1',
|
|
@@ -1149,25 +1234,24 @@ export function openSettingsDialog() {
|
|
|
1149
1234
|
timer = setTimeout(() => commit(v), 300);
|
|
1150
1235
|
});
|
|
1151
1236
|
return h('div', { class: 'flex flex-col gap-0.5' },
|
|
1152
|
-
h('div', { class: 'flex items-center gap-
|
|
1237
|
+
h('div', { class: 'flex items-center gap-2' }, lab, range, valLabel),
|
|
1153
1238
|
hint ? h('span', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, hint) : null);
|
|
1154
1239
|
};
|
|
1155
1240
|
// 数值兜底:null(旧配置带入)与 undefined 都要落默认,?? 只兜 undefined
|
|
1156
1241
|
const numOr = (v, d) => (typeof v === 'number' && Number.isFinite(v) ? v : d);
|
|
1157
|
-
const maskRow = () => sliderRow(L.themeBgMask,
|
|
1158
|
-
(v) => { void saveTheme({ bg: { maskOpacity: v / 100 } }); },
|
|
1242
|
+
const maskRow = () => sliderRow(L.themeBgMask, '', 0, 99, 1, Math.round(numOr(themeCfg.bg.maskOpacity, 0.82) * 100), '%',
|
|
1243
|
+
(v) => { void saveTheme({ bg: { maskOpacity: v / 100 } }); }, '');
|
|
1159
1244
|
const blurRow = () => sliderRow(L.themeBgBlur, '', 0, 24, 1, numOr(themeCfg.bg.blurPx, 0), 'px',
|
|
1160
1245
|
(v) => { void saveTheme({ bg: { blurPx: v } }); }, '');
|
|
1161
1246
|
const panelRow = () => sliderRow(L.themeBgPanel, '', 0, 100, 1, Math.round(numOr(themeCfg.bg.panelOpacity, 0.3) * 100), '%',
|
|
1162
|
-
(v) => { void saveTheme({ bg: { panelOpacity: v / 100 } }); },
|
|
1247
|
+
(v) => { void saveTheme({ bg: { panelOpacity: v / 100 } }); }, '');
|
|
1163
1248
|
const modeBtn = (id, label) => h('button', {
|
|
1164
1249
|
type: 'button', class: 'zcodepro-tab',
|
|
1165
1250
|
'data-state': themeCfg.bg.mode === id ? 'active' : 'inactive',
|
|
1166
1251
|
onClick: () => {
|
|
1167
|
-
// url 与 web 共用 bg.url
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
void saveTheme({ bg: cross ? { mode: id, url: '' } : { mode: id } });
|
|
1252
|
+
// url 与 web 共用 bg.url:互切保留已填网址(输入框里可见,不算静默失效),
|
|
1253
|
+
// 免得误点一下模式就把输入清空
|
|
1254
|
+
void saveTheme({ bg: { mode: id } });
|
|
1171
1255
|
},
|
|
1172
1256
|
}, label);
|
|
1173
1257
|
// 文件夹路径输入 + 浏览(系统对话框);确认时先校验目录再保存
|
|
@@ -1197,9 +1281,29 @@ export function openSettingsDialog() {
|
|
|
1197
1281
|
} finally { browseBtn.disabled = false; }
|
|
1198
1282
|
})();
|
|
1199
1283
|
});
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1284
|
+
// 开关用功能页同款 [data-zcodepro-switch];整行可点,按钮只做视觉(点击
|
|
1285
|
+
// 冒泡到行统一处理,不会切两次)
|
|
1286
|
+
const mkSwitch = (checked) => h('button', {
|
|
1287
|
+
type: 'button', role: 'switch', 'aria-checked': String(checked),
|
|
1288
|
+
class: 'relative inline-flex shrink-0 cursor-pointer items-center',
|
|
1289
|
+
}, h('span', { class: 'zcodepro-switch', 'data-zcodepro-switch': '', 'data-state': checked ? 'on' : 'off' },
|
|
1290
|
+
h('span', { class: 'zcodepro-switch-knob' })));
|
|
1291
|
+
const switchRow = (text, checked, onToggle) => h('div', {
|
|
1292
|
+
class: 'flex cursor-pointer items-center gap-2 text-ui-sm text-foreground-subtle', onClick: onToggle,
|
|
1293
|
+
}, text, mkSwitch(checked));
|
|
1294
|
+
const randomRow = () => {
|
|
1295
|
+
const checked = themeCfg.bg.folderRandom !== false;
|
|
1296
|
+
return switchRow(L.themeBgFolderRandom, checked, () => {
|
|
1297
|
+
void saveTheme({ bg: { folderRandom: !(themeCfg.bg.folderRandom !== false) } });
|
|
1298
|
+
});
|
|
1299
|
+
};
|
|
1300
|
+
// 设置弹窗磨砂开关:默认开(旧配置没有该键也按开处理)
|
|
1301
|
+
const dialogFrostRow = () => {
|
|
1302
|
+
const checked = themeCfg.bg.dialogFrost !== false;
|
|
1303
|
+
return switchRow(L.themeBgDialogFrost, checked, () => {
|
|
1304
|
+
void saveTheme({ bg: { dialogFrost: !(themeCfg.bg.dialogFrost !== false) } });
|
|
1305
|
+
});
|
|
1306
|
+
};
|
|
1203
1307
|
// 图片网址输入:change 提交;空值回无壁纸
|
|
1204
1308
|
const urlInput = h('input', { type: 'url', value: themeCfg.bg.url, class: themeInputCls, placeholder: 'https://...' });
|
|
1205
1309
|
urlInput.addEventListener('change', () => {
|
|
@@ -1242,35 +1346,35 @@ export function openSettingsDialog() {
|
|
|
1242
1346
|
};
|
|
1243
1347
|
const section = (titleText, body) => h('div', { class: 'mt-3' },
|
|
1244
1348
|
h('div', { class: 'mb-1.5 text-ui-xs font-medium text-foreground-subtle' }, titleText), body);
|
|
1349
|
+
// 分组卡片:与设置弹窗其他面板(如视觉代理)的卡片风格一致
|
|
1350
|
+
const card = (titleText, body) => h('div', { class: 'mt-3 rounded-xl border border-border p-2' },
|
|
1351
|
+
h('div', { class: 'mb-1.5 text-ui-xs font-medium text-foreground-subtle' }, titleText), body);
|
|
1245
1352
|
const modeArea = themeCfg.bg.mode === 'library' ? [
|
|
1246
1353
|
section(L.themeBgLibrary + (bgFiles.length ? `(${bgFiles.length})` : ''), h('div', { class: 'flex flex-col gap-2' },
|
|
1247
1354
|
h('div', { class: 'flex items-center justify-between gap-2' },
|
|
1248
1355
|
h('span', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, bgLoading ? '…' : (bgFiles.length ? '' : L.themeBgEmpty)),
|
|
1249
1356
|
btnSmall(L.themeBgUpload, () => bgInput.click())),
|
|
1250
1357
|
bgFiles.length ? h('div', { class: 'grid grid-cols-4 gap-2', style: 'max-height:13.5rem;overflow-y:auto;' },
|
|
1251
|
-
...bgFiles.map(libCard)) : null,
|
|
1252
|
-
h('div', { class: 'flex items-center gap-2' },
|
|
1253
|
-
h('label', { class: 'flex items-center gap-1.5 text-ui-xs text-foreground-subtle' }, randomCheck, L.themeBgFolderRandom),
|
|
1254
|
-
numField(themeCfg.bg.intervalMin, 0, 1440, (v) => { void saveTheme({ bg: { intervalMin: v } }); }, L.themeBgIntervalHint),
|
|
1255
|
-
h('span', { class: 'text-ui-xs text-foreground-subtle' }, L.themeBgIntervalUnit)))),
|
|
1358
|
+
...bgFiles.map(libCard)) : null)),
|
|
1256
1359
|
] : themeCfg.bg.mode === 'folder' ? [
|
|
1257
1360
|
section(L.themeBgModeFolder, h('div', { class: 'flex flex-col gap-2' },
|
|
1258
1361
|
h('div', { class: 'flex items-center gap-2' }, folderInput, browseBtn),
|
|
1259
1362
|
h('div', { class: 'flex items-center gap-2' },
|
|
1260
|
-
|
|
1363
|
+
randomRow(),
|
|
1261
1364
|
numField(themeCfg.bg.intervalMin, 0, 1440, (v) => { void saveTheme({ bg: { intervalMin: v } }); }, L.themeBgIntervalHint)
|
|
1262
|
-
, h('span', { class: 'text-ui-
|
|
1365
|
+
, h('span', { class: 'text-ui-sm text-foreground-subtle' }, L.themeBgIntervalUnit)),
|
|
1263
1366
|
h('p', { class: 'text-ui-xs/relaxed text-foreground-subtle' },
|
|
1264
1367
|
themeCfg.bg.folder
|
|
1265
|
-
? (folderInfo.count > 0
|
|
1368
|
+
? (folderInfo.count > 0
|
|
1369
|
+
? (themeCfg.bg.intervalMin > 0 ? L.themeBgFolderCount : L.themeBgFolderCountIdle).replaceAll('{n}', String(folderInfo.count))
|
|
1370
|
+
: L.themeBgFolderMissing)
|
|
1266
1371
|
: L.themeBgFolderHint))),
|
|
1267
1372
|
] : themeCfg.bg.mode === 'url' ? [
|
|
1268
|
-
|
|
1373
|
+
h('div', { class: 'flex flex-col gap-2' },
|
|
1269
1374
|
urlInput,
|
|
1270
1375
|
h('div', { class: 'flex items-center gap-2' },
|
|
1271
|
-
numField(themeCfg.bg.intervalMin, 0, 1440, (v) => { void saveTheme({ bg: { intervalMin: v } }); },
|
|
1272
|
-
h('span', { class: 'text-ui-
|
|
1273
|
-
h('p', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgUrlHint))),
|
|
1376
|
+
numField(themeCfg.bg.intervalMin, 0, 1440, (v) => { void saveTheme({ bg: { intervalMin: v } }); }, ''),
|
|
1377
|
+
h('span', { class: 'text-ui-sm text-foreground-subtle' }, L.themeBgUrlIntervalUnit))),
|
|
1274
1378
|
] : themeCfg.bg.mode === 'web' ? [
|
|
1275
1379
|
section(L.themeBgModeWeb, h('div', { class: 'flex flex-col gap-2' },
|
|
1276
1380
|
webInput,
|
|
@@ -1287,57 +1391,64 @@ export function openSettingsDialog() {
|
|
|
1287
1391
|
onClick: () => void saveTheme({ bg: { transition: id } }),
|
|
1288
1392
|
}, label);
|
|
1289
1393
|
const pauseCheck = (key, label) => {
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1394
|
+
const checked = key === 'pauseOnHidden' ? themeCfg.bg.pauseOnHidden !== false : !!themeCfg.bg[key];
|
|
1395
|
+
return switchRow(label, checked, () => {
|
|
1396
|
+
// 点按时现算当前值取反:快速连点两次不会都打成同一个目标值
|
|
1397
|
+
const curVal = key === 'pauseOnHidden' ? themeCfg.bg[key] !== false : !!themeCfg.bg[key];
|
|
1398
|
+
void saveTheme({ bg: { [key]: !curVal } });
|
|
1399
|
+
});
|
|
1294
1400
|
};
|
|
1295
1401
|
// 播放行只作用于视频壁纸:音量滑杆 + 倍速/帧率下拉
|
|
1296
1402
|
const selectField = (value, options, commit) => {
|
|
1297
|
-
const sel = h('select', { class: 'h-7 rounded-lg border border-border bg-input px-1.5 text-ui-
|
|
1403
|
+
const sel = h('select', { class: 'h-7 rounded-lg border border-border bg-input px-1.5 text-ui-sm text-foreground outline-none' });
|
|
1298
1404
|
for (const [v, label] of options) sel.append(h('option', { value: String(v) }, label));
|
|
1299
1405
|
sel.value = String(value);
|
|
1300
1406
|
sel.addEventListener('change', () => commit(sel.value));
|
|
1301
1407
|
return sel;
|
|
1302
1408
|
};
|
|
1303
1409
|
const labelledRow = (label, ctrl) => h('div', { class: 'flex items-center gap-3' },
|
|
1304
|
-
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-
|
|
1410
|
+
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, label), ctrl);
|
|
1305
1411
|
const volumeRow = () => sliderRow(L.themeBgVolume, L.themeBgVolumeHint, 0, 100, 1, Math.round(numOr(themeCfg.bg.videoVolume, 0) * 100), '%',
|
|
1306
1412
|
(v) => { void saveTheme({ bg: { videoVolume: v / 100 } }); }, '');
|
|
1307
|
-
const rateRow = () => labelledRow(L.themeBgRate,
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
const fpsRow = () =>
|
|
1311
|
-
|
|
1312
|
-
(v) => { void saveTheme({ bg: { fpsCap: Number(v) } }); })),
|
|
1313
|
-
h('span', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgFpsHint));
|
|
1413
|
+
const rateRow = () => labelledRow(L.themeBgRate, h('div', { class: 'flex items-center gap-1' },
|
|
1414
|
+
numField(numOr(themeCfg.bg.playbackRate, 1), 0.5, 2, (v) => { void saveTheme({ bg: { playbackRate: v } }); }, '0.5-2', 0.25),
|
|
1415
|
+
h('span', { class: 'text-ui-sm text-foreground-subtle' }, 'x')));
|
|
1416
|
+
const fpsRow = () => labelledRow(L.themeBgFps, selectField(numOr(themeCfg.bg.fpsCap, 0), [['0', L.themeBgFpsOff], ['15', '15 fps'], ['30', '30 fps'], ['60', '60 fps'], ['90', '90 fps'], ['120', '120 fps']],
|
|
1417
|
+
(v) => { void saveTheme({ bg: { fpsCap: Number(v) } }); }));
|
|
1314
1418
|
paneStylesSub4.replaceChildren(
|
|
1315
1419
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.themeBgDesc),
|
|
1316
|
-
h('div', { class: '
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1420
|
+
card(L.themeBgSource, h('div', { class: 'flex flex-col gap-2' },
|
|
1421
|
+
h('div', { class: 'flex flex-wrap gap-1' },
|
|
1422
|
+
modeBtn('none', L.themeBgModeNone), modeBtn('library', L.themeBgModeLibrary),
|
|
1423
|
+
modeBtn('folder', L.themeBgModeFolder), modeBtn('url', L.themeBgModeUrl),
|
|
1424
|
+
modeBtn('web', L.themeBgModeWeb)),
|
|
1425
|
+
...modeArea)),
|
|
1426
|
+
card(L.themeBgImage, h('div', { class: 'grid grid-cols-2 gap-x-6 gap-y-2' },
|
|
1427
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
1428
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, L.themeBgFit),
|
|
1429
|
+
fitBtn('cover', L.themeBgFitCover), fitBtn('contain', L.themeBgFitContain),
|
|
1430
|
+
fitBtn('fill', L.themeBgFitFill), fitBtn('tile', L.themeBgFitTile)),
|
|
1431
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
1432
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, L.themeBgTransition),
|
|
1433
|
+
transBtn('cut', L.themeBgTransitionCut), transBtn('fade', L.themeBgTransitionFade)),
|
|
1434
|
+
h('div', { class: 'col-span-2' }, maskRow()),
|
|
1435
|
+
blurRow(), panelRow())),
|
|
1436
|
+
card(L.themeBgPlayback, h('div', { class: 'grid grid-cols-2 gap-x-6 gap-y-2' },
|
|
1437
|
+
h('div', { class: 'col-span-2' }, volumeRow()),
|
|
1438
|
+
rateRow(), fpsRow(),
|
|
1439
|
+
h('p', { class: 'col-span-2 text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgFpsHint))),
|
|
1440
|
+
card(L.themeBgRegions, h('div', { class: 'flex flex-col gap-2' },
|
|
1322
1441
|
regionRow('left', L.themeBgRegionLeft),
|
|
1323
1442
|
regionRow('center', L.themeBgRegionCenter),
|
|
1324
|
-
regionRow('right', L.themeBgRegionRight)
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
h('span', { class: 'text-ui-xs font-medium text-foreground-subtle' }, L.themeBgPause),
|
|
1334
|
-
pauseCheck('pauseOnHidden', L.themeBgPauseHidden),
|
|
1335
|
-
pauseCheck('pauseOnBlur', L.themeBgPauseBlur),
|
|
1336
|
-
pauseCheck('pauseOnBattery', L.themeBgPauseBattery)),
|
|
1337
|
-
h('div', { class: 'mt-3 flex flex-col gap-2' },
|
|
1338
|
-
maskRow(), blurRow(), panelRow()),
|
|
1339
|
-
section(L.themeBgPlayback, h('div', { class: 'flex flex-col gap-2' },
|
|
1340
|
-
volumeRow(), rateRow(), fpsRow())),
|
|
1443
|
+
regionRow('right', L.themeBgRegionRight),
|
|
1444
|
+
h('p', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgRegionsHint))),
|
|
1445
|
+
card(L.themeBgMisc, h('div', { class: 'flex flex-col gap-2' },
|
|
1446
|
+
h('div', { class: 'flex flex-wrap items-center gap-x-4 gap-y-2' },
|
|
1447
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground-subtle' }, L.themeBgPause),
|
|
1448
|
+
pauseCheck('pauseOnHidden', L.themeBgPauseHidden),
|
|
1449
|
+
pauseCheck('pauseOnBlur', L.themeBgPauseBlur),
|
|
1450
|
+
pauseCheck('pauseOnBattery', L.themeBgPauseBattery)),
|
|
1451
|
+
dialogFrostRow())),
|
|
1341
1452
|
bgInput,
|
|
1342
1453
|
);
|
|
1343
1454
|
};
|
|
@@ -1346,13 +1457,13 @@ export function openSettingsDialog() {
|
|
|
1346
1457
|
void refreshBgFiles();
|
|
1347
1458
|
void refreshFolderInfo();
|
|
1348
1459
|
|
|
1349
|
-
let stylesSubTab = '
|
|
1460
|
+
let stylesSubTab = 'bgimg'; // 默认停在第一个子页(壁纸)
|
|
1350
1461
|
const stylesSubTablist = h('div', { role: 'tablist', 'aria-orientation': 'horizontal', class: 'zcodepro-tablist' });
|
|
1351
1462
|
const renderStylesSubTabs = () => stylesSubTablist.replaceChildren(...[
|
|
1463
|
+
['bgimg', L.themeBgPane],
|
|
1464
|
+
['colors', L.themeColorsPane],
|
|
1352
1465
|
['styles', L.tabStylesPane],
|
|
1353
1466
|
['status', L.tabStatusPane],
|
|
1354
|
-
['colors', L.themeColorsPane],
|
|
1355
|
-
['bgimg', L.themeBgPane],
|
|
1356
1467
|
].map(([id, label]) => h('button', {
|
|
1357
1468
|
type: 'button', role: 'tab', class: 'zcodepro-tab',
|
|
1358
1469
|
'aria-selected': String(stylesSubTab === id),
|
|
@@ -1601,12 +1712,6 @@ export function openSettingsDialog() {
|
|
|
1601
1712
|
const proxyTestBtn = btnSmall(L.proxyTest, () => { void runProxyTest(); }, 'shrink-0');
|
|
1602
1713
|
const runProxyTest = async () => {
|
|
1603
1714
|
if (proxyTesting) return;
|
|
1604
|
-
// 空地址不发请求(等网络超时才报“检测失败”的体验太差),立即提示
|
|
1605
|
-
if (!proxyInput.value.trim()) {
|
|
1606
|
-
proxyTestState.className = 'mt-2 text-ui-xs/relaxed text-amber-500';
|
|
1607
|
-
proxyTestState.textContent = L.proxyTestEmpty;
|
|
1608
|
-
return;
|
|
1609
|
-
}
|
|
1610
1715
|
proxyTesting = true;
|
|
1611
1716
|
proxyTestBtn.disabled = true;
|
|
1612
1717
|
proxyTestBtn.textContent = L.proxyTesting;
|
|
@@ -1687,25 +1792,30 @@ export function openSettingsDialog() {
|
|
|
1687
1792
|
renderPerfToggle();
|
|
1688
1793
|
const perfNumberRow = (labelText, tip, key, fallback, min) => {
|
|
1689
1794
|
const v = Number(config[key]);
|
|
1795
|
+
const nf = numberField({
|
|
1796
|
+
value: Number.isFinite(v) ? v : fallback,
|
|
1797
|
+
fallback,
|
|
1798
|
+
min,
|
|
1799
|
+
max: 1440,
|
|
1800
|
+
step: 1,
|
|
1801
|
+
onCommit: async (n) => {
|
|
1802
|
+
const res = await rpc('/config', { method: 'POST', body: { [key]: n } });
|
|
1803
|
+
if (res.ok && res.config) {
|
|
1804
|
+
config[key] = res.config[key];
|
|
1805
|
+
clearConfigCache();
|
|
1806
|
+
} else {
|
|
1807
|
+
// 保存失败:提示并回滚显示值,别让界面留着没存上的数字
|
|
1808
|
+
showToast(L.failed + ': ' + errText(res), 'error');
|
|
1809
|
+
nf.set(Number.isFinite(Number(config[key])) ? Number(config[key]) : fallback);
|
|
1810
|
+
}
|
|
1811
|
+
},
|
|
1812
|
+
});
|
|
1690
1813
|
return h('div', { class: 'flex items-center justify-between gap-2 px-2 py-1.5' },
|
|
1691
1814
|
h('div', { class: 'min-w-0' },
|
|
1692
1815
|
h('div', { class: 'text-ui-sm font-medium text-foreground' }, labelText),
|
|
1693
1816
|
...(tip ? [h('div', { class: 'mt-0.5 text-ui-xs/relaxed text-foreground-subtle' }, tip)] : [])),
|
|
1694
1817
|
h('div', { class: 'flex shrink-0 items-center gap-1' },
|
|
1695
|
-
|
|
1696
|
-
value: Number.isFinite(v) ? v : fallback,
|
|
1697
|
-
fallback,
|
|
1698
|
-
min,
|
|
1699
|
-
max: 1440,
|
|
1700
|
-
step: 1,
|
|
1701
|
-
onCommit: async (n) => {
|
|
1702
|
-
const res = await rpc('/config', { method: 'POST', body: { [key]: n } });
|
|
1703
|
-
if (res.ok && res.config) {
|
|
1704
|
-
config[key] = res.config[key];
|
|
1705
|
-
clearConfigCache();
|
|
1706
|
-
}
|
|
1707
|
-
},
|
|
1708
|
-
}).el,
|
|
1818
|
+
nf.el,
|
|
1709
1819
|
h('span', { class: 'text-ui-xs text-foreground-subtle' }, L.idleReclaimUnit)));
|
|
1710
1820
|
};
|
|
1711
1821
|
panePerf.append(
|
|
@@ -2100,9 +2210,43 @@ export function openSettingsDialog() {
|
|
|
2100
2210
|
// 就自己刷新,宁可多刷一次也不能停在旧代码 + 失效 token 上
|
|
2101
2211
|
setTimeout(() => { try { location.reload(); } catch { /* ignore */ } }, 2000);
|
|
2102
2212
|
};
|
|
2213
|
+
// 开发者工具开关:官方侧栏面板(Token 调试/网络状态)由官方自己读 localStorage 的
|
|
2214
|
+
// zcode:developer-tools:enabled / zcode:token-debug:enabled(每秒轮询,值为
|
|
2215
|
+
// 0/false/off/no 算关)。默认关闭,打开与否完全由用户决定
|
|
2216
|
+
const DT_KEYS = ['zcode:developer-tools:enabled', 'zcode:token-debug:enabled'];
|
|
2217
|
+
const dtRead = (v) => v !== null && !['0', 'false', 'off', 'no'].includes(v.trim().toLowerCase());
|
|
2218
|
+
const dtOn = () => DT_KEYS.some((k) => dtRead(localStorage.getItem(k)));
|
|
2219
|
+
const dtSet = (on) => {
|
|
2220
|
+
for (const k of DT_KEYS) {
|
|
2221
|
+
if (on) localStorage.setItem(k, 'true');
|
|
2222
|
+
else localStorage.removeItem(k);
|
|
2223
|
+
}
|
|
2224
|
+
};
|
|
2225
|
+
const dtSwitchBtn = (checked) => h('button', {
|
|
2226
|
+
type: 'button', role: 'switch', 'aria-checked': String(checked),
|
|
2227
|
+
class: 'relative inline-flex shrink-0 cursor-pointer items-center',
|
|
2228
|
+
}, h('span', { class: 'zcodepro-switch', 'data-zcodepro-switch': '', 'data-state': checked ? 'on' : 'off' },
|
|
2229
|
+
h('span', { class: 'zcodepro-switch-knob' })));
|
|
2230
|
+
const devToolsRow = () => {
|
|
2231
|
+
const sw = dtSwitchBtn(dtOn());
|
|
2232
|
+
return h('div', {
|
|
2233
|
+
class: 'flex cursor-pointer items-center justify-between gap-2 px-2 py-1.5',
|
|
2234
|
+
onClick: () => {
|
|
2235
|
+
dtSet(!dtOn());
|
|
2236
|
+
const n = dtOn();
|
|
2237
|
+
sw.setAttribute('aria-checked', String(n));
|
|
2238
|
+
sw.firstElementChild.setAttribute('data-state', n ? 'on' : 'off');
|
|
2239
|
+
},
|
|
2240
|
+
},
|
|
2241
|
+
h('div', { class: 'min-w-0' },
|
|
2242
|
+
h('div', { class: 'text-ui-sm font-medium text-foreground' }, L.devToolsSwitch),
|
|
2243
|
+
h('div', { class: 'mt-0.5 text-ui-xs/relaxed text-foreground-subtle' }, L.devToolsSwitchDesc)),
|
|
2244
|
+
sw);
|
|
2245
|
+
};
|
|
2103
2246
|
paneDebug.append(
|
|
2104
2247
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.devModeDesc),
|
|
2105
|
-
h('div', { class: 'mt-3 rounded-xl border border-border' },
|
|
2248
|
+
h('div', { class: 'mt-3 divide-y divide-border rounded-xl border border-border' },
|
|
2249
|
+
devToolsRow(),
|
|
2106
2250
|
h('div', { class: 'flex items-center justify-between gap-2 px-2 py-1.5' },
|
|
2107
2251
|
h('div', { class: 'min-w-0' },
|
|
2108
2252
|
h('div', { class: 'text-ui-sm font-medium text-foreground' }, L.devReload),
|
|
@@ -2116,7 +2260,15 @@ export function openSettingsDialog() {
|
|
|
2116
2260
|
// 默认单级链与 zcode-vision 插件 DEFAULT_CONFIG 保持一致:session(跟随会话供应商、
|
|
2117
2261
|
// 模型留空=会话当前模型)。需要兜底级可手动加 GLM 订阅直连。
|
|
2118
2262
|
// 赠送额度级 trust-build 暂不进默认:ZCode 网关不放行无人值守调用(ADR-0002)。
|
|
2119
|
-
const
|
|
2263
|
+
const VISION_DEFAULT_PROMPT_ZH = '请详细描述这张图片的全部内容。若是界面或图表截图,请先把所有错误、警告、异常状态逐字引用出来(含完整原文),再描述整体布局、文字与关键数据。';
|
|
2264
|
+
const VISION_DEFAULT_PROMPT_EN = 'Describe the entire content of this image in detail. If it is a UI or chart screenshot, first quote every error, warning, and abnormal state verbatim (including the full text), then describe the overall layout, text, and key data.';
|
|
2265
|
+
const VISION_DEFAULT_PROMPT = isZhLocale() ? VISION_DEFAULT_PROMPT_ZH : VISION_DEFAULT_PROMPT_EN;
|
|
2266
|
+
// 已保存的配置里如果是内置默认提示词(旧版固定中文),按当前语言重新取:
|
|
2267
|
+
// 否则切到英文后老配置仍然发中文提示词。用户自己改过的提示词不动。
|
|
2268
|
+
const isBuiltinVisionPrompt = (p) => {
|
|
2269
|
+
const text = String(p || '').trim();
|
|
2270
|
+
return text === VISION_DEFAULT_PROMPT_ZH || text === VISION_DEFAULT_PROMPT_EN;
|
|
2271
|
+
};
|
|
2120
2272
|
const VISION_DEFAULT_CFG = {
|
|
2121
2273
|
enabled: true,
|
|
2122
2274
|
chainMode: 'fallback',
|
|
@@ -2134,6 +2286,11 @@ export function openSettingsDialog() {
|
|
|
2134
2286
|
let visionCfg = visionRes.ok && visionRes.config && typeof visionRes.config === 'object'
|
|
2135
2287
|
? structuredClone(visionRes.config)
|
|
2136
2288
|
: null;
|
|
2289
|
+
if (visionCfg && Array.isArray(visionCfg.proxies)) {
|
|
2290
|
+
for (const proxy of visionCfg.proxies) {
|
|
2291
|
+
if (isBuiltinVisionPrompt(proxy.prompt)) proxy.prompt = VISION_DEFAULT_PROMPT;
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2137
2294
|
// 自动初始化只试一次(每次打开弹窗):写盘失败回退手动“添加代理”卡
|
|
2138
2295
|
let visionAutoInitTried = false;
|
|
2139
2296
|
let visionSaveTimer = null;
|
|
@@ -2223,7 +2380,7 @@ export function openSettingsDialog() {
|
|
|
2223
2380
|
// 信息卡(仅版本行;配置未建,启用开关随配置出现)
|
|
2224
2381
|
h('div', { class: 'mt-3 rounded-xl border border-border p-2' },
|
|
2225
2382
|
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
2226
|
-
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-xs/relaxed text-foreground-subtle' },
|
|
2383
|
+
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-xs/relaxed text-foreground-subtle' }, `${L.pluginLabel} ${visionRes.pluginVersion || '—'}`))),
|
|
2227
2384
|
h('div', { class: 'mt-3 flex justify-end' }, initBtn),
|
|
2228
2385
|
);
|
|
2229
2386
|
return;
|
|
@@ -2340,14 +2497,14 @@ export function openSettingsDialog() {
|
|
|
2340
2497
|
const res = await rpc('/vision/test', { method: 'POST', body: {} });
|
|
2341
2498
|
testBtn.disabled = false;
|
|
2342
2499
|
testBtn.textContent = L.visionTest;
|
|
2343
|
-
visionTestPre.textContent = res.output || res
|
|
2500
|
+
visionTestPre.textContent = res.output || errText(res) || '';
|
|
2344
2501
|
});
|
|
2345
2502
|
paneVision.replaceChildren(
|
|
2346
2503
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.visionDesc),
|
|
2347
2504
|
// 信息卡:插件版本 + 启用图片识别开关(与 rtk/headroom 面板同款式)
|
|
2348
2505
|
h('div', { class: 'mt-3 rounded-xl border border-border p-2' },
|
|
2349
2506
|
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
2350
|
-
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-xs/relaxed text-foreground-subtle' },
|
|
2507
|
+
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-xs/relaxed text-foreground-subtle' }, `${L.pluginLabel} ${visionRes.pluginVersion || '—'}`),
|
|
2351
2508
|
h('div', { class: 'ml-auto' },
|
|
2352
2509
|
settingRow(L.visionEnabled, '', visionCfg.enabled !== false, async () => {
|
|
2353
2510
|
visionCfg.enabled = !(visionCfg.enabled !== false);
|
|
@@ -2450,7 +2607,7 @@ export function openSettingsDialog() {
|
|
|
2450
2607
|
let rtkLocText = '';
|
|
2451
2608
|
const renderRtkVersion = (meta) => {
|
|
2452
2609
|
const v = String(meta.version || '').replace(/^rtk\s+/i, '').trim();
|
|
2453
|
-
rtkVersionLine.textContent =
|
|
2610
|
+
rtkVersionLine.textContent = `${L.pluginLabel} ${meta.pluginVersion || '—'}${v ? ` · rtk ${v}` : ''}`;
|
|
2454
2611
|
rtkLocText = meta.binPath || '';
|
|
2455
2612
|
};
|
|
2456
2613
|
renderRtkVersion(rtkRes);
|
|
@@ -2647,7 +2804,7 @@ export function openSettingsDialog() {
|
|
|
2647
2804
|
// 关 = 直连上游;只改供应商地址,不动代理进程(headroom 可被其他程序共用)
|
|
2648
2805
|
const hrSwitchRow = h('div');
|
|
2649
2806
|
const renderHrVersion = (meta) => {
|
|
2650
|
-
hrVersionLine.textContent =
|
|
2807
|
+
hrVersionLine.textContent = `${L.pluginLabel} ${meta.pluginVersion || '—'}${meta.version ? ` · headroom ${meta.version}` : ''}`;
|
|
2651
2808
|
hrLocText = meta.binPath || '';
|
|
2652
2809
|
};
|
|
2653
2810
|
renderHrVersion(headroomRes);
|
|
@@ -2730,10 +2887,10 @@ export function openSettingsDialog() {
|
|
|
2730
2887
|
const doneMsg = isStart ? L.hrStarted : L.hrStopped;
|
|
2731
2888
|
const timeoutMs = isStart ? 90 * 1000 : 30 * 1000;
|
|
2732
2889
|
const t0 = Date.now();
|
|
2733
|
-
const timerSpan = h('span', { class: 'text-ui-sm text-foreground-subtle/70' }, msg + ' (0s)');
|
|
2890
|
+
const timerSpan = h('span', { class: 'text-ui-sm text-foreground-subtle/70' }, msg + (isZhLocale() ? '(0s)' : ' (0s)'));
|
|
2734
2891
|
hrStatusLine.replaceChildren(timerSpan);
|
|
2735
2892
|
timerIv = setInterval(() => {
|
|
2736
|
-
timerSpan.textContent = msg + ` (${Math.round((Date.now() - t0) / 1000)}s)
|
|
2893
|
+
timerSpan.textContent = msg + (isZhLocale() ? `(${Math.round((Date.now() - t0) / 1000)}s)` : ` (${Math.round((Date.now() - t0) / 1000)}s)`);
|
|
2737
2894
|
}, 1000);
|
|
2738
2895
|
// RPC 完成后进入轮询(RPC 执行实际的 stop/start,可能要 3-10 秒)。
|
|
2739
2896
|
// 轮询出结果前 hrBusy 一直占着:期间再点开关或按钮直接忽略,否则
|
|
@@ -2842,6 +2999,25 @@ export function openSettingsDialog() {
|
|
|
2842
2999
|
}));
|
|
2843
3000
|
};
|
|
2844
3001
|
renderHrUsageSwitch();
|
|
3002
|
+
// Serena:语义代码检索 MCP 开关。不走 hrRun(与压缩代理进程无关),点击即时
|
|
3003
|
+
// 写 cli/config.json;ZCode 新会话启动时加载该 MCP,当前会话不重连。
|
|
3004
|
+
const hrSerenaRow = h('div');
|
|
3005
|
+
const renderSerenaSwitch = () => {
|
|
3006
|
+
const serenaOn = !!(headroomRes.serena && headroomRes.serena.enabled);
|
|
3007
|
+
hrSerenaRow.replaceChildren(
|
|
3008
|
+
settingRow(L.serenaSwitch, L.serenaSwitchDesc, serenaOn, async () => {
|
|
3009
|
+
const next = !serenaOn;
|
|
3010
|
+
const res = await rpc('/headroom', { method: 'POST', body: { serena: next } });
|
|
3011
|
+
if (!res.ok) {
|
|
3012
|
+
showToast(L.failed + ': ' + errText(res), 'error');
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
3015
|
+
if (res.serena) headroomRes.serena = res.serena;
|
|
3016
|
+
renderSerenaSwitch();
|
|
3017
|
+
showToast(next ? L.serenaEnabled : L.serenaDisabled, 'success');
|
|
3018
|
+
}));
|
|
3019
|
+
};
|
|
3020
|
+
renderSerenaSwitch();
|
|
2845
3021
|
const hrRefreshBtn = btnSmall(L.headroomRefresh, () => { void hrRefresh(); });
|
|
2846
3022
|
const hrStartBtn = btnSmall(L.headroomStart, () => { void hrRun({ action: 'start' }); });
|
|
2847
3023
|
const hrRestartBtn = btnSmall(L.headroomRestart, () => { void hrRun({ action: 'restart' }); });
|
|
@@ -3010,6 +3186,7 @@ export function openSettingsDialog() {
|
|
|
3010
3186
|
hrIntervalField.el,
|
|
3011
3187
|
h('span', { class: 'w-4 text-ui-xs text-foreground-subtle' }, L.headroomSecUnit))),
|
|
3012
3188
|
hrPwrHint),
|
|
3189
|
+
h('div', { class: 'mt-2 rounded-xl border border-border p-1' }, hrSerenaRow),
|
|
3013
3190
|
);
|
|
3014
3191
|
};
|
|
3015
3192
|
renderHeadroomPane();
|
|
@@ -3038,7 +3215,7 @@ export function openSettingsDialog() {
|
|
|
3038
3215
|
if (!titleGenCfg) {
|
|
3039
3216
|
paneTitleGen.replaceChildren(
|
|
3040
3217
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.titleGenShortDesc),
|
|
3041
|
-
h('p', { class: 'mt-2 text-ui-sm text-destructive' }, L.
|
|
3218
|
+
h('p', { class: 'mt-2 text-ui-sm text-destructive' }, L.titleGenLoadFailed + ': ' + errText(titleGenRes)),
|
|
3042
3219
|
);
|
|
3043
3220
|
return;
|
|
3044
3221
|
}
|
|
@@ -3155,6 +3332,28 @@ export function openSettingsDialog() {
|
|
|
3155
3332
|
promptArea.focus();
|
|
3156
3333
|
})),
|
|
3157
3334
|
promptArea),
|
|
3335
|
+
// 手动重命名:任务行悬浮按钮 / 右键菜单两个入口的开关 + 起名素材轮数
|
|
3336
|
+
h('div', { class: 'mt-2 rounded-xl border border-border p-2' },
|
|
3337
|
+
h('div', { class: 'mb-1 text-ui-xs font-medium text-foreground-subtle' }, L.titleGenManual),
|
|
3338
|
+
settingRow(L.titleGenHoverBtn, L.titleGenHoverBtnDesc, titleGenCfg.hoverBtn !== false, () => {
|
|
3339
|
+
titleGenCfg.hoverBtn = !(titleGenCfg.hoverBtn !== false);
|
|
3340
|
+
void persistTitleGen();
|
|
3341
|
+
renderTitleGenPane();
|
|
3342
|
+
}),
|
|
3343
|
+
settingRow(L.titleGenMenuEntry, L.titleGenMenuEntryDesc, titleGenCfg.menuEntry !== false, () => {
|
|
3344
|
+
titleGenCfg.menuEntry = !(titleGenCfg.menuEntry !== false);
|
|
3345
|
+
void persistTitleGen();
|
|
3346
|
+
renderTitleGenPane();
|
|
3347
|
+
}),
|
|
3348
|
+
h('div', { class: 'flex items-center gap-2 rounded-lg p-1.5' },
|
|
3349
|
+
h('div', { class: 'min-w-0 flex-1' },
|
|
3350
|
+
h('div', { class: 'text-ui-sm font-medium text-foreground' }, L.titleGenRecentQa),
|
|
3351
|
+
h('div', { class: 'mt-0.5 text-ui-xs/relaxed text-foreground-subtle' }, L.titleGenRecentQaDesc)),
|
|
3352
|
+
numberField({
|
|
3353
|
+
value: Number.isFinite(Number(titleGenCfg.recentQa)) ? Number(titleGenCfg.recentQa) : 3,
|
|
3354
|
+
fallback: 3, min: 1, max: 20, step: 1,
|
|
3355
|
+
onCommit: (v) => { titleGenCfg.recentQa = v; saveTitleGenSoon(); },
|
|
3356
|
+
}).el)),
|
|
3158
3357
|
// 测试(两行:输入框整行;说明 + 按钮一行。结果只显示在本区下方,
|
|
3159
3358
|
// 不弹窗;从没对话过时的引导见 testState 错误文案)
|
|
3160
3359
|
h('div', { class: 'mt-2 rounded-xl border border-border p-2' },
|