Files
SoonDesign/docs/网页端功能清单.md
T
24kycj 2e6578247e 网页端:平台桥与部署修复(宝塔/Nginx)
- lib/platform:网页 Electron 统一 bridge/web/electron,子目录 API 基路径、返回首页跳站点根、路径末尾斜杠兼容
- index/design*.web.html:网页入口,web.js 加缓存参数避免旧脚本缓存
- api:PHP 读写 soon;文档说明目录权限与 Nginx
- lib/design*、lib/index:与 platformBridge 对接及网页侧逻辑
- 公共资源 JsBarcode/jr-qrcode;文档与 package/README/.gitignore 等同步更新

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 18:57:53 +08:00

84 lines
5.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SoonDesign 网页端功能清单
本文档列出 SoonDesign 各功能在**桌面端(Electron)**与**网页端**的实现情况,以及网页端不可用时的替代方案。
---
## 一、首页(index
| 功能 | 桌面端 | 网页端 | 替代/说明 |
|------|--------|--------|----------|
| 打开文件 | ✅ 系统对话框选文件,打开设计页 | ✅ 使用 `<input type="file">` 选文件,项目 JSON 存入 `sessionStorage`,通过 `soondesign_session:文件名` 传给设计页 | 网页端选文件后在新页打开,关闭后需重新选择 |
| 新建 1(单面) | ✅ 通过 ipcRenderer 打开设计页 | ✅ 通过 `platformBridge.openDesignPage("", 1)` 跳转 design1.web.html | 一致 |
| 新建 2(双面) | ✅ 通过 ipcRenderer 打开设计页 | ✅ 通过 `platformBridge.openDesignPage("", 2)` 跳转 design2.web.html | 一致 |
| 历史记录 | ✅ 从本地文件读取并展示 | ✅ 使用 `platformBridge.readHistory()`localStorage) | 网页端历史仅限当前域名,且为路径/名称列表,点击打开需支持 sessionKey |
| 语言切换 | ✅ 正常 | ✅ 使用 localStorage 存语言,无系统 API 时沿用本地存储 | 一致 |
| 关于 | ✅ 正常 | ✅ 可显示版本等信息(若未注入 sysAPI 则仅显示界面) | 一致 |
| 关闭 | ✅ 通过 ipcRenderer 关闭窗口 | ⚠️ 使用 `window.close()` 或隐藏;部分浏览器限制脚本关闭页签 | 替代:用户手动关闭页签 |
---
## 二、设计页(design1 / design2 通用)
### 2.1 文件操作
| 功能 | 桌面端 | 网页端 | 替代/说明 |
|------|--------|--------|----------|
| 打开项目 | ✅ `fs.readFileSync` 读 .soon 后加载画布 | ✅ `platformBridge.readJsonFile(file)` 支持路径或 `soondesign_session:xxx`,异步加载 | 从首页“打开文件”传入的 sessionKey 在设计页通过 readJsonFile 从 sessionStorage 读取 |
| 保存 | ✅ `dialog.showSaveDialog` + `fs.writeFileSync` | ✅ 使用 `platformBridge.writeFile`fileHandle 或默认文件名)+ 异步写入 | 网页端无 fileHandle 时触发下载 |
| 另存为 | ✅ 同上 | ✅ 同上,通过 showSaveDialog 选保存位置或文件名 | 一致 |
| 导出 PNG | ✅ 对话框选路径 + fs 写入 | ✅ Blob + `fileHandle.createWritable()``<a download>` + `URL.createObjectURL(blob)` 下载 | 一致 |
| 导出 PDF(仅 design2 | ✅ `dialog.showSaveDialog` + `fs.writeFile` | ✅ 使用桥 `showSaveDialog` + `writeFile(Blob)`,或 Blob 下载 | 一致 |
| 写历史(saveHistory | ✅ fs 读写本地历史文件 | ✅ `platformBridge.readHistory` / `writeHistory`localStorage | 一致 |
### 2.2 预览与打印
| 功能 | 桌面端 | 网页端 | 替代/说明 |
|------|--------|--------|----------|
| 预览 | ✅ 生成临时文件 + printJS 等 | ✅ 使用画布导出 Blob → base64 → Uint8Array → Blob URL 显示预览图 | 一致 |
| 打印 | ✅ 同上,调用打印 | ✅ 使用 `platformBridge.printPdf(blob)` 或 Blob URL 交给浏览器打印 | 一致(依赖桥提供 printPdf |
### 2.3 界面与编辑
| 功能 | 桌面端 | 网页端 | 替代/说明 |
|------|--------|--------|----------|
| 帮助 | ✅ 打开本地或在线帮助 | ✅ 新窗口打开帮助链接或 PDF | 一致 |
| 返回首页 | ✅ ipcRenderer 跳转首页 | ✅ `location.href` 跳转 index.web.html | 一致 |
| 字体 / 剪贴板 / 撤销重做 | ✅ 不依赖 Node | ✅ 同桌面端 | 一致 |
| 关闭前提示(未保存) | ✅ 通过 IPC 或 beforeunload | ✅ beforeunload 提示 | 一致 |
---
## 三、design2 额外说明
- **保存 / 另存为**design2 的 `output.js``ui.js` 已统一为:有 `platformBridge.writeFile` 时异步写入,否则使用 `fs.writeFileSync`,网页端走桥或下载。
- **导出 PDF**`design2/core.js``savePdf` 已接桥:网页端使用 `showSaveDialog` + `writeFile(blob)` 或 Blob 下载;预览/打印在无 fs 时使用 data URL,打印可走 `platformBridge.printPdf(pdfBlob)`
- **打开项目**design2 已支持 `platformBridge.readJsonFile``openFile(file, jAlready)``ui.js` 打开对话框在网页端使用 `showOpenDialog``readJsonFile(file)` 后调用 `openFile(name, j)`
---
## 四、平台桥接口(网页端 lib/platform/web.js
网页端通过 `window.platformBridge` 提供:
- `openDesignPage(file, type)`:跳转设计页(file 可为空或 sessionKey
- `openFirstPage()`:跳转首页
- `openHelp()`:新窗口打开帮助
- `runClose()`:尝试关闭当前页(受浏览器限制)
- `onClose(callback)`beforeunload 时回调(关闭前确认)
- `readJsonFile(pathOrHandle)`:支持 `soondesign_session:xxx` 从 sessionStorage 读 JSON
- `readHistory` / `writeHistory`:历史记录(localStorage
- `showOpenDialog` / `showSaveDialog`:文件选择(input 或 File System Access
- `writeFile(content, fileHandleOrFilename)`:写字符串或 Blob
- `printPdf(blob)`:打印 PDF Blob(若未实现则可不提供)
网页端 `ipcRenderer` 桩会响应:`get-sys-language``open-first-page``open-design-page``open-help-file``run-close`,并转发到上述桥方法。
---
## 五、总结
- **首页**:打开、新建、历史、语言、关于在网页端均可用;关闭为浏览器限制,无替代实现则用户手动关页。
- **设计页**:打开(含 sessionKey)、保存、另存为、导出 PNG、预览、打印、历史、帮助、返回首页、编辑相关功能在网页端可用;design2 导出 PDF 建议后续接桥或改为下载。
- **无法在网页实现的**:无;仅“关闭窗口”受浏览器限制,其余均有实现或替代方案。