mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 13:09:19 +08:00
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
/**
|
|
* 远程功能包入口(IIFE → dist-features/pdd-ad-fee.js)。
|
|
* 在页面 MAIN world 执行;Open API / 设置走壳侧 postMessage 桥接。
|
|
*/
|
|
import { installMainWorldAdapters } from '@/features/runtime/mainWorldAdapters';
|
|
import { setFloatingVisible } from '@/content/floating/mount';
|
|
|
|
const FEATURE_ID = 'pdd-ad-fee';
|
|
const FEATURE_VERSION = '0.3.10';
|
|
|
|
export interface RemoteFeatureExport {
|
|
id: string;
|
|
version: string;
|
|
executionWorld: 'main';
|
|
mount: () => Promise<void>;
|
|
unmount: () => Promise<void>;
|
|
}
|
|
|
|
installMainWorldAdapters();
|
|
|
|
const feature: RemoteFeatureExport = {
|
|
id: FEATURE_ID,
|
|
version: FEATURE_VERSION,
|
|
executionWorld: 'main',
|
|
async mount() {
|
|
setFloatingVisible(true);
|
|
},
|
|
async unmount() {
|
|
setFloatingVisible(false);
|
|
},
|
|
};
|
|
|
|
declare global {
|
|
interface Window {
|
|
__ECBI_FEATURES__?: Record<string, RemoteFeatureExport>;
|
|
}
|
|
}
|
|
|
|
const g = globalThis as typeof globalThis & {
|
|
__ECBI_FEATURES__?: Record<string, RemoteFeatureExport>;
|
|
};
|
|
g.__ECBI_FEATURES__ = g.__ECBI_FEATURES__ ?? {};
|
|
g.__ECBI_FEATURES__[FEATURE_ID] = feature;
|
|
|
|
export default feature;
|