Skip to content

Commit 83aa433

Browse files
committed
feat(notify):新增只提醒红字或关注个股新闻的设置
- 在 App 中实现只推送红字或关注个股新闻的逻辑 - 在前端添加 enableOnlyPushRedNews 配置项 - 更新后端设置 API 以支持新功能
1 parent d4d3c44 commit 83aa433

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

app.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,21 @@ func (a *App) CheckStockBaseInfo(ctx context.Context) {
545545

546546
}
547547
func (a *App) NewsPush(news *[]models.Telegraph) {
548+
549+
follows := data.NewStockDataApi().GetFollowList(0)
550+
stockNames := slice.Map(*follows, func(index int, item data.FollowedStock) string {
551+
return item.Name
552+
})
553+
548554
for _, telegraph := range *news {
549-
//if telegraph.IsRed {
550-
go runtime.EventsEmit(a.ctx, "newsPush", telegraph)
551-
go data.NewAlertWindowsApi("go-stock", telegraph.Source+" "+telegraph.Time, telegraph.Content, string(icon)).SendNotification()
555+
if a.GetConfig().EnableOnlyPushRedNews {
556+
if telegraph.IsRed || strutil.ContainsAny(telegraph.Content, stockNames) {
557+
go runtime.EventsEmit(a.ctx, "newsPush", telegraph)
558+
}
559+
} else {
560+
go runtime.EventsEmit(a.ctx, "newsPush", telegraph)
561+
}
562+
//go data.NewAlertWindowsApi("go-stock", telegraph.Source+" "+telegraph.Time, telegraph.Content, string(icon)).SendNotification()
552563
//}
553564
}
554565
}

