feat(frontend): 优化股票代码输入和搜索功能

- 改进股票列表显示格式,增加连字符分隔
- 添加支持直接输入股票代码进行搜索的功能
- 优化股票选择逻辑,支持不同格式的股票代码
-增加调试日志输出,便于问题排查
This commit is contained in:
spark 2025-01-02 15:39:39 +08:00
parent f9a0c8d94e
commit 15120c98da
2 changed files with 18 additions and 4 deletions

View File

@ -233,6 +233,7 @@ func (receiver StockDataApi) GetStockCodeRealTimeData(StockCode string) (*StockI
}
func (receiver StockDataApi) Follow(stockCode string) string {
logger.SugaredLogger.Infof("Follow %s", stockCode)
stockInfo, err := receiver.GetStockCodeRealTimeData(stockCode)
if err != nil {
logger.SugaredLogger.Error(err.Error())

View File

@ -64,6 +64,7 @@ onMounted(() => {
ticker.value=setInterval(() => {
if(isTradingTime()){
monitor()
data.fenshiURL='http://image.sinajs.cn/newchart/min/n/'+data.code+'.gif'+"?t="+Date.now()
}
}, 3000)
@ -138,15 +139,19 @@ function removeMonitor(code,name) {
})
}
function getStockList(){
function getStockList(value){
console.log("getStockList",value)
let result;
result=stockList.value.filter(item => item.name.includes(data.name)||item.ts_code.includes(data.name))
options.value=result.map(item => {
return {
label: item.name+" "+item.ts_code,
label: item.name+" - "+item.ts_code,
value: item.ts_code
}
})
if(value.indexOf("-")<=0){
data.code=value
}
}
async function monitor() {
@ -189,7 +194,15 @@ async function monitor() {
}
}
function onSelect(item) {
data.code=item.split(".")[1].toLowerCase()+item.split(".")[0]
console.log("onSelect",item)
if(item.indexOf("-")>0){
item=item.split("-")[1].toLowerCase()
}
if(item.indexOf(".")>0){
data.code=item.split(".")[1].toLowerCase()+item.split(".")[0]
}
}
function search(code,name){
@ -306,7 +319,7 @@ function fullscreen(){
}"
:options="options"
placeholder="请输入股票名称或者代码"
clearable @input="getStockList" :on-select="onSelect"/>
clearable @update-value="getStockList" :on-select="onSelect"/>
<n-button type="primary" @click="AddStock">
<n-icon :component="Add"/> &nbsp;关注该股票
</n-button>