From 899bd05defb2710fd00c59fde9e725a4ad662cdc Mon Sep 17 00:00:00 2001
From: lidashuang
Date: Thu, 28 Nov 2024 21:11:22 +0800
Subject: [PATCH] fix(wallstreetcn): crash when article delete (#17734)
* fix(wallstreetcn): crash when article delete
TypeError: Cannot read properties of undefined (reading 'display_name')
* fix(style): camelCase
---
lib/routes/wallstreetcn/news.ts | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/routes/wallstreetcn/news.ts b/lib/routes/wallstreetcn/news.ts
index f7674c75f..84320dc8f 100644
--- a/lib/routes/wallstreetcn/news.ts
+++ b/lib/routes/wallstreetcn/news.ts
@@ -74,7 +74,14 @@ async function handler(ctx) {
url: `${apiRootUrl}/apiv1/content/${item.type === 'live' ? `lives/${item.guid}` : `articles/${item.guid}?extract=0`}`,
});
- const data = detailResponse.data.data;
+ const responseData = detailResponse.data;
+
+ // 处理 { code: 60301, message: '内容不存在或已被删除', data: {} }
+ if (responseData.code !== 20000) {
+ return null;
+ }
+
+ const data = responseData.data;
item.title = data.title || data.content_text;
item.author = data.source_name ?? data.author.display_name;
@@ -95,6 +102,8 @@ async function handler(ctx) {
)
);
+ items = items.filter((item) => item !== null);
+
return {
title: `华尔街见闻 - 资讯 - ${titles[category]}`,
link: currentUrl,