新增: 文件操作增强与预览扩展
- 文件剪贴板复制剪切粘贴,重名自动副本 - SFTP下载到本机与外部文件拖入,目录递归 - 传输进度浮动面板,transfer-progress事件链 - Drawio预览,Excel工作线程,冻结看门狗 - cmd与bat自写batch语法高亮,psm1等映射补齐
This commit is contained in:
+19
-7
@@ -6,13 +6,24 @@ import (
|
||||
"u-desk/internal/api"
|
||||
)
|
||||
|
||||
// requirePdfAPI 检查 pdfAPI 是否已初始化
|
||||
func (a *App) requirePdfAPI() (*api.PdfAPI, error) {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
if a.pdfAPI == nil {
|
||||
return nil, fmt.Errorf("PDF导出功能正在初始化中")
|
||||
}
|
||||
return a.pdfAPI, nil
|
||||
}
|
||||
|
||||
// ExportPDF 导出PDF文件
|
||||
func (a *App) ExportPDF(content string, title string, fileName string, fontSize int, pageWidth int, pageHeight int) (map[string]interface{}, error) {
|
||||
if a.pdfAPI == nil {
|
||||
pdfAPI, err := a.requirePdfAPI()
|
||||
if err != nil {
|
||||
return map[string]interface{}{
|
||||
"success": false,
|
||||
"message": "PDF导出功能未初始化",
|
||||
}, fmt.Errorf("PDF导出功能未初始化")
|
||||
"message": err.Error(),
|
||||
}, err
|
||||
}
|
||||
|
||||
req := api.PdfExportRequest{
|
||||
@@ -24,7 +35,7 @@ func (a *App) ExportPDF(content string, title string, fileName string, fontSize
|
||||
PageHeight: pageHeight,
|
||||
}
|
||||
|
||||
result, err := a.pdfAPI.ExportMarkdownToPDF(req)
|
||||
result, err := pdfAPI.ExportMarkdownToPDF(req)
|
||||
if err != nil {
|
||||
return map[string]interface{}{
|
||||
"success": false,
|
||||
@@ -42,9 +53,10 @@ func (a *App) ExportPDF(content string, title string, fileName string, fontSize
|
||||
|
||||
// SelectPDFSaveDirectory 选择PDF保存目录
|
||||
func (a *App) SelectPDFSaveDirectory() (string, error) {
|
||||
if a.pdfAPI == nil {
|
||||
return "", fmt.Errorf("PDF导出功能未初始化")
|
||||
pdfAPI, err := a.requirePdfAPI()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return a.pdfAPI.SelectDirectory()
|
||||
return pdfAPI.SelectDirectory()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user