From 0154e114d98c32e9ebf3ee1fc686f97bb44a0de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=82=85=E5=85=89=E5=AD=9F?= Date: Wed, 11 Feb 2026 12:01:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E9=87=8D=E6=9E=84=E6=96=B0?= =?UTF-8?q?=E9=97=BBAPI=E8=AF=B7=E6=B1=82=E6=96=B9=E5=BC=8F=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将拼接字符串的请求方式改为对象配置方式 - 添加对测试环境API地址的支持 - 增加baseURL配置以支持不同环境 refactor(news): 优化多个组件的代码结构和错误处理 - 修复数据为空时的访问错误,添加安全检查 - 限制股票显示数量为前两个 - 优化API响应数据的安全访问 style(article): 调整样式和注释相关修改 - 注释掉不需要的底部填充样式 - 隐藏分割线和评论组件 - 更新星级评分的显示方式 --- src/api/newsInfo.ts | 46 +++++++++++++++++-- src/components/article/indexNewsInfo.vue | 2 +- src/pages/detail/indexNewsInfo.vue | 6 +-- src/pages/foreign/index.vue | 10 ++-- .../components/ConceptNewsView/index.vue | 3 +- .../components/IndustryNewsView/index.vue | 3 +- src/pages/recommend/index.vue | 12 +++-- src/utils/indexDatav.ts | 2 +- 8 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/api/newsInfo.ts b/src/api/newsInfo.ts index 43b43f7..6df2e9b 100644 --- a/src/api/newsInfo.ts +++ b/src/api/newsInfo.ts @@ -23,7 +23,15 @@ export const getTopNewsDay = (data: any) => { // 概念标签贴标 export const getTopNews = (data: any) => { - return request.get("/top_news_h5_period?start_date=" + data.start_date + "&end_date=" + data.end_date + "&limit_num=" + data.limit_num, data); + return request.get( + "/top_news_h5_period?start_date=" + + data.start_date + + "&end_date=" + + data.end_date + + "&limit_num=" + + data.limit_num, + data, + ); // return request.get("/top_news_h5_d", data); }; // 概念标签贴标 @@ -48,14 +56,44 @@ export const getNews_cnt_d = (data: any) => { // 热门标签某时间段内topN列表(左边第一个) export const getTopConceptPeriod = (data: any) => { - return request.get("/top_concept_period?start_date=" + data.start_time + "&end_date=" + data.end_time + "&limit_num=" + data.limit_num, data); + // return request.get("/top_concept_period?start_date=" + data.start_time + "&end_date=" + data.end_time + "&limit_num=" + data.limit_num, data); + console.log("output >>>>> ", import.meta.env.MODE); + return request({ + baseURL: import.meta.env.VITE_API_TEST_DATAV_URL, + url: "/top_concept_period", + method: "get", + params: { + start_date: data.start_time, + end_date: data.end_time, + limit_num: data.limit_num, + }, + }); }; // 热门行业某时间段内topN列表(中间第二个) export const getTopIndustryPeriod = (data: any) => { - return request.get("/top_industry_period?start_date=" + data.start_time + "&end_date=" + data.end_time + "&limit_num=" + data.limit_num, data); + // return request.get("/top_industry_period?start_date=" + data.start_time + "&end_date=" + data.end_time + "&limit_num=" + data.limit_num, data); + + return request({ + baseURL: import.meta.env.VITE_API_TEST_DATAV_URL, + url: "/top_industry_period", + method: "get", + params: { + start_date: data.start_time, + end_date: data.end_time, + limit_num: data.limit_num, + }, + }); }; // 热门标签某时间段内topN列表(右边) export const getTopSourcePeriod = (data: any) => { - return request.get("/top_source_period?start_date=" + data.start_time + "&end_date=" + data.end_time + "&limit_num=" + data.limit_num, data); + return request.get( + "/top_source_period?start_date=" + + data.start_time + + "&end_date=" + + data.end_time + + "&limit_num=" + + data.limit_num, + data, + ); }; diff --git a/src/components/article/indexNewsInfo.vue b/src/components/article/indexNewsInfo.vue index 5415f13..6df8182 100644 --- a/src/components/article/indexNewsInfo.vue +++ b/src/components/article/indexNewsInfo.vue @@ -340,7 +340,7 @@ const getMoreNews = () => {