优化了侧边栏数据请求代码

This commit is contained in:
xlmessage 2025-02-17 10:11:10 +08:00
parent 7ca272ab7e
commit c4e53ee2b6

@ -15,7 +15,7 @@ const message = ref(''); // 用于存储要发送的消息
* 万策页面进行保存筛选条件保存的是一个请求参数可在数据库的user_strategy表中查看
* 通过https://wance.cqxqg.tech/api/v1/strategy/getStockPageList
* 后端的逻辑处理可在src/akshare_data/router.py文件中查看
* 由于user_strategy表中的信息仅仅是请求参数对我在后续中对分组管理操作无任何帮助所以我将请求返回来的数据进行存储在
* 由于user_strategy表中的信息仅仅是请求参数对我在后续中对分组管理操作无法对接所以我将请求返回来的数据进行存储在
* 新的一个数据库表中名为new_user_strategy的数据库表中
* 最后通过新的接口得到股票数据显示在侧边栏中
* 下面代码的逻辑大致就是这样
@ -193,27 +193,30 @@ let stocktypes = ref<StockType[]>([
info: [],
}
])
axios({
url: 'http://127.0.0.1:8012/akshare/ganggudata',
method: 'get',
}).then((res) => {
stocktypes.value[0].info = res.data
cacheinfo.value.push(res.data)
})
axios({
url: 'http://127.0.0.1:8012/akshare/meigudata',
method: 'get',
}).then((res) => {
stocktypes.value[1].info = res.data
cacheinfo.value.push(res.data)
})
axios({
url: 'http://127.0.0.1:8012/akshare/hushendata',
method: 'get',
}).then((res) => {
stocktypes.value[2].info = res.data
cacheinfo.value.push(res.data)
})
const fetchData = async () => {
const urls = [
'http://127.0.0.1:8012/akshare/ganggudata',
'http://127.0.0.1:8012/akshare/meigudata',
'http://127.0.0.1:8012/akshare/hushendata'
];
try {
const responses = await Promise.all(urls.map(url => axios.get(url)));
responses.forEach((res, index) => {
stocktypes.value[index].info = res.data;
cacheinfo.value.push(res.data);
});
} catch (error) {
console.error('Error fetching data:', error);
}
};
fetchData();
// ----------------------------------------------
const changestate = (item: any) => {
item.state = !item.state