Skip to content

Commit 4f4fa46

Browse files
committed
refactor(app):优化代码结构和功能
- 调整导入顺序,提高代码可读性 - 使用 cron 定时任务替代直接调用检查更新方法 - 在前端 App.vue 中添加名站优选市场选项 -调整主窗口高度 -优化股票情感分析数据处理
1 parent 05bf35f commit 4f4fa46

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

app.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"encoding/hex"
88
"encoding/json"
99
"fmt"
10-
"github.com/duke-git/lancet/v2/cryptor"
11-
"github.com/inconshreveable/go-update"
1210
"go-stock/backend/data"
1311
"go-stock/backend/db"
1412
"go-stock/backend/logger"
@@ -18,6 +16,9 @@ import (
1816
"strings"
1917
"time"
2018

19+
"github.com/duke-git/lancet/v2/cryptor"
20+
"github.com/inconshreveable/go-update"
21+
2122
"github.com/PuerkitoBio/goquery"
2223
"github.com/coocood/freecache"
2324
"github.com/duke-git/lancet/v2/convertor"
@@ -464,7 +465,10 @@ func (a *App) domReady(ctx context.Context) {
464465
//检查新版本
465466
go func() {
466467
a.CheckUpdate(0)
467-
a.CheckStockBaseInfo(a.ctx)
468+
a.cron.AddFunc("0 0 2 * * *", func() {
469+
logger.SugaredLogger.Errorf("Checking for updates...")
470+
a.CheckStockBaseInfo(a.ctx)
471+
})
468472
a.cron.AddFunc("30 05 8,12,20 * * *", func() {
469473
logger.SugaredLogger.Errorf("Checking for updates...")
470474
a.CheckUpdate(0)

backend/data/stock_sentiment_analysis.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package data
33
import (
44
"bufio"
55
"fmt"
6-
"github.com/go-ego/gse"
76
"go-stock/backend/logger"
87
"os"
98
"strings"
9+
10+
"github.com/go-ego/gse"
1011
)
1112

1213
// 金融情感词典,包含股票市场相关的专业词汇

frontend/src/App.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
Wallet, WarningOutline,
2929
} from '@vicons/ionicons5'
3030
import {AnalyzeSentiment, GetConfig, GetGroupList,GetVersionInfo} from "../wailsjs/go/main/App";
31-
import {Dragon, Fire, Gripfire, Robot} from "@vicons/fa";
31+
import {Dragon, Fire, FirefoxBrowser, Gripfire, Robot} from "@vicons/fa";
3232
import {ReportSearch} from "@vicons/tabler";
3333
import {LocalFireDepartmentRound} from "@vicons/material";
3434
import {BoxSearch20Regular, CommentNote20Filled} from "@vicons/fluent";
@@ -369,6 +369,28 @@ const menuOptions = ref([
369369
key: 'market11',
370370
icon: renderIcon(BoxSearch20Regular),
371371
},
372+
{
373+
label: () =>
374+
h(
375+
RouterLink,
376+
{
377+
href: '#',
378+
to: {
379+
name: 'market',
380+
query: {
381+
name: "名站优选",
382+
}
383+
},
384+
onClick: () => {
385+
activeKey.value = 'market'
386+
EventsEmit("changeMarketTab", {ID: 0, name: '名站优选'})
387+
},
388+
},
389+
{default: () => '名站优选',}
390+
),
391+
key: 'market12',
392+
icon: renderIcon(FirefoxBrowser),
393+
},
372394
]
373395
},
374396
{

main.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import (
55
"embed"
66
"encoding/json"
77
"fmt"
8+
"go-stock/backend/data"
9+
"go-stock/backend/db"
10+
log "go-stock/backend/logger"
11+
"go-stock/backend/models"
12+
"os"
13+
"runtime/debug"
14+
"strings"
15+
816
"github.com/duke-git/lancet/v2/slice"
917
"github.com/wailsapp/wails/v2"
1018
"github.com/wailsapp/wails/v2/pkg/logger"
@@ -13,13 +21,6 @@ import (
1321
"github.com/wailsapp/wails/v2/pkg/options/mac"
1422
"github.com/wailsapp/wails/v2/pkg/options/windows"
1523
"github.com/wailsapp/wails/v2/pkg/runtime"
16-
"go-stock/backend/data"
17-
"go-stock/backend/db"
18-
log "go-stock/backend/logger"
19-
"go-stock/backend/models"
20-
"os"
21-
"runtime/debug"
22-
"strings"
2324
)
2425

2526
//go:embed frontend/dist
@@ -125,7 +126,7 @@ func main() {
125126
err = wails.Run(&options.App{
126127
Title: "go-stock:AI赋能股票分析✨",
127128
Width: width * 4 / 5,
128-
Height: 950,
129+
Height: 920,
129130
MinWidth: minWidth,
130131
MinHeight: minHeight,
131132
//MaxWidth: width,

0 commit comments

Comments
 (0)