优化: PDF导出成功后打开所在位置选中文件

- 导出落盘后explorer选中PDF,不再只靠一闪而过的弹窗
- 成功文案明确指向导出位置
- explorer用WINDIR绝对路径,不依赖PATH
This commit is contained in:
lxy
2026-09-28 09:33:53 +08:00
parent fa3c3234b9
commit e8ccb4280b
2 changed files with 11 additions and 1 deletions
+9
View File
@@ -451,6 +451,15 @@ func (api *PdfAPI) ExportHtmlFileToPDF(srcPath string, saveName string) (resp *P
return nil, fmt.Errorf("获取文件信息失败: %v", err)
}
// 成功弹窗几秒即逝用户难感知产物位置,改用资源管理器选中 PDF 明示落盘位置;失败静默不影响导出结果
// 用户 PATH 无 C:\Windows 根目录,explorer 走 LookPath 解析不到,必须用 WINDIR 拼绝对路径
if common.IsWindows() {
exePath := filepath.Join(os.Getenv("WINDIR"), "explorer.exe")
if selectErr := exec.Command(exePath, "/select,", savePath).Start(); selectErr != nil {
appendExportLog(fmt.Sprintf("ExportHtmlFileToPDF explorer select error=%s", selectErr.Error()))
}
}
return &PdfExportResponse{
Success: true,
Message: "PDF生成成功",