Skip to content

查询结果支持复制为 Markdown - #3257

Open
Shikanor wants to merge 2 commits into
hhyo:masterfrom
Shikanor:feat-query-result-copy-export
Open

查询结果支持复制为 Markdown#3257
Shikanor wants to merge 2 commits into
hhyo:masterfrom
Shikanor:feat-query-result-copy-export

Conversation

@Shikanor

@Shikanor Shikanor commented Sep 4, 2026

Copy link
Copy Markdown

功能说明

SQL 查询页每个「执行结果」标签页的工具栏新增**「复制为Markdown」**按钮,一键将当前查询结果复制为 Markdown 表格文本,便于粘贴到 Wiki、邮件、IM 等场景。

实现说明

  • 基于 bootstrap-table 1.22 的自定义 buttons 选项实现,按钮样式与工具栏原生按钮一致(按钮 HTML 通过 html 字段自定义,规避 showButtonText 默认关闭导致文本不渲染的问题)
  • 取数口径与页面显示一致:getVisibleColumns(隐藏列不参与)+ getData(全量数据);数组/对象值 JSON.stringify,null/undefined 显示为 (null)(与表格 undefinedText 口径一致)
  • Markdown 转义:单元格中的 \| 先后转义、换行替换为空格,保证粘贴后表格结构不被破坏
  • 纯前端实现:无后端/API 变更、无新增依赖,单文件改动

兼容性

  • 复制优先使用 Clipboard API;HTTP 内网部署(非安全上下文)下自动回退 document.execCommand(copy),并恢复页面焦点
  • 生成与复制过程中的同步异常均有兜底,按钮状态始终可恢复(成功提示「已复制」/失败提示「复制失败」)

测试

  • 本地部署实测:含 null、竖线、换行、JSON、中文样本数据,复制后 Markdown 表格渲染正常
  • HTTP 非安全上下文(execCommand 回退路径)实测通过

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.70%. Comparing base (7faf9a8) to head (515c256).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3257   +/-   ##
=======================================
  Coverage   88.70%   88.70%           
=======================================
  Files         158      158           
  Lines       29780    29780           
=======================================
  Hits        26415    26415           
  Misses       3365     3365           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a812073e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sql/templates/sqlquery.html Outdated
Comment thread sql/templates/sqlquery.html Outdated
Comment thread sql/templates/sqlquery.html Outdated
Comment thread sql/templates/sqlquery.html
Comment thread sql/templates/sqlquery.html Outdated
@Shikanor

Shikanor commented Sep 4, 2026

Copy link
Copy Markdown
Author

感谢 review,5 条意见(2×P1、3×P2)均已在 515c256 处理,详见各行内回复:按钮按 can_download 门控(含建表语句结果页)、复制成功记录独立审计动作「复制Markdown」、标题不再剔除尖括号别名、剪贴板写入移回用户手势任务内(Safari 兼容)。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 515c2564a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sql/templates/sqlquery.html
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