fix(desktop): 报告 PDF 导出在壳内改走原生桥 —— WKWebView 拦死 window.open
实机验证抓到的:桌面壳内点 PDF 报「打印窗口被拦截」——Wails v3 的 WKWebView 把 window.open 拦成 null,前端弹打印窗那条路在壳内根本走不通(浏览器预览没事)。 - app.go 加 PrintReportPage(filename, html):打印视图 HTML 落临时文件(文件名 过滤路径字符),openInSystem 交系统默认浏览器打开,页面 onload 自动唤起打印框, 用户直接「存储为 PDF」。CJK 零字体依赖的原有优势不变。 - desktop.ts printReportHtml 改 async:inWails 走原生桥,浏览器维持 window.open; RunsView 调用点随之 async + 错误透 toast。 - 绑定重新生成(注意要 `wails3 generate bindings -ts`,裸跑默认吐 JS 且要 GOWORK=off,否则 go.work 干扰找不到 Service)。 验证:go test/tsc/68 例 vitest 全绿;壳内被拦是用户实机复现的。 ⚠️ 原生桥新路径(临时文件→浏览器→打印框)用户尚未实机点验,重新打的包已就位, 下次跑报告顺手验。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -90,14 +90,19 @@ export function RunsView({ run, focusTaskId }: { run: RunState; focusTaskId?: st
|
||||
}
|
||||
};
|
||||
// 导出 PDF:把预览到的正文(已渲染 HTML)送进打印视图(CJK 零字体依赖,故走前端打印而非后端渲染)。
|
||||
const exportPdf = () => {
|
||||
// 桌面壳内由原生桥转交系统浏览器打开(webview 拦 window.open),浏览器预览则直接弹打印窗。
|
||||
const exportPdf = async () => {
|
||||
const html = previewRef.current?.innerHTML;
|
||||
if (!html) {
|
||||
toast.push("error", "暂无报告正文可导出");
|
||||
return;
|
||||
}
|
||||
if (!printReportHtml(curTopic || curId, html)) {
|
||||
toast.push("error", "打印窗口被拦截,请允许弹出窗口后重试");
|
||||
try {
|
||||
if (!(await printReportHtml(curTopic || curId, html))) {
|
||||
toast.push("error", "打印窗口被拦截,请允许弹出窗口后重试");
|
||||
}
|
||||
} catch (e) {
|
||||
toast.push("error", (e as Error).message);
|
||||
}
|
||||
};
|
||||
const nodes = deriveNodes(cur.exec);
|
||||
|
||||
Reference in New Issue
Block a user