This commit is contained in:
2025-09-25 15:31:11 +08:00
parent d18a3d5279
commit 972e76e655
11 changed files with 766 additions and 453 deletions

View File

@@ -23,9 +23,10 @@ export class AppRegistry {
*/
registerApp(registration: AppRegistration): void {
// 使用 markRaw 标记组件,避免被设为响应式
// 注意对于异步组件我们不立即标记为raw而是在实际加载时处理
const safeRegistration = {
...registration,
component: registration.component ? markRaw(registration.component) : registration.component
component: registration.component,
}
this.apps.set(registration.manifest.id, safeRegistration)
console.log(`已注册内置应用: ${registration.manifest.name}`)
@@ -49,7 +50,7 @@ export class AppRegistry {
* 获取所有内置应用
*/
getBuiltInApps(): AppRegistration[] {
return Array.from(this.apps.values()).filter(app => app.isBuiltIn)
return Array.from(this.apps.values()).filter((app) => app.isBuiltIn)
}
/**
@@ -63,9 +64,7 @@ export class AppRegistry {
* 按类别获取应用
*/
getAppsByCategory(category: string): AppRegistration[] {
return Array.from(this.apps.values()).filter(
app => app.manifest.category === category
)
return Array.from(this.apps.values()).filter((app) => app.manifest.category === category)
}
/**
@@ -73,14 +72,12 @@ export class AppRegistry {
*/
searchApps(query: string): AppRegistration[] {
const lowercaseQuery = query.toLowerCase()
return Array.from(this.apps.values()).filter(app => {
return Array.from(this.apps.values()).filter((app) => {
const manifest = app.manifest
return (
manifest.name.toLowerCase().includes(lowercaseQuery) ||
manifest.description.toLowerCase().includes(lowercaseQuery) ||
manifest.keywords?.some(keyword =>
keyword.toLowerCase().includes(lowercaseQuery)
)
manifest.keywords?.some((keyword) => keyword.toLowerCase().includes(lowercaseQuery))
)
})
}
@@ -94,4 +91,4 @@ export class AppRegistry {
}
// 导出单例实例
export const appRegistry = AppRegistry.getInstance()
export const appRegistry = AppRegistry.getInstance()