zcode-pro 1.5.1 → 1.6.2
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 +33 -21
- package/README.md +23 -13
- package/dist/inject.js +9803 -7820
- package/package.json +3 -2
- package/src/host/cdp.mjs +13 -3
- package/src/host/helper.mjs +1591 -495
- package/src/host/main.mjs +412 -26
- 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 +57 -18
- package/src/host/skill-stats.mjs +163 -0
- package/src/host/taskIndex.mjs +198 -66
- package/src/host/taskOrder.mjs +128 -57
- package/src/host/version.mjs +15 -7
- package/src/host/wallpaper.mjs +328 -0
- package/src/host/webdav.mjs +66 -10
- package/src/inject/core.js +300 -105
- package/src/inject/features/alias-migration.js +8 -4
- package/src/inject/features/alias.js +2 -2
- package/src/inject/features/auto-rename.js +166 -0
- package/src/inject/features/composer-provider.js +82 -63
- package/src/inject/features/copy-path.js +1 -1
- package/src/inject/features/file-menu.js +9 -3
- package/src/inject/features/idle-reclaim.js +31 -8
- package/src/inject/features/image-menu.js +2 -2
- package/src/inject/features/newtab-panels.js +13 -3
- package/src/inject/features/pinned-collapse.js +11 -3
- package/src/inject/features/plugin-card-retry.js +18 -8
- package/src/inject/features/project-menu.js +1 -1
- package/src/inject/features/relocate-dialog.js +2 -1
- package/src/inject/features/sandbox-reclaim.js +17 -1
- package/src/inject/features/session-link.js +200 -0
- package/src/inject/features/session-switch.js +61 -27
- package/src/inject/features/settings-dialog.js +544 -158
- package/src/inject/features/status-bar.js +126 -24
- package/src/inject/features/table-copy.js +18 -2
- package/src/inject/features/task-order.js +48 -14
- package/src/inject/features/theme.js +644 -99
- 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 +69 -29
- package/src/inject/features/ws-running.js +32 -11
- package/src/inject/index.js +18 -1
- package/src/inject/provider-fields.js +2 -2
- package/src/inject/ui.js +91 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// “ZCode Pro 增强设置”弹窗:功能开关 + 外观 + 运行状态。
|
|
2
2
|
// 顶部标签页切换(视觉参考侧栏“分组/项目”切换);配置写入 helper(~/.zcode/zcodepro.json)。
|
|
3
|
-
import { h, t, rpc, getConfig, clearConfigCache, errText, HELPER_URL, isZhLocale, isNewProjectSidebar, DEFAULT_SHORTCUTS, DEFAULT_STATUS_ITEMS, DEFAULT_TURN_ITEMS, STATUS_SESSION_IDS, STATUS_GLOBAL_IDS } from '../core.js';
|
|
3
|
+
import { h, t, rpc, getConfig, clearConfigCache, errText, HELPER_URL, liveBoot, isZhLocale, isNewProjectSidebar, DEFAULT_SHORTCUTS, DEFAULT_STATUS_ITEMS, DEFAULT_TURN_ITEMS, STATUS_SESSION_IDS, STATUS_GLOBAL_IDS } from '../core.js';
|
|
4
4
|
import { openDialog, dialogFooter, btnPrimary, btnSecondary, btnSmall, settingRow, ensureStyle, showToast, numberField, unitField } from '../ui.js';
|
|
5
5
|
import { comboField, providerOptionsOf, modelOptionsOf, modelPlaceholderOf, isManualConn } from '../provider-fields.js';
|
|
6
6
|
import { refreshAliases } from './alias.js';
|
|
@@ -14,6 +14,9 @@ function openExternal(url) {
|
|
|
14
14
|
try { void window.zcode.openExternal(url); } catch { /* ignore */ }
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// 文件名比较归一:Windows 大小写不敏感、macOS 返回 NFD 分解字符
|
|
18
|
+
const sameName = (a, b) => String(a).normalize('NFC').toLowerCase() === String(b).normalize('NFC').toLowerCase();
|
|
19
|
+
|
|
17
20
|
// 插件市场仓库(设置页“自动更新”行的仓库名链接指向它)
|
|
18
21
|
const PLUGINS_REPO_URL = 'https://github.com/duanluan/zcode-plugins';
|
|
19
22
|
|
|
@@ -158,7 +161,7 @@ export function openSettingsDialog() {
|
|
|
158
161
|
// sm:max-w-3xl 不存在会失去约束拉满全屏;max-w-3xl=48rem 存在——英文界面
|
|
159
162
|
// 标签栏较长,42rem 会挤出一块空白并触发横向滚动
|
|
160
163
|
width: 'max-w-3xl',
|
|
161
|
-
bodyClass: 'mt-
|
|
164
|
+
bodyClass: 'mt-0',
|
|
162
165
|
overlay: 'none',
|
|
163
166
|
draggable: true,
|
|
164
167
|
posKey: 'settings',
|
|
@@ -168,9 +171,13 @@ export function openSettingsDialog() {
|
|
|
168
171
|
if (rtkUpgradePollStop) rtkUpgradePollStop();
|
|
169
172
|
},
|
|
170
173
|
onMount: async ({ body, close, content }) => {
|
|
174
|
+
// 标记设置弹窗:showToast 据此把弹窗内触发的提示居中叠在弹窗上
|
|
175
|
+
if (content) content.setAttribute('data-zcodepro-settings', '1');
|
|
171
176
|
// 标题行:左侧“ZCode Pro”点击跳转 GitHub 仓库;右上角 X 关闭弹窗(替代底部按钮)。
|
|
172
177
|
// h2 仍是拖拽把手——X 上阻止 mousedown 冒泡,避免点关闭时误触发拖拽
|
|
173
178
|
const titleEl = content && content.firstElementChild;
|
|
179
|
+
// 版本行稍后并入标题(要等 health 请求返回),这里先留引用
|
|
180
|
+
let titleLeft = null;
|
|
174
181
|
if (titleEl && titleEl.tagName === 'H2') {
|
|
175
182
|
titleEl.classList.add('flex', 'w-full', 'items-center', 'justify-between');
|
|
176
183
|
const ns = 'http://www.w3.org/2000/svg';
|
|
@@ -184,7 +191,7 @@ export function openSettingsDialog() {
|
|
|
184
191
|
}
|
|
185
192
|
return svg;
|
|
186
193
|
};
|
|
187
|
-
|
|
194
|
+
titleLeft = h('span', { class: 'flex min-w-0 items-center' }, L.settingsTitle);
|
|
188
195
|
if (typeof window.zcode?.openExternal === 'function') {
|
|
189
196
|
const REPO_URL = 'https://github.com/duanluan/zcode-pro';
|
|
190
197
|
titleLeft.replaceChildren(
|
|
@@ -206,9 +213,9 @@ export function openSettingsDialog() {
|
|
|
206
213
|
}, '✕');
|
|
207
214
|
titleEl.replaceChildren(titleLeft, closeX);
|
|
208
215
|
}
|
|
209
|
-
//
|
|
216
|
+
// 九个只读请求相互独立:并行取(串行时 headroom 的版本探测一项就约
|
|
210
217
|
// 700ms,弹窗打开明显卡顿)
|
|
211
|
-
const [health, config, agentsRes, visionRes, titleGenRes, titleGenProvidersRes, rtkRes, headroomRes] = await Promise.all([
|
|
218
|
+
const [health, config, agentsRes, visionRes, titleGenRes, titleGenProvidersRes, rtkRes, headroomRes, zcodeConfigRes] = await Promise.all([
|
|
212
219
|
rpc('/health'),
|
|
213
220
|
getConfig(true),
|
|
214
221
|
rpc('/agents'),
|
|
@@ -217,6 +224,7 @@ export function openSettingsDialog() {
|
|
|
217
224
|
rpc('/title-gen/providers'),
|
|
218
225
|
rpc('/rtk'),
|
|
219
226
|
rpc('/headroom'),
|
|
227
|
+
rpc('/zcode-config'),
|
|
220
228
|
]);
|
|
221
229
|
// 供应商表(含各供应商可选模型):视觉代理的模型下拉也用这份
|
|
222
230
|
const titleGenProviders = titleGenProvidersRes.ok && Array.isArray(titleGenProvidersRes.providers)
|
|
@@ -228,7 +236,7 @@ export function openSettingsDialog() {
|
|
|
228
236
|
// 通知常驻功能(如侧栏菜单并入顶栏)立即按新配置启用/停用
|
|
229
237
|
window.dispatchEvent(new CustomEvent('zcodepro:config-changed'));
|
|
230
238
|
if (!res.ok) {
|
|
231
|
-
|
|
239
|
+
statusLine.replaceChildren(
|
|
232
240
|
h('span', { class: 'text-ui-sm text-destructive' }, L.failed + ': ' + errText(res))
|
|
233
241
|
);
|
|
234
242
|
return false;
|
|
@@ -236,13 +244,15 @@ export function openSettingsDialog() {
|
|
|
236
244
|
return true;
|
|
237
245
|
};
|
|
238
246
|
|
|
247
|
+
// 版本行跟在标题文字后(左留间距);也是功能开关保存失败时的报错位置
|
|
239
248
|
const statusLine = h('div', {
|
|
240
|
-
class: 'flex items-center gap-
|
|
249
|
+
class: 'ml-2 flex min-w-0 items-center gap-1.5 text-ui-xs text-foreground-subtle',
|
|
241
250
|
'data-zcodepro-status': '1',
|
|
242
251
|
},
|
|
243
252
|
h('span', { class: 'inline-block size-2 rounded-full bg-emerald-500' }),
|
|
244
|
-
h('span', { class: 'text-foreground-subtle/70' }, `${health.version} · ${HELPER_URL}`)
|
|
253
|
+
h('span', { class: 'truncate text-foreground-subtle/70' }, `${health.version} · ${HELPER_URL}`)
|
|
245
254
|
);
|
|
255
|
+
if (titleLeft) titleLeft.append(statusLine);
|
|
246
256
|
|
|
247
257
|
// 双列网格:功能开关行短小(名称+开关+折行描述),两列排布把 15+ 行压到
|
|
248
258
|
// 一屏内。列间加分隔线、行距拉开(gap-y-1),格内不留底 padding——
|
|
@@ -252,7 +262,7 @@ export function openSettingsDialog() {
|
|
|
252
262
|
// 状态文字写入统一入口:文本与悬停 title 一起更新(描述位被动态内容替换后
|
|
253
263
|
// 仍保持悬停全文约定)
|
|
254
264
|
const setPluginsStatus = (text) => {
|
|
255
|
-
|
|
265
|
+
pluginsStatusLine.textContent = text;
|
|
256
266
|
pluginsStatusLine.setAttribute('title', text);
|
|
257
267
|
};
|
|
258
268
|
const pluginsBtn = btnSmall(L.pluginsCheckNow, () => { void runPluginsUpdate(); });
|
|
@@ -374,6 +384,11 @@ export function openSettingsDialog() {
|
|
|
374
384
|
if (await setFeature('tableCopy', next)) f.tableCopy = next;
|
|
375
385
|
refreshRows();
|
|
376
386
|
}),
|
|
387
|
+
settingRow(L.featureSessionLink, L.featureSessionLinkDesc, f.sessionLink !== false, async () => {
|
|
388
|
+
const next = !(f.sessionLink !== false);
|
|
389
|
+
if (await setFeature('sessionLink', next)) f.sessionLink = next;
|
|
390
|
+
refreshRows();
|
|
391
|
+
}),
|
|
377
392
|
settingRow(L.featureComposerProvider, L.featureComposerProviderDesc, f.composerProvider !== false, async () => {
|
|
378
393
|
const next = !(f.composerProvider !== false);
|
|
379
394
|
if (await setFeature('composerProvider', next)) f.composerProvider = next;
|
|
@@ -461,15 +476,17 @@ export function openSettingsDialog() {
|
|
|
461
476
|
communityCard(L.wechatGroupTitle, L.wechatGroupDesc.replaceAll('{id}', WECHAT_ID),
|
|
462
477
|
() => hCopyIcon('size-4 shrink-0 text-foreground-subtle'),
|
|
463
478
|
async () => {
|
|
464
|
-
if (await copyToClipboard(WECHAT_ID)) showToast(L.wechatIdCopied);
|
|
479
|
+
if (await copyToClipboard(WECHAT_ID)) showToast(L.wechatIdCopied, 'success');
|
|
465
480
|
}));
|
|
466
481
|
|
|
467
482
|
// 标签页切换:功能(现有内容)/ 外观 / 全局提示词 / 视觉代理
|
|
468
483
|
let activeTab = 'features';
|
|
484
|
+
// 二级 tab 栏(外观 / 行为各一条):登记后统一放到滚动区上方的固定区
|
|
485
|
+
const subTabBars = {};
|
|
469
486
|
// 插件更新卡片:显示 duanluan-zcode-plugins 市场状态,一键更新(helper /plugins/* 端点);
|
|
470
487
|
// 状态异步加载,打开弹窗不等待
|
|
471
488
|
|
|
472
|
-
const paneFeatures = h('div', { role: 'tabpanel', class: 'mt-
|
|
489
|
+
const paneFeatures = h('div', { role: 'tabpanel', class: 'mt-2' },
|
|
473
490
|
h('div', {}, rows),
|
|
474
491
|
communityCards,
|
|
475
492
|
);
|
|
@@ -522,12 +539,12 @@ export function openSettingsDialog() {
|
|
|
522
539
|
e.stopImmediatePropagation();
|
|
523
540
|
if (e.key === 'Escape') { stopHkRecording(); return; }
|
|
524
541
|
const k = e.key.toLowerCase();
|
|
525
|
-
if (!/^[a-z0-9]$/.test(k)) { showToast(L.hkInvalid, '
|
|
542
|
+
if (!/^[a-z0-9]$/.test(k)) { showToast(L.hkInvalid, 'warning'); return; }
|
|
526
543
|
const keys = hkKeys();
|
|
527
544
|
const names = hkNames();
|
|
528
545
|
const conflict = HK_ACTIONS.find(([a]) => a !== hkRecording && keys[a] === k);
|
|
529
546
|
if (conflict) {
|
|
530
|
-
showToast(L.hkConflict.replaceAll('{k}', k).replaceAll('{name}', names[conflict[0]]), '
|
|
547
|
+
showToast(L.hkConflict.replaceAll('{k}', k).replaceAll('{name}', names[conflict[0]]), 'warning');
|
|
531
548
|
return;
|
|
532
549
|
}
|
|
533
550
|
const a = hkRecording;
|
|
@@ -562,23 +579,23 @@ export function openSettingsDialog() {
|
|
|
562
579
|
refreshRows(); // 功能标签页的开关描述跟随默认键位
|
|
563
580
|
renderShortcuts();
|
|
564
581
|
};
|
|
565
|
-
const paneShortcuts = h('div', { role: 'tabpanel',
|
|
582
|
+
const paneShortcuts = h('div', { role: 'tabpanel', style: 'display:none' },
|
|
566
583
|
h('div', { class: 'mb-2 text-ui-sm font-medium' }, L.hkTitle),
|
|
567
584
|
h('div', { class: 'mb-2 flex items-center gap-2' },
|
|
568
585
|
h('div', { class: 'min-w-0 flex-1 text-ui-xs/relaxed text-foreground-subtle' }, L.hkEditHint),
|
|
569
586
|
h('div', { class: 'shrink-0' }, btnSmall(L.hkReset, () => { void resetShortcuts(); }))),
|
|
570
587
|
hkCard,
|
|
571
588
|
);
|
|
572
|
-
const paneStyles = h('div', { role: 'tabpanel',
|
|
573
|
-
const panePerf = h('div', { role: 'tabpanel',
|
|
574
|
-
const paneAgents = h('div', { role: 'tabpanel',
|
|
575
|
-
const paneProxy = h('div', { role: 'tabpanel',
|
|
576
|
-
const paneSync = h('div', { role: 'tabpanel',
|
|
577
|
-
const paneVision = h('div', { role: 'tabpanel',
|
|
578
|
-
const paneRtk = h('div', { role: 'tabpanel',
|
|
579
|
-
const paneHeadroom = h('div', { role: 'tabpanel',
|
|
580
|
-
const paneTitleGen = h('div', { role: 'tabpanel',
|
|
581
|
-
const paneDebug = h('div', { role: 'tabpanel',
|
|
589
|
+
const paneStyles = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
590
|
+
const panePerf = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
591
|
+
const paneAgents = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
592
|
+
const paneProxy = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
593
|
+
const paneSync = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
594
|
+
const paneVision = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
595
|
+
const paneRtk = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
596
|
+
const paneHeadroom = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
597
|
+
const paneTitleGen = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
598
|
+
const paneDebug = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
582
599
|
const panes = { features: paneFeatures, shortcuts: paneShortcuts, styles: paneStyles, perf: panePerf, agents: paneAgents, proxy: paneProxy, sync: paneSync, vision: paneVision, headroom: paneHeadroom, rtk: paneRtk, debug: paneDebug };
|
|
583
600
|
// 一级 tab 顺序:功能 → 外观 → 行为 → 性能 → 快捷键 → 代理/同步/插件页
|
|
584
601
|
const tabDefs = [
|
|
@@ -609,6 +626,7 @@ export function openSettingsDialog() {
|
|
|
609
626
|
// 切走“快捷键”标签页时结束键位录制:否则在其它标签页打字会被录制监听吞掉
|
|
610
627
|
if (name !== 'shortcuts' && hkRecording) stopHkRecording();
|
|
611
628
|
for (const [id, pane] of Object.entries(panes)) pane.style.display = id === name ? '' : 'none';
|
|
629
|
+
for (const [id, bar] of Object.entries(subTabBars)) bar.style.display = id === name ? '' : 'none';
|
|
612
630
|
renderTabs();
|
|
613
631
|
};
|
|
614
632
|
renderTabs();
|
|
@@ -617,10 +635,15 @@ export function openSettingsDialog() {
|
|
|
617
635
|
// 数字框滚轮/手输调节,改完即存即生效
|
|
618
636
|
const savedStyles = config.styles || {};
|
|
619
637
|
let saveTimer = null;
|
|
638
|
+
let pendingStyles = {};
|
|
620
639
|
const persistStyles = (partial) => {
|
|
640
|
+
// 防抖期间的多次改动合并提交:150ms 内连调两个字段时前一个不能丢
|
|
641
|
+
Object.assign(pendingStyles, partial);
|
|
621
642
|
clearTimeout(saveTimer);
|
|
622
643
|
saveTimer = setTimeout(async () => {
|
|
623
|
-
const
|
|
644
|
+
const body = pendingStyles;
|
|
645
|
+
pendingStyles = {};
|
|
646
|
+
const res = await rpc('/config', { method: 'POST', body: { styles: body } });
|
|
624
647
|
clearConfigCache();
|
|
625
648
|
if (res.ok) applyStyles((res.config && res.config.styles) || savedStyles);
|
|
626
649
|
else showToast(L.failed + ': ' + errText(res), 'error');
|
|
@@ -766,12 +789,12 @@ export function openSettingsDialog() {
|
|
|
766
789
|
renderToolbarSwitch();
|
|
767
790
|
// “外观”标签页的二级结构:样式(原内容)/ 状态栏(统计项顺序与显隐)/
|
|
768
791
|
// 主题(皮肤与自定义主题)/ 背景图(图库、文件夹轮换、网址)
|
|
769
|
-
const paneStylesSub1 = h('div', { class: 'mt-
|
|
770
|
-
const paneStylesSub2 = h('div', { class: 'mt-
|
|
771
|
-
const paneStylesSub3 = h('div', { class: 'mt-
|
|
772
|
-
const paneStylesSub4 = h('div', { class: 'mt-
|
|
792
|
+
const paneStylesSub1 = h('div', { class: 'mt-2', style: 'display:none' });
|
|
793
|
+
const paneStylesSub2 = h('div', { class: 'mt-2', style: 'display:none' });
|
|
794
|
+
const paneStylesSub3 = h('div', { class: 'mt-2', style: 'display:none' });
|
|
795
|
+
const paneStylesSub4 = h('div', { class: 'mt-2' }); // 默认子页是壁纸,初始显示它
|
|
773
796
|
const ITEM_NAMES = {
|
|
774
|
-
ctx: 'sbItemCtx', questions: 'sbItemQuestions',
|
|
797
|
+
ctx: 'sbItemCtx', tokRate: 'sbItemTokRate', questions: 'sbItemQuestions',
|
|
775
798
|
todayTokens: 'sbItemTodayTokens', totalTokens: 'sbItemTotalTokens', tasks: 'sbItemTasks',
|
|
776
799
|
};
|
|
777
800
|
// 读取并归一化:会话组项在前、全局组项在后(组内保持保存的顺序),
|
|
@@ -779,9 +802,13 @@ export function openSettingsDialog() {
|
|
|
779
802
|
const sbItems = () => {
|
|
780
803
|
const saved = config.statusBar && Array.isArray(config.statusBar.items) ? config.statusBar.items : null;
|
|
781
804
|
if (!saved) return DEFAULT_STATUS_ITEMS.map((x) => ({ ...x }));
|
|
782
|
-
const byId = new Map(saved.map((x) => [x.id, x]));
|
|
783
805
|
const list = saved.filter((x) => ITEM_NAMES[x.id]).map((x) => ({ on: x.on !== false, id: x.id }));
|
|
784
|
-
|
|
806
|
+
// 新默认项按默认位插入(同 status-bar.js 的归一化),不补到组末尾;
|
|
807
|
+
// 缺失判定用过滤后的清单,防止默认项被过滤“藏起来”
|
|
808
|
+
const known = new Set(list.map((x) => x.id));
|
|
809
|
+
for (const d of DEFAULT_STATUS_ITEMS) {
|
|
810
|
+
if (!known.has(d.id)) list.splice(Math.min(DEFAULT_STATUS_ITEMS.indexOf(d), list.length), 0, { ...d });
|
|
811
|
+
}
|
|
785
812
|
return [
|
|
786
813
|
...list.filter((x) => STATUS_SESSION_IDS.has(x.id)),
|
|
787
814
|
...list.filter((x) => STATUS_GLOBAL_IDS.has(x.id)),
|
|
@@ -870,6 +897,7 @@ export function openSettingsDialog() {
|
|
|
870
897
|
const res = await rpc('/config', { method: 'POST', body: { features: { statusBar: to } } });
|
|
871
898
|
clearConfigCache();
|
|
872
899
|
if (res.ok) { config.features = { ...(config.features || {}), statusBar: to }; }
|
|
900
|
+
else showToast(L.failed + ': ' + errText(res), 'error'); // 失败提示;下面 renderMaster 按配置重画,开关自己弹回
|
|
873
901
|
window.dispatchEvent(new CustomEvent('zcodepro:config-changed'));
|
|
874
902
|
renderMaster();
|
|
875
903
|
});
|
|
@@ -888,7 +916,7 @@ export function openSettingsDialog() {
|
|
|
888
916
|
h('div', { class: 'mt-3 mb-1 text-ui-sm font-medium' }, L.sbGroupTurn),
|
|
889
917
|
turnList);
|
|
890
918
|
// —— “颜色”子页(paneStylesSub3):预设皮肤卡片 + 自定义主题编辑 ——
|
|
891
|
-
// ——
|
|
919
|
+
// —— “壁纸”子页(paneStylesSub4):无壁纸 / 图库 / 文件夹轮换 / 图片网址 / 网页 ——
|
|
892
920
|
let themeCfg = structuredClone(config.theme || {});
|
|
893
921
|
const numOrBg = (v, d) => (typeof v === 'number' && Number.isFinite(v) ? v : d);
|
|
894
922
|
themeCfg.skin = themeCfg.skin || 'default';
|
|
@@ -909,20 +937,24 @@ export function openSettingsDialog() {
|
|
|
909
937
|
let bgLoading = false;
|
|
910
938
|
let folderInfo = { count: 0, dir: '' };
|
|
911
939
|
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';
|
|
912
|
-
const numField = (val, min, max, commit, title) => {
|
|
940
|
+
const numField = (val, min, max, commit, title, step = 1) => {
|
|
913
941
|
const n = h('input', {
|
|
914
|
-
type: 'number', min: String(min), max: String(max), step:
|
|
915
|
-
|
|
942
|
+
type: 'number', min: String(min), max: String(max), step: String(step), title,
|
|
943
|
+
inputmode: step < 1 ? 'decimal' : 'numeric',
|
|
944
|
+
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',
|
|
916
945
|
});
|
|
917
946
|
n.value = String(val);
|
|
918
947
|
n.addEventListener('change', () => {
|
|
919
|
-
|
|
948
|
+
// 按步进精度取整;step 带小数时(倍速)取两位小数并限制范围
|
|
949
|
+
const d = String(step).includes('.') ? String(step).split('.')[1].length : 0;
|
|
950
|
+
const raw = Number(n.value);
|
|
951
|
+
const v = Math.max(min, Math.min(max, Number.isFinite(raw) ? Number(raw.toFixed(d)) : min));
|
|
920
952
|
n.value = String(v);
|
|
921
953
|
commit(v);
|
|
922
954
|
});
|
|
923
955
|
return n;
|
|
924
956
|
};
|
|
925
|
-
const bgUrl = (name) => `${HELPER_URL}/bg/file/${encodeURIComponent(name)}`;
|
|
957
|
+
const bgUrl = (name) => `${HELPER_URL}/bg/file/${encodeURIComponent(name)}?t=${encodeURIComponent(liveBoot().token || '')}`; // 媒体路由认 URL 上的 token
|
|
926
958
|
const saveTheme = async (patch) => {
|
|
927
959
|
themeCfg = {
|
|
928
960
|
skin: patch.skin !== undefined ? patch.skin : themeCfg.skin,
|
|
@@ -941,14 +973,28 @@ export function openSettingsDialog() {
|
|
|
941
973
|
renderThemeBg();
|
|
942
974
|
const res = await rpc('/bg');
|
|
943
975
|
bgLoading = false;
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
976
|
+
const listed = res.ok && Array.isArray(res.files);
|
|
977
|
+
if (listed) bgFiles = res.files;
|
|
978
|
+
// 清"指向已删文件的引用"只在拿到真实列表后做:取数失败时 bgFiles 是空的,
|
|
979
|
+
// 按空列表当"全删了"清引用会把还在的文件引用误清掉
|
|
980
|
+
if (listed) {
|
|
981
|
+
// 分区背景指向已删文件的引用一并清掉:否则分区继续请求已删文件名,静默铺不出图
|
|
982
|
+
const regionPatch = {};
|
|
983
|
+
for (const [k, r] of Object.entries(themeCfg.bg.regions || {})) {
|
|
984
|
+
if (r && r.mode === 'library' && r.file && !bgFiles.some((f) => sameName(f.name, r.file))) regionPatch[k] = { ...r, file: '' };
|
|
985
|
+
}
|
|
986
|
+
if (Object.keys(regionPatch).length) {
|
|
987
|
+
themeCfg = { ...themeCfg, bg: { ...themeCfg.bg, regions: { ...themeCfg.bg.regions, ...regionPatch } } };
|
|
988
|
+
await saveTheme({ bg: { regions: { ...themeCfg.bg.regions } } });
|
|
989
|
+
}
|
|
990
|
+
// 图库模式下当前文件可能已被删(同步/手动删除):自动回无背景并提示一次
|
|
991
|
+
if (themeCfg.bg.mode === 'library' && themeCfg.bg.file
|
|
992
|
+
&& !bgFiles.some((f) => sameName(f.name, themeCfg.bg.file))) {
|
|
993
|
+
themeCfg = { ...themeCfg, bg: { ...themeCfg.bg, file: '' } };
|
|
994
|
+
await saveTheme({ bg: { file: '' } });
|
|
995
|
+
showToast(L.themeBgDeletedActive, 'warning');
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
952
998
|
}
|
|
953
999
|
renderThemeBg();
|
|
954
1000
|
};
|
|
@@ -960,8 +1006,9 @@ export function openSettingsDialog() {
|
|
|
960
1006
|
: { count: 0, dir: themeCfg.bg.folder };
|
|
961
1007
|
renderThemeBg();
|
|
962
1008
|
};
|
|
963
|
-
//
|
|
964
|
-
|
|
1009
|
+
// 上传:图片转 base64 传 helper,视频走 raw 字节流接口(base64 会把内存翻倍);
|
|
1010
|
+
// 第一个上传且当前无壁纸时自动选为当前
|
|
1011
|
+
const bgInput = h('input', { type: 'file', accept: '.png,.jpg,.jpeg,.webp,.gif,.bmp,.avif,.mp4,.webm,.mov', multiple: '', style: 'display:none' });
|
|
965
1012
|
bgInput.addEventListener('change', () => {
|
|
966
1013
|
const files = [...bgInput.files || []];
|
|
967
1014
|
bgInput.value = '';
|
|
@@ -969,17 +1016,26 @@ export function openSettingsDialog() {
|
|
|
969
1016
|
void (async () => {
|
|
970
1017
|
let first = themeCfg.bg.file;
|
|
971
1018
|
for (const f of files) {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1019
|
+
let res = null;
|
|
1020
|
+
if (/\.(mp4|webm|mov)$/i.test(f.name)) {
|
|
1021
|
+
res = await fetch(`${HELPER_URL}/bg/upload?name=${encodeURIComponent(f.name)}`, {
|
|
1022
|
+
method: 'POST',
|
|
1023
|
+
headers: { 'X-ZCodePro-Token': liveBoot().token || '' },
|
|
1024
|
+
body: f,
|
|
1025
|
+
}).then((r) => r.json()).catch((e) => ({ ok: false, error: String((e && e.message) || e) }));
|
|
1026
|
+
} else {
|
|
1027
|
+
const dataUrl = await new Promise((resolve) => {
|
|
1028
|
+
const r = new FileReader();
|
|
1029
|
+
r.onload = () => resolve(String(r.result || ''));
|
|
1030
|
+
r.onerror = () => resolve('');
|
|
1031
|
+
r.readAsDataURL(f);
|
|
1032
|
+
});
|
|
1033
|
+
if (!dataUrl) continue;
|
|
1034
|
+
res = await rpc('/bg', { method: 'POST', body: { name: f.name, data: dataUrl } });
|
|
1035
|
+
}
|
|
1036
|
+
if (!res || !res.ok) { showToast(L.failed + ': ' + errText(res || {}), 'error'); continue; }
|
|
981
1037
|
if (Array.isArray(res.files)) bgFiles = res.files;
|
|
982
|
-
if (!first) first = f.name;
|
|
1038
|
+
if (!first) first = res.name || f.name; // 落盘名以 helper 回传为准(清洗可能改名)
|
|
983
1039
|
}
|
|
984
1040
|
if (first && first !== themeCfg.bg.file) await saveTheme({ bg: { file: first } });
|
|
985
1041
|
else renderThemeBg();
|
|
@@ -1047,6 +1103,9 @@ export function openSettingsDialog() {
|
|
|
1047
1103
|
);
|
|
1048
1104
|
};
|
|
1049
1105
|
// 分区背景行:跟随全局 / 图库(下拉选图)/ 文件夹 / 网址
|
|
1106
|
+
// regionMaskTimers 记各分区遮罩滑杆的防抖提交(按行分开,互不误撤);
|
|
1107
|
+
// 只有"跟随全局"胶囊撤本行在途提交(它写 null 与拖动值直接冲突)
|
|
1108
|
+
const regionMaskTimers = {};
|
|
1050
1109
|
const setRegion = (region, value) => {
|
|
1051
1110
|
void saveTheme({ bg: { regions: { ...themeCfg.bg.regions, [region]: value } } });
|
|
1052
1111
|
};
|
|
@@ -1059,40 +1118,104 @@ export function openSettingsDialog() {
|
|
|
1059
1118
|
onClick: () => {
|
|
1060
1119
|
if (id === null) { setRegion(region, null); return; }
|
|
1061
1120
|
const keep = themeCfg.bg.regions[region];
|
|
1062
|
-
setRegion(region, {
|
|
1121
|
+
setRegion(region, {
|
|
1122
|
+
mode: id, file: keep && keep.file || '', folder: keep && keep.folder || '', url: keep && keep.url || '',
|
|
1123
|
+
fit: (keep && keep.fit) || null, maskOpacity: keep && keep.maskOpacity != null ? keep.maskOpacity : null,
|
|
1124
|
+
});
|
|
1063
1125
|
},
|
|
1064
1126
|
}, text);
|
|
1065
1127
|
let valueCtrl = null;
|
|
1066
1128
|
if (mode === 'library') {
|
|
1067
|
-
const sel = h('select', { class: 'h-7 max-w-40 rounded-lg border border-border bg-input px-1.5 text-ui-
|
|
1129
|
+
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' });
|
|
1068
1130
|
sel.append(h('option', { value: '' }, '—'));
|
|
1069
|
-
for (const f of bgFiles)
|
|
1131
|
+
for (const f of bgFiles) {
|
|
1132
|
+
if (/\.(mp4|webm|mov)$/i.test(f.name)) continue; // 分区是 CSS 铺图,视频播不了
|
|
1133
|
+
sel.append(h('option', { value: f.name }, f.name));
|
|
1134
|
+
}
|
|
1070
1135
|
sel.value = (cur && cur.file) || '';
|
|
1071
|
-
sel.addEventListener('change', () =>
|
|
1136
|
+
sel.addEventListener('change', () => {
|
|
1137
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1138
|
+
if (fresh) setRegion(region, { ...fresh, file: sel.value });
|
|
1139
|
+
});
|
|
1072
1140
|
valueCtrl = sel;
|
|
1073
1141
|
} else if (mode === 'folder') {
|
|
1074
1142
|
const inp = h('input', { type: 'text', value: (cur && cur.folder) || '', class: themeInputCls.replace('h-8', 'h-7'), placeholder: '/path/to/wallpapers' });
|
|
1075
|
-
inp.addEventListener('change', () => {
|
|
1143
|
+
inp.addEventListener('change', () => { // 空值 = 清空目录,应用侧会撤掉旧图规则
|
|
1144
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1145
|
+
if (fresh) setRegion(region, { ...fresh, folder: inp.value.trim() });
|
|
1146
|
+
});
|
|
1076
1147
|
valueCtrl = inp;
|
|
1077
1148
|
} else if (mode === 'url') {
|
|
1078
1149
|
const inp = h('input', { type: 'url', value: (cur && cur.url) || '', class: themeInputCls.replace('h-8', 'h-7'), placeholder: 'https://...' });
|
|
1079
|
-
inp.addEventListener('change', () => {
|
|
1150
|
+
inp.addEventListener('change', () => {
|
|
1151
|
+
const v = inp.value.trim();
|
|
1152
|
+
if (!/^https?:\/\/\S+$/.test(v) || /[<>"'\\]/.test(v)) { showToast(L.themeBgUrlInvalid, 'warning'); renderThemeBg(); return; } // 非法网址不保存:提示并回显已存值
|
|
1153
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1154
|
+
if (fresh) setRegion(region, { ...fresh, url: v });
|
|
1155
|
+
});
|
|
1080
1156
|
valueCtrl = inp;
|
|
1081
1157
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1158
|
+
// 分区缩放/遮罩:与"画面"同款组件、分两列一行;跟随态由"跟随全局"胶囊表示
|
|
1159
|
+
const fitChip = (id, text) => h('button', {
|
|
1160
|
+
type: 'button', class: 'zcodepro-tab',
|
|
1161
|
+
'data-state': (cur && cur.fit ? cur.fit === id : id === '') ? 'active' : 'inactive',
|
|
1162
|
+
onClick: () => {
|
|
1163
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1164
|
+
if (fresh) setRegion(region, { ...fresh, fit: id || null });
|
|
1165
|
+
},
|
|
1166
|
+
}, text);
|
|
1167
|
+
const maskFollow = !(cur && cur.maskOpacity != null);
|
|
1168
|
+
const maskVal = Math.round((maskFollow ? themeCfg.bg.maskOpacity : cur.maskOpacity) * 100);
|
|
1169
|
+
const maskValLabel = h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm tabular-nums text-foreground-subtle' }, maskVal + '%');
|
|
1170
|
+
// 跟随中滑杆仍可拖:一拖就自动退出跟随(变淡只是视觉提示,不禁用)
|
|
1171
|
+
const maskRange = h('input', {
|
|
1172
|
+
type: 'range', min: '0', max: '99', step: '1', value: String(maskVal),
|
|
1173
|
+
class: 'zcodepro-range', 'aria-label': L.themeBgMask, style: 'flex:1' + (maskFollow ? ';opacity:0.55' : ''),
|
|
1174
|
+
});
|
|
1175
|
+
maskRange.addEventListener('input', () => {
|
|
1176
|
+
const v = Number(maskRange.value);
|
|
1177
|
+
maskValLabel.textContent = v + '%';
|
|
1178
|
+
clearTimeout(regionMaskTimers[region]);
|
|
1179
|
+
regionMaskTimers[region] = setTimeout(() => {
|
|
1180
|
+
// 调用时读取分区当前值再合并:防抖期间点过胶囊/换过来源时不拿旧对象盖回去
|
|
1181
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1182
|
+
if (fresh) setRegion(region, { ...fresh, maskOpacity: v / 100 });
|
|
1183
|
+
}, 300);
|
|
1184
|
+
});
|
|
1185
|
+
const maskChip = h('button', {
|
|
1186
|
+
type: 'button', class: 'zcodepro-tab',
|
|
1187
|
+
'data-state': maskFollow ? 'active' : 'inactive',
|
|
1188
|
+
// 与缩放的"跟随全局"钮同为"回到跟随":跟随中点按无操作,退出跟随拖滑杆
|
|
1189
|
+
onClick: () => {
|
|
1190
|
+
if (maskFollow) return;
|
|
1191
|
+
clearTimeout(regionMaskTimers[region]);
|
|
1192
|
+
const fresh = themeCfg.bg.regions[region];
|
|
1193
|
+
if (fresh) setRegion(region, { ...fresh, maskOpacity: null });
|
|
1194
|
+
},
|
|
1195
|
+
}, L.themeBgFollowGlobal);
|
|
1196
|
+
return h('div', { class: 'flex flex-col gap-1' },
|
|
1197
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
1198
|
+
h('span', { class: 'w-16 shrink-0 text-ui-sm text-foreground' }, label),
|
|
1199
|
+
h('div', { class: 'flex flex-wrap gap-1' },
|
|
1200
|
+
rBtn(null, L.themeBgRegionFollow), rBtn('library', L.themeBgModeLibrary),
|
|
1201
|
+
rBtn('folder', L.themeBgModeFolder), rBtn('url', L.themeBgModeUrl)),
|
|
1202
|
+
valueCtrl || h('span', { class: 'text-ui-xs text-foreground-subtle' }, '')),
|
|
1203
|
+
cur ? h('div', { class: 'grid grid-cols-2 gap-x-6 gap-y-2' },
|
|
1204
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
1205
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, L.themeBgFit),
|
|
1206
|
+
fitChip('', L.themeBgFollowGlobal), fitChip('cover', L.themeBgFitCover), fitChip('contain', L.themeBgFitContain),
|
|
1207
|
+
fitChip('fill', L.themeBgFitFill), fitChip('tile', L.themeBgFitTile)),
|
|
1208
|
+
h('div', { class: 'flex items-center gap-2' },
|
|
1209
|
+
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, L.themeBgMask),
|
|
1210
|
+
maskRange, maskValLabel, maskChip)) : null);
|
|
1088
1211
|
};
|
|
1089
1212
|
const renderThemeBg = () => {
|
|
1090
1213
|
// 三个调节参数(滑杆行构造器:label + 范围 + 单位 + 提示 + 防抖保存)
|
|
1091
1214
|
const sliderRow = (label, title, min, max, step, val, unit, commit, hint) => {
|
|
1092
1215
|
// 标签列固定宽(容最长标签六字;内联样式——应用的 Tailwind 按需编译
|
|
1093
1216
|
// 不包含 w-[72px] 这类任意值类):多行滑杆的轨道起点对齐同一竖线
|
|
1094
|
-
const lab = h('span', { class: 'shrink-0 whitespace-nowrap text-ui-
|
|
1095
|
-
const valLabel = h('span', { class: '
|
|
1217
|
+
const lab = h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm font-medium text-foreground-subtle', title, style: 'width:72px' }, label);
|
|
1218
|
+
const valLabel = h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm tabular-nums text-foreground-subtle' }, val + unit);
|
|
1096
1219
|
const range = h('input', {
|
|
1097
1220
|
type: 'range', min: String(min), max: String(max), step: String(step), value: String(val),
|
|
1098
1221
|
class: 'zcodepro-range', 'aria-label': label, style: 'flex:1',
|
|
@@ -1105,21 +1228,25 @@ export function openSettingsDialog() {
|
|
|
1105
1228
|
timer = setTimeout(() => commit(v), 300);
|
|
1106
1229
|
});
|
|
1107
1230
|
return h('div', { class: 'flex flex-col gap-0.5' },
|
|
1108
|
-
h('div', { class: 'flex items-center gap-
|
|
1231
|
+
h('div', { class: 'flex items-center gap-2' }, lab, range, valLabel),
|
|
1109
1232
|
hint ? h('span', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, hint) : null);
|
|
1110
1233
|
};
|
|
1111
1234
|
// 数值兜底:null(旧配置带入)与 undefined 都要落默认,?? 只兜 undefined
|
|
1112
1235
|
const numOr = (v, d) => (typeof v === 'number' && Number.isFinite(v) ? v : d);
|
|
1113
|
-
const maskRow = () => sliderRow(L.themeBgMask,
|
|
1114
|
-
(v) => { void saveTheme({ bg: { maskOpacity: v / 100 } }); },
|
|
1236
|
+
const maskRow = () => sliderRow(L.themeBgMask, '', 0, 99, 1, Math.round(numOr(themeCfg.bg.maskOpacity, 0.82) * 100), '%',
|
|
1237
|
+
(v) => { void saveTheme({ bg: { maskOpacity: v / 100 } }); }, '');
|
|
1115
1238
|
const blurRow = () => sliderRow(L.themeBgBlur, '', 0, 24, 1, numOr(themeCfg.bg.blurPx, 0), 'px',
|
|
1116
1239
|
(v) => { void saveTheme({ bg: { blurPx: v } }); }, '');
|
|
1117
1240
|
const panelRow = () => sliderRow(L.themeBgPanel, '', 0, 100, 1, Math.round(numOr(themeCfg.bg.panelOpacity, 0.3) * 100), '%',
|
|
1118
|
-
(v) => { void saveTheme({ bg: { panelOpacity: v / 100 } }); },
|
|
1241
|
+
(v) => { void saveTheme({ bg: { panelOpacity: v / 100 } }); }, '');
|
|
1119
1242
|
const modeBtn = (id, label) => h('button', {
|
|
1120
1243
|
type: 'button', class: 'zcodepro-tab',
|
|
1121
1244
|
'data-state': themeCfg.bg.mode === id ? 'active' : 'inactive',
|
|
1122
|
-
onClick: () =>
|
|
1245
|
+
onClick: () => {
|
|
1246
|
+
// url 与 web 共用 bg.url:互切保留已填网址(输入框里可见,不算静默失效),
|
|
1247
|
+
// 免得误点一下模式就把输入清空
|
|
1248
|
+
void saveTheme({ bg: { mode: id } });
|
|
1249
|
+
},
|
|
1123
1250
|
}, label);
|
|
1124
1251
|
// 文件夹路径输入 + 浏览(系统对话框);确认时先校验目录再保存
|
|
1125
1252
|
const folderInput = h('input', { type: 'text', value: themeCfg.bg.folder, class: themeInputCls, placeholder: '/path/to/wallpapers' });
|
|
@@ -1148,17 +1275,45 @@ export function openSettingsDialog() {
|
|
|
1148
1275
|
} finally { browseBtn.disabled = false; }
|
|
1149
1276
|
})();
|
|
1150
1277
|
});
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1278
|
+
// 开关用功能页同款 [data-zcodepro-switch];整行可点,按钮只做视觉(点击
|
|
1279
|
+
// 冒泡到行统一处理,不会切两次)
|
|
1280
|
+
const mkSwitch = (checked) => h('button', {
|
|
1281
|
+
type: 'button', role: 'switch', 'aria-checked': String(checked),
|
|
1282
|
+
class: 'relative inline-flex shrink-0 cursor-pointer items-center',
|
|
1283
|
+
}, h('span', { class: 'zcodepro-switch', 'data-zcodepro-switch': '', 'data-state': checked ? 'on' : 'off' },
|
|
1284
|
+
h('span', { class: 'zcodepro-switch-knob' })));
|
|
1285
|
+
const switchRow = (text, checked, onToggle) => h('div', {
|
|
1286
|
+
class: 'flex cursor-pointer items-center gap-2 text-ui-sm text-foreground-subtle', onClick: onToggle,
|
|
1287
|
+
}, text, mkSwitch(checked));
|
|
1288
|
+
const randomRow = () => {
|
|
1289
|
+
const checked = themeCfg.bg.folderRandom !== false;
|
|
1290
|
+
return switchRow(L.themeBgFolderRandom, checked, () => {
|
|
1291
|
+
void saveTheme({ bg: { folderRandom: !(themeCfg.bg.folderRandom !== false) } });
|
|
1292
|
+
});
|
|
1293
|
+
};
|
|
1294
|
+
// 设置弹窗磨砂开关:默认开(旧配置没有该键也按开处理)
|
|
1295
|
+
const dialogFrostRow = () => {
|
|
1296
|
+
const checked = themeCfg.bg.dialogFrost !== false;
|
|
1297
|
+
return switchRow(L.themeBgDialogFrost, checked, () => {
|
|
1298
|
+
void saveTheme({ bg: { dialogFrost: !(themeCfg.bg.dialogFrost !== false) } });
|
|
1299
|
+
});
|
|
1300
|
+
};
|
|
1301
|
+
// 图片网址输入:change 提交;空值回无壁纸
|
|
1155
1302
|
const urlInput = h('input', { type: 'url', value: themeCfg.bg.url, class: themeInputCls, placeholder: 'https://...' });
|
|
1156
1303
|
urlInput.addEventListener('change', () => {
|
|
1157
1304
|
const v = urlInput.value.trim();
|
|
1158
1305
|
if (!v) { void saveTheme({ bg: { mode: 'none', url: '' } }); return; }
|
|
1159
|
-
if (!/^https?:\/\/\S+$/.test(v)) { showToast(L.themeBgUrlInvalid, '
|
|
1306
|
+
if (!/^https?:\/\/\S+$/.test(v) || /[<>"'\\]/.test(v)) { showToast(L.themeBgUrlInvalid, 'warning'); renderThemeBg(); return; }
|
|
1160
1307
|
void saveTheme({ bg: { mode: 'url', url: v } });
|
|
1161
1308
|
});
|
|
1309
|
+
// 网页壁纸输入:与图片网址共用 bg.url 字段,模式不同渲染方式不同
|
|
1310
|
+
const webInput = h('input', { type: 'url', value: themeCfg.bg.url, class: themeInputCls, placeholder: 'https://...' });
|
|
1311
|
+
webInput.addEventListener('change', () => {
|
|
1312
|
+
const v = webInput.value.trim();
|
|
1313
|
+
if (!v) { void saveTheme({ bg: { mode: 'none', url: '' } }); return; }
|
|
1314
|
+
if (!/^https?:\/\/\S+$/.test(v) || /[<>"'\\]/.test(v)) { showToast(L.themeBgUrlInvalid, 'warning'); renderThemeBg(); return; }
|
|
1315
|
+
void saveTheme({ bg: { mode: 'web', url: v } });
|
|
1316
|
+
});
|
|
1162
1317
|
const libCard = (f) => {
|
|
1163
1318
|
const del = h('button', {
|
|
1164
1319
|
type: 'button', class: 'zcodepro-bg-del', title: L.themeBgDelete,
|
|
@@ -1172,15 +1327,22 @@ export function openSettingsDialog() {
|
|
|
1172
1327
|
})();
|
|
1173
1328
|
},
|
|
1174
1329
|
}, '✕');
|
|
1330
|
+
// 视频用 <video> 拉首帧当缩略图(preload=metadata 只取元数据不下载全片)
|
|
1331
|
+
const thumb = /\.(mp4|webm|mov)$/i.test(f.name)
|
|
1332
|
+
? h('video', { src: bgUrl(f.name), preload: 'metadata', muted: '' })
|
|
1333
|
+
: h('img', { src: bgUrl(f.name), alt: '', loading: 'lazy' });
|
|
1175
1334
|
return h('button', {
|
|
1176
1335
|
type: 'button', class: 'zcodepro-bg-card',
|
|
1177
|
-
'data-state': themeCfg.bg.mode === 'library' && themeCfg.bg.file
|
|
1336
|
+
'data-state': themeCfg.bg.mode === 'library' && sameName(themeCfg.bg.file, f.name) ? 'active' : 'inactive',
|
|
1178
1337
|
title: f.name,
|
|
1179
1338
|
onClick: () => void saveTheme({ bg: { mode: 'library', file: themeCfg.bg.file === f.name ? '' : f.name } }),
|
|
1180
|
-
},
|
|
1339
|
+
}, thumb, del);
|
|
1181
1340
|
};
|
|
1182
1341
|
const section = (titleText, body) => h('div', { class: 'mt-3' },
|
|
1183
1342
|
h('div', { class: 'mb-1.5 text-ui-xs font-medium text-foreground-subtle' }, titleText), body);
|
|
1343
|
+
// 分组卡片:与设置弹窗其他面板(如视觉代理)的卡片风格一致
|
|
1344
|
+
const card = (titleText, body) => h('div', { class: 'mt-3 rounded-xl border border-border p-2' },
|
|
1345
|
+
h('div', { class: 'mb-1.5 text-ui-xs font-medium text-foreground-subtle' }, titleText), body);
|
|
1184
1346
|
const modeArea = themeCfg.bg.mode === 'library' ? [
|
|
1185
1347
|
section(L.themeBgLibrary + (bgFiles.length ? `(${bgFiles.length})` : ''), h('div', { class: 'flex flex-col gap-2' },
|
|
1186
1348
|
h('div', { class: 'flex items-center justify-between gap-2' },
|
|
@@ -1192,42 +1354,95 @@ export function openSettingsDialog() {
|
|
|
1192
1354
|
section(L.themeBgModeFolder, h('div', { class: 'flex flex-col gap-2' },
|
|
1193
1355
|
h('div', { class: 'flex items-center gap-2' }, folderInput, browseBtn),
|
|
1194
1356
|
h('div', { class: 'flex items-center gap-2' },
|
|
1195
|
-
|
|
1357
|
+
randomRow(),
|
|
1196
1358
|
numField(themeCfg.bg.intervalMin, 0, 1440, (v) => { void saveTheme({ bg: { intervalMin: v } }); }, L.themeBgIntervalHint)
|
|
1197
|
-
, h('span', { class: 'text-ui-
|
|
1359
|
+
, h('span', { class: 'text-ui-sm text-foreground-subtle' }, L.themeBgIntervalUnit)),
|
|
1198
1360
|
h('p', { class: 'text-ui-xs/relaxed text-foreground-subtle' },
|
|
1199
1361
|
themeCfg.bg.folder
|
|
1200
|
-
? (folderInfo.count > 0
|
|
1362
|
+
? (folderInfo.count > 0
|
|
1363
|
+
? (themeCfg.bg.intervalMin > 0 ? L.themeBgFolderCount : L.themeBgFolderCountIdle).replaceAll('{n}', String(folderInfo.count))
|
|
1364
|
+
: L.themeBgFolderMissing)
|
|
1201
1365
|
: L.themeBgFolderHint))),
|
|
1202
1366
|
] : themeCfg.bg.mode === 'url' ? [
|
|
1203
|
-
|
|
1367
|
+
h('div', { class: 'flex flex-col gap-2' },
|
|
1204
1368
|
urlInput,
|
|
1205
1369
|
h('div', { class: 'flex items-center gap-2' },
|
|
1206
|
-
numField(themeCfg.bg.intervalMin, 0, 1440, (v) => { void saveTheme({ bg: { intervalMin: v } }); },
|
|
1207
|
-
h('span', { class: 'text-ui-
|
|
1208
|
-
|
|
1370
|
+
numField(themeCfg.bg.intervalMin, 0, 1440, (v) => { void saveTheme({ bg: { intervalMin: v } }); }, ''),
|
|
1371
|
+
h('span', { class: 'text-ui-sm text-foreground-subtle' }, L.themeBgUrlIntervalUnit))),
|
|
1372
|
+
] : themeCfg.bg.mode === 'web' ? [
|
|
1373
|
+
section(L.themeBgModeWeb, h('div', { class: 'flex flex-col gap-2' },
|
|
1374
|
+
webInput,
|
|
1375
|
+
h('p', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgWebHint))),
|
|
1209
1376
|
] : [h('p', { class: 'mt-3 text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgNoneHint)];
|
|
1210
1377
|
const fitBtn = (id, label) => h('button', {
|
|
1211
1378
|
type: 'button', class: 'zcodepro-tab',
|
|
1212
1379
|
'data-state': (themeCfg.bg.fit || 'cover') === id ? 'active' : 'inactive',
|
|
1213
1380
|
onClick: () => void saveTheme({ bg: { fit: id } }),
|
|
1214
1381
|
}, label);
|
|
1382
|
+
const transBtn = (id, label) => h('button', {
|
|
1383
|
+
type: 'button', class: 'zcodepro-tab',
|
|
1384
|
+
'data-state': (themeCfg.bg.transition || 'cut') === id ? 'active' : 'inactive',
|
|
1385
|
+
onClick: () => void saveTheme({ bg: { transition: id } }),
|
|
1386
|
+
}, label);
|
|
1387
|
+
const pauseCheck = (key, label) => {
|
|
1388
|
+
const checked = key === 'pauseOnHidden' ? themeCfg.bg.pauseOnHidden !== false : !!themeCfg.bg[key];
|
|
1389
|
+
return switchRow(label, checked, () => {
|
|
1390
|
+
// 点按时现算当前值取反:快速连点两次不会都打成同一个目标值
|
|
1391
|
+
const curVal = key === 'pauseOnHidden' ? themeCfg.bg[key] !== false : !!themeCfg.bg[key];
|
|
1392
|
+
void saveTheme({ bg: { [key]: !curVal } });
|
|
1393
|
+
});
|
|
1394
|
+
};
|
|
1395
|
+
// 播放行只作用于视频壁纸:音量滑杆 + 倍速/帧率下拉
|
|
1396
|
+
const selectField = (value, options, commit) => {
|
|
1397
|
+
const sel = h('select', { class: 'h-7 rounded-lg border border-border bg-input px-1.5 text-ui-sm text-foreground outline-none' });
|
|
1398
|
+
for (const [v, label] of options) sel.append(h('option', { value: String(v) }, label));
|
|
1399
|
+
sel.value = String(value);
|
|
1400
|
+
sel.addEventListener('change', () => commit(sel.value));
|
|
1401
|
+
return sel;
|
|
1402
|
+
};
|
|
1403
|
+
const labelledRow = (label, ctrl) => h('div', { class: 'flex items-center gap-3' },
|
|
1404
|
+
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, label), ctrl);
|
|
1405
|
+
const volumeRow = () => sliderRow(L.themeBgVolume, L.themeBgVolumeHint, 0, 100, 1, Math.round(numOr(themeCfg.bg.videoVolume, 0) * 100), '%',
|
|
1406
|
+
(v) => { void saveTheme({ bg: { videoVolume: v / 100 } }); }, '');
|
|
1407
|
+
const rateRow = () => labelledRow(L.themeBgRate, h('div', { class: 'flex items-center gap-1' },
|
|
1408
|
+
numField(numOr(themeCfg.bg.playbackRate, 1), 0.5, 2, (v) => { void saveTheme({ bg: { playbackRate: v } }); }, '0.5-2', 0.25),
|
|
1409
|
+
h('span', { class: 'text-ui-sm text-foreground-subtle' }, 'x')));
|
|
1410
|
+
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']],
|
|
1411
|
+
(v) => { void saveTheme({ bg: { fpsCap: Number(v) } }); }));
|
|
1215
1412
|
paneStylesSub4.replaceChildren(
|
|
1216
1413
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.themeBgDesc),
|
|
1217
|
-
h('div', { class: '
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1414
|
+
card(L.themeBgSource, h('div', { class: 'flex flex-col gap-2' },
|
|
1415
|
+
h('div', { class: 'flex flex-wrap gap-1' },
|
|
1416
|
+
modeBtn('none', L.themeBgModeNone), modeBtn('library', L.themeBgModeLibrary),
|
|
1417
|
+
modeBtn('folder', L.themeBgModeFolder), modeBtn('url', L.themeBgModeUrl),
|
|
1418
|
+
modeBtn('web', L.themeBgModeWeb)),
|
|
1419
|
+
...modeArea)),
|
|
1420
|
+
card(L.themeBgImage, h('div', { class: 'grid grid-cols-2 gap-x-6 gap-y-2' },
|
|
1421
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
1422
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, L.themeBgFit),
|
|
1423
|
+
fitBtn('cover', L.themeBgFitCover), fitBtn('contain', L.themeBgFitContain),
|
|
1424
|
+
fitBtn('fill', L.themeBgFitFill), fitBtn('tile', L.themeBgFitTile)),
|
|
1425
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
1426
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground-subtle', style: 'width:72px' }, L.themeBgTransition),
|
|
1427
|
+
transBtn('cut', L.themeBgTransitionCut), transBtn('fade', L.themeBgTransitionFade)),
|
|
1428
|
+
h('div', { class: 'col-span-2' }, maskRow()),
|
|
1429
|
+
blurRow(), panelRow())),
|
|
1430
|
+
card(L.themeBgPlayback, h('div', { class: 'grid grid-cols-2 gap-x-6 gap-y-2' },
|
|
1431
|
+
h('div', { class: 'col-span-2' }, volumeRow()),
|
|
1432
|
+
rateRow(), fpsRow(),
|
|
1433
|
+
h('p', { class: 'col-span-2 text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgFpsHint))),
|
|
1434
|
+
card(L.themeBgRegions, h('div', { class: 'flex flex-col gap-2' },
|
|
1222
1435
|
regionRow('left', L.themeBgRegionLeft),
|
|
1223
1436
|
regionRow('center', L.themeBgRegionCenter),
|
|
1224
|
-
regionRow('right', L.themeBgRegionRight)
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1437
|
+
regionRow('right', L.themeBgRegionRight),
|
|
1438
|
+
h('p', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgRegionsHint))),
|
|
1439
|
+
card(L.themeBgMisc, h('div', { class: 'flex flex-col gap-2' },
|
|
1440
|
+
h('div', { class: 'flex flex-wrap items-center gap-x-4 gap-y-2' },
|
|
1441
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground-subtle' }, L.themeBgPause),
|
|
1442
|
+
pauseCheck('pauseOnHidden', L.themeBgPauseHidden),
|
|
1443
|
+
pauseCheck('pauseOnBlur', L.themeBgPauseBlur),
|
|
1444
|
+
pauseCheck('pauseOnBattery', L.themeBgPauseBattery)),
|
|
1445
|
+
dialogFrostRow())),
|
|
1231
1446
|
bgInput,
|
|
1232
1447
|
);
|
|
1233
1448
|
};
|
|
@@ -1236,13 +1451,13 @@ export function openSettingsDialog() {
|
|
|
1236
1451
|
void refreshBgFiles();
|
|
1237
1452
|
void refreshFolderInfo();
|
|
1238
1453
|
|
|
1239
|
-
let stylesSubTab = '
|
|
1454
|
+
let stylesSubTab = 'bgimg'; // 默认停在第一个子页(壁纸)
|
|
1240
1455
|
const stylesSubTablist = h('div', { role: 'tablist', 'aria-orientation': 'horizontal', class: 'zcodepro-tablist' });
|
|
1241
1456
|
const renderStylesSubTabs = () => stylesSubTablist.replaceChildren(...[
|
|
1457
|
+
['bgimg', L.themeBgPane],
|
|
1458
|
+
['colors', L.themeColorsPane],
|
|
1242
1459
|
['styles', L.tabStylesPane],
|
|
1243
1460
|
['status', L.tabStatusPane],
|
|
1244
|
-
['colors', L.themeColorsPane],
|
|
1245
|
-
['bgimg', L.themeBgPane],
|
|
1246
1461
|
].map(([id, label]) => h('button', {
|
|
1247
1462
|
type: 'button', role: 'tab', class: 'zcodepro-tab',
|
|
1248
1463
|
'aria-selected': String(stylesSubTab === id),
|
|
@@ -1257,7 +1472,8 @@ export function openSettingsDialog() {
|
|
|
1257
1472
|
},
|
|
1258
1473
|
}, label)));
|
|
1259
1474
|
renderStylesSubTabs();
|
|
1260
|
-
|
|
1475
|
+
subTabBars.styles = stylesSubTablist;
|
|
1476
|
+
paneStyles.append(paneStylesSub1, paneStylesSub2, paneStylesSub3, paneStylesSub4);
|
|
1261
1477
|
paneStylesSub1.append(
|
|
1262
1478
|
toolbarSwitchWrap,
|
|
1263
1479
|
h('div', { class: 'mt-2 flex flex-col gap-0.5 rounded-xl border border-border p-1' },
|
|
@@ -1297,16 +1513,138 @@ export function openSettingsDialog() {
|
|
|
1297
1513
|
const res = await rpc('/agents', { method: 'POST', body: { content: agentsArea.value } });
|
|
1298
1514
|
if (res.ok) {
|
|
1299
1515
|
agentsOriginal = typeof res.content === 'string' ? res.content : agentsArea.value;
|
|
1300
|
-
showToast(L.agentsSaved);
|
|
1516
|
+
showToast(L.agentsSaved, 'success');
|
|
1301
1517
|
} else {
|
|
1302
1518
|
showToast(L.failed + ': ' + errText(res), 'error');
|
|
1303
1519
|
agentsSaveBtn.disabled = false;
|
|
1304
1520
|
}
|
|
1305
1521
|
};
|
|
1306
|
-
//
|
|
1522
|
+
// “行为 → ZCode CLI”:zcode-cli 运行时的行为配置(写 ~/.zcode/cli/config.json)+
|
|
1523
|
+
// 技能清单检查。开关与预算数字框改动即存,每次只提交自己那个键;
|
|
1524
|
+
// 目录列表显式保存
|
|
1525
|
+
const paneZcode = h('div', { class: 'mt-2' });
|
|
1526
|
+
let snap = zcodeConfigRes;
|
|
1527
|
+
const setZcode = async (body) => {
|
|
1528
|
+
const res = await rpc('/zcode-config', { method: 'POST', body });
|
|
1529
|
+
if (!res.ok) {
|
|
1530
|
+
showToast(L.failed + ': ' + errText(res), 'error');
|
|
1531
|
+
return false;
|
|
1532
|
+
}
|
|
1533
|
+
snap = res;
|
|
1534
|
+
return true;
|
|
1535
|
+
};
|
|
1536
|
+
if (!snap.ok) {
|
|
1537
|
+
paneZcode.append(h('p', { class: 'mt-2 text-ui-sm text-destructive' }, L.failed + ': ' + errText(snap)));
|
|
1538
|
+
} else {
|
|
1539
|
+
const fmt = (n) => String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
1540
|
+
// —— 技能清单检查:完整清单字符数对照预算,超了就提示被降级 ——
|
|
1541
|
+
const countsEl = h('div', { class: 'text-ui-sm text-foreground' });
|
|
1542
|
+
const charsEl = h('div', { class: 'mt-0.5 text-ui-sm text-foreground' });
|
|
1543
|
+
const statusEl = h('div', { class: 'mt-0.5 text-ui-sm' });
|
|
1544
|
+
// —— 技能清单预算:数字框改动即存;“用建议值”写入并保存 ——
|
|
1545
|
+
const budgetField = numberField({
|
|
1546
|
+
value: snap.values.skills.metadataBudget,
|
|
1547
|
+
fallback: snap.stats.defaultBudget,
|
|
1548
|
+
min: 0,
|
|
1549
|
+
max: 1000000,
|
|
1550
|
+
step: 1000,
|
|
1551
|
+
onCommit: async (v) => {
|
|
1552
|
+
if (await setZcode({ skills: { metadataBudget: v } })) renderStats();
|
|
1553
|
+
},
|
|
1554
|
+
});
|
|
1555
|
+
const budgetTag = h('span', { class: 'text-ui-xs text-foreground-subtle' });
|
|
1556
|
+
const suggestEl = h('div', { class: 'min-w-0 flex-1 text-ui-xs/relaxed text-foreground-subtle' });
|
|
1557
|
+
const renderStats = () => {
|
|
1558
|
+
countsEl.textContent = L.zcodeStatsCounts
|
|
1559
|
+
.replaceAll('{total}', fmt(snap.stats.total))
|
|
1560
|
+
.replaceAll('{user}', fmt(snap.stats.userCount))
|
|
1561
|
+
.replaceAll('{plugin}', fmt(snap.stats.pluginCount));
|
|
1562
|
+
charsEl.textContent = L.zcodeStatsChars.replaceAll('{n}', fmt(snap.stats.fullChars));
|
|
1563
|
+
statusEl.textContent = snap.stats.degraded ? L.zcodeStatsDegraded : L.zcodeStatsOk;
|
|
1564
|
+
statusEl.className = 'mt-0.5 text-ui-sm ' + (snap.stats.degraded ? 'text-destructive' : 'text-foreground');
|
|
1565
|
+
budgetTag.textContent = snap.configured.skills.metadataBudget ? '' : L.zcodeBudgetDefaultTag;
|
|
1566
|
+
suggestEl.textContent = L.zcodeStatsSuggest.replaceAll('{n}', fmt(snap.stats.suggested));
|
|
1567
|
+
};
|
|
1568
|
+
const applyBtn = btnSmall(L.zcodeBudgetApply, async () => {
|
|
1569
|
+
if (await setZcode({ skills: { metadataBudget: snap.stats.suggested } })) {
|
|
1570
|
+
budgetField.set(snap.values.skills.metadataBudget);
|
|
1571
|
+
renderStats();
|
|
1572
|
+
showToast(L.zcodeBudgetApplied, 'success');
|
|
1573
|
+
}
|
|
1574
|
+
}, 'shrink-0');
|
|
1575
|
+
// 检查与预算同一行两个块
|
|
1576
|
+
const statsBudgetRow = h('div', { class: 'mt-2 flex items-stretch gap-2' },
|
|
1577
|
+
h('div', { class: 'flex min-w-0 flex-1 flex-col rounded-xl border border-border p-3' },
|
|
1578
|
+
h('div', { class: 'text-ui-sm font-medium' }, L.zcodeStatsTitle),
|
|
1579
|
+
countsEl, charsEl, statusEl,
|
|
1580
|
+
h('div', { class: 'mt-1 text-ui-xs/relaxed text-foreground-subtle' }, L.zcodeStatsNote)),
|
|
1581
|
+
h('div', { class: 'flex min-w-0 flex-1 flex-col rounded-xl border border-border p-3' },
|
|
1582
|
+
h('div', { class: 'text-ui-sm font-medium' }, L.zcodeSkillBudget),
|
|
1583
|
+
h('div', { class: 'mt-0.5 text-ui-xs/relaxed text-foreground-subtle' }, L.zcodeSkillBudgetDesc),
|
|
1584
|
+
h('div', { class: 'mt-2 flex items-center gap-1' }, budgetField.el, budgetTag),
|
|
1585
|
+
h('div', { class: 'mt-1 flex items-center gap-2' }, suggestEl, applyBtn)));
|
|
1586
|
+
// —— 开关组:skills / features 两段配置键,点一次只写一个键 ——
|
|
1587
|
+
const togglesWrap = h('div', { class: 'mt-2 flex flex-col gap-0.5 rounded-xl border border-border p-1' });
|
|
1588
|
+
const renderToggles = () => {
|
|
1589
|
+
const v = snap.values;
|
|
1590
|
+
const row = (name, desc, checked, patch) => settingRow(name, desc, checked, async () => {
|
|
1591
|
+
if (await setZcode(patch(!checked))) renderToggles();
|
|
1592
|
+
});
|
|
1593
|
+
// 分组标题省略:每行描述都带 skills./features. 键名前缀,分组名是重复信息
|
|
1594
|
+
togglesWrap.replaceChildren(
|
|
1595
|
+
row(L.zcodeSkillEnabled, L.zcodeSkillEnabledDesc, v.skills.enabled, (n) => ({ skills: { enabled: n } })),
|
|
1596
|
+
row(L.zcodeSkillIncludeInstructions, L.zcodeSkillIncludeInstructionsDesc, v.skills.includeInstructions, (n) => ({ skills: { includeInstructions: n } })),
|
|
1597
|
+
row(L.zcodeFeatCompact, L.zcodeFeatCompactDesc, v.features.compact, (n) => ({ features: { compact: n } })),
|
|
1598
|
+
row(L.zcodeFeatRewind, L.zcodeFeatRewindDesc, v.features.rewind, (n) => ({ features: { rewind: n } })),
|
|
1599
|
+
row(L.zcodeFeatSubagent, L.zcodeFeatSubagentDesc, v.features.subagent, (n) => ({ features: { subagent: n } })),
|
|
1600
|
+
row(L.zcodeFeatSkill, L.zcodeFeatSkillDesc, v.features.skill, (n) => ({ features: { skill: n } })),
|
|
1601
|
+
row(L.zcodeFeatMcp, L.zcodeFeatMcpDesc, v.features.mcp, (n) => ({ features: { mcp: n } })),
|
|
1602
|
+
// 记忆不放这里:官方“工作区记忆”是桌面设置里的 memoryEnabled
|
|
1603
|
+
// (~/.zcode/v2/setting.json),与本页写的 agent 配置不是同一层开关
|
|
1604
|
+
h('div', { class: 'px-2 pb-1 pt-1 text-ui-xs/relaxed text-foreground-subtle' }, L.zcodeMemoryHint),
|
|
1605
|
+
);
|
|
1606
|
+
};
|
|
1607
|
+
// —— 额外技能目录:多行文本,显式保存 ——
|
|
1608
|
+
const rootsArea = h('textarea', {
|
|
1609
|
+
class: 'zcodepro-textarea zcodepro-textarea-sm',
|
|
1610
|
+
rows: 3,
|
|
1611
|
+
spellcheck: 'false',
|
|
1612
|
+
placeholder: '/path/to/skills',
|
|
1613
|
+
});
|
|
1614
|
+
let rootsOriginal = snap.values.skills.roots.join('\n');
|
|
1615
|
+
rootsArea.value = rootsOriginal;
|
|
1616
|
+
const rootsSaveBtn = btnSmall(L.zcodeSave, async () => {
|
|
1617
|
+
rootsSaveBtn.disabled = true;
|
|
1618
|
+
const lines = rootsArea.value.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
1619
|
+
if (await setZcode({ skills: { roots: lines } })) {
|
|
1620
|
+
rootsOriginal = snap.values.skills.roots.join('\n');
|
|
1621
|
+
renderStats(); // 目录影响清单统计
|
|
1622
|
+
showToast(L.zcodeRootsSaved, 'success');
|
|
1623
|
+
} else {
|
|
1624
|
+
rootsSaveBtn.disabled = false;
|
|
1625
|
+
}
|
|
1626
|
+
}, 'shrink-0', 'primary');
|
|
1627
|
+
rootsSaveBtn.disabled = true;
|
|
1628
|
+
rootsArea.addEventListener('input', () => {
|
|
1629
|
+
rootsSaveBtn.disabled = rootsArea.value === rootsOriginal;
|
|
1630
|
+
});
|
|
1631
|
+
renderStats();
|
|
1632
|
+
renderToggles();
|
|
1633
|
+
paneZcode.append(
|
|
1634
|
+
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.zcodeDesc),
|
|
1635
|
+
statsBudgetRow,
|
|
1636
|
+
togglesWrap,
|
|
1637
|
+
h('div', { class: 'mt-2 rounded-xl border border-border p-2' },
|
|
1638
|
+
h('div', { class: 'text-ui-sm font-medium text-foreground' }, L.zcodeSkillRoots),
|
|
1639
|
+
h('div', { class: 'mt-0.5 text-ui-xs/relaxed text-foreground-subtle' }, L.zcodeSkillRootsDesc),
|
|
1640
|
+
h('div', { class: 'mt-2' }, rootsArea),
|
|
1641
|
+
h('div', { class: 'mt-2 flex justify-end' }, rootsSaveBtn)),
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
// “行为”标签页:二级标签切换“ZCode / 全局提示词 / 任务名”。全局提示词编辑
|
|
1307
1645
|
// ~/.zcode/AGENTS.md;任务名(智能起名)面板复用 paneTitleGen(原本是
|
|
1308
1646
|
// 一级标签页,收进来后不再单独出现在顶部标签栏)
|
|
1309
|
-
const agentsPromptPane = h('div', { class: 'mt-
|
|
1647
|
+
const agentsPromptPane = h('div', { class: 'mt-2' });
|
|
1310
1648
|
agentsPromptPane.append(
|
|
1311
1649
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.agentsDesc),
|
|
1312
1650
|
...(agentsFailed
|
|
@@ -1315,11 +1653,12 @@ export function openSettingsDialog() {
|
|
|
1315
1653
|
h('div', { class: 'mt-3' }, agentsArea),
|
|
1316
1654
|
h('div', { class: 'mt-3 flex justify-end' }, agentsSaveBtn),
|
|
1317
1655
|
);
|
|
1318
|
-
let agentsSubTab = '
|
|
1319
|
-
const agentsSubPanes = { prompt: agentsPromptPane, titleGen: paneTitleGen };
|
|
1656
|
+
let agentsSubTab = 'zcode';
|
|
1657
|
+
const agentsSubPanes = { zcode: paneZcode, prompt: agentsPromptPane, titleGen: paneTitleGen };
|
|
1320
1658
|
const agentsSubList = h('div', { role: 'tablist', 'aria-orientation': 'horizontal', class: 'zcodepro-tablist' });
|
|
1321
1659
|
const renderAgentsSubTabs = () => {
|
|
1322
1660
|
agentsSubList.replaceChildren(...[
|
|
1661
|
+
['zcode', L.tabZcode],
|
|
1323
1662
|
['prompt', L.tabAgents],
|
|
1324
1663
|
['titleGen', L.tabTitleGen],
|
|
1325
1664
|
].map(([id, label]) => h('button', {
|
|
@@ -1335,7 +1674,8 @@ export function openSettingsDialog() {
|
|
|
1335
1674
|
};
|
|
1336
1675
|
for (const [pid, pane] of Object.entries(agentsSubPanes)) pane.style.display = pid === agentsSubTab ? '' : 'none';
|
|
1337
1676
|
renderAgentsSubTabs();
|
|
1338
|
-
|
|
1677
|
+
subTabBars.agents = agentsSubList;
|
|
1678
|
+
paneAgents.append(paneZcode, agentsPromptPane, paneTitleGen);
|
|
1339
1679
|
|
|
1340
1680
|
// “代理”:为 helper 发起的网络访问(插件市场更新/安装、headroom 本体升级)设
|
|
1341
1681
|
// HTTP 代理;保存即生效(helper 子进程环境变量注入),不影响 ZCode 应用与模型请求。
|
|
@@ -1355,7 +1695,7 @@ export function openSettingsDialog() {
|
|
|
1355
1695
|
if (res.ok) {
|
|
1356
1696
|
proxyOriginal = res.config && typeof res.config.proxy === 'string' ? res.config.proxy : proxyInput.value.trim();
|
|
1357
1697
|
proxyInput.value = proxyOriginal;
|
|
1358
|
-
showToast(L.proxySaved);
|
|
1698
|
+
showToast(L.proxySaved, 'success');
|
|
1359
1699
|
} else {
|
|
1360
1700
|
proxySaveBtn.disabled = false;
|
|
1361
1701
|
showToast(L.failed + ': ' + errText(res), 'error');
|
|
@@ -1452,25 +1792,30 @@ export function openSettingsDialog() {
|
|
|
1452
1792
|
renderPerfToggle();
|
|
1453
1793
|
const perfNumberRow = (labelText, tip, key, fallback, min) => {
|
|
1454
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
|
+
});
|
|
1455
1813
|
return h('div', { class: 'flex items-center justify-between gap-2 px-2 py-1.5' },
|
|
1456
1814
|
h('div', { class: 'min-w-0' },
|
|
1457
1815
|
h('div', { class: 'text-ui-sm font-medium text-foreground' }, labelText),
|
|
1458
1816
|
...(tip ? [h('div', { class: 'mt-0.5 text-ui-xs/relaxed text-foreground-subtle' }, tip)] : [])),
|
|
1459
1817
|
h('div', { class: 'flex shrink-0 items-center gap-1' },
|
|
1460
|
-
|
|
1461
|
-
value: Number.isFinite(v) ? v : fallback,
|
|
1462
|
-
fallback,
|
|
1463
|
-
min,
|
|
1464
|
-
max: 1440,
|
|
1465
|
-
step: 1,
|
|
1466
|
-
onCommit: async (n) => {
|
|
1467
|
-
const res = await rpc('/config', { method: 'POST', body: { [key]: n } });
|
|
1468
|
-
if (res.ok && res.config) {
|
|
1469
|
-
config[key] = res.config[key];
|
|
1470
|
-
clearConfigCache();
|
|
1471
|
-
}
|
|
1472
|
-
},
|
|
1473
|
-
}).el,
|
|
1818
|
+
nf.el,
|
|
1474
1819
|
h('span', { class: 'text-ui-xs text-foreground-subtle' }, L.idleReclaimUnit)));
|
|
1475
1820
|
};
|
|
1476
1821
|
panePerf.append(
|
|
@@ -1550,7 +1895,7 @@ export function openSettingsDialog() {
|
|
|
1550
1895
|
syncLoginInput.value = res.sync.login;
|
|
1551
1896
|
syncPasswordInput.value = res.sync.password;
|
|
1552
1897
|
syncHistoryInput.value = syncFormOriginal.historyLimit;
|
|
1553
|
-
showToast(L.syncSaved);
|
|
1898
|
+
showToast(L.syncSaved, 'success');
|
|
1554
1899
|
} else {
|
|
1555
1900
|
showToast(L.failed + ': ' + errText(res), 'error');
|
|
1556
1901
|
syncCheckDirty();
|
|
@@ -1894,7 +2239,7 @@ export function openSettingsDialog() {
|
|
|
1894
2239
|
compressThresholdKB: 1024,
|
|
1895
2240
|
skipAfterFailures: 2,
|
|
1896
2241
|
skipMinutes: 30,
|
|
1897
|
-
forceIntercept
|
|
2242
|
+
// forceIntercept 不写:缺省 = 自动(跟随宿主「模型设置」图片开关,zcode-vision ≥1.7.9)
|
|
1898
2243
|
};
|
|
1899
2244
|
let visionCfg = visionRes.ok && visionRes.config && typeof visionRes.config === 'object'
|
|
1900
2245
|
? structuredClone(visionRes.config)
|
|
@@ -1988,7 +2333,7 @@ export function openSettingsDialog() {
|
|
|
1988
2333
|
// 信息卡(仅版本行;配置未建,启用开关随配置出现)
|
|
1989
2334
|
h('div', { class: 'mt-3 rounded-xl border border-border p-2' },
|
|
1990
2335
|
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
1991
|
-
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-xs/relaxed text-foreground-subtle' },
|
|
2336
|
+
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-xs/relaxed text-foreground-subtle' }, `${L.pluginLabel} ${visionRes.pluginVersion || '—'}`))),
|
|
1992
2337
|
h('div', { class: 'mt-3 flex justify-end' }, initBtn),
|
|
1993
2338
|
);
|
|
1994
2339
|
return;
|
|
@@ -2105,40 +2450,51 @@ export function openSettingsDialog() {
|
|
|
2105
2450
|
const res = await rpc('/vision/test', { method: 'POST', body: {} });
|
|
2106
2451
|
testBtn.disabled = false;
|
|
2107
2452
|
testBtn.textContent = L.visionTest;
|
|
2108
|
-
visionTestPre.textContent = res.output || res
|
|
2453
|
+
visionTestPre.textContent = res.output || errText(res) || '';
|
|
2109
2454
|
});
|
|
2110
2455
|
paneVision.replaceChildren(
|
|
2111
2456
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.visionDesc),
|
|
2112
2457
|
// 信息卡:插件版本 + 启用图片识别开关(与 rtk/headroom 面板同款式)
|
|
2113
2458
|
h('div', { class: 'mt-3 rounded-xl border border-border p-2' },
|
|
2114
2459
|
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
2115
|
-
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-xs/relaxed text-foreground-subtle' },
|
|
2460
|
+
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-xs/relaxed text-foreground-subtle' }, `${L.pluginLabel} ${visionRes.pluginVersion || '—'}`),
|
|
2116
2461
|
h('div', { class: 'ml-auto' },
|
|
2117
2462
|
settingRow(L.visionEnabled, '', visionCfg.enabled !== false, async () => {
|
|
2118
2463
|
visionCfg.enabled = !(visionCfg.enabled !== false);
|
|
2119
2464
|
await persistVision();
|
|
2120
2465
|
renderVision();
|
|
2121
2466
|
})))),
|
|
2122
|
-
// 链模式
|
|
2123
|
-
h('div', { class: 'mt-3
|
|
2124
|
-
h('
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2467
|
+
// 链模式 / 主模型策略 / 识图卡片 三项均分一行、各格内容左对齐(启用开关已上移信息卡)
|
|
2468
|
+
h('div', { class: 'mt-3 grid grid-cols-1 items-center gap-1.5 rounded-xl border border-border p-2 sm:grid-cols-3' },
|
|
2469
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
2470
|
+
h('span', { class: 'shrink-0 text-ui-sm font-medium text-foreground' }, L.visionMode),
|
|
2471
|
+
modeBtn('fallback', L.visionModeFallback, L.visionModeFallbackDesc),
|
|
2472
|
+
modeBtn('pipeline', L.visionModePipeline, L.visionModePipelineDesc),
|
|
2473
|
+
),
|
|
2474
|
+
(() => {
|
|
2475
|
+
// 三态:不能识图就使用插件(null,POST 侧删键恢复插件缺省联动)/ 始终使用插件 / 不使用插件
|
|
2476
|
+
const sel = h('select', { class: 'h-8 rounded-lg border border-border bg-input px-2 text-ui-sm text-foreground outline-none', title: L.visionForceInterceptHint },
|
|
2477
|
+
h('option', { value: 'auto' }, L.visionForceInterceptAuto),
|
|
2478
|
+
h('option', { value: 'true' }, L.visionForceInterceptTrue),
|
|
2479
|
+
h('option', { value: 'false' }, L.visionForceInterceptFalse));
|
|
2480
|
+
sel.value = visionCfg.forceIntercept === true ? 'true' : visionCfg.forceIntercept === false ? 'false' : 'auto';
|
|
2481
|
+
sel.addEventListener('change', () => {
|
|
2482
|
+
visionCfg.forceIntercept = sel.value === 'true' ? true : sel.value === 'false' ? false : null;
|
|
2483
|
+
void persistVision();
|
|
2484
|
+
});
|
|
2485
|
+
return h('label', { class: 'flex items-center gap-1.5', title: L.visionForceInterceptHint },
|
|
2486
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground' }, L.visionForceIntercept), sel);
|
|
2487
|
+
})(),
|
|
2488
|
+
h('div', { class: 'flex items-center' },
|
|
2128
2489
|
settingRow(L.visionCardUi, '', visionCfg.cardUi !== false, async () => {
|
|
2129
2490
|
visionCfg.cardUi = !(visionCfg.cardUi !== false);
|
|
2130
2491
|
await persistVision();
|
|
2131
2492
|
renderVision();
|
|
2132
2493
|
}),
|
|
2133
|
-
settingRow(L.visionForceIntercept, '', visionCfg.forceIntercept !== false, async () => {
|
|
2134
|
-
visionCfg.forceIntercept = !(visionCfg.forceIntercept !== false);
|
|
2135
|
-
await persistVision();
|
|
2136
|
-
renderVision();
|
|
2137
|
-
}),
|
|
2138
2494
|
),
|
|
2139
2495
|
),
|
|
2140
|
-
// 压缩阈值 / 连续失败次数 / 跳过分钟数
|
|
2141
|
-
h('div', { class: 'mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 rounded-xl border border-border p-
|
|
2496
|
+
// 压缩阈值 / 连续失败次数 / 跳过分钟数 三个数字一行(p-2 与上方信息卡对齐)
|
|
2497
|
+
h('div', { class: 'mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 rounded-xl border border-border p-2' },
|
|
2142
2498
|
(() => {
|
|
2143
2499
|
const n = h('input', { type: 'number', min: '0', step: '128', title: L.visionCompressKBHint,
|
|
2144
2500
|
class: 'h-7 w-16 rounded-lg border border-border bg-input px-2 text-right text-ui-xs tabular-nums text-foreground outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40' });
|
|
@@ -2204,7 +2560,7 @@ export function openSettingsDialog() {
|
|
|
2204
2560
|
let rtkLocText = '';
|
|
2205
2561
|
const renderRtkVersion = (meta) => {
|
|
2206
2562
|
const v = String(meta.version || '').replace(/^rtk\s+/i, '').trim();
|
|
2207
|
-
rtkVersionLine.textContent =
|
|
2563
|
+
rtkVersionLine.textContent = `${L.pluginLabel} ${meta.pluginVersion || '—'}${v ? ` · rtk ${v}` : ''}`;
|
|
2208
2564
|
rtkLocText = meta.binPath || '';
|
|
2209
2565
|
};
|
|
2210
2566
|
renderRtkVersion(rtkRes);
|
|
@@ -2279,7 +2635,7 @@ export function openSettingsDialog() {
|
|
|
2279
2635
|
const v = input.value.trim();
|
|
2280
2636
|
if (!v) return;
|
|
2281
2637
|
if (!/^(git:)?[A-Za-z0-9._-]+$/.test(v) || rtkCfg.whitelist.includes(v)) {
|
|
2282
|
-
showToast(L.rtkWhitelistInvalid, '
|
|
2638
|
+
showToast(L.rtkWhitelistInvalid, 'warning');
|
|
2283
2639
|
return;
|
|
2284
2640
|
}
|
|
2285
2641
|
if (await persistRtk({ whitelist: [...rtkCfg.whitelist, v] })) {
|
|
@@ -2382,7 +2738,7 @@ export function openSettingsDialog() {
|
|
|
2382
2738
|
if (await persistRtk({ whitelist: [] })) {
|
|
2383
2739
|
rtkCfg.whitelist = [];
|
|
2384
2740
|
renderRtk();
|
|
2385
|
-
showToast(L.rtkWhitelistCleared);
|
|
2741
|
+
showToast(L.rtkWhitelistCleared, 'success');
|
|
2386
2742
|
}
|
|
2387
2743
|
})();
|
|
2388
2744
|
}, 'shrink-0'))),
|
|
@@ -2401,7 +2757,7 @@ export function openSettingsDialog() {
|
|
|
2401
2757
|
// 关 = 直连上游;只改供应商地址,不动代理进程(headroom 可被其他程序共用)
|
|
2402
2758
|
const hrSwitchRow = h('div');
|
|
2403
2759
|
const renderHrVersion = (meta) => {
|
|
2404
|
-
hrVersionLine.textContent =
|
|
2760
|
+
hrVersionLine.textContent = `${L.pluginLabel} ${meta.pluginVersion || '—'}${meta.version ? ` · headroom ${meta.version}` : ''}`;
|
|
2405
2761
|
hrLocText = meta.binPath || '';
|
|
2406
2762
|
};
|
|
2407
2763
|
renderHrVersion(headroomRes);
|
|
@@ -2484,10 +2840,10 @@ export function openSettingsDialog() {
|
|
|
2484
2840
|
const doneMsg = isStart ? L.hrStarted : L.hrStopped;
|
|
2485
2841
|
const timeoutMs = isStart ? 90 * 1000 : 30 * 1000;
|
|
2486
2842
|
const t0 = Date.now();
|
|
2487
|
-
const timerSpan = h('span', { class: 'text-ui-sm text-foreground-subtle/70' }, msg + ' (0s)');
|
|
2843
|
+
const timerSpan = h('span', { class: 'text-ui-sm text-foreground-subtle/70' }, msg + (isZhLocale() ? '(0s)' : ' (0s)'));
|
|
2488
2844
|
hrStatusLine.replaceChildren(timerSpan);
|
|
2489
2845
|
timerIv = setInterval(() => {
|
|
2490
|
-
timerSpan.textContent = msg + ` (${Math.round((Date.now() - t0) / 1000)}s)
|
|
2846
|
+
timerSpan.textContent = msg + (isZhLocale() ? `(${Math.round((Date.now() - t0) / 1000)}s)` : ` (${Math.round((Date.now() - t0) / 1000)}s)`);
|
|
2491
2847
|
}, 1000);
|
|
2492
2848
|
// RPC 完成后进入轮询(RPC 执行实际的 stop/start,可能要 3-10 秒)。
|
|
2493
2849
|
// 轮询出结果前 hrBusy 一直占着:期间再点开关或按钮直接忽略,否则
|
|
@@ -2504,7 +2860,7 @@ export function openSettingsDialog() {
|
|
|
2504
2860
|
clearInterval(timerIv);
|
|
2505
2861
|
hrBusy = false;
|
|
2506
2862
|
await hrRefresh();
|
|
2507
|
-
showToast(doneMsg,
|
|
2863
|
+
showToast(doneMsg, 'success');
|
|
2508
2864
|
return;
|
|
2509
2865
|
}
|
|
2510
2866
|
}
|
|
@@ -2523,7 +2879,7 @@ export function openSettingsDialog() {
|
|
|
2523
2879
|
return false;
|
|
2524
2880
|
}
|
|
2525
2881
|
if (res.config) Object.assign(hrCfg, res.config);
|
|
2526
|
-
if (warn) showToast(warn);
|
|
2882
|
+
if (warn) showToast(warn, 'warning');
|
|
2527
2883
|
// 非生命周期动作(backend/power):稍等后刷一次
|
|
2528
2884
|
if (!isStart && !isStop) {
|
|
2529
2885
|
hrBusy = false;
|
|
@@ -2592,7 +2948,7 @@ export function openSettingsDialog() {
|
|
|
2592
2948
|
}
|
|
2593
2949
|
if (res.usage) headroomRes.usage = res.usage;
|
|
2594
2950
|
renderHrUsageSwitch();
|
|
2595
|
-
if (next && !res.changed && !(res.usage && res.usage.enabled)) showToast(L.hrUsageNone);
|
|
2951
|
+
if (next && !res.changed && !(res.usage && res.usage.enabled)) showToast(L.hrUsageNone, 'warning');
|
|
2596
2952
|
}));
|
|
2597
2953
|
};
|
|
2598
2954
|
renderHrUsageSwitch();
|
|
@@ -2792,7 +3148,7 @@ export function openSettingsDialog() {
|
|
|
2792
3148
|
if (!titleGenCfg) {
|
|
2793
3149
|
paneTitleGen.replaceChildren(
|
|
2794
3150
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.titleGenShortDesc),
|
|
2795
|
-
h('p', { class: 'mt-2 text-ui-sm text-destructive' }, L.
|
|
3151
|
+
h('p', { class: 'mt-2 text-ui-sm text-destructive' }, L.titleGenLoadFailed + ': ' + errText(titleGenRes)),
|
|
2796
3152
|
);
|
|
2797
3153
|
return;
|
|
2798
3154
|
}
|
|
@@ -2909,6 +3265,28 @@ export function openSettingsDialog() {
|
|
|
2909
3265
|
promptArea.focus();
|
|
2910
3266
|
})),
|
|
2911
3267
|
promptArea),
|
|
3268
|
+
// 手动重命名:任务行悬浮按钮 / 右键菜单两个入口的开关 + 起名素材轮数
|
|
3269
|
+
h('div', { class: 'mt-2 rounded-xl border border-border p-2' },
|
|
3270
|
+
h('div', { class: 'mb-1 text-ui-xs font-medium text-foreground-subtle' }, L.titleGenManual),
|
|
3271
|
+
settingRow(L.titleGenHoverBtn, L.titleGenHoverBtnDesc, titleGenCfg.hoverBtn !== false, () => {
|
|
3272
|
+
titleGenCfg.hoverBtn = !(titleGenCfg.hoverBtn !== false);
|
|
3273
|
+
void persistTitleGen();
|
|
3274
|
+
renderTitleGenPane();
|
|
3275
|
+
}),
|
|
3276
|
+
settingRow(L.titleGenMenuEntry, L.titleGenMenuEntryDesc, titleGenCfg.menuEntry !== false, () => {
|
|
3277
|
+
titleGenCfg.menuEntry = !(titleGenCfg.menuEntry !== false);
|
|
3278
|
+
void persistTitleGen();
|
|
3279
|
+
renderTitleGenPane();
|
|
3280
|
+
}),
|
|
3281
|
+
h('div', { class: 'flex items-center gap-2 rounded-lg p-1.5' },
|
|
3282
|
+
h('div', { class: 'min-w-0 flex-1' },
|
|
3283
|
+
h('div', { class: 'text-ui-sm font-medium text-foreground' }, L.titleGenRecentQa),
|
|
3284
|
+
h('div', { class: 'mt-0.5 text-ui-xs/relaxed text-foreground-subtle' }, L.titleGenRecentQaDesc)),
|
|
3285
|
+
numberField({
|
|
3286
|
+
value: Number.isFinite(Number(titleGenCfg.recentQa)) ? Number(titleGenCfg.recentQa) : 3,
|
|
3287
|
+
fallback: 3, min: 1, max: 20, step: 1,
|
|
3288
|
+
onCommit: (v) => { titleGenCfg.recentQa = v; saveTitleGenSoon(); },
|
|
3289
|
+
}).el)),
|
|
2912
3290
|
// 测试(两行:输入框整行;说明 + 按钮一行。结果只显示在本区下方,
|
|
2913
3291
|
// 不弹窗;从没对话过时的引导见 testState 错误文案)
|
|
2914
3292
|
h('div', { class: 'mt-2 rounded-xl border border-border p-2' },
|
|
@@ -2921,9 +3299,17 @@ export function openSettingsDialog() {
|
|
|
2921
3299
|
};
|
|
2922
3300
|
renderTitleGenPane();
|
|
2923
3301
|
|
|
3302
|
+
// 一级 / 二级 tab 放到滚动区(body)之上的固定区:内容滚动时标题、
|
|
3303
|
+
// 版本行(已并入标题行)与两级 tab 始终可见
|
|
3304
|
+
const subTabHost = h('div', { class: 'mt-2' });
|
|
3305
|
+
for (const bar of Object.values(subTabBars)) {
|
|
3306
|
+
bar.style.display = 'none';
|
|
3307
|
+
subTabHost.append(bar);
|
|
3308
|
+
}
|
|
3309
|
+
// flex-col:两个 tab 栏都是 inline-flex,走块布局会在栏下垫出基线空隙;
|
|
3310
|
+
// items-start:不拉伸子项,tab 栏胶囊底色保持内容宽度
|
|
3311
|
+
content.insertBefore(h('div', { class: 'flex flex-col items-start' }, tablist, subTabHost), body);
|
|
2924
3312
|
body.append(
|
|
2925
|
-
statusLine,
|
|
2926
|
-
tablist,
|
|
2927
3313
|
paneFeatures,
|
|
2928
3314
|
paneShortcuts,
|
|
2929
3315
|
paneAgents,
|