feat(host): 注册 DSH 设置命名空间(设置→插件 里的悬浮窗卡片)

- ctx.settings.register('dsh-float-window', schema) best-effort:schemastery 解析不到时只跳过
- 设置变更通过 SSE 广播给浮窗
- 说明:link: 安装的插件解析不到 profile 依赖时降级,浮窗自带设置面板仍然可用
This commit is contained in:
2026-09-27 14:04:28 +08:00
parent 8e4a648465
commit 472bbe243e
+32
View File
@@ -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`)
}