diff --git a/frontend/src/pages/News.jsx b/frontend/src/pages/News.jsx index a7a7c5b..04cb53f 100644 --- a/frontend/src/pages/News.jsx +++ b/frontend/src/pages/News.jsx @@ -73,11 +73,19 @@ export default function News() { // 始终传递token,以便获取准确的matched_count const headers = token ? { Authorization: `Bearer ${token}` } : {} const res = await fetch(`${API_BASE}/api/information/list?info_type=${type}`, { headers }) + // 检查响应状态 + if (!res.ok) { + console.error('获取资讯列表失败:', res.status) + setInfoList([]) + setLoading(false) + return + } const data = await res.json() console.log('资讯列表:', data) setInfoList(data || []) } catch (e) { console.error(e) + setInfoList([]) } setLoading(false) }