zcode-pro 1.5.1 → 1.6.1
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 +3 -1
- package/README.md +4 -2
- package/dist/inject.js +1261 -268
- package/package.json +2 -2
- package/src/host/helper.mjs +667 -89
- package/src/host/main.mjs +53 -5
- package/src/host/setup.mjs +3 -3
- package/src/host/skill-stats.mjs +158 -0
- package/src/host/wallpaper.mjs +311 -0
- package/src/inject/core.js +142 -36
- package/src/inject/features/alias-migration.js +3 -3
- package/src/inject/features/alias.js +2 -2
- 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 +3 -1
- package/src/inject/features/image-menu.js +2 -2
- package/src/inject/features/newtab-panels.js +2 -2
- package/src/inject/features/project-menu.js +1 -1
- package/src/inject/features/relocate-dialog.js +2 -1
- package/src/inject/features/session-switch.js +4 -4
- package/src/inject/features/settings-dialog.js +343 -89
- package/src/inject/features/task-order.js +1 -1
- package/src/inject/features/theme.js +586 -98
- package/src/inject/features/ws-running.js +6 -0
- package/src/inject/index.js +13 -1
- package/src/inject/ui.js +85 -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(); });
|
|
@@ -461,15 +471,17 @@ export function openSettingsDialog() {
|
|
|
461
471
|
communityCard(L.wechatGroupTitle, L.wechatGroupDesc.replaceAll('{id}', WECHAT_ID),
|
|
462
472
|
() => hCopyIcon('size-4 shrink-0 text-foreground-subtle'),
|
|
463
473
|
async () => {
|
|
464
|
-
if (await copyToClipboard(WECHAT_ID)) showToast(L.wechatIdCopied);
|
|
474
|
+
if (await copyToClipboard(WECHAT_ID)) showToast(L.wechatIdCopied, 'success');
|
|
465
475
|
}));
|
|
466
476
|
|
|
467
477
|
// 标签页切换:功能(现有内容)/ 外观 / 全局提示词 / 视觉代理
|
|
468
478
|
let activeTab = 'features';
|
|
479
|
+
// 二级 tab 栏(外观 / 行为各一条):登记后统一放到滚动区上方的固定区
|
|
480
|
+
const subTabBars = {};
|
|
469
481
|
// 插件更新卡片:显示 duanluan-zcode-plugins 市场状态,一键更新(helper /plugins/* 端点);
|
|
470
482
|
// 状态异步加载,打开弹窗不等待
|
|
471
483
|
|
|
472
|
-
const paneFeatures = h('div', { role: 'tabpanel', class: 'mt-
|
|
484
|
+
const paneFeatures = h('div', { role: 'tabpanel', class: 'mt-2' },
|
|
473
485
|
h('div', {}, rows),
|
|
474
486
|
communityCards,
|
|
475
487
|
);
|
|
@@ -522,12 +534,12 @@ export function openSettingsDialog() {
|
|
|
522
534
|
e.stopImmediatePropagation();
|
|
523
535
|
if (e.key === 'Escape') { stopHkRecording(); return; }
|
|
524
536
|
const k = e.key.toLowerCase();
|
|
525
|
-
if (!/^[a-z0-9]$/.test(k)) { showToast(L.hkInvalid, '
|
|
537
|
+
if (!/^[a-z0-9]$/.test(k)) { showToast(L.hkInvalid, 'warning'); return; }
|
|
526
538
|
const keys = hkKeys();
|
|
527
539
|
const names = hkNames();
|
|
528
540
|
const conflict = HK_ACTIONS.find(([a]) => a !== hkRecording && keys[a] === k);
|
|
529
541
|
if (conflict) {
|
|
530
|
-
showToast(L.hkConflict.replaceAll('{k}', k).replaceAll('{name}', names[conflict[0]]), '
|
|
542
|
+
showToast(L.hkConflict.replaceAll('{k}', k).replaceAll('{name}', names[conflict[0]]), 'warning');
|
|
531
543
|
return;
|
|
532
544
|
}
|
|
533
545
|
const a = hkRecording;
|
|
@@ -562,23 +574,23 @@ export function openSettingsDialog() {
|
|
|
562
574
|
refreshRows(); // 功能标签页的开关描述跟随默认键位
|
|
563
575
|
renderShortcuts();
|
|
564
576
|
};
|
|
565
|
-
const paneShortcuts = h('div', { role: 'tabpanel',
|
|
577
|
+
const paneShortcuts = h('div', { role: 'tabpanel', style: 'display:none' },
|
|
566
578
|
h('div', { class: 'mb-2 text-ui-sm font-medium' }, L.hkTitle),
|
|
567
579
|
h('div', { class: 'mb-2 flex items-center gap-2' },
|
|
568
580
|
h('div', { class: 'min-w-0 flex-1 text-ui-xs/relaxed text-foreground-subtle' }, L.hkEditHint),
|
|
569
581
|
h('div', { class: 'shrink-0' }, btnSmall(L.hkReset, () => { void resetShortcuts(); }))),
|
|
570
582
|
hkCard,
|
|
571
583
|
);
|
|
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',
|
|
584
|
+
const paneStyles = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
585
|
+
const panePerf = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
586
|
+
const paneAgents = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
587
|
+
const paneProxy = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
588
|
+
const paneSync = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
589
|
+
const paneVision = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
590
|
+
const paneRtk = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
591
|
+
const paneHeadroom = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
592
|
+
const paneTitleGen = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
593
|
+
const paneDebug = h('div', { role: 'tabpanel', style: 'display:none' });
|
|
582
594
|
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
595
|
// 一级 tab 顺序:功能 → 外观 → 行为 → 性能 → 快捷键 → 代理/同步/插件页
|
|
584
596
|
const tabDefs = [
|
|
@@ -609,6 +621,7 @@ export function openSettingsDialog() {
|
|
|
609
621
|
// 切走“快捷键”标签页时结束键位录制:否则在其它标签页打字会被录制监听吞掉
|
|
610
622
|
if (name !== 'shortcuts' && hkRecording) stopHkRecording();
|
|
611
623
|
for (const [id, pane] of Object.entries(panes)) pane.style.display = id === name ? '' : 'none';
|
|
624
|
+
for (const [id, bar] of Object.entries(subTabBars)) bar.style.display = id === name ? '' : 'none';
|
|
612
625
|
renderTabs();
|
|
613
626
|
};
|
|
614
627
|
renderTabs();
|
|
@@ -766,10 +779,10 @@ export function openSettingsDialog() {
|
|
|
766
779
|
renderToolbarSwitch();
|
|
767
780
|
// “外观”标签页的二级结构:样式(原内容)/ 状态栏(统计项顺序与显隐)/
|
|
768
781
|
// 主题(皮肤与自定义主题)/ 背景图(图库、文件夹轮换、网址)
|
|
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-
|
|
782
|
+
const paneStylesSub1 = h('div', { class: 'mt-2' });
|
|
783
|
+
const paneStylesSub2 = h('div', { class: 'mt-2', style: 'display:none' });
|
|
784
|
+
const paneStylesSub3 = h('div', { class: 'mt-2', style: 'display:none' });
|
|
785
|
+
const paneStylesSub4 = h('div', { class: 'mt-2', style: 'display:none' });
|
|
773
786
|
const ITEM_NAMES = {
|
|
774
787
|
ctx: 'sbItemCtx', questions: 'sbItemQuestions',
|
|
775
788
|
todayTokens: 'sbItemTodayTokens', totalTokens: 'sbItemTotalTokens', tasks: 'sbItemTasks',
|
|
@@ -888,7 +901,7 @@ export function openSettingsDialog() {
|
|
|
888
901
|
h('div', { class: 'mt-3 mb-1 text-ui-sm font-medium' }, L.sbGroupTurn),
|
|
889
902
|
turnList);
|
|
890
903
|
// —— “颜色”子页(paneStylesSub3):预设皮肤卡片 + 自定义主题编辑 ——
|
|
891
|
-
// ——
|
|
904
|
+
// —— “壁纸”子页(paneStylesSub4):无壁纸 / 图库 / 文件夹轮换 / 图片网址 / 网页 ——
|
|
892
905
|
let themeCfg = structuredClone(config.theme || {});
|
|
893
906
|
const numOrBg = (v, d) => (typeof v === 'number' && Number.isFinite(v) ? v : d);
|
|
894
907
|
themeCfg.skin = themeCfg.skin || 'default';
|
|
@@ -941,14 +954,28 @@ export function openSettingsDialog() {
|
|
|
941
954
|
renderThemeBg();
|
|
942
955
|
const res = await rpc('/bg');
|
|
943
956
|
bgLoading = false;
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
957
|
+
const listed = res.ok && Array.isArray(res.files);
|
|
958
|
+
if (listed) bgFiles = res.files;
|
|
959
|
+
// 清"指向已删文件的引用"只在拿到真实列表后做:取数失败时 bgFiles 是空的,
|
|
960
|
+
// 按空列表当"全删了"清引用会把还在的文件引用误清掉
|
|
961
|
+
if (listed) {
|
|
962
|
+
// 分区背景指向已删文件的引用一并清掉:否则分区继续请求已删文件名,静默铺不出图
|
|
963
|
+
const regionPatch = {};
|
|
964
|
+
for (const [k, r] of Object.entries(themeCfg.bg.regions || {})) {
|
|
965
|
+
if (r && r.mode === 'library' && r.file && !bgFiles.some((f) => sameName(f.name, r.file))) regionPatch[k] = { ...r, file: '' };
|
|
966
|
+
}
|
|
967
|
+
if (Object.keys(regionPatch).length) {
|
|
968
|
+
themeCfg = { ...themeCfg, bg: { ...themeCfg.bg, regions: { ...themeCfg.bg.regions, ...regionPatch } } };
|
|
969
|
+
await saveTheme({ bg: { regions: { ...themeCfg.bg.regions } } });
|
|
970
|
+
}
|
|
971
|
+
// 图库模式下当前文件可能已被删(同步/手动删除):自动回无背景并提示一次
|
|
972
|
+
if (themeCfg.bg.mode === 'library' && themeCfg.bg.file
|
|
973
|
+
&& !bgFiles.some((f) => sameName(f.name, themeCfg.bg.file))) {
|
|
974
|
+
themeCfg = { ...themeCfg, bg: { ...themeCfg.bg, file: '' } };
|
|
975
|
+
await saveTheme({ bg: { file: '' } });
|
|
976
|
+
showToast(L.themeBgDeletedActive, 'success');
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
952
979
|
}
|
|
953
980
|
renderThemeBg();
|
|
954
981
|
};
|
|
@@ -960,8 +987,9 @@ export function openSettingsDialog() {
|
|
|
960
987
|
: { count: 0, dir: themeCfg.bg.folder };
|
|
961
988
|
renderThemeBg();
|
|
962
989
|
};
|
|
963
|
-
//
|
|
964
|
-
|
|
990
|
+
// 上传:图片转 base64 传 helper,视频走 raw 字节流接口(base64 会把内存翻倍);
|
|
991
|
+
// 第一个上传且当前无壁纸时自动选为当前
|
|
992
|
+
const bgInput = h('input', { type: 'file', accept: '.png,.jpg,.jpeg,.webp,.gif,.bmp,.avif,.mp4,.webm,.mov', multiple: '', style: 'display:none' });
|
|
965
993
|
bgInput.addEventListener('change', () => {
|
|
966
994
|
const files = [...bgInput.files || []];
|
|
967
995
|
bgInput.value = '';
|
|
@@ -969,17 +997,26 @@ export function openSettingsDialog() {
|
|
|
969
997
|
void (async () => {
|
|
970
998
|
let first = themeCfg.bg.file;
|
|
971
999
|
for (const f of files) {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1000
|
+
let res = null;
|
|
1001
|
+
if (/\.(mp4|webm|mov)$/i.test(f.name)) {
|
|
1002
|
+
res = await fetch(`${HELPER_URL}/bg/upload?name=${encodeURIComponent(f.name)}`, {
|
|
1003
|
+
method: 'POST',
|
|
1004
|
+
headers: { 'X-ZCodePro-Token': liveBoot().token || '' },
|
|
1005
|
+
body: f,
|
|
1006
|
+
}).then((r) => r.json()).catch((e) => ({ ok: false, error: String((e && e.message) || e) }));
|
|
1007
|
+
} else {
|
|
1008
|
+
const dataUrl = await new Promise((resolve) => {
|
|
1009
|
+
const r = new FileReader();
|
|
1010
|
+
r.onload = () => resolve(String(r.result || ''));
|
|
1011
|
+
r.onerror = () => resolve('');
|
|
1012
|
+
r.readAsDataURL(f);
|
|
1013
|
+
});
|
|
1014
|
+
if (!dataUrl) continue;
|
|
1015
|
+
res = await rpc('/bg', { method: 'POST', body: { name: f.name, data: dataUrl } });
|
|
1016
|
+
}
|
|
1017
|
+
if (!res || !res.ok) { showToast(L.failed + ': ' + errText(res || {}), 'error'); continue; }
|
|
981
1018
|
if (Array.isArray(res.files)) bgFiles = res.files;
|
|
982
|
-
if (!first) first = f.name;
|
|
1019
|
+
if (!first) first = res.name || f.name; // 落盘名以 helper 回传为准(清洗可能改名)
|
|
983
1020
|
}
|
|
984
1021
|
if (first && first !== themeCfg.bg.file) await saveTheme({ bg: { file: first } });
|
|
985
1022
|
else renderThemeBg();
|
|
@@ -1066,17 +1103,24 @@ export function openSettingsDialog() {
|
|
|
1066
1103
|
if (mode === 'library') {
|
|
1067
1104
|
const sel = h('select', { class: 'h-7 max-w-40 rounded-lg border border-border bg-input px-1.5 text-ui-xs text-foreground outline-none' });
|
|
1068
1105
|
sel.append(h('option', { value: '' }, '—'));
|
|
1069
|
-
for (const f of bgFiles)
|
|
1106
|
+
for (const f of bgFiles) {
|
|
1107
|
+
if (/\.(mp4|webm|mov)$/i.test(f.name)) continue; // 分区是 CSS 铺图,视频播不了
|
|
1108
|
+
sel.append(h('option', { value: f.name }, f.name));
|
|
1109
|
+
}
|
|
1070
1110
|
sel.value = (cur && cur.file) || '';
|
|
1071
1111
|
sel.addEventListener('change', () => setRegion(region, { ...cur, file: sel.value }));
|
|
1072
1112
|
valueCtrl = sel;
|
|
1073
1113
|
} else if (mode === 'folder') {
|
|
1074
1114
|
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', () => {
|
|
1115
|
+
inp.addEventListener('change', () => { setRegion(region, { ...cur, folder: inp.value.trim() }); }); // 空值 = 清空目录,应用侧会撤掉旧图规则
|
|
1076
1116
|
valueCtrl = inp;
|
|
1077
1117
|
} else if (mode === 'url') {
|
|
1078
1118
|
const inp = h('input', { type: 'url', value: (cur && cur.url) || '', class: themeInputCls.replace('h-8', 'h-7'), placeholder: 'https://...' });
|
|
1079
|
-
inp.addEventListener('change', () => {
|
|
1119
|
+
inp.addEventListener('change', () => {
|
|
1120
|
+
const v = inp.value.trim();
|
|
1121
|
+
if (/^https?:\/\/\S+$/.test(v) && !/[<>"'\\]/.test(v)) setRegion(region, { ...cur, url: v });
|
|
1122
|
+
else { showToast(L.themeBgUrlInvalid, 'warning'); renderThemeBg(); } // 非法网址不保存:提示并回显已存值
|
|
1123
|
+
});
|
|
1080
1124
|
valueCtrl = inp;
|
|
1081
1125
|
}
|
|
1082
1126
|
return h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
@@ -1119,7 +1163,12 @@ export function openSettingsDialog() {
|
|
|
1119
1163
|
const modeBtn = (id, label) => h('button', {
|
|
1120
1164
|
type: 'button', class: 'zcodepro-tab',
|
|
1121
1165
|
'data-state': themeCfg.bg.mode === id ? 'active' : 'inactive',
|
|
1122
|
-
onClick: () =>
|
|
1166
|
+
onClick: () => {
|
|
1167
|
+
// url 与 web 共用 bg.url:互切时清空,别让另一模式的网址留着静默失效
|
|
1168
|
+
const cur = themeCfg.bg.mode;
|
|
1169
|
+
const cross = (cur === 'url' || cur === 'web') && (id === 'url' || id === 'web') && cur !== id;
|
|
1170
|
+
void saveTheme({ bg: cross ? { mode: id, url: '' } : { mode: id } });
|
|
1171
|
+
},
|
|
1123
1172
|
}, label);
|
|
1124
1173
|
// 文件夹路径输入 + 浏览(系统对话框);确认时先校验目录再保存
|
|
1125
1174
|
const folderInput = h('input', { type: 'text', value: themeCfg.bg.folder, class: themeInputCls, placeholder: '/path/to/wallpapers' });
|
|
@@ -1151,14 +1200,22 @@ export function openSettingsDialog() {
|
|
|
1151
1200
|
const randomCheck = h('input', { type: 'checkbox' });
|
|
1152
1201
|
randomCheck.checked = themeCfg.bg.folderRandom !== false;
|
|
1153
1202
|
randomCheck.addEventListener('change', () => { void saveTheme({ bg: { folderRandom: randomCheck.checked } }); });
|
|
1154
|
-
//
|
|
1203
|
+
// 图片网址输入:change 提交;空值回无壁纸
|
|
1155
1204
|
const urlInput = h('input', { type: 'url', value: themeCfg.bg.url, class: themeInputCls, placeholder: 'https://...' });
|
|
1156
1205
|
urlInput.addEventListener('change', () => {
|
|
1157
1206
|
const v = urlInput.value.trim();
|
|
1158
1207
|
if (!v) { void saveTheme({ bg: { mode: 'none', url: '' } }); return; }
|
|
1159
|
-
if (!/^https?:\/\/\S+$/.test(v)) { showToast(L.themeBgUrlInvalid, '
|
|
1208
|
+
if (!/^https?:\/\/\S+$/.test(v) || /[<>"'\\]/.test(v)) { showToast(L.themeBgUrlInvalid, 'warning'); renderThemeBg(); return; }
|
|
1160
1209
|
void saveTheme({ bg: { mode: 'url', url: v } });
|
|
1161
1210
|
});
|
|
1211
|
+
// 网页壁纸输入:与图片网址共用 bg.url 字段,模式不同渲染方式不同
|
|
1212
|
+
const webInput = h('input', { type: 'url', value: themeCfg.bg.url, class: themeInputCls, placeholder: 'https://...' });
|
|
1213
|
+
webInput.addEventListener('change', () => {
|
|
1214
|
+
const v = webInput.value.trim();
|
|
1215
|
+
if (!v) { void saveTheme({ bg: { mode: 'none', url: '' } }); return; }
|
|
1216
|
+
if (!/^https?:\/\/\S+$/.test(v) || /[<>"'\\]/.test(v)) { showToast(L.themeBgUrlInvalid, 'warning'); renderThemeBg(); return; }
|
|
1217
|
+
void saveTheme({ bg: { mode: 'web', url: v } });
|
|
1218
|
+
});
|
|
1162
1219
|
const libCard = (f) => {
|
|
1163
1220
|
const del = h('button', {
|
|
1164
1221
|
type: 'button', class: 'zcodepro-bg-del', title: L.themeBgDelete,
|
|
@@ -1172,12 +1229,16 @@ export function openSettingsDialog() {
|
|
|
1172
1229
|
})();
|
|
1173
1230
|
},
|
|
1174
1231
|
}, '✕');
|
|
1232
|
+
// 视频用 <video> 拉首帧当缩略图(preload=metadata 只取元数据不下载全片)
|
|
1233
|
+
const thumb = /\.(mp4|webm|mov)$/i.test(f.name)
|
|
1234
|
+
? h('video', { src: bgUrl(f.name), preload: 'metadata', muted: '' })
|
|
1235
|
+
: h('img', { src: bgUrl(f.name), alt: '', loading: 'lazy' });
|
|
1175
1236
|
return h('button', {
|
|
1176
1237
|
type: 'button', class: 'zcodepro-bg-card',
|
|
1177
|
-
'data-state': themeCfg.bg.mode === 'library' && themeCfg.bg.file
|
|
1238
|
+
'data-state': themeCfg.bg.mode === 'library' && sameName(themeCfg.bg.file, f.name) ? 'active' : 'inactive',
|
|
1178
1239
|
title: f.name,
|
|
1179
1240
|
onClick: () => void saveTheme({ bg: { mode: 'library', file: themeCfg.bg.file === f.name ? '' : f.name } }),
|
|
1180
|
-
},
|
|
1241
|
+
}, thumb, del);
|
|
1181
1242
|
};
|
|
1182
1243
|
const section = (titleText, body) => h('div', { class: 'mt-3' },
|
|
1183
1244
|
h('div', { class: 'mb-1.5 text-ui-xs font-medium text-foreground-subtle' }, titleText), body);
|
|
@@ -1187,7 +1248,11 @@ export function openSettingsDialog() {
|
|
|
1187
1248
|
h('span', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, bgLoading ? '…' : (bgFiles.length ? '' : L.themeBgEmpty)),
|
|
1188
1249
|
btnSmall(L.themeBgUpload, () => bgInput.click())),
|
|
1189
1250
|
bgFiles.length ? h('div', { class: 'grid grid-cols-4 gap-2', style: 'max-height:13.5rem;overflow-y:auto;' },
|
|
1190
|
-
...bgFiles.map(libCard)) : null
|
|
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)))),
|
|
1191
1256
|
] : themeCfg.bg.mode === 'folder' ? [
|
|
1192
1257
|
section(L.themeBgModeFolder, h('div', { class: 'flex flex-col gap-2' },
|
|
1193
1258
|
h('div', { class: 'flex items-center gap-2' }, folderInput, browseBtn),
|
|
@@ -1206,17 +1271,52 @@ export function openSettingsDialog() {
|
|
|
1206
1271
|
numField(themeCfg.bg.intervalMin, 0, 1440, (v) => { void saveTheme({ bg: { intervalMin: v } }); }, L.themeBgUrlIntervalHint),
|
|
1207
1272
|
h('span', { class: 'text-ui-xs text-foreground-subtle' }, L.themeBgIntervalUnit)),
|
|
1208
1273
|
h('p', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgUrlHint))),
|
|
1274
|
+
] : themeCfg.bg.mode === 'web' ? [
|
|
1275
|
+
section(L.themeBgModeWeb, h('div', { class: 'flex flex-col gap-2' },
|
|
1276
|
+
webInput,
|
|
1277
|
+
h('p', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgWebHint))),
|
|
1209
1278
|
] : [h('p', { class: 'mt-3 text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgNoneHint)];
|
|
1210
1279
|
const fitBtn = (id, label) => h('button', {
|
|
1211
1280
|
type: 'button', class: 'zcodepro-tab',
|
|
1212
1281
|
'data-state': (themeCfg.bg.fit || 'cover') === id ? 'active' : 'inactive',
|
|
1213
1282
|
onClick: () => void saveTheme({ bg: { fit: id } }),
|
|
1214
1283
|
}, label);
|
|
1284
|
+
const transBtn = (id, label) => h('button', {
|
|
1285
|
+
type: 'button', class: 'zcodepro-tab',
|
|
1286
|
+
'data-state': (themeCfg.bg.transition || 'cut') === id ? 'active' : 'inactive',
|
|
1287
|
+
onClick: () => void saveTheme({ bg: { transition: id } }),
|
|
1288
|
+
}, label);
|
|
1289
|
+
const pauseCheck = (key, label) => {
|
|
1290
|
+
const c = h('input', { type: 'checkbox' });
|
|
1291
|
+
c.checked = key === 'pauseOnHidden' ? themeCfg.bg.pauseOnHidden !== false : !!themeCfg.bg[key];
|
|
1292
|
+
c.addEventListener('change', () => void saveTheme({ bg: { [key]: c.checked } }));
|
|
1293
|
+
return h('label', { class: 'flex items-center gap-1.5 text-ui-xs text-foreground-subtle' }, c, label);
|
|
1294
|
+
};
|
|
1295
|
+
// 播放行只作用于视频壁纸:音量滑杆 + 倍速/帧率下拉
|
|
1296
|
+
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-xs text-foreground outline-none' });
|
|
1298
|
+
for (const [v, label] of options) sel.append(h('option', { value: String(v) }, label));
|
|
1299
|
+
sel.value = String(value);
|
|
1300
|
+
sel.addEventListener('change', () => commit(sel.value));
|
|
1301
|
+
return sel;
|
|
1302
|
+
};
|
|
1303
|
+
const labelledRow = (label, ctrl) => h('div', { class: 'flex items-center gap-3' },
|
|
1304
|
+
h('span', { class: 'shrink-0 whitespace-nowrap text-ui-xs font-medium text-foreground-subtle', style: 'width:72px' }, label), ctrl);
|
|
1305
|
+
const volumeRow = () => sliderRow(L.themeBgVolume, L.themeBgVolumeHint, 0, 100, 1, Math.round(numOr(themeCfg.bg.videoVolume, 0) * 100), '%',
|
|
1306
|
+
(v) => { void saveTheme({ bg: { videoVolume: v / 100 } }); }, '');
|
|
1307
|
+
const rateRow = () => labelledRow(L.themeBgRate,
|
|
1308
|
+
selectField(numOr(themeCfg.bg.playbackRate, 1), [['0.5', '0.5x'], ['0.75', '0.75x'], ['1', '1x'], ['1.25', '1.25x'], ['1.5', '1.5x'], ['2', '2x']],
|
|
1309
|
+
(v) => { void saveTheme({ bg: { playbackRate: Number(v) } }); }));
|
|
1310
|
+
const fpsRow = () => h('div', { class: 'flex flex-col gap-0.5' },
|
|
1311
|
+
labelledRow(L.themeBgFps, selectField(numOr(themeCfg.bg.fpsCap, 0), [['0', L.themeBgFpsOff], ['15', '15 fps'], ['30', '30 fps'], ['60', '60 fps']],
|
|
1312
|
+
(v) => { void saveTheme({ bg: { fpsCap: Number(v) } }); })),
|
|
1313
|
+
h('span', { class: 'text-ui-xs/relaxed text-foreground-subtle' }, L.themeBgFpsHint));
|
|
1215
1314
|
paneStylesSub4.replaceChildren(
|
|
1216
1315
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.themeBgDesc),
|
|
1217
1316
|
h('div', { class: 'mt-2 flex flex-wrap gap-1' },
|
|
1218
1317
|
modeBtn('none', L.themeBgModeNone), modeBtn('library', L.themeBgModeLibrary),
|
|
1219
|
-
modeBtn('folder', L.themeBgModeFolder), modeBtn('url', L.themeBgModeUrl)
|
|
1318
|
+
modeBtn('folder', L.themeBgModeFolder), modeBtn('url', L.themeBgModeUrl),
|
|
1319
|
+
modeBtn('web', L.themeBgModeWeb)),
|
|
1220
1320
|
...modeArea,
|
|
1221
1321
|
section(L.themeBgRegions, h('div', { class: 'flex flex-col gap-2' },
|
|
1222
1322
|
regionRow('left', L.themeBgRegionLeft),
|
|
@@ -1226,8 +1326,18 @@ export function openSettingsDialog() {
|
|
|
1226
1326
|
h('span', { class: 'text-ui-xs font-medium text-foreground-subtle' }, L.themeBgFit),
|
|
1227
1327
|
fitBtn('cover', L.themeBgFitCover), fitBtn('contain', L.themeBgFitContain),
|
|
1228
1328
|
fitBtn('fill', L.themeBgFitFill), fitBtn('tile', L.themeBgFitTile)),
|
|
1329
|
+
h('div', { class: 'mt-3 flex flex-wrap items-center gap-2' },
|
|
1330
|
+
h('span', { class: 'text-ui-xs font-medium text-foreground-subtle' }, L.themeBgTransition),
|
|
1331
|
+
transBtn('cut', L.themeBgTransitionCut), transBtn('fade', L.themeBgTransitionFade)),
|
|
1332
|
+
h('div', { class: 'mt-3 flex flex-wrap items-center gap-2' },
|
|
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)),
|
|
1229
1337
|
h('div', { class: 'mt-3 flex flex-col gap-2' },
|
|
1230
1338
|
maskRow(), blurRow(), panelRow()),
|
|
1339
|
+
section(L.themeBgPlayback, h('div', { class: 'flex flex-col gap-2' },
|
|
1340
|
+
volumeRow(), rateRow(), fpsRow())),
|
|
1231
1341
|
bgInput,
|
|
1232
1342
|
);
|
|
1233
1343
|
};
|
|
@@ -1257,7 +1367,8 @@ export function openSettingsDialog() {
|
|
|
1257
1367
|
},
|
|
1258
1368
|
}, label)));
|
|
1259
1369
|
renderStylesSubTabs();
|
|
1260
|
-
|
|
1370
|
+
subTabBars.styles = stylesSubTablist;
|
|
1371
|
+
paneStyles.append(paneStylesSub1, paneStylesSub2, paneStylesSub3, paneStylesSub4);
|
|
1261
1372
|
paneStylesSub1.append(
|
|
1262
1373
|
toolbarSwitchWrap,
|
|
1263
1374
|
h('div', { class: 'mt-2 flex flex-col gap-0.5 rounded-xl border border-border p-1' },
|
|
@@ -1297,16 +1408,138 @@ export function openSettingsDialog() {
|
|
|
1297
1408
|
const res = await rpc('/agents', { method: 'POST', body: { content: agentsArea.value } });
|
|
1298
1409
|
if (res.ok) {
|
|
1299
1410
|
agentsOriginal = typeof res.content === 'string' ? res.content : agentsArea.value;
|
|
1300
|
-
showToast(L.agentsSaved);
|
|
1411
|
+
showToast(L.agentsSaved, 'success');
|
|
1301
1412
|
} else {
|
|
1302
1413
|
showToast(L.failed + ': ' + errText(res), 'error');
|
|
1303
1414
|
agentsSaveBtn.disabled = false;
|
|
1304
1415
|
}
|
|
1305
1416
|
};
|
|
1306
|
-
//
|
|
1417
|
+
// “行为 → ZCode CLI”:zcode-cli 运行时的行为配置(写 ~/.zcode/cli/config.json)+
|
|
1418
|
+
// 技能清单检查。开关与预算数字框改动即存,每次只提交自己那个键;
|
|
1419
|
+
// 目录列表显式保存
|
|
1420
|
+
const paneZcode = h('div', { class: 'mt-2' });
|
|
1421
|
+
let snap = zcodeConfigRes;
|
|
1422
|
+
const setZcode = async (body) => {
|
|
1423
|
+
const res = await rpc('/zcode-config', { method: 'POST', body });
|
|
1424
|
+
if (!res.ok) {
|
|
1425
|
+
showToast(L.failed + ': ' + errText(res), 'error');
|
|
1426
|
+
return false;
|
|
1427
|
+
}
|
|
1428
|
+
snap = res;
|
|
1429
|
+
return true;
|
|
1430
|
+
};
|
|
1431
|
+
if (!snap.ok) {
|
|
1432
|
+
paneZcode.append(h('p', { class: 'mt-2 text-ui-sm text-destructive' }, L.failed + ': ' + errText(snap)));
|
|
1433
|
+
} else {
|
|
1434
|
+
const fmt = (n) => String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
1435
|
+
// —— 技能清单检查:完整清单字符数对照预算,超了就提示被降级 ——
|
|
1436
|
+
const countsEl = h('div', { class: 'text-ui-sm text-foreground' });
|
|
1437
|
+
const charsEl = h('div', { class: 'mt-0.5 text-ui-sm text-foreground' });
|
|
1438
|
+
const statusEl = h('div', { class: 'mt-0.5 text-ui-sm' });
|
|
1439
|
+
// —— 技能清单预算:数字框改动即存;“用建议值”写入并保存 ——
|
|
1440
|
+
const budgetField = numberField({
|
|
1441
|
+
value: snap.values.skills.metadataBudget,
|
|
1442
|
+
fallback: snap.stats.defaultBudget,
|
|
1443
|
+
min: 0,
|
|
1444
|
+
max: 1000000,
|
|
1445
|
+
step: 1000,
|
|
1446
|
+
onCommit: async (v) => {
|
|
1447
|
+
if (await setZcode({ skills: { metadataBudget: v } })) renderStats();
|
|
1448
|
+
},
|
|
1449
|
+
});
|
|
1450
|
+
const budgetTag = h('span', { class: 'text-ui-xs text-foreground-subtle' });
|
|
1451
|
+
const suggestEl = h('div', { class: 'min-w-0 flex-1 text-ui-xs/relaxed text-foreground-subtle' });
|
|
1452
|
+
const renderStats = () => {
|
|
1453
|
+
countsEl.textContent = L.zcodeStatsCounts
|
|
1454
|
+
.replaceAll('{total}', fmt(snap.stats.total))
|
|
1455
|
+
.replaceAll('{user}', fmt(snap.stats.userCount))
|
|
1456
|
+
.replaceAll('{plugin}', fmt(snap.stats.pluginCount));
|
|
1457
|
+
charsEl.textContent = L.zcodeStatsChars.replaceAll('{n}', fmt(snap.stats.fullChars));
|
|
1458
|
+
statusEl.textContent = snap.stats.degraded ? L.zcodeStatsDegraded : L.zcodeStatsOk;
|
|
1459
|
+
statusEl.className = 'mt-0.5 text-ui-sm ' + (snap.stats.degraded ? 'text-destructive' : 'text-foreground');
|
|
1460
|
+
budgetTag.textContent = snap.configured.skills.metadataBudget ? '' : L.zcodeBudgetDefaultTag;
|
|
1461
|
+
suggestEl.textContent = L.zcodeStatsSuggest.replaceAll('{n}', fmt(snap.stats.suggested));
|
|
1462
|
+
};
|
|
1463
|
+
const applyBtn = btnSmall(L.zcodeBudgetApply, async () => {
|
|
1464
|
+
if (await setZcode({ skills: { metadataBudget: snap.stats.suggested } })) {
|
|
1465
|
+
budgetField.set(snap.values.skills.metadataBudget);
|
|
1466
|
+
renderStats();
|
|
1467
|
+
showToast(L.zcodeBudgetApplied, 'success');
|
|
1468
|
+
}
|
|
1469
|
+
}, 'shrink-0');
|
|
1470
|
+
// 检查与预算同一行两个块
|
|
1471
|
+
const statsBudgetRow = h('div', { class: 'mt-2 flex items-stretch gap-2' },
|
|
1472
|
+
h('div', { class: 'flex min-w-0 flex-1 flex-col rounded-xl border border-border p-3' },
|
|
1473
|
+
h('div', { class: 'text-ui-sm font-medium' }, L.zcodeStatsTitle),
|
|
1474
|
+
countsEl, charsEl, statusEl,
|
|
1475
|
+
h('div', { class: 'mt-1 text-ui-xs/relaxed text-foreground-subtle' }, L.zcodeStatsNote)),
|
|
1476
|
+
h('div', { class: 'flex min-w-0 flex-1 flex-col rounded-xl border border-border p-3' },
|
|
1477
|
+
h('div', { class: 'text-ui-sm font-medium' }, L.zcodeSkillBudget),
|
|
1478
|
+
h('div', { class: 'mt-0.5 text-ui-xs/relaxed text-foreground-subtle' }, L.zcodeSkillBudgetDesc),
|
|
1479
|
+
h('div', { class: 'mt-2 flex items-center gap-1' }, budgetField.el, budgetTag),
|
|
1480
|
+
h('div', { class: 'mt-1 flex items-center gap-2' }, suggestEl, applyBtn)));
|
|
1481
|
+
// —— 开关组:skills / features 两段配置键,点一次只写一个键 ——
|
|
1482
|
+
const togglesWrap = h('div', { class: 'mt-2 flex flex-col gap-0.5 rounded-xl border border-border p-1' });
|
|
1483
|
+
const renderToggles = () => {
|
|
1484
|
+
const v = snap.values;
|
|
1485
|
+
const row = (name, desc, checked, patch) => settingRow(name, desc, checked, async () => {
|
|
1486
|
+
if (await setZcode(patch(!checked))) renderToggles();
|
|
1487
|
+
});
|
|
1488
|
+
// 分组标题省略:每行描述都带 skills./features. 键名前缀,分组名是重复信息
|
|
1489
|
+
togglesWrap.replaceChildren(
|
|
1490
|
+
row(L.zcodeSkillEnabled, L.zcodeSkillEnabledDesc, v.skills.enabled, (n) => ({ skills: { enabled: n } })),
|
|
1491
|
+
row(L.zcodeSkillIncludeInstructions, L.zcodeSkillIncludeInstructionsDesc, v.skills.includeInstructions, (n) => ({ skills: { includeInstructions: n } })),
|
|
1492
|
+
row(L.zcodeFeatCompact, L.zcodeFeatCompactDesc, v.features.compact, (n) => ({ features: { compact: n } })),
|
|
1493
|
+
row(L.zcodeFeatRewind, L.zcodeFeatRewindDesc, v.features.rewind, (n) => ({ features: { rewind: n } })),
|
|
1494
|
+
row(L.zcodeFeatSubagent, L.zcodeFeatSubagentDesc, v.features.subagent, (n) => ({ features: { subagent: n } })),
|
|
1495
|
+
row(L.zcodeFeatSkill, L.zcodeFeatSkillDesc, v.features.skill, (n) => ({ features: { skill: n } })),
|
|
1496
|
+
row(L.zcodeFeatMcp, L.zcodeFeatMcpDesc, v.features.mcp, (n) => ({ features: { mcp: n } })),
|
|
1497
|
+
// 记忆不放这里:官方“工作区记忆”是桌面设置里的 memoryEnabled
|
|
1498
|
+
// (~/.zcode/v2/setting.json),与本页写的 agent 配置不是同一层开关
|
|
1499
|
+
h('div', { class: 'px-2 pb-1 pt-1 text-ui-xs/relaxed text-foreground-subtle' }, L.zcodeMemoryHint),
|
|
1500
|
+
);
|
|
1501
|
+
};
|
|
1502
|
+
// —— 额外技能目录:多行文本,显式保存 ——
|
|
1503
|
+
const rootsArea = h('textarea', {
|
|
1504
|
+
class: 'zcodepro-textarea zcodepro-textarea-sm',
|
|
1505
|
+
rows: 3,
|
|
1506
|
+
spellcheck: 'false',
|
|
1507
|
+
placeholder: '/path/to/skills',
|
|
1508
|
+
});
|
|
1509
|
+
let rootsOriginal = snap.values.skills.roots.join('\n');
|
|
1510
|
+
rootsArea.value = rootsOriginal;
|
|
1511
|
+
const rootsSaveBtn = btnSmall(L.zcodeSave, async () => {
|
|
1512
|
+
rootsSaveBtn.disabled = true;
|
|
1513
|
+
const lines = rootsArea.value.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
1514
|
+
if (await setZcode({ skills: { roots: lines } })) {
|
|
1515
|
+
rootsOriginal = snap.values.skills.roots.join('\n');
|
|
1516
|
+
renderStats(); // 目录影响清单统计
|
|
1517
|
+
showToast(L.zcodeRootsSaved, 'success');
|
|
1518
|
+
} else {
|
|
1519
|
+
rootsSaveBtn.disabled = false;
|
|
1520
|
+
}
|
|
1521
|
+
}, 'shrink-0', 'primary');
|
|
1522
|
+
rootsSaveBtn.disabled = true;
|
|
1523
|
+
rootsArea.addEventListener('input', () => {
|
|
1524
|
+
rootsSaveBtn.disabled = rootsArea.value === rootsOriginal;
|
|
1525
|
+
});
|
|
1526
|
+
renderStats();
|
|
1527
|
+
renderToggles();
|
|
1528
|
+
paneZcode.append(
|
|
1529
|
+
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.zcodeDesc),
|
|
1530
|
+
statsBudgetRow,
|
|
1531
|
+
togglesWrap,
|
|
1532
|
+
h('div', { class: 'mt-2 rounded-xl border border-border p-2' },
|
|
1533
|
+
h('div', { class: 'text-ui-sm font-medium text-foreground' }, L.zcodeSkillRoots),
|
|
1534
|
+
h('div', { class: 'mt-0.5 text-ui-xs/relaxed text-foreground-subtle' }, L.zcodeSkillRootsDesc),
|
|
1535
|
+
h('div', { class: 'mt-2' }, rootsArea),
|
|
1536
|
+
h('div', { class: 'mt-2 flex justify-end' }, rootsSaveBtn)),
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
// “行为”标签页:二级标签切换“ZCode / 全局提示词 / 任务名”。全局提示词编辑
|
|
1307
1540
|
// ~/.zcode/AGENTS.md;任务名(智能起名)面板复用 paneTitleGen(原本是
|
|
1308
1541
|
// 一级标签页,收进来后不再单独出现在顶部标签栏)
|
|
1309
|
-
const agentsPromptPane = h('div', { class: 'mt-
|
|
1542
|
+
const agentsPromptPane = h('div', { class: 'mt-2' });
|
|
1310
1543
|
agentsPromptPane.append(
|
|
1311
1544
|
h('p', { class: 'text-ui-sm/relaxed text-foreground-subtle' }, L.agentsDesc),
|
|
1312
1545
|
...(agentsFailed
|
|
@@ -1315,11 +1548,12 @@ export function openSettingsDialog() {
|
|
|
1315
1548
|
h('div', { class: 'mt-3' }, agentsArea),
|
|
1316
1549
|
h('div', { class: 'mt-3 flex justify-end' }, agentsSaveBtn),
|
|
1317
1550
|
);
|
|
1318
|
-
let agentsSubTab = '
|
|
1319
|
-
const agentsSubPanes = { prompt: agentsPromptPane, titleGen: paneTitleGen };
|
|
1551
|
+
let agentsSubTab = 'zcode';
|
|
1552
|
+
const agentsSubPanes = { zcode: paneZcode, prompt: agentsPromptPane, titleGen: paneTitleGen };
|
|
1320
1553
|
const agentsSubList = h('div', { role: 'tablist', 'aria-orientation': 'horizontal', class: 'zcodepro-tablist' });
|
|
1321
1554
|
const renderAgentsSubTabs = () => {
|
|
1322
1555
|
agentsSubList.replaceChildren(...[
|
|
1556
|
+
['zcode', L.tabZcode],
|
|
1323
1557
|
['prompt', L.tabAgents],
|
|
1324
1558
|
['titleGen', L.tabTitleGen],
|
|
1325
1559
|
].map(([id, label]) => h('button', {
|
|
@@ -1335,7 +1569,8 @@ export function openSettingsDialog() {
|
|
|
1335
1569
|
};
|
|
1336
1570
|
for (const [pid, pane] of Object.entries(agentsSubPanes)) pane.style.display = pid === agentsSubTab ? '' : 'none';
|
|
1337
1571
|
renderAgentsSubTabs();
|
|
1338
|
-
|
|
1572
|
+
subTabBars.agents = agentsSubList;
|
|
1573
|
+
paneAgents.append(paneZcode, agentsPromptPane, paneTitleGen);
|
|
1339
1574
|
|
|
1340
1575
|
// “代理”:为 helper 发起的网络访问(插件市场更新/安装、headroom 本体升级)设
|
|
1341
1576
|
// HTTP 代理;保存即生效(helper 子进程环境变量注入),不影响 ZCode 应用与模型请求。
|
|
@@ -1355,7 +1590,7 @@ export function openSettingsDialog() {
|
|
|
1355
1590
|
if (res.ok) {
|
|
1356
1591
|
proxyOriginal = res.config && typeof res.config.proxy === 'string' ? res.config.proxy : proxyInput.value.trim();
|
|
1357
1592
|
proxyInput.value = proxyOriginal;
|
|
1358
|
-
showToast(L.proxySaved);
|
|
1593
|
+
showToast(L.proxySaved, 'success');
|
|
1359
1594
|
} else {
|
|
1360
1595
|
proxySaveBtn.disabled = false;
|
|
1361
1596
|
showToast(L.failed + ': ' + errText(res), 'error');
|
|
@@ -1550,7 +1785,7 @@ export function openSettingsDialog() {
|
|
|
1550
1785
|
syncLoginInput.value = res.sync.login;
|
|
1551
1786
|
syncPasswordInput.value = res.sync.password;
|
|
1552
1787
|
syncHistoryInput.value = syncFormOriginal.historyLimit;
|
|
1553
|
-
showToast(L.syncSaved);
|
|
1788
|
+
showToast(L.syncSaved, 'success');
|
|
1554
1789
|
} else {
|
|
1555
1790
|
showToast(L.failed + ': ' + errText(res), 'error');
|
|
1556
1791
|
syncCheckDirty();
|
|
@@ -1894,7 +2129,7 @@ export function openSettingsDialog() {
|
|
|
1894
2129
|
compressThresholdKB: 1024,
|
|
1895
2130
|
skipAfterFailures: 2,
|
|
1896
2131
|
skipMinutes: 30,
|
|
1897
|
-
forceIntercept
|
|
2132
|
+
// forceIntercept 不写:缺省 = 自动(跟随宿主「模型设置」图片开关,zcode-vision ≥1.7.9)
|
|
1898
2133
|
};
|
|
1899
2134
|
let visionCfg = visionRes.ok && visionRes.config && typeof visionRes.config === 'object'
|
|
1900
2135
|
? structuredClone(visionRes.config)
|
|
@@ -2119,26 +2354,37 @@ export function openSettingsDialog() {
|
|
|
2119
2354
|
await persistVision();
|
|
2120
2355
|
renderVision();
|
|
2121
2356
|
})))),
|
|
2122
|
-
// 链模式
|
|
2123
|
-
h('div', { class: 'mt-3
|
|
2124
|
-
h('
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2357
|
+
// 链模式 / 主模型策略 / 识图卡片 三项均分一行、各格内容左对齐(启用开关已上移信息卡)
|
|
2358
|
+
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' },
|
|
2359
|
+
h('div', { class: 'flex flex-wrap items-center gap-2' },
|
|
2360
|
+
h('span', { class: 'shrink-0 text-ui-sm font-medium text-foreground' }, L.visionMode),
|
|
2361
|
+
modeBtn('fallback', L.visionModeFallback, L.visionModeFallbackDesc),
|
|
2362
|
+
modeBtn('pipeline', L.visionModePipeline, L.visionModePipelineDesc),
|
|
2363
|
+
),
|
|
2364
|
+
(() => {
|
|
2365
|
+
// 三态:不能识图就使用插件(null,POST 侧删键恢复插件缺省联动)/ 始终使用插件 / 不使用插件
|
|
2366
|
+
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 },
|
|
2367
|
+
h('option', { value: 'auto' }, L.visionForceInterceptAuto),
|
|
2368
|
+
h('option', { value: 'true' }, L.visionForceInterceptTrue),
|
|
2369
|
+
h('option', { value: 'false' }, L.visionForceInterceptFalse));
|
|
2370
|
+
sel.value = visionCfg.forceIntercept === true ? 'true' : visionCfg.forceIntercept === false ? 'false' : 'auto';
|
|
2371
|
+
sel.addEventListener('change', () => {
|
|
2372
|
+
visionCfg.forceIntercept = sel.value === 'true' ? true : sel.value === 'false' ? false : null;
|
|
2373
|
+
void persistVision();
|
|
2374
|
+
});
|
|
2375
|
+
return h('label', { class: 'flex items-center gap-1.5', title: L.visionForceInterceptHint },
|
|
2376
|
+
h('span', { class: 'text-ui-sm font-medium text-foreground' }, L.visionForceIntercept), sel);
|
|
2377
|
+
})(),
|
|
2378
|
+
h('div', { class: 'flex items-center' },
|
|
2128
2379
|
settingRow(L.visionCardUi, '', visionCfg.cardUi !== false, async () => {
|
|
2129
2380
|
visionCfg.cardUi = !(visionCfg.cardUi !== false);
|
|
2130
2381
|
await persistVision();
|
|
2131
2382
|
renderVision();
|
|
2132
2383
|
}),
|
|
2133
|
-
settingRow(L.visionForceIntercept, '', visionCfg.forceIntercept !== false, async () => {
|
|
2134
|
-
visionCfg.forceIntercept = !(visionCfg.forceIntercept !== false);
|
|
2135
|
-
await persistVision();
|
|
2136
|
-
renderVision();
|
|
2137
|
-
}),
|
|
2138
2384
|
),
|
|
2139
2385
|
),
|
|
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-
|
|
2386
|
+
// 压缩阈值 / 连续失败次数 / 跳过分钟数 三个数字一行(p-2 与上方信息卡对齐)
|
|
2387
|
+
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
2388
|
(() => {
|
|
2143
2389
|
const n = h('input', { type: 'number', min: '0', step: '128', title: L.visionCompressKBHint,
|
|
2144
2390
|
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' });
|
|
@@ -2279,7 +2525,7 @@ export function openSettingsDialog() {
|
|
|
2279
2525
|
const v = input.value.trim();
|
|
2280
2526
|
if (!v) return;
|
|
2281
2527
|
if (!/^(git:)?[A-Za-z0-9._-]+$/.test(v) || rtkCfg.whitelist.includes(v)) {
|
|
2282
|
-
showToast(L.rtkWhitelistInvalid, '
|
|
2528
|
+
showToast(L.rtkWhitelistInvalid, 'warning');
|
|
2283
2529
|
return;
|
|
2284
2530
|
}
|
|
2285
2531
|
if (await persistRtk({ whitelist: [...rtkCfg.whitelist, v] })) {
|
|
@@ -2382,7 +2628,7 @@ export function openSettingsDialog() {
|
|
|
2382
2628
|
if (await persistRtk({ whitelist: [] })) {
|
|
2383
2629
|
rtkCfg.whitelist = [];
|
|
2384
2630
|
renderRtk();
|
|
2385
|
-
showToast(L.rtkWhitelistCleared);
|
|
2631
|
+
showToast(L.rtkWhitelistCleared, 'success');
|
|
2386
2632
|
}
|
|
2387
2633
|
})();
|
|
2388
2634
|
}, 'shrink-0'))),
|
|
@@ -2504,7 +2750,7 @@ export function openSettingsDialog() {
|
|
|
2504
2750
|
clearInterval(timerIv);
|
|
2505
2751
|
hrBusy = false;
|
|
2506
2752
|
await hrRefresh();
|
|
2507
|
-
showToast(doneMsg,
|
|
2753
|
+
showToast(doneMsg, 'success');
|
|
2508
2754
|
return;
|
|
2509
2755
|
}
|
|
2510
2756
|
}
|
|
@@ -2523,7 +2769,7 @@ export function openSettingsDialog() {
|
|
|
2523
2769
|
return false;
|
|
2524
2770
|
}
|
|
2525
2771
|
if (res.config) Object.assign(hrCfg, res.config);
|
|
2526
|
-
if (warn) showToast(warn);
|
|
2772
|
+
if (warn) showToast(warn, 'warning');
|
|
2527
2773
|
// 非生命周期动作(backend/power):稍等后刷一次
|
|
2528
2774
|
if (!isStart && !isStop) {
|
|
2529
2775
|
hrBusy = false;
|
|
@@ -2592,7 +2838,7 @@ export function openSettingsDialog() {
|
|
|
2592
2838
|
}
|
|
2593
2839
|
if (res.usage) headroomRes.usage = res.usage;
|
|
2594
2840
|
renderHrUsageSwitch();
|
|
2595
|
-
if (next && !res.changed && !(res.usage && res.usage.enabled)) showToast(L.hrUsageNone);
|
|
2841
|
+
if (next && !res.changed && !(res.usage && res.usage.enabled)) showToast(L.hrUsageNone, 'warning');
|
|
2596
2842
|
}));
|
|
2597
2843
|
};
|
|
2598
2844
|
renderHrUsageSwitch();
|
|
@@ -2921,9 +3167,17 @@ export function openSettingsDialog() {
|
|
|
2921
3167
|
};
|
|
2922
3168
|
renderTitleGenPane();
|
|
2923
3169
|
|
|
3170
|
+
// 一级 / 二级 tab 放到滚动区(body)之上的固定区:内容滚动时标题、
|
|
3171
|
+
// 版本行(已并入标题行)与两级 tab 始终可见
|
|
3172
|
+
const subTabHost = h('div', { class: 'mt-2' });
|
|
3173
|
+
for (const bar of Object.values(subTabBars)) {
|
|
3174
|
+
bar.style.display = 'none';
|
|
3175
|
+
subTabHost.append(bar);
|
|
3176
|
+
}
|
|
3177
|
+
// flex-col:两个 tab 栏都是 inline-flex,走块布局会在栏下垫出基线空隙;
|
|
3178
|
+
// items-start:不拉伸子项,tab 栏胶囊底色保持内容宽度
|
|
3179
|
+
content.insertBefore(h('div', { class: 'flex flex-col items-start' }, tablist, subTabHost), body);
|
|
2924
3180
|
body.append(
|
|
2925
|
-
statusLine,
|
|
2926
|
-
tablist,
|
|
2927
3181
|
paneFeatures,
|
|
2928
3182
|
paneShortcuts,
|
|
2929
3183
|
paneAgents,
|