mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 08:29:19 +08:00
feat: 新增浏览器插件
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import type { PlatformAdapter } from '@/platform/core/PlatformAdapter';
|
||||
import type { AdvertisingCostBatch, PageContext } from '@/types/advertisingCost';
|
||||
|
||||
/**
|
||||
* 第一阶段 Mock Adapter:不读真实 DOM,返回固定样例数据。
|
||||
*/
|
||||
export class MockPlatformAdapter implements PlatformAdapter {
|
||||
readonly platform = 'mock' as const;
|
||||
|
||||
canHandle(_url: string): boolean {
|
||||
// 未接入真实平台前,任意页面均可由 Mock 处理
|
||||
return true;
|
||||
}
|
||||
|
||||
async getPageContext(): Promise<PageContext> {
|
||||
return {
|
||||
url: typeof location !== 'undefined' ? location.href : '',
|
||||
title: typeof document !== 'undefined' ? document.title : '',
|
||||
platform: 'mock',
|
||||
ready: true,
|
||||
message: '当前为 Mock Adapter(未解析真实平台页面)',
|
||||
};
|
||||
}
|
||||
|
||||
async parseAdvertisingCost(
|
||||
feeDate: string,
|
||||
): Promise<Omit<AdvertisingCostBatch, 'channelShopId'>> {
|
||||
const items = [
|
||||
{ goodsId: 'mock-goods-1001', feeAmount: 128.5 },
|
||||
{ goodsId: 'mock-goods-1002', feeAmount: 56.0 },
|
||||
{ goodsId: 'mock-goods-1003', feeAmount: 1050.06 },
|
||||
];
|
||||
|
||||
return {
|
||||
platform: 'mock',
|
||||
feeDate,
|
||||
items,
|
||||
source: 'browser-extension',
|
||||
importedAt: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user