mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
feat(frontend): 优化股票代码输入和搜索功能
- 改进股票列表显示格式,增加连字符分隔 - 添加支持直接输入股票代码进行搜索的功能 - 优化股票选择逻辑,支持不同格式的股票代码 -增加调试日志输出,便于问题排查
This commit is contained in:
parent
f9a0c8d94e
commit
15120c98da
@ -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())
|
||||
|
@ -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) {
|
||||
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"/> 关注该股票
|
||||
</n-button>
|
||||
|
Loading…
x
Reference in New Issue
Block a user