File tree Expand file tree Collapse file tree 5 files changed +16
-4
lines changed Expand file tree Collapse file tree 5 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 88
99type Settings struct {
1010 gorm.Model
11+ TushareToken string `json:"tushareToken"`
1112 LocalPushEnable bool `json:"localPushEnable"`
1213 DingPushEnable bool `json:"dingPushEnable"`
1314 DingRobot string `json:"dingRobot"`
@@ -52,6 +53,7 @@ func (s SettingsApi) UpdateConfig() string {
5253 "open_ai_model_name" : s .Config .OpenAiModelName ,
5354 "open_ai_max_tokens" : s .Config .OpenAiMaxTokens ,
5455 "open_ai_temperature" : s .Config .OpenAiTemperature ,
56+ "tushare_token" : s .Config .TushareToken ,
5557 })
5658 } else {
5759 logger .SugaredLogger .Infof ("未找到配置,创建默认配置:%+v" , s .Config )
@@ -67,6 +69,7 @@ func (s SettingsApi) UpdateConfig() string {
6769 OpenAiModelName : s .Config .OpenAiModelName ,
6870 OpenAiMaxTokens : s .Config .OpenAiMaxTokens ,
6971 OpenAiTemperature : s .Config .OpenAiTemperature ,
72+ TushareToken : s .Config .TushareToken ,
7073 })
7174 }
7275 return "保存成功!"
Original file line number Diff line number Diff line change @@ -28,10 +28,10 @@ import (
2828
2929const sinaStockUrl = "http://hq.sinajs.cn/rn=%d&list=%s"
3030const tushareApiUrl = "http://api.tushare.pro"
31- const TushareToken = "9125ec636217a99a3218a64fc63507e95205f2666590792923cbaedf"
3231
3332type StockDataApi struct {
3433 client * resty.Client
34+ config * Settings
3535}
3636type StockInfo struct {
3737 gorm.Model
@@ -181,6 +181,7 @@ func (receiver StockBasic) TableName() string {
181181func NewStockDataApi () * StockDataApi {
182182 return & StockDataApi {
183183 client : resty .New (),
184+ config : getConfig (),
184185 }
185186}
186187
@@ -192,7 +193,7 @@ func (receiver StockDataApi) GetIndexBasic() {
192193 SetHeader ("content-type" , "application/json" ).
193194 SetBody (& TushareRequest {
194195 ApiName : "index_basic" ,
195- Token : TushareToken ,
196+ Token : receiver . config . TushareToken ,
196197 Params : nil ,
197198 Fields : fields }).
198199 SetResult (res ).
@@ -236,7 +237,7 @@ func (receiver StockDataApi) GetStockBaseInfo() {
236237 SetHeader ("content-type" , "application/json" ).
237238 SetBody (& TushareRequest {
238239 ApiName : "stock_basic" ,
239- Token : TushareToken ,
240+ Token : receiver . config . TushareToken ,
240241 Params : nil ,
241242 Fields : fields ,
242243 }).
Original file line number Diff line number Diff line change 1- 21651c02a381710ff84c03c3ee0a8235
1+ 39a415166f03acc0270e24443a9e2445
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const message = useMessage()
99const formRef = ref (null )
1010const formValue = ref ({
1111 ID : 1 ,
12+ tushareToken: ' ' ,
1213 dingPush: {
1314 enable: false ,
1415 dingRobot: ' '
@@ -31,6 +32,7 @@ const formValue = ref({
3132onMounted (()=> {
3233 GetConfig ().then (res => {
3334 formValue .value .ID = res .ID
35+ formValue .value .tushareToken = res .tushareToken
3436 formValue .value .dingPush = {
3537 enable: res .dingPushEnable ,
3638 dingRobot: res .dingRobot
@@ -68,6 +70,7 @@ function saveConfig(){
6870 openAiModelName: formValue .value .openAI .model ,
6971 openAiMaxTokens: formValue .value .openAI .maxTokens ,
7072 openAiTemperature: formValue .value .openAI .temperature ,
73+ tushareToken: formValue .value .tushareToken
7174 })
7275
7376 // console.log("Settings",config)
@@ -106,6 +109,9 @@ function sendTestNotice(){
106109 <n-gi :span =" 24" >
107110 <n-text type =" default" style =" font-size : 25px ;font-weight : bold " >基础设置</n-text >
108111 </n-gi >
112+ <n-form-item-gi :span =" 10" label =" Tushare api token:" path =" tushareToken" >
113+ <n-input type =" text" placeholder =" Tushare api token" v-model:value =" formValue.tushareToken" clearable />
114+ </n-form-item-gi >
109115 <n-form-item-gi :span =" 6" label =" 启动时更新A股/指数信息:" path =" updateBasicInfoOnStart" >
110116 <n-switch v-model:value =" formValue.updateBasicInfoOnStart" />
111117 </n-form-item-gi >
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ export namespace data {
6161 UpdatedAt : any ;
6262 // Go type: gorm
6363 DeletedAt : any ;
64+ tushareToken : string ;
6465 localPushEnable : boolean ;
6566 dingPushEnable : boolean ;
6667 dingRobot : string ;
@@ -83,6 +84,7 @@ export namespace data {
8384 this . CreatedAt = this . convertValues ( source [ "CreatedAt" ] , null ) ;
8485 this . UpdatedAt = this . convertValues ( source [ "UpdatedAt" ] , null ) ;
8586 this . DeletedAt = this . convertValues ( source [ "DeletedAt" ] , null ) ;
87+ this . tushareToken = source [ "tushareToken" ] ;
8688 this . localPushEnable = source [ "localPushEnable" ] ;
8789 this . dingPushEnable = source [ "dingPushEnable" ] ;
8890 this . dingRobot = source [ "dingRobot" ] ;
You can’t perform that action at this time.
0 commit comments