backend/data/settings_api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Settings struct {
3131
BrowserPoolSize int `json:"browserPoolSize"`
3232
EnableFund bool `json:"enableFund"`
3333
EnablePushNews bool `json:"enablePushNews"`
34+
EnableOnlyPushRedNews bool `json:"enableOnlyPushRedNews"`
3435
SponsorCode string `json:"sponsorCode"`
3536
HttpProxy string `json:"httpProxy"`
3637
HttpProxyEnabled bool `json:"httpProxyEnabled"`
@@ -100,6 +101,7 @@ func UpdateConfig(s *SettingConfig) string {
100101
"dark_theme": s.DarkTheme,
101102
"enable_fund": s.EnableFund,
102103
"enable_push_news": s.EnablePushNews,
104+
"enable_only_push_red_news": s.EnableOnlyPushRedNews,
103105
"sponsor_code": s.SponsorCode,
104106
"http_proxy": s.HttpProxy,
105107
"http_proxy_enabled": s.HttpProxyEnabled,

frontend/src/components/settings.vue

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const formValue = ref({
4141
darkTheme: true,
4242
enableFund: false,
4343
enablePushNews: false,
44+
enableOnlyPushRedNews: false,
4445
sponsorCode: "",
4546
httpProxy:"",
4647
httpProxyEnabled:false,
@@ -98,9 +99,11 @@ onMounted(() => {
9899
formValue.value.darkTheme = res.darkTheme
99100
formValue.value.enableFund = res.enableFund
100101
formValue.value.enablePushNews = res.enablePushNews
102+
formValue.value.enableOnlyPushRedNews = res.enableOnlyPushRedNews
101103
formValue.value.sponsorCode = res.sponsorCode
102104
formValue.value.httpProxy=res.httpProxy;
103105
formValue.value.httpProxyEnabled=res.httpProxyEnabled;
106+
104107
})
105108
106109
GetPromptTemplates("", "").then(res => {
@@ -135,6 +138,7 @@ function saveConfig() {
135138
darkTheme: formValue.value.darkTheme,
136139
enableFund: formValue.value.enableFund,
137140
enablePushNews: formValue.value.enablePushNews,
141+
enableOnlyPushRedNews: formValue.value.enableOnlyPushRedNews,
138142
sponsorCode: formValue.value.sponsorCode,
139143
httpProxy:formValue.value.httpProxy,
140144
httpProxyEnabled:formValue.value.httpProxyEnabled,
@@ -223,6 +227,7 @@ function importConfig() {
223227
formValue.value.darkTheme = config.darkTheme
224228
formValue.value.enableFund = config.enableFund
225229
formValue.value.enablePushNews = config.enablePushNews
230+
formValue.value.enableOnlyPushRedNews = config.enableOnlyPushRedNews
226231
formValue.value.sponsorCode = config.sponsorCode
227232
formValue.value.httpProxy=config.httpProxy
228233
formValue.value.httpProxyEnabled=config.httpProxyEnabled
@@ -329,21 +334,25 @@ function deletePrompt(ID) {
329334

330335
<n-card :title="() => h(NTag, { type: 'primary', bordered: false }, () => '通知设置')" size="small">
331336
<n-grid :cols="24" :x-gap="24" style="text-align: left">
332-
<n-form-item-gi :span="4" label="钉钉推送:" path="dingPush.enable">
337+
<n-form-item-gi :span="3" label="钉钉推送:" path="dingPush.enable">
333338
<n-switch v-model:value="formValue.dingPush.enable"/>
334339
</n-form-item-gi>
335-
<n-form-item-gi :span="4" label="本地推送:" path="localPush.enable">
340+
<n-form-item-gi :span="3" label="本地推送:" path="localPush.enable">
336341
<n-switch v-model:value="formValue.localPush.enable"/>
337342
</n-form-item-gi>
338-
<n-form-item-gi :span="4" label="弹幕功能:" path="enableDanmu">
343+
<n-form-item-gi :span="3" label="弹幕功能:" path="enableDanmu">
339344
<n-switch v-model:value="formValue.enableDanmu"/>
340345
</n-form-item-gi>
341-
<n-form-item-gi :span="4" label="显示滚动快讯:" path="enableNews">
346+
<n-form-item-gi :span="3" label="显示滚动快讯:" path="enableNews">
342347
<n-switch v-model:value="formValue.enableNews"/>
343348
</n-form-item-gi>
344-
<n-form-item-gi :span="4" label="市场资讯提醒:" path="enablePushNews">
349+
<n-form-item-gi :span="3" label="市场资讯提醒:" path="enablePushNews">
345350
<n-switch v-model:value="formValue.enablePushNews"/>
346351
</n-form-item-gi>
352+
<n-form-item-gi v-if="formValue.enablePushNews" :span="4" label="只提醒红字或关注个股的新闻:" path="enableOnlyPushRedNews">
353+
<n-switch v-model:value="formValue.enableOnlyPushRedNews"/>
354+
</n-form-item-gi>
355+
347356
<n-form-item-gi :span="22" v-if="formValue.dingPush.enable" label="钉钉机器人接口地址:"
348357
path="dingPush.dingRobot">
349358
<n-input placeholder="请输入钉钉机器人接口地址" v-model:value="formValue.dingPush.dingRobot"/>
@@ -461,7 +470,6 @@ function deletePrompt(ID) {
461470

462471
</n-grid>
463472
</n-card>
464-
465473
</n-space>
466474
</n-form>
467475
</n-flex>

frontend/wailsjs/go/models.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ export namespace data {
389389
browserPoolSize: number;
390390
enableFund: boolean;
391391
enablePushNews: boolean;
392+
enableOnlyPushRedNews: boolean;
392393
sponsorCode: string;
393394
httpProxy: string;
394395
httpProxyEnabled: boolean;
@@ -423,6 +424,7 @@ export namespace data {
423424
this.browserPoolSize = source["browserPoolSize"];
424425
this.enableFund = source["enableFund"];
425426
this.enablePushNews = source["enablePushNews"];
427+
this.enableOnlyPushRedNews = source["enableOnlyPushRedNews"];
426428
this.sponsorCode = source["sponsorCode"];
427429
this.httpProxy = source["httpProxy"];
428430
this.httpProxyEnabled = source["httpProxyEnabled"];

0 commit comments

Comments
 (0)