mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
feat(settings):增加滚动快讯配置选项
- 在 Settings 结构中添加 EnableNews 字段 - 前端增加滚动快讯配置开关 - 后端逻辑中根据配置决定是否显示滚动快讯
This commit is contained in:
parent
ee5c47f2dc
commit
f7a2681157
8
app.go
8
app.go
@ -96,8 +96,8 @@ func (a *App) domReady(ctx context.Context) {
|
|||||||
|
|
||||||
// Add your action here
|
// Add your action here
|
||||||
//定时更新数据
|
//定时更新数据
|
||||||
|
config := data.NewSettingsApi(&data.Settings{}).GetConfig()
|
||||||
go func() {
|
go func() {
|
||||||
config := data.NewSettingsApi(&data.Settings{}).GetConfig()
|
|
||||||
interval := config.RefreshInterval
|
interval := config.RefreshInterval
|
||||||
if interval <= 0 {
|
if interval <= 0 {
|
||||||
interval = 1
|
interval = 1
|
||||||
@ -123,13 +123,15 @@ func (a *App) domReady(ctx context.Context) {
|
|||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
telegraph := refreshTelegraphList()
|
telegraph := refreshTelegraphList()
|
||||||
if telegraph != nil {
|
if telegraph != nil && config.EnableNews {
|
||||||
go runtime.EventsEmit(a.ctx, "telegraph", telegraph)
|
go runtime.EventsEmit(a.ctx, "telegraph", telegraph)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
go runtime.EventsEmit(a.ctx, "telegraph", refreshTelegraphList())
|
if config.EnableNews {
|
||||||
|
go runtime.EventsEmit(a.ctx, "telegraph", refreshTelegraphList())
|
||||||
|
}
|
||||||
go MonitorStockPrices(a)
|
go MonitorStockPrices(a)
|
||||||
go MonitorFundPrices(a)
|
go MonitorFundPrices(a)
|
||||||
go data.NewFundApi().AllFund()
|
go data.NewFundApi().AllFund()
|
||||||
|
@ -30,6 +30,7 @@ type Settings struct {
|
|||||||
KDays int64 `json:"kDays"`
|
KDays int64 `json:"kDays"`
|
||||||
EnableDanmu bool `json:"enableDanmu"`
|
EnableDanmu bool `json:"enableDanmu"`
|
||||||
BrowserPath string `json:"browserPath"`
|
BrowserPath string `json:"browserPath"`
|
||||||
|
EnableNews bool `json:"enableNews"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver Settings) TableName() string {
|
func (receiver Settings) TableName() string {
|
||||||
@ -71,6 +72,7 @@ func (s SettingsApi) UpdateConfig() string {
|
|||||||
"k_days": s.Config.KDays,
|
"k_days": s.Config.KDays,
|
||||||
"enable_danmu": s.Config.EnableDanmu,
|
"enable_danmu": s.Config.EnableDanmu,
|
||||||
"browser_path": s.Config.BrowserPath,
|
"browser_path": s.Config.BrowserPath,
|
||||||
|
"enable_news": s.Config.EnableNews,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
logger.SugaredLogger.Infof("未找到配置,创建默认配置:%+v", s.Config)
|
logger.SugaredLogger.Infof("未找到配置,创建默认配置:%+v", s.Config)
|
||||||
@ -95,6 +97,7 @@ func (s SettingsApi) UpdateConfig() string {
|
|||||||
KDays: s.Config.KDays,
|
KDays: s.Config.KDays,
|
||||||
EnableDanmu: s.Config.EnableDanmu,
|
EnableDanmu: s.Config.EnableDanmu,
|
||||||
BrowserPath: s.Config.BrowserPath,
|
BrowserPath: s.Config.BrowserPath,
|
||||||
|
EnableNews: s.Config.EnableNews,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return "保存成功!"
|
return "保存成功!"
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
WindowSetPosition,
|
WindowSetPosition,
|
||||||
WindowUnfullscreen
|
WindowUnfullscreen
|
||||||
} from '../wailsjs/runtime'
|
} from '../wailsjs/runtime'
|
||||||
import {h, onMounted, ref} from "vue";
|
import {h, onBeforeMount, onMounted, ref} from "vue";
|
||||||
import { RouterLink } from 'vue-router'
|
import { RouterLink } from 'vue-router'
|
||||||
import {darkTheme, NGradientText, NIcon, NText,} from 'naive-ui'
|
import {darkTheme, NGradientText, NIcon, NText,} from 'naive-ui'
|
||||||
import {
|
import {
|
||||||
@ -17,7 +17,8 @@ import {
|
|||||||
ExpandOutline,
|
ExpandOutline,
|
||||||
PowerOutline, LogoGithub, MoveOutline, WalletOutline, StarOutline, AlarmOutline, SparklesOutline,
|
PowerOutline, LogoGithub, MoveOutline, WalletOutline, StarOutline, AlarmOutline, SparklesOutline,
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
|
import {GetConfig} from "../wailsjs/go/main/App";
|
||||||
|
const enableNews= ref(false)
|
||||||
const contentStyle = ref("")
|
const contentStyle = ref("")
|
||||||
const content = ref('数据来源于网络,仅供参考;投资有风险,入市需谨慎')
|
const content = ref('数据来源于网络,仅供参考;投资有风险,入市需谨慎')
|
||||||
const isFullscreen = ref(false)
|
const isFullscreen = ref(false)
|
||||||
@ -197,6 +198,15 @@ window.onerror = function (msg, source, lineno, colno, error) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onBeforeMount(()=>{
|
||||||
|
GetConfig().then((res)=>{
|
||||||
|
console.log(res)
|
||||||
|
if(res.enableNews){
|
||||||
|
enableNews.value=true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
contentStyle.value="max-height: calc(90vh);overflow: hidden"
|
contentStyle.value="max-height: calc(90vh);overflow: hidden"
|
||||||
})
|
})
|
||||||
@ -232,7 +242,7 @@ onMounted(()=>{
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<n-gi>
|
<n-gi>
|
||||||
<n-marquee :speed="100" style="position: relative;top:0;z-index: 19;width: 100%" v-if="telegraph.length>0">
|
<n-marquee :speed="100" style="position: relative;top:0;z-index: 19;width: 100%" v-if="(telegraph.length>0)&&(enableNews)">
|
||||||
<n-tag type="warning" v-for="item in telegraph" style="margin-right: 10px">
|
<n-tag type="warning" v-for="item in telegraph" style="margin-right: 10px">
|
||||||
{{item}}
|
{{item}}
|
||||||
</n-tag>
|
</n-tag>
|
||||||
|
@ -35,6 +35,7 @@ const formValue = ref({
|
|||||||
},
|
},
|
||||||
enableDanmu:false,
|
enableDanmu:false,
|
||||||
browserPath: '',
|
browserPath: '',
|
||||||
|
enableNews:false,
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
@ -65,6 +66,8 @@ onMounted(()=>{
|
|||||||
}
|
}
|
||||||
formValue.value.enableDanmu = res.enableDanmu
|
formValue.value.enableDanmu = res.enableDanmu
|
||||||
formValue.value.browserPath = res.browserPath
|
formValue.value.browserPath = res.browserPath
|
||||||
|
formValue.value.enableNews = res.enableNews
|
||||||
|
|
||||||
console.log(res)
|
console.log(res)
|
||||||
})
|
})
|
||||||
//message.info("加载完成")
|
//message.info("加载完成")
|
||||||
@ -92,7 +95,8 @@ function saveConfig(){
|
|||||||
crawlTimeOut:formValue.value.openAI.crawlTimeOut,
|
crawlTimeOut:formValue.value.openAI.crawlTimeOut,
|
||||||
kDays:formValue.value.openAI.kDays,
|
kDays:formValue.value.openAI.kDays,
|
||||||
enableDanmu:formValue.value.enableDanmu,
|
enableDanmu:formValue.value.enableDanmu,
|
||||||
browserPath:formValue.value.browserPath
|
browserPath:formValue.value.browserPath,
|
||||||
|
enableNews:formValue.value.enableNews,
|
||||||
})
|
})
|
||||||
|
|
||||||
//console.log("Settings",config)
|
//console.log("Settings",config)
|
||||||
@ -165,6 +169,7 @@ function importConfig(){
|
|||||||
}
|
}
|
||||||
formValue.value.enableDanmu = config.enableDanmu
|
formValue.value.enableDanmu = config.enableDanmu
|
||||||
formValue.value.browserPath = config.browserPath
|
formValue.value.browserPath = config.browserPath
|
||||||
|
formValue.value.enableNews = config.enableNews
|
||||||
// formRef.value.resetFields()
|
// formRef.value.resetFields()
|
||||||
};
|
};
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
@ -227,6 +232,9 @@ window.onerror = function (event, source, lineno, colno, error) {
|
|||||||
<n-form-item-gi :span="5" label="弹幕功能:" path="enableDanmu" >
|
<n-form-item-gi :span="5" label="弹幕功能:" path="enableDanmu" >
|
||||||
<n-switch v-model:value="formValue.enableDanmu" />
|
<n-switch v-model:value="formValue.enableDanmu" />
|
||||||
</n-form-item-gi>
|
</n-form-item-gi>
|
||||||
|
<n-form-item-gi :span="5" label="是否显示滚动快讯(重启生效):" path="enableNews" >
|
||||||
|
<n-switch v-model:value="formValue.enableNews" />
|
||||||
|
</n-form-item-gi>
|
||||||
<n-form-item-gi :span="22" v-if="formValue.dingPush.enable" label="钉钉机器人接口地址:" path="dingPush.dingRobot" >
|
<n-form-item-gi :span="22" v-if="formValue.dingPush.enable" label="钉钉机器人接口地址:" path="dingPush.dingRobot" >
|
||||||
<n-input placeholder="请输入钉钉机器人接口地址" v-model:value="formValue.dingPush.dingRobot"/>
|
<n-input placeholder="请输入钉钉机器人接口地址" v-model:value="formValue.dingPush.dingRobot"/>
|
||||||
<n-button type="primary" @click="sendTestNotice">发送测试通知</n-button>
|
<n-button type="primary" @click="sendTestNotice">发送测试通知</n-button>
|
||||||
|
@ -171,6 +171,7 @@ export namespace data {
|
|||||||
kDays: number;
|
kDays: number;
|
||||||
enableDanmu: boolean;
|
enableDanmu: boolean;
|
||||||
browserPath: string;
|
browserPath: string;
|
||||||
|
enableNews: boolean;
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
static createFrom(source: any = {}) {
|
||||||
return new Settings(source);
|
return new Settings(source);
|
||||||
@ -202,6 +203,7 @@ export namespace data {
|
|||||||
this.kDays = source["kDays"];
|
this.kDays = source["kDays"];
|
||||||
this.enableDanmu = source["enableDanmu"];
|
this.enableDanmu = source["enableDanmu"];
|
||||||
this.browserPath = source["browserPath"];
|
this.browserPath = source["browserPath"];
|
||||||
|
this.enableNews = source["enableNews"];
|
||||||
}
|
}
|
||||||
|
|
||||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user