标签页右键菜单增强 + PDF 导出样式系统(字体/颜色/24模板/实时预览) - #27
Open
9527La wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
标签页右键菜单增强 + PDF 导出样式系统(+ 窗口置前修复)
背景与动机
本 PR 解决用户反馈的问题,并顺带做了若干增强:
一、标签页右键菜单增强
TabBar.vue新增右键菜单项:App.vue接入对应事件处理,新增copyPath()(navigator.clipboard+execCommand兜底)。二、PDF 导出样式系统
独立设置标签页
设置对话框新增「PDF 导出」独立标签页(
settingsTab切换),与阅读设置分离,更清晰。24 套预设模板
分为三组:
间距变体(紧凑 / 标准 / 宽松)
对应 md-to.com 的 Compact / Standard / Loose。通过
PdfDensity+PDF_DENSITY_SPACING(lineHeight / blockGap)驱动,导出的 HTML 用calc(var(--pdf-block-gap,1em)*N)实现段落间距。分组下拉
模板下拉按「文档 / 开发 / 创意」用
<optgroup>分组,便于浏览。实时预览
新增
usePdfPreview.ts,复用真实导出管线(renderMarkdown+buildExportHtml)在隔离<iframe :srcdoc>中渲染:字体 / 颜色 / 页面自定义
正文 / 标题 / 代码字体、正文字号、行高、正文色 / 标题色 / 链接色 / 代码背景 / 页面背景、页边距、页面尺寸(A4 / Letter)、方向(纵向 / 横向)均可调;通过
--pdf-*CSS 变量注入导出 HTML。三、其他改进
pdf_export.rs移除cmd.arg("--no-margins"),使注入的@page { margin }生效(需重新tauri build才能生效)。四、国际化
zh-CN.ts/en-US.ts新增:标签菜单(复制路径等)、PDF 样式(间距 / 紧凑 / 标准 / 宽松 / 预览 / 示例文本 / 对比 / 明 / 暗 / 分组标题)及 8 套开发模板名称,中英文一一对应。五、文件清单
六、验证
eslint .无错误vue-tsc --noEmit类型通过vite build构建通过tauri build/tauri dev后手动验证(沙箱未编译 Rust)。七、注意事项
pdf_export.rs移除--no-margins、lib.rs单实例窗口置前)都需重新tauri build/tauri dev后生效。八、窗口置前修复(补充提交)
.md文件,前端虽然打开了对应标签页,但窗口仍停留在最小化状态、不弹到前台。src-tauri/src/lib.rs的tauri_plugin_single_instance回调只调用了show()+set_focus(),缺少unminimize();且 Windows 前台锁会阻止后台进程把窗口带到最前。show()之前新增window.unminimize(),先把最小化窗口恢复;set_always_on_top(true)→set_focus()→set_always_on_top(false)」短暂置顶再回落,绕开 Windows 前台锁,确保最小化窗口稳定置前。tauri build/tauri dev后生效;跨平台(unminimize + show + set_focus)对非 Windows 同样有效。