支持wx/browser的worker(由于wx限制默认不开启worker)

This commit is contained in:
YHH
2025-09-29 13:21:08 +08:00
parent be11060674
commit 62bc6b547e
10 changed files with 1545 additions and 31 deletions

View File

@@ -0,0 +1,48 @@
/**
* 平台适配模块导出
*/
// 接口和类型
export type {
IPlatformAdapter,
PlatformWorker,
WorkerCreationOptions,
PlatformConfig,
PlatformDetectionResult,
WeChatDeviceInfo,
BrowserDeviceInfo
} from './IPlatformAdapter';
// 平台检测器
export { PlatformDetector } from './PlatformDetector';
// 平台管理器
export { PlatformManager } from './PlatformManager';
// 平台适配器实现
export { BrowserAdapter } from './BrowserAdapter';
export { WeChatMiniGameAdapter } from './WeChatMiniGameAdapter';
// 内部导入用于便利函数
import { PlatformManager } from './PlatformManager';
// 便利函数
export function getCurrentPlatform() {
return PlatformManager.getInstance().getDetectionResult();
}
export function getCurrentAdapter() {
return PlatformManager.getInstance().getAdapter();
}
export function getBasicWorkerConfig() {
return PlatformManager.getInstance().getBasicWorkerConfig();
}
export function getFullPlatformConfig() {
return PlatformManager.getInstance().getFullPlatformConfig();
}
export function supportsFeature(feature: 'worker' | 'shared-array-buffer' | 'transferable-objects' | 'module-worker') {
return PlatformManager.getInstance().supportsFeature(feature);
}