From 2a274db7aec71f90491907856ea97fb99f0257c9 Mon Sep 17 00:00:00 2001 From: ArvinLovegood Date: Thu, 15 May 2025 18:36:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=E6=B7=BB=E5=8A=A0=E8=82=A1?= =?UTF-8?q?=E7=A5=A8=E8=B5=84=E9=87=91=E8=B6=8B=E5=8A=BF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在前端添加了股票资金趋势页面组件 - 在后端实现了获取股票资金趋势数据的接口 - 优化了前端界面布局,增加了资金趋势按钮 --- app.go | 5 + backend/data/market_news_api.go | 18 ++ backend/data/market_news_api_test.go | 7 + frontend/src/App.vue | 3 +- frontend/src/components/moneyTrend.vue | 279 +++++++++++++++++++++++++ frontend/src/components/stock.vue | 15 ++ frontend/wailsjs/go/main/App.d.ts | 2 + frontend/wailsjs/go/main/App.js | 4 + 8 files changed, 332 insertions(+), 1 deletion(-) create mode 100644 frontend/src/components/moneyTrend.vue diff --git a/app.go b/app.go index b3192c3..87c2903 100644 --- a/app.go +++ b/app.go @@ -1131,3 +1131,8 @@ func (a *App) GetMoneyRankSina(sort string) []map[string]any { res := data.NewMarketNewsApi().GetMoneyRankSina(sort) return res } + +func (a *App) GetStockMoneyTrendByDay(stockCode string, days int) []map[string]any { + res := data.NewMarketNewsApi().GetStockMoneyTrendByDay(stockCode, days) + return res +} diff --git a/backend/data/market_news_api.go b/backend/data/market_news_api.go index 801ad19..015101c 100644 --- a/backend/data/market_news_api.go +++ b/backend/data/market_news_api.go @@ -275,3 +275,21 @@ func (m MarketNewsApi) GetMoneyRankSina(sort string) []map[string]any { } return *res } + +func (m MarketNewsApi) GetStockMoneyTrendByDay(stockCode string, days int) []map[string]any { + url := fmt.Sprintf("http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/MoneyFlow.ssl_qsfx_zjlrqs?page=1&num=%d&sort=opendate&asc=0&daima=%s", days, stockCode) + + response, _ := resty.New().SetTimeout(time.Duration(5)*time.Second).R(). + SetHeader("Host", "vip.stock.finance.sina.com.cn"). + SetHeader("Referer", "https://finance.sina.com.cn"). + SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.60").Get(url) + js := string(response.Body()) + res := &[]map[string]any{} + err := json.Unmarshal([]byte(js), &res) + if err != nil { + logger.SugaredLogger.Error(err) + return *res + } + return *res + +} diff --git a/backend/data/market_news_api_test.go b/backend/data/market_news_api_test.go index 31fd7aa..ee51597 100644 --- a/backend/data/market_news_api_test.go +++ b/backend/data/market_news_api_test.go @@ -49,3 +49,10 @@ func TestGetMoneyRankSina(t *testing.T) { } } + +func TestGetStockMoneyTrendByDay(t *testing.T) { + res := NewMarketNewsApi().GetStockMoneyTrendByDay("sh600438", 120) + for i, re := range res { + logger.SugaredLogger.Debugf("key: %+v, value: %+v", i, re) + } +} diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 1a5338c..15fea9c 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -446,7 +446,7 @@ onBeforeMount(() => { }) onMounted(() => { - contentStyle.value = "max-height: calc(90vh);overflow: hidden" + contentStyle.value = "max-height: calc(92vh);overflow: hidden" GetConfig().then((res) => { if (res.enableNews) { enableNews.value = true @@ -488,6 +488,7 @@ onMounted(() => { + diff --git a/frontend/src/components/moneyTrend.vue b/frontend/src/components/moneyTrend.vue new file mode 100644 index 0000000..2f67fb8 --- /dev/null +++ b/frontend/src/components/moneyTrend.vue @@ -0,0 +1,279 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/stock.vue b/frontend/src/components/stock.vue index bc65e9e..828efd3 100644 --- a/frontend/src/components/stock.vue +++ b/frontend/src/components/stock.vue @@ -63,6 +63,7 @@ import {asBlob} from 'html-docx-js-typescript'; import vueDanmaku from 'vue3-danmaku' import {keys, pad, padStart} from "lodash"; import {useRoute, useRouter} from 'vue-router' +import MoneyTrend from "./moneyTrend.vue"; const route = useRoute() const router = useRouter() @@ -98,6 +99,7 @@ const modalShow = ref(false) const modalShow2 = ref(false) const modalShow3 = ref(false) const modalShow4 = ref(false) +const modalShow5 = ref(false) const addBTN = ref(true) const formModel = ref({ name: "", @@ -1241,6 +1243,12 @@ function handleKLine(){ }); }) } +function showMoney(code,name){ + data.code=code + data.name=name + modalShow5.value=true +} + function showK(code,name){ data.code=code data.name=name @@ -1710,6 +1718,8 @@ function delStockGroup(code,name,groupId){ 成本 分时 日K + 资金 + 详情 设置分组 @@ -1821,6 +1831,8 @@ function delStockGroup(code,name,groupId){ 成本 分时 日K + 资金 + 详情 设置分组 @@ -1988,6 +2000,9 @@ function delStockGroup(code,name,groupId){ + + +