feat: 完成多日读取支持

This commit is contained in:
2026-08-16 17:28:53 +08:00
parent f209d93733
commit c35c985eb0
22 changed files with 1263 additions and 246 deletions
+18 -14
View File
@@ -39,20 +39,20 @@ pnpm build
## 项目架构
```text
Popup(配置 / 选店 / 读数 / 同步)
Popup(配置 API Key / 默认店铺 / 打开悬浮层)
↓ chrome.tabs.sendMessage
Content Script(Platform Adapter)
↓ Mock / 未来真实平台
统一 AdvertisingCostBatch
↓ 映射
BI Open API(API Key)
Content Script
├─ 页内悬浮层(选日期、自动读取、同步)
└─ Platform Adapter(当前 Mock)
↓
BI Open API
```
| 环境 | 职责 |
|------|------|
| Popup | UI、配置、选 channelShopId、发起同步 |
| Content Script | 调 Adapter,不直接调 BI API |
| Background | 生命周期占位,业务不塞这里 |
| Popup | 配置、打开/开关页内悬浮层 |
| Content 悬浮层 | 选日期(变更自动读取)、选店、预览、同步到 BI |
| Background | 生命周期占位 |
新增平台:在 `src/platform/<name>/` 实现 `PlatformAdapter`,并注册到 `PlatformDetector`。
@@ -75,7 +75,7 @@ Key 需具备:
| 插件 | 后端 batch-import |
|------|-------------------|
| `channelShopId` | `channelShopId`(`channel_pdd_shop.id`) |
| `feeDate` | `feeDate`(YYYY-MM-DD,以 Popup 所选为准) |
| `items[].feeDate` | `feeDate`(YYYY-MM-DD,来自页面每条数据) |
| `items[].goodsId` | `goodsId` |
| `items[].feeAmount` | `feeAmount`(元) |
@@ -86,11 +86,15 @@ Key 需具备:
鉴权头:`X-Api-Key: <key>`(或 `Authorization: Bearer <key>`)。
## 当前 Mock 说明
## 当前能力说明
- 任意页面均可由 `MockPlatformAdapter` 处理
- 「读取数据」返回 3 条样例 `goodsId` / 金额
- 同步仍会打真实 Open API;若要用 Mock 联调,请先在 BI 侧准备对应 `channel_pdd_goods` 与 Key
- **拼多多推广总览**(`yingxiao.pinduoduo.com/.../report/promotion/overView`)已接入真实 DOM 解析:
- 店铺名:`AccountNew_mallName` → 调用店铺分页接口按名匹配 `channelShopId`
- 日期:URL `beginDate`/`endDate`(或主 RangePicker);**仅 begin=end 的单日**才读取
- 商品:`OverviewTable_goodsId`;费用列:**总花费(元)**
- 范围日期报表会提示「不记录」,不写入预览/同步
- 非上述页面仍回退 `MockPlatformAdapter` 便于本地联调
- Popup 只负责配置与打开悬浮层
## 权限说明