feat(pugongying): 接入 data_summary 和 fans_summary 代理接口
通过中间 API 新增 dataSummary 和 fansSummary 两个补充端点, 自动获取浏览器 cookie 并通过 X-Cookie header 传递。 新增字段映射: - 数据概览:外溢进店中位数、预估CPM、预估阅读单价、粉丝量变化幅度 - 粉丝概览:活跃/阅读/互动粉丝占比 前端字段选择器新增"数据概览"分组。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0875e20a89
commit
ad10b171e9
@ -16,6 +16,7 @@
|
|||||||
})(typeof globalThis !== "undefined" ? globalThis : this, function factory(root) {
|
})(typeof globalThis !== "undefined" ? globalThis : this, function factory(root) {
|
||||||
const API_BASE =
|
const API_BASE =
|
||||||
"https://pgy.xiaohongshu.com/api/solar/cooperator/user/blogger/";
|
"https://pgy.xiaohongshu.com/api/solar/cooperator/user/blogger/";
|
||||||
|
const PROXY_API_BASE = "https://api.internal.intelligrow.cn";
|
||||||
const SUPPLEMENTAL_ENDPOINTS = [
|
const SUPPLEMENTAL_ENDPOINTS = [
|
||||||
{
|
{
|
||||||
namespace: "fansProfile",
|
namespace: "fansProfile",
|
||||||
@ -24,12 +25,37 @@
|
|||||||
userId,
|
userId,
|
||||||
)}/fans_profile`,
|
)}/fans_profile`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
namespace: "dataSummary",
|
||||||
|
buildUrl: (userId) =>
|
||||||
|
`${PROXY_API_BASE}/v1/pugongying/data_summary?userId=${encodeURIComponent(userId)}`,
|
||||||
|
extraHeaders: () => ({ "X-Cookie": root.document.cookie }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
namespace: "fansSummary",
|
||||||
|
buildUrl: (userId) =>
|
||||||
|
`${PROXY_API_BASE}/v1/pugongying/fans_summary?userId=${encodeURIComponent(userId)}`,
|
||||||
|
extraHeaders: () => ({ "X-Cookie": root.document.cookie }),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
const NAMESPACE_LABEL_MAP = {
|
const NAMESPACE_LABEL_MAP = {
|
||||||
fansProfile: "粉丝画像",
|
fansProfile: "粉丝画像",
|
||||||
|
dataSummary: "数据概览",
|
||||||
|
fansSummary: "粉丝概览",
|
||||||
};
|
};
|
||||||
const FIELD_LABEL_MAP = {
|
const FIELD_LABEL_MAP = {
|
||||||
id: "ID",
|
id: "ID",
|
||||||
|
dataSummary: "数据概览",
|
||||||
|
"dataSummary.mCpuvNum": "外溢进店中位数",
|
||||||
|
"dataSummary.estimatePictureCpm": "预估CPM(图文)",
|
||||||
|
"dataSummary.estimateVideoCpm": "预估CPM(视频)",
|
||||||
|
"dataSummary.picReadCost": "预估阅读单价(图文)",
|
||||||
|
"dataSummary.videoReadCost": "预估阅读单价(视频)",
|
||||||
|
"dataSummary.fans30GrowthRate": "粉丝量变化幅度",
|
||||||
|
fansSummary: "粉丝概览",
|
||||||
|
"fansSummary.activeFansRate": "活跃粉丝占比(%)",
|
||||||
|
"fansSummary.readFansRate": "阅读粉丝占比(%)",
|
||||||
|
"fansSummary.engageFansRate": "互动粉丝占比(%)",
|
||||||
fansProfile: "粉丝画像",
|
fansProfile: "粉丝画像",
|
||||||
"fansProfile.ages.<18": "18岁以下粉丝占比",
|
"fansProfile.ages.<18": "18岁以下粉丝占比",
|
||||||
"fansProfile.ages.18-24": "18-24岁粉丝占比",
|
"fansProfile.ages.18-24": "18-24岁粉丝占比",
|
||||||
@ -62,11 +88,19 @@
|
|||||||
const FIELD_GROUPS = [
|
const FIELD_GROUPS = [
|
||||||
{
|
{
|
||||||
label: "达人信息",
|
label: "达人信息",
|
||||||
fields: SELECTABLE_FIELD_PATHS.filter((p) => !p.startsWith("fansProfile.")),
|
fields: SELECTABLE_FIELD_PATHS.filter(
|
||||||
|
(p) => !p.startsWith("fansProfile.") && !p.startsWith("dataSummary.") && !p.startsWith("fansSummary."),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "数据概览",
|
||||||
|
fields: SELECTABLE_FIELD_PATHS.filter((p) => p.startsWith("dataSummary.")),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "粉丝画像",
|
label: "粉丝画像",
|
||||||
fields: SELECTABLE_FIELD_PATHS.filter((p) => p.startsWith("fansProfile.")),
|
fields: SELECTABLE_FIELD_PATHS.filter(
|
||||||
|
(p) => p.startsWith("fansProfile.") || p.startsWith("fansSummary."),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const STORAGE_INPUT_KEY = "xhs-pgy-export:last-input";
|
const STORAGE_INPUT_KEY = "xhs-pgy-export:last-input";
|
||||||
@ -353,11 +387,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchSupplementalPayload(userId, fetchImpl, config) {
|
async function fetchSupplementalPayload(userId, fetchImpl, config) {
|
||||||
|
const extra =
|
||||||
|
typeof config.extraHeaders === "function" ? config.extraHeaders() : {};
|
||||||
const response = await fetchImpl(config.buildUrl(userId), {
|
const response = await fetchImpl(config.buildUrl(userId), {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
accept: "application/json, text/plain, */*",
|
accept: "application/json, text/plain, */*",
|
||||||
|
...extra,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user