From 0875e20a893c5ca2785d5b664838b542a9541912 Mon Sep 17 00:00:00 2001 From: wxs Date: Fri, 13 Mar 2026 19:54:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(pugongying):=20=E5=B0=86=E7=B2=89=E4=B8=9D?= =?UTF-8?q?=E5=B9=B4=E9=BE=84=E5=88=86=E5=B8=83=E6=8B=86=E5=88=86=E4=B8=BA?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E5=88=97=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 fansProfile.ages 从单个汇总字段拆分为 5 个独立年龄段列 (<18、18-24、25-34、35-44、>44),每列对应该年龄段的粉丝占比。 Co-Authored-By: Claude Opus 4.6 --- pugongying/xhs-pgy-export.user.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pugongying/xhs-pgy-export.user.js b/pugongying/xhs-pgy-export.user.js index 218bc4a..0d0806b 100644 --- a/pugongying/xhs-pgy-export.user.js +++ b/pugongying/xhs-pgy-export.user.js @@ -31,7 +31,11 @@ const FIELD_LABEL_MAP = { id: "ID", fansProfile: "粉丝画像", - "fansProfile.ages": "粉丝年龄分布", + "fansProfile.ages.<18": "18岁以下粉丝占比", + "fansProfile.ages.18-24": "18-24岁粉丝占比", + "fansProfile.ages.25-34": "25-34岁粉丝占比", + "fansProfile.ages.35-44": "35-44岁粉丝占比", + "fansProfile.ages.>44": "44岁以上粉丝占比", "fansProfile.gender.male": "粉丝男性占比", "fansProfile.gender.female": "粉丝女性占比", userId: "达人ID", @@ -142,7 +146,19 @@ const value = record[key]; if (Array.isArray(value)) { - baseTarget[nextPath] = summarizeArray(value); + if ( + value.length && + value.every( + (item) => + isPlainObject(item) && "group" in item && "percent" in item, + ) + ) { + for (const item of value) { + baseTarget[`${nextPath}.${item.group}`] = item.percent; + } + } else { + baseTarget[nextPath] = summarizeArray(value); + } continue; }