From ae7b617e839bc34f8274cd2fee769344a29b5356 Mon Sep 17 00:00:00 2001 From: spark Date: Sat, 8 Feb 2025 15:05:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E6=B7=BB=E5=8A=A0=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=E8=BD=AF=E4=BB=B6=E9=A1=B5=E9=9D=A2=E5=B9=B6=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 about.vue 组件,包含软件介绍、更新说明和作者信息 - 添加 GetVersionInfo 函数,用于获取版本信息 - 在 App.vue 中添加关于软件的菜单项 - 在 router.js 中添加关于软件的路由 - 优化页面布局和样式 --- .github/workflows/main.yml | 8 ++- app.go | 13 +++++ backend/models/models.go | 13 +++++ frontend/src/components/about.vue | 93 +++++++++++++++++++++++++------ frontend/wailsjs/go/main/App.d.ts | 2 + frontend/wailsjs/go/main/App.js | 4 ++ frontend/wailsjs/go/models.ts | 49 ++++++++++++++++ main.go | 2 + 8 files changed, 166 insertions(+), 18 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3a59273..8aeb803 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,8 +31,13 @@ jobs: with: submodules: recursive + - name: Get commit message + run: | + commit_message=$(git log -1 --pretty=format:"# [%an %ad] # %s %b") + echo "Commit message: $commit_message" + - name: Build wails - uses: ArvinLovegood/wails-build-action@v2.4 + uses: ArvinLovegood/wails-build-action@v2.5 id: build with: build-name: ${{ matrix.build.name }} @@ -40,3 +45,4 @@ jobs: package: true go-version: '1.23' build-tags: ${{ github.ref_name }} + build-commit-message: $commit_message diff --git a/app.go b/app.go index 596f4b6..7ca1e84 100644 --- a/app.go +++ b/app.go @@ -4,6 +4,7 @@ package main import ( "context" + "encoding/base64" "fmt" "github.com/PuerkitoBio/goquery" "github.com/coocood/freecache" @@ -431,6 +432,18 @@ func (a *App) GetAIResponseResult(stock string) *models.AIResponseResult { return data.NewDeepSeekOpenAi().GetAIResponseResult(stock) } +func (a *App) GetVersionInfo() *models.VersionInfo { + return &models.VersionInfo{ + Version: Version, + Icon: GetImageBase(icon), + Content: VersionCommit, + } +} + +func GetImageBase(bytes []byte) string { + return "data:image/jpeg;base64," + base64.StdEncoding.EncodeToString(bytes) +} + func GenNotificationMsg(stockInfo *data.StockInfo) string { Price, err := convertor.ToFloat(stockInfo.Price) if err != nil { diff --git a/backend/models/models.go b/backend/models/models.go index 3697526..d547d63 100644 --- a/backend/models/models.go +++ b/backend/models/models.go @@ -144,3 +144,16 @@ type AIResponseResult struct { func (receiver AIResponseResult) TableName() string { return "ai_response_result" } + +type VersionInfo struct { + gorm.Model + Version string `json:"version"` + Content string `json:"content"` + Icon string `json:"icon"` + BuildTimeStamp int64 `json:"buildTimeStamp"` + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag"` +} + +func (receiver VersionInfo) TableName() string { + return "version_info" +} diff --git a/frontend/src/components/about.vue b/frontend/src/components/about.vue index 8f12e76..73f29cb 100644 --- a/frontend/src/components/about.vue +++ b/frontend/src/components/about.vue @@ -1,28 +1,87 @@ \ No newline at end of file +p { + margin: 2px 0; +} + +ul { + list-style-type: disc; + padding-left: 20px; +} + +a { + color: #18a058; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts index 3231ea6..3f84d6f 100644 --- a/frontend/wailsjs/go/main/App.d.ts +++ b/frontend/wailsjs/go/main/App.d.ts @@ -13,6 +13,8 @@ export function GetFollowList():Promise>; export function GetStockList(arg1:string):Promise>; +export function GetVersionInfo():Promise; + export function Greet(arg1:string):Promise; export function NewChat(arg1:string):Promise; diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js index addc5ee..d9b62a7 100644 --- a/frontend/wailsjs/go/main/App.js +++ b/frontend/wailsjs/go/main/App.js @@ -22,6 +22,10 @@ export function GetStockList(arg1) { return window['go']['main']['App']['GetStockList'](arg1); } +export function GetVersionInfo() { + return window['go']['main']['App']['GetVersionInfo'](); +} + export function Greet(arg1) { return window['go']['main']['App']['Greet'](arg1); } diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index c32a511..c0689d6 100644 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -378,6 +378,55 @@ export namespace models { return a; } } + export class VersionInfo { + ID: number; + // Go type: time + CreatedAt: any; + // Go type: time + UpdatedAt: any; + // Go type: gorm + DeletedAt: any; + version: string; + content: string; + icon: string; + buildTimeStamp: number; + IsDel: number; + + static createFrom(source: any = {}) { + return new VersionInfo(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.ID = source["ID"]; + this.CreatedAt = this.convertValues(source["CreatedAt"], null); + this.UpdatedAt = this.convertValues(source["UpdatedAt"], null); + this.DeletedAt = this.convertValues(source["DeletedAt"], null); + this.version = source["version"]; + this.content = source["content"]; + this.icon = source["icon"]; + this.buildTimeStamp = source["buildTimeStamp"]; + this.IsDel = source["IsDel"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (a.slice && a.map) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } + } } diff --git a/main.go b/main.go index cccbd77..849b547 100644 --- a/main.go +++ b/main.go @@ -36,6 +36,7 @@ var stocksBin []byte //go:generate cp -R ./data ./build/bin var Version string +var VersionCommit string func main() { checkDir("data") @@ -88,6 +89,7 @@ func main() { // runtime.Quit(app.ctx) //}) logger.NewDefaultLogger().Info("version: " + Version) + logger.NewDefaultLogger().Info("commit: " + VersionCommit) // Create application with options err := wails.Run(&options.App{ Title: "go-stock",