From 827fb6dabdadd64c825c758a7cdab217308eebdf Mon Sep 17 00:00:00 2001 From: Evian Date: Sun, 22 Mar 2026 15:19:34 +0800 Subject: [PATCH 1/2] fix(route/zsxq): fix topic link precision loss and missing group_id in URL - topic_id values (17+ digits) exceed Number.MAX_SAFE_INTEGER, causing precision loss when parsed by JSON.parse (e.g., 82811428122848582 becomes 82811428122848580), resulting in broken topic links. - Topic URLs were missing the group_id path segment, causing 404 errors on the zsxq website. Fix: Pre-process raw JSON response to convert large integer ID fields to strings before JSON.parse. Also update the URL template to include group_id: /group/{group_id}/topic/{topic_id} --- lib/routes/zsxq/types.ts | 2 +- lib/routes/zsxq/utils.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/routes/zsxq/types.ts b/lib/routes/zsxq/types.ts index 2d1178549c1e..45473a79a7bc 100644 --- a/lib/routes/zsxq/types.ts +++ b/lib/routes/zsxq/types.ts @@ -29,7 +29,7 @@ interface BasicTopic { readers_count: number; reading_count: number; rewards_count: number; - topic_id: number; + topic_id: number | string; type: string; user_specific: { liked: false; diff --git a/lib/routes/zsxq/utils.ts b/lib/routes/zsxq/utils.ts index 00e08fcf5fb2..e2f8f25af32f 100644 --- a/lib/routes/zsxq/utils.ts +++ b/lib/routes/zsxq/utils.ts @@ -12,8 +12,12 @@ export async function customFetch>(path: s headers: { cookie: `zsxq_access_token=${config.zsxq.accessToken};`, }, + responseType: 'text', }); - const { succeeded, code, resp_data } = response.data as T; + // Preserve large integer IDs (topic_id, group_id, user_id etc.) by converting them to strings + // before JSON.parse, which would otherwise lose precision on numbers > Number.MAX_SAFE_INTEGER + const safeBody = (response.body as string).replaceAll(/("(?:topic_id|group_id|user_id|task_id|image_id|category_id)"\s*:\s*)(\d+)/g, '$1"$2"'); + const { succeeded, code, resp_data } = JSON.parse(safeBody) as T; if (succeeded) { return resp_data; } @@ -39,7 +43,7 @@ export function generateTopicDataItem(topics: Topic[]): DataItem[] { return topics.map((topic) => { let description: string | undefined; let title = ''; - const url = `https://wx.zsxq.com/topic/${topic.topic_id}`; + const url = `https://wx.zsxq.com/group/${topic.group.group_id}/topic/${topic.topic_id}`; switch (topic.type) { case 'talk': title = topic.talk?.text?.split('\n')[0] ?? '文章'; From e8cce60ade56c30f707d51979f0bb667af0b77ec Mon Sep 17 00:00:00 2001 From: Evian Date: Sun, 22 Mar 2026 15:32:31 +0800 Subject: [PATCH 2/2] fix: update group_id and user_id types to number | string --- lib/routes/zsxq/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/zsxq/types.ts b/lib/routes/zsxq/types.ts index 45473a79a7bc..19d5b8ea17b7 100644 --- a/lib/routes/zsxq/types.ts +++ b/lib/routes/zsxq/types.ts @@ -11,7 +11,7 @@ interface BasicTopic { create_time: string; digested: boolean; group: { - group_id: number; + group_id: number | string; name: string; type: string; background_url: string; @@ -22,7 +22,7 @@ interface BasicTopic { avatar_url: string; name: string; number: number; - user_id: number; + user_id: number | string; }; }>; likes_count: number;