Skip to content

ER 图导出新增 PNG / JPG 格式并升级 VS Code 插件 - #3

Open
fengyily wants to merge 1 commit into
mainfrom
feat/req_3ca08e9ea2b40df6
Open

fengyily wants to merge 1 commit into
mainfrom
feat/req_3ca08e9ea2b40df6

Conversation

@fengyily

@fengyily fengyily commented Oct 9, 2026

Copy link
Copy Markdown
Owner

改动概述

ER Diagram 此前仅支持导出 SVG。本次将工具栏的 SVG 按钮改为 Export 下拉菜单,新增 PNG、JPG 两种位图导出格式,并同步升级 VS Code 扩展版本至 0.1.2。

主要变更

  • 导出逻辑重构:抽出 buildExportSvg() 与 triggerDownload(),三种格式共用同一份「按内容自适应裁剪 + 30px 留白」的独立 SVG,避免重复实现。
  • 位图导出:新增 exportERImage(format),通过 <img> + <canvas> 以 2x 倍率栅格化;PNG 保留透明背景,JPG 因无 alpha 通道先填充白底并以 0.92 质量编码。
  • 资源与异常处理:URL.revokeObjectURL 延后释放以兼容下载触发;补充 img.onerror、空画布、toBlob 返回空等分支的 toast 提示。
  • 工具栏交互:新增 showERExportMenu() / closeERExportMenu(),复用既有 .export-dropdown 样式,并与 SQL 导出下拉菜单互斥。
  • VS Code 扩展:版本 0.1.1 → 0.1.2,更新 CHANGELOG 与 README,重新打包 .vsix(替换此前遗留的 0.0.1 产物)。

关键文件

文件 说明
shield-plugin-postgres/static/er.js 导出核心逻辑:buildExportSvg / triggerDownload / exportERImage
shield-plugin-postgres/static/index.html Export 下拉菜单与工具栏按钮
shield-plugin-postgres/vscode-extension/package.json 版本号升至 0.1.2
shield-plugin-postgres/vscode-extension/CHANGELOG.md / README.md 版本说明与功能文档
shield-plugin-postgres/vscode-extension/shield-postgresql-0.1.2.vsix 重新打包的扩展产物

验证方式

  1. cd shield-plugin-postgres && go build -ldflags="-s -w" -o shield-plugin-postgres .
  2. 按 CLAUDE.md 中的 stdin JSON 协议启动插件,打开 Web UI 进入 ER Diagram。
  3. 点击工具栏 Export,分别导出 SVG / PNG / JPG:
    • 三份文件内容边界一致、无裁切;
    • PNG 背景透明,JPG 背景为白色,位图均为 2x 分辨率;
    • 空图表时提示 Nothing to export。
  4. 校验 Export 与 SQL 两个下拉菜单互斥,点击空白处可关闭。

Replace the single "SVG" button in the ER toolbar with an "Export"
dropdown offering SVG (vector), PNG (2x, transparent) and JPG (2x,
white background).

- er.js: extract buildExportSvg()/triggerDownload() so all three
  formats share one content-fitted SVG; add exportERImage(format)
  which rasterizes it via <img> + canvas at 2x
- index.html: showERExportMenu()/closeERExportMenu() reusing the
  existing .export-dropdown styles, mutually exclusive with the SQL
  export dropdown
- vscode-extension: bump to 0.1.2, update CHANGELOG/README, repackage
  .vsix (replaces the stale 0.0.1 artifact)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant