feat: 新增平台注册表基础设施
This commit is contained in:
parent
a1134d85ad
commit
1fa28d10db
19
src/platforms/registry.js
Normal file
19
src/platforms/registry.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/** 平台注册表:id → definePlatform 工厂函数 */
|
||||||
|
const registry = {}
|
||||||
|
|
||||||
|
/** 注册平台 */
|
||||||
|
export function registerPlatform(id, factory) {
|
||||||
|
registry[id] = factory
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据平台类型创建平台实例 */
|
||||||
|
export function createPlatform(type) {
|
||||||
|
const factory = registry[type]
|
||||||
|
if (!factory) throw new Error(`未注册的平台: ${type}`)
|
||||||
|
return factory()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取所有已注册平台 ID */
|
||||||
|
export function getRegisteredPlatforms() {
|
||||||
|
return Object.keys(registry)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user