diff --git a/src/views/TheNewView.vue b/src/views/TheNewView.vue index 8e2c868..e23eb8b 100644 --- a/src/views/TheNewView.vue +++ b/src/views/TheNewView.vue @@ -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([ 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