From bbd4bb5b488de2dbe34495501fcb2afe248089e8 Mon Sep 17 00:00:00 2001 From: Gico001 Date: Thu, 10 Jul 2025 14:49:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(app):=20=E5=85=BC=E5=AE=B9darwin=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=B5=8F=E8=A7=88=E8=B7=B3=E8=BD=AC,=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=9B=BE=E7=89=87=E6=96=87=E4=BB=B6=E7=AD=89=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.go | 79 ++++++++++++ frontend/package.json.md5 | 2 +- frontend/src/components/HotTopics.vue | 22 +++- frontend/src/components/SelectStock.vue | 157 +++++++++++++----------- frontend/src/components/about.vue | 15 ++- frontend/src/components/fund.vue | 15 ++- frontend/src/components/stock.vue | 149 +++++++++++++++------- frontend/wailsjs/go/main/App.d.ts | 6 + frontend/wailsjs/go/main/App.js | 12 ++ 9 files changed, 334 insertions(+), 123 deletions(-) diff --git a/app.go b/app.go index 4513fc9..8f33d7b 100644 --- a/app.go +++ b/app.go @@ -14,6 +14,7 @@ import ( "go-stock/backend/logger" "go-stock/backend/models" "os" + "path/filepath" "strings" "time" @@ -1201,3 +1202,81 @@ func (a *App) GetStockMoneyTrendByDay(stockCode string, days int) []map[string]a slice.Reverse(res) return res } + +// OpenURL +// +// @Description: 跨平台打开默认浏览器 +// @receiver a +// @param url +func (a *App) OpenURL(url string) { + runtime.BrowserOpenURL(a.ctx, url) +} + +// SaveImage +// +// @Description: 跨平台保存图片 +// @receiver a +// @param name +// @param base64Data +// @return error +func (a *App) SaveImage(name, base64Data string) string { + // 打开保存文件对话框 + filePath, err := runtime.SaveFileDialog(a.ctx, runtime.SaveDialogOptions{ + Title: "保存图片", + DefaultFilename: name + "AI分析.png", + Filters: []runtime.FileFilter{ + { + DisplayName: "PNG 图片", + Pattern: "*.png", + }, + }, + }) + if err != nil || filePath == "" { + return "文件路径,无法保存。" + } + + // 解码并保存 + decodeString, err := base64.StdEncoding.DecodeString(base64Data) + if err != nil { + return "文件内容异常,无法保存。" + } + + err = os.WriteFile(filepath.Clean(filePath), decodeString, 0777) + if err != nil { + return "保存结果异常,无法保存。" + } + return filePath +} + +// SaveWordFile +// +// @Description: // 跨平台保存word +// @receiver a +// @param filename +// @param base64Data +// @return error +func (a *App) SaveWordFile(filename string, base64Data string) string { + // 弹出保存文件对话框 + filePath, err := runtime.SaveFileDialog(a.ctx, runtime.SaveDialogOptions{ + Title: "保存 Word 文件", + DefaultFilename: filename, + Filters: []runtime.FileFilter{ + {DisplayName: "Word 文件", Pattern: "*.docx"}, + }, + }) + if err != nil || filePath == "" { + return "文件路径,无法保存。" + } + + // 解码 base64 内容 + decodeString, err := base64.StdEncoding.DecodeString(base64Data) + if err != nil { + return "文件内容异常,无法保存。" + } + // 保存为文件 + err = os.WriteFile(filepath.Clean(filePath), decodeString, 0777) + if err != nil { + return "保存结果异常,无法保存。" + } + return filePath +} diff --git a/frontend/package.json.md5 b/frontend/package.json.md5 index fce852e..799119d 100644 --- a/frontend/package.json.md5 +++ b/frontend/package.json.md5 @@ -1 +1 @@ -2d63c3a999d797889c01d6c96451b197 \ No newline at end of file +8d3264f90073dfceb29c3619775d830d \ No newline at end of file diff --git a/frontend/src/components/HotTopics.vue b/frontend/src/components/HotTopics.vue index e203788..c4c1c2b 100644 --- a/frontend/src/components/HotTopics.vue +++ b/frontend/src/components/HotTopics.vue @@ -1,6 +1,7 @@ @@ -1756,7 +1815,9 @@ function searchStockReport(stockCode) { {{ result["日期"] + " " + result["时间"] }} {{ result.volume + "股" }} - {{ "成本:" + result.costPrice + "*" + result.costVolume + " " + result.profit + "%" + " ( " + result.profitAmount + " ¥ )" }} + {{ + "成本:" + result.costPrice + "*" + result.costVolume + " " + result.profit + "%" + " ( " + result.profitAmount + " ¥ )" + }} @@ -1815,7 +1876,8 @@ function searchStockReport(stockCode) { - + @@ -1886,9 +1948,10 @@ function searchStockReport(stockCode) { 取消关注   - - AI分析 - + + AI分析 + 移出分组 @@ -1898,7 +1961,9 @@ function searchStockReport(stockCode) { {{ result["日期"] + " " + result["时间"] }} {{ result.volume + "股" }} - {{ "成本:" + result.costPrice + "*" + result.costVolume + " " + result.profit + "%" + " ( " + result.profitAmount + " ¥ )" }} + {{ + "成本:" + result.costPrice + "*" + result.costVolume + " " + result.profit + "%" + " ( " + result.profitAmount + " ¥ )" + }} @@ -2087,7 +2152,9 @@ function searchStockReport(stockCode) { 不启用AI函数工具调用 - *AI函数工具调用可以增强AI获取数据的能力,但会消耗更多tokens。 + + *AI函数工具调用可以增强AI获取数据的能力,但会消耗更多tokens。 + ; +export function OpenURL(arg1:string):Promise; + export function ReFleshTelegraphList(arg1:string):Promise; export function RemoveGroup(arg1:number):Promise; @@ -99,6 +101,10 @@ export function SaveAIResponseResult(arg1:string,arg2:string,arg3:string,arg4:st export function SaveAsMarkdown(arg1:string,arg2:string):Promise; +export function SaveImage(arg1:string,arg2:string):Promise; + +export function SaveWordFile(arg1:string,arg2:string):Promise; + export function SearchStock(arg1:string):Promise>; export function SendDingDingMessage(arg1:string,arg2:string):Promise; diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js index d2625de..8034116 100755 --- a/frontend/wailsjs/go/main/App.js +++ b/frontend/wailsjs/go/main/App.js @@ -174,6 +174,10 @@ export function NewsPush(arg1) { return window['go']['main']['App']['NewsPush'](arg1); } +export function OpenURL(arg1) { + return window['go']['main']['App']['OpenURL'](arg1); +} + export function ReFleshTelegraphList(arg1) { return window['go']['main']['App']['ReFleshTelegraphList'](arg1); } @@ -194,6 +198,14 @@ export function SaveAsMarkdown(arg1, arg2) { return window['go']['main']['App']['SaveAsMarkdown'](arg1, arg2); } +export function SaveImage(arg1, arg2) { + return window['go']['main']['App']['SaveImage'](arg1, arg2); +} + +export function SaveWordFile(arg1, arg2) { + return window['go']['main']['App']['SaveWordFile'](arg1, arg2); +} + export function SearchStock(arg1) { return window['go']['main']['App']['SearchStock'](arg1); }