Files
store_ai_extension/src/config/platforms.ts
2026-05-06 17:42:40 +08:00

311 lines
14 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type {PlatformConfig} from '@/types';
export const PLATFORM_CONFIGS: PlatformConfig[] = [
{
id: 'Shopee',
name: 'Shopee 后台',
steps: [
{
name: '数据看板',
uniqueKey: 'databoard',
url: 'https://seller.shopee.com.my/',
checkSelector: '.page-container',
fields: [
{
label: "出货统计",
className: ".status .custom-row",
keys: [
{
label: "待处理出货",
className: ".custom-col-5:nth-child(1) .item-title"
},
{
label: "已处理出货",
className: ".custom-col-5:nth-child(2) .item-title"
},
{
label: "退货/退款/取消",
className: ".custom-col-5:nth-child(3) .item-title"
},
{
label: "已禁止/压制商品",
className: ".custom-col-5:nth-child(4) .item-title"
},
]
},
{
label: "商业分析",
className: ".data-dashboard .metrics",
keys: [
{
label: "销售",
className: ".metric:nth-child(1) ",
keys: [
{label: "value", className: ".metric-value"},
{label: "change", className: ".metric-rate"}
]
},
{
label: "访客数",
className: ".metric:nth-child(2) ",
keys: [
{label: "value", className: ".metric-value"},
{label: "change", className: ".metric-rate"}
]
},
{
label: "Product Clicks",
className: ".metric:nth-child(3)",
keys: [
{label: "value", className: ".metric-value"},
{label: "change", className: ".metric-rate"}
]
},
{
label: "订单",
className: ".metric:nth-child(4)",
keys: [
{label: "value", className: ".metric-value"},
{label: "change", className: ".metric-rate"}
]
},
{
label: "Order Conversion Rate",
className: ".metric:nth-child(5)",
keys: [
{label: "value", className: ".metric-value"},
{label: "change", className: ".metric-rate"}
]
},
]
},
{
label: "Shopee广告",
className: ".ads-data-container",
keys: [
{
label: "广告余额",
className: ".ads-data-cell:nth-of-type(1) ",
keys: [
{label: "value", className: ".ads-data-report-number"},
]
},
{
label: "销售额",
className: ".ads-data-cell:nth-child(3) ",
keys: [
{label: "value", className: ".ads-data-report-number"},
{label: "change", className: ".ratio "}
]
},
{
label: "花费",
className: ".ads-data-cell:nth-child(4)",
keys: [
{label: "value", className: ".ads-data-report-number"},
{label: "change", className: ".ratio "}
]
},
{
label: "广告支出回报率",
className: ".ads-data-cell:nth-child(5)",
keys: [
{label: "value", className: ".ads-data-report-number"},
{label: "change", className: ".ratio "}
]
},
]
},
],
},
{
name: "广告中心",
uniqueKey: "adscenter",
url: "https://seller.shopee.com.my/portal/marketing/pas/index",
checkSelector: '.page-container',
fields: [
{
label: "我的账户",
className: ".my-account-wrap",
keys: [
{
label: "广告余额",
className: ".credit-expense-label-wrapper:nth-child(1) .ellipsis-content"
},
{
label: "今日广告花费",
className: ".credit-expense-label-wrapper:nth-child(2) .ellipsis-content"
},
]
},
{
label: "进行中广告列表",
className: ".eds-table__body-container",
type: 2,
condition: {
list: [".eds-radio-group label:nth-child(3)"],
time: 400
},
tableParts: [
{name: "fixed", select: ".eds-table__fix-body"},
{name: "main", select: ".eds-table__main-body"}
],
keys: [
{
label: "广告信息",
className: ".info-containter",
part: "fixed",
keys: [
{
label: "广告名称",
className: ".campaign-name-container"
},
{
label: "广告类型",
className: ".gmv-max-noti"
},
{
label: "结束时间",
className: ".time-edit-wrapper"
}
]
},
{
label: "每日预算",
part: "main",
className: "td:nth-child(1)"
},
{
label: "目标ROAS",
part: "main",
className: "td:nth-child(2)"
},
{
label: "花费",
part: "main",
className: "td:nth-child(4)"
},
{
label: "销售额",
part: "main",
className: "td:nth-child(5)"
},
{
label: "广告支出回报率",
part: "main",
className: "td:nth-child(6)"
}
],
pagination: {
nextBtn: ".eds-pager__button-next", // 下一页按钮
disabledClass: ".eds-button--disabled", // 按钮禁用时的class用来判断结束
maxPage: 1, // 最大爬取页数
delay: 2000 // 翻页后的等待加载时间
},
}
]
},
{
name: "评论管理",
uniqueKey: "message",
url: "https://seller.shopee.com.my/portal/settings/shop/rating?pageNumber=1&fromPageNumber=1&cursor=0&pageSize=20&replied=TO_REPLY&ratingStar=2&ratingStar=1",
checkSelector: '.page-container',
fields: [
{
label: "低星评论",
className: ".border-solid.rounded",
type: 1,
keys: [
{
label: "用户",
className: ".flex.items-center.justify-start .ml-2"
},
{
label: "订单编号",
className: ".underline.px-1"
},
{
label: "商品名称",
className: ".min-w-0.font-medium.break-all"
},
{
label: "规格",
className: ".min-w-0.font-medium.break-all + div"
},
{
label: "评价内容",
className: ".min-w-0.overflow-hidden",
condition: {
list: [
"span.cursor-pointer"
],
time: 200,
},
},
],
pagination: {
nextBtn: ".eds-react-pagination-pager__button-next",
maxPage: 2, // 最大爬取页数
delay: 2000 // 翻页后的等待加载时间
},
},
]
},
{
name: "账户健康状态",
uniqueKey: "accounthealth",
url: "https://seller.shopee.com.my/portal/accounthealth/home",
checkSelector: '.page-container',
fields: [
{
label: "健康状态",
className: ".metric-content",
type: 1,
keys: [
{
label: "模块名",
className: ".metric-type"
},
{
label: "值",
className: ".metric-item",
type: 1,
keys: [
{
label: "指标",
className: "p.metric-text"
},
{
label: "值",
className: ".metric-my"
},
{
label: "目标",
className: ".metric-target"
},
{
label: "使用类型",
className: ".metric-applied-to"
},
]
},
],
},
]
}
],
},
]
/**
* 根据平台 ID 返回对应的平台抓取配置。
*/
export function getPlatformById(platformId: string) {
return PLATFORM_CONFIGS.find((item) => item.id === platformId) ?? null;
}