抽象worker接口,避免污染项目
This commit is contained in:
@@ -8,9 +8,7 @@ export type {
|
||||
PlatformWorker,
|
||||
WorkerCreationOptions,
|
||||
PlatformConfig,
|
||||
PlatformDetectionResult,
|
||||
WeChatDeviceInfo,
|
||||
BrowserDeviceInfo
|
||||
PlatformDetectionResult
|
||||
} from './IPlatformAdapter';
|
||||
|
||||
// 平台检测器
|
||||
@@ -19,16 +17,13 @@ export { PlatformDetector } from './PlatformDetector';
|
||||
// 平台管理器
|
||||
export { PlatformManager } from './PlatformManager';
|
||||
|
||||
// 平台适配器实现
|
||||
export { BrowserAdapter } from './BrowserAdapter';
|
||||
export { WeChatMiniGameAdapter } from './WeChatMiniGameAdapter';
|
||||
|
||||
// 内部导入用于便利函数
|
||||
import { PlatformManager } from './PlatformManager';
|
||||
import type { IPlatformAdapter } from './IPlatformAdapter';
|
||||
|
||||
// 便利函数
|
||||
export function getCurrentPlatform() {
|
||||
return PlatformManager.getInstance().getDetectionResult();
|
||||
export function registerPlatformAdapter(adapter: IPlatformAdapter) {
|
||||
return PlatformManager.getInstance().registerAdapter(adapter);
|
||||
}
|
||||
|
||||
export function getCurrentAdapter() {
|
||||
@@ -45,4 +40,8 @@ export function getFullPlatformConfig() {
|
||||
|
||||
export function supportsFeature(feature: 'worker' | 'shared-array-buffer' | 'transferable-objects' | 'module-worker') {
|
||||
return PlatformManager.getInstance().supportsFeature(feature);
|
||||
}
|
||||
|
||||
export function hasAdapter() {
|
||||
return PlatformManager.getInstance().hasAdapter();
|
||||
}
|
||||
Reference in New Issue
Block a user