diff --git a/README.md b/README.md index 071402d..6895a4a 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ ## 👀 更新日志 -### 2025.06.18 更新内置股票基础数据 +### 2025.06.18 更新内置股票基础数据,软件内实时市场资讯信息提醒 ### 2025.06.15 添加公司公告信息搜索/查看功能 ### 2025.06.15 添加个股研报到弹出菜单 ### 2025.06.13 添加个股研报功能 diff --git a/app.go b/app.go index a4049d9..147c0de 100644 --- a/app.go +++ b/app.go @@ -178,6 +178,9 @@ func (a *App) domReady(ctx context.Context) { } entryID, err := a.cron.AddFunc(fmt.Sprintf("@every %ds", interval+10), func() { news := data.NewMarketNewsApi().GetNewTelegraph(30) + if config.EnablePushNews { + go a.NewsPush(news) + } go runtime.EventsEmit(a.ctx, "newTelegraph", news) }) if err != nil { @@ -188,6 +191,9 @@ func (a *App) domReady(ctx context.Context) { entryIDSina, err := a.cron.AddFunc(fmt.Sprintf("@every %ds", interval+10), func() { news := data.NewMarketNewsApi().GetSinaNews(30) + if config.EnablePushNews { + go a.NewsPush(news) + } go runtime.EventsEmit(a.ctx, "newSinaNews", news) }) if err != nil { @@ -292,6 +298,15 @@ func (a *App) domReady(ctx context.Context) { } +func (a *App) NewsPush(news *[]models.Telegraph) { + for _, telegraph := range *news { + //if telegraph.IsRed { + go runtime.EventsEmit(a.ctx, "newsPush", telegraph) + go data.NewAlertWindowsApi("go-stock", telegraph.Source+" "+telegraph.Time, telegraph.Content, string(icon)).SendNotification() + //} + } +} + func (a *App) AddCronTask(follow data.FollowedStock) func() { return func() { go runtime.EventsEmit(a.ctx, "warnMsg", "开始自动分析"+follow.Name+"_"+follow.StockCode) diff --git a/backend/data/settings_api.go b/backend/data/settings_api.go index 5ca4bb6..5134c45 100644 --- a/backend/data/settings_api.go +++ b/backend/data/settings_api.go @@ -34,6 +34,7 @@ type Settings struct { DarkTheme bool `json:"darkTheme"` BrowserPoolSize int `json:"browserPoolSize"` EnableFund bool `json:"enableFund"` + EnablePushNews bool `json:"enablePushNews"` } func (receiver Settings) TableName() string { @@ -78,6 +79,7 @@ func (s SettingsApi) UpdateConfig() string { "enable_news": s.Config.EnableNews, "dark_theme": s.Config.DarkTheme, "enable_fund": s.Config.EnableFund, + "enable_push_news": s.Config.EnablePushNews, }) } else { logger.SugaredLogger.Infof("未找到配置,创建默认配置:%+v", s.Config) @@ -105,6 +107,7 @@ func (s SettingsApi) UpdateConfig() string { EnableNews: s.Config.EnableNews, DarkTheme: s.Config.DarkTheme, EnableFund: s.Config.EnableFund, + EnablePushNews: s.Config.EnablePushNews, }) } return "保存成功!" diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 760e45c..aed2fd3 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -10,7 +10,7 @@ import { } from '../wailsjs/runtime' import {h, onBeforeMount, onBeforeUnmount, onMounted, ref} from "vue"; import {RouterLink, useRouter} from 'vue-router' -import {darkTheme, NIcon, NText,dateZhCN,zhCN} from 'naive-ui' +import {createDiscreteApi,darkTheme,lightTheme , NIcon, NText,dateZhCN,zhCN} from 'naive-ui' import { AlarmOutline, AnalyticsOutline, @@ -29,6 +29,9 @@ import { } from '@vicons/ionicons5' import {GetConfig, GetGroupList} from "../wailsjs/go/main/App"; + + + const router = useRouter() const loading = ref(true) const loadingMsg = ref("加载数据中...") @@ -430,6 +433,7 @@ onBeforeUnmount(() => { EventsOff("realtime_profit") EventsOff("loadingMsg") EventsOff("telegraph") + EventsOff("newsPush") }) window.onerror = function (msg, source, lineno, colno, error) { @@ -515,9 +519,17 @@ onMounted(() => { enableNews.value = true } enableFund.value = res.enableFund + const {notification } =createDiscreteApi(["notification"], { + configProviderProps: { + theme: enableDarkTheme.value ? darkTheme : lightTheme , + max: 3, + }, + }) + EventsOn("newsPush", (data) => { + notification.create({ title: data.time, content: data.content,duration:1000*60 }) + }) }) }) -