From 472bbe243ec897db9d79fdb1e1d42f2abec17030 Mon Sep 17 00:00:00 2001 From: jiangchen <1703935164@qq.com> Date: Sun, 27 Sep 2026 14:04:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(host):=20=E6=B3=A8=E5=86=8C=20DSH=20?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4=EF=BC=88?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E2=86=92=E6=8F=92=E4=BB=B6=20=E9=87=8C?= =?UTF-8?q?=E7=9A=84=E6=82=AC=E6=B5=AE=E7=AA=97=E5=8D=A1=E7=89=87=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ctx.settings.register('dsh-float-window', schema) best-effort:schemastery 解析不到时只跳过 - 设置变更通过 SSE 广播给浮窗 - 说明:link: 安装的插件解析不到 profile 依赖时降级,浮窗自带设置面板仍然可用 --- lib/host.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/host.js b/lib/host.js index ad8fd3b..c536482 100644 --- a/lib/host.js +++ b/lib/host.js @@ -264,5 +264,37 @@ export function apply(ctx) { // 抓屏前隐藏:给其它插件/工具用的门面(没有消费者时静默) ctx.set?.('floatWindow', { hide: pushHidden, show: () => broadcast({ type: 'cmd', cmd: 'show' }), snapshot, endpoint: () => endpointFile }) + // ---------------------------------------------------------------- DSH 设置入口 + // 注册一个设置命名空间,DSH 的「设置 → 插件」会把它渲染成一张卡片。 + // schemastery 是从 profile 的 node_modules 解析的;link: 安装的插件解析不到时 + // 只跳过这一步(浮窗自己的设置面板照常可用)。 + ; (async () => { + try { + const settings = ctx.get('settings') + if (!settings?.register) { log('settings service absent; skip settings entry'); return } + let z = null + try { z = (await import('@deepseek-ai/schemastery')).default } catch { } + if (!z) { log('schemastery not resolvable; skip settings entry'); return } + const schema = z.object({ + topmost: z.boolean().default(true).description('始终置顶'), + posLock: z.boolean().default(false).description('固定位置'), + sizeLock: z.boolean().default(false).description('锁定尺寸'), + exclude: z.boolean().default(true).description('抓屏时隐藏本窗'), + opacity: z.number().min(0.3).max(1).default(0.92).description('不透明度'), + scale: z.number().min(0.8).max(1.5).default(1).description('界面缩放'), + backdrop: z.union(['opaque', 'translucent', 'acrylic', 'mica', 'blur']).default('opaque').description('背景效果'), + }) + const scope = settings.register('dsh-float-window', schema) + const scope2 = scope + ctx.effect(() => { + const stop = scope2.watch?.((next) => { + try { broadcast({ type: 'settings', value: next?.value ?? next }) } catch { } + }) + return () => { try { stop?.() } catch { } } + }) + log('settings namespace registered') + } catch (e) { log('settings registration failed:', String(e?.message || e)) } + })() + log('ready; endpoints:', `${ROUTE}/events`, `${ROUTE}/state`, `${ROUTE}/health`) }