feat: DSH 悬浮窗 v0.1.0 — 原生置顶小窗 + 会话镜像 + 抓屏隐身
- shell: WinForms + WebView2 原生壳(无边框/置顶/固定位置/锁定尺寸/全屏/自适应缩放/截图排除) - shell/ui.html: 自适应界面(工具栏、会话镜像区、底部聊天框、轮/步/tok/s/MTOK/缓存命中/上下文状态条、外观设置) - lib/host.js: DSH 插件 Host 半(endpoint 写入、SSE 会话与指标快照、float_window Agent 工具) - tools: WebView2 SDK 拉取、BOM 修复、Host 冒烟测试 - README: 架构、实测结论(WDA_EXCLUDEFROMCAPTURE、玻璃模式、DPI、WebView2 加载)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 冒烟测试:用假的 ctx 调 apply(),确认插件不会抛异常,路由能应答。
|
||||
* 用法:node tools/smoke-host.mjs
|
||||
*/
|
||||
import { apply, name, inject } from '../lib/host.js'
|
||||
|
||||
const routes = []
|
||||
const events = []
|
||||
const effects = []
|
||||
|
||||
const ctx = {
|
||||
logger: { info: (...a) => console.log('[mock]', ...a) },
|
||||
webServer: {
|
||||
port: 3099,
|
||||
host: '127.0.0.1',
|
||||
register: (r) => { routes.push(r); return () => { } },
|
||||
},
|
||||
get: () => undefined,
|
||||
set: () => { },
|
||||
on: (ev, fn) => { events.push([ev, fn]); return () => { } },
|
||||
effect: (fn) => { const d = fn(); effects.push(d); return () => { } },
|
||||
}
|
||||
|
||||
console.log('name =', name, '| inject =', JSON.stringify(inject))
|
||||
apply(ctx)
|
||||
console.log('routes =', routes.map((r) => `${r.kind}:${r.path}`).join(', '))
|
||||
console.log('events =', events.map((e) => e[0]).join(', '))
|
||||
console.log('effects =', effects.length)
|
||||
|
||||
function fakeRes() {
|
||||
return {
|
||||
status: 0, headers: null, body: '',
|
||||
writeHead(s, h) { this.status = s; this.headers = h },
|
||||
write(chunk) { this.body += chunk; return true },
|
||||
end(chunk) { if (chunk) this.body += chunk },
|
||||
}
|
||||
}
|
||||
|
||||
const route = routes[0]
|
||||
for (const p of ['/dsh-float-window/health', '/dsh-float-window/state', '/dsh-float-window/nope']) {
|
||||
const res = fakeRes()
|
||||
await route.handler({ method: 'GET', url: p, on: () => { } }, res)
|
||||
console.log(p, '->', res.status, String(res.body).slice(0, 120))
|
||||
}
|
||||
|
||||
// SSE 分支:只验证不抛异常且写出了 data:
|
||||
const res = fakeRes()
|
||||
await route.handler({ method: 'GET', url: '/dsh-float-window/events', on: () => { } }, res)
|
||||
console.log('events ->', res.status, res.headers['Content-Type'], JSON.stringify(res.body.slice(0, 80)))
|
||||
|
||||
console.log('SMOKE OK')
|
||||
Reference in New Issue
Block a user