feat(frontend): 添加关于软件页面并实现版本信息动态获取

- 新增 about.vue 组件,包含软件介绍、更新说明和作者信息
- 添加 GetVersionInfo 函数,用于获取版本信息
- 在 App.vue 中添加关于软件的菜单项
- 在 router.js 中添加关于软件的路由
- 优化页面布局和样式
This commit is contained in:
spark 2025-02-08 15:05:52 +08:00
parent 1035f2a800
commit ae7b617e83
8 changed files with 166 additions and 18 deletions

View File

@ -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

13
app.go
View File

@ -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 {

View File

@ -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"
}

View File

@ -1,28 +1,87 @@
<script setup>
import { MdPreview } from 'md-editor-v3';
// preview.cssstyle.css
import 'md-editor-v3/lib/preview.css';
import {onMounted, ref} from 'vue';
import {GetVersionInfo} from "../../wailsjs/go/main/App";
const updateLog = ref(`
feat(frontend): 添加关于软件页面
- App.vue 中添加关于软件的菜单项
- router.js 中添加关于软件的路由- 新增 about.vue 组件包含软件介绍和作者信息
`)
const versionInfo = ref('');
const icon = ref('https://raw.githubusercontent.com/ArvinLovegood/go-stock/master/build/appicon.png');
onMounted(() => {
document.title = '关于软件';
GetVersionInfo().then((res) => {
updateLog.value = res.content;
versionInfo.value = res.version;
icon.value = res.icon;
});
})
</script>
<template>
<n-config-provider>
<n-layout>
<n-space vertical size="large">
<!-- 软件描述 -->
<n-card size="large">
<n-space vertical>
<n-image width="100" :src="icon" />
<h1>go-stock <n-tag size="small" round>{{versionInfo}}</n-tag></h1>
<p>自选股行情实时监控基于Wails和NaiveUI构建的AI赋能股票分析工具</p>
<p>
欢迎点赞GitHub<a href="https://github.com/ArvinLovegood/go-stock" target="_blank">go-stock</a>
</p>
</n-space>
</n-card>
<n-flex justify="center" style="margin-top: 12px;padding-left: 12px;height: 100%">
<n-card size="large">
<h1>go-stock</h1>
<n-image size="large" src="https://raw.githubusercontent.com/ArvinLovegood/go-stock/master/build/appicon.png" />
<p>自选股行情实时监控基于Wails和NaiveUI构建的AI赋能股票分析工具</p>
<p>
欢迎点赞GitHub<a href="https://github.com/ArvinLovegood/go-stock" target="_blank">go-stock</a>
</p>
</n-card>
<n-card size="large">
<h1>关于作者</h1>
<n-image size="large" src="https://avatars.githubusercontent.com/u/7401917?v=4" />
<h1><a href="https://github.com/ArvinLovegood" target="_blank">@ArvinLovegood</a></h1>
<p>一个热爱编程的小白欢迎关注我的Github</p>
</n-card>
</n-flex>
<!-- 更新说明 -->
<n-card size="large">
<n-flex justify="center">
<h1>更新说明</h1>
<MdPreview style="text-align: left" :modelValue="updateLog" :theme="'dark'"/>
</n-flex>
</n-card>
<!-- 关于作者 -->
<n-card size="large">
<n-space vertical>
<h1>关于作者</h1>
<n-avatar width="100" src="https://avatars.githubusercontent.com/u/7401917?v=4" />
<h2><a href="https://github.com/ArvinLovegood" target="_blank">@ArvinLovegood</a></h2>
<p>一个热爱编程的小白欢迎关注我的Github</p>
</n-space>
</n-card>
</n-space>
</n-layout>
</n-config-provider>
</template>
<style scoped>
/* 可以在这里添加一些样式 */
h1, h2 {
margin: 0;
padding: 6px 0;
}
</style>
p {
margin: 2px 0;
}
ul {
list-style-type: disc;
padding-left: 20px;
}
a {
color: #18a058;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>

View File

@ -13,6 +13,8 @@ export function GetFollowList():Promise<Array<data.FollowedStock>>;
export function GetStockList(arg1:string):Promise<Array<data.StockBasic>>;
export function GetVersionInfo():Promise<models.VersionInfo>;
export function Greet(arg1:string):Promise<data.StockInfo>;
export function NewChat(arg1:string):Promise<string>;

View File

@ -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);
}

View File

@ -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;
}
}
}

View File

@ -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",