优化
This commit is contained in:
@@ -35,7 +35,7 @@ const builtInWindows = ref<BuiltInWindow[]>([])
|
||||
const systemService = inject<SystemServiceIntegration>('systemService')
|
||||
|
||||
// 添加内置应用窗口
|
||||
const addBuiltInWindow = (windowId: string, appId: string) => {
|
||||
const addBuiltInWindow = async (windowId: string, appId: string) => {
|
||||
// 检查应用是否存在
|
||||
const appRegistration = appRegistry.getApp(appId)
|
||||
if (!appRegistration) {
|
||||
@@ -50,11 +50,23 @@ const addBuiltInWindow = (windowId: string, appId: string) => {
|
||||
return
|
||||
}
|
||||
|
||||
// 处理异步组件加载
|
||||
let component = appRegistration.component
|
||||
if (typeof component === 'function') {
|
||||
try {
|
||||
// 如果是函数,调用它来获取组件
|
||||
component = await component()
|
||||
} catch (error) {
|
||||
console.error(`加载应用组件失败: ${appId}`, error)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 添加窗口
|
||||
const window: BuiltInWindow = {
|
||||
id: windowId,
|
||||
appId,
|
||||
component: appRegistration.component,
|
||||
component,
|
||||
props: {
|
||||
windowId,
|
||||
appId
|
||||
@@ -99,9 +111,9 @@ onMounted(() => {
|
||||
const eventService = systemService.getEventService()
|
||||
|
||||
// 监听内置应用窗口创建事件
|
||||
const subscriberId = eventService.subscribe('system', 'built-in-window-created', (message) => {
|
||||
const subscriberId = eventService.subscribe('system', 'built-in-window-created', async (message) => {
|
||||
const { windowId, appId } = message.payload
|
||||
addBuiltInWindow(windowId, appId)
|
||||
await addBuiltInWindow(windowId, appId)
|
||||
})
|
||||
|
||||
// 监听内置应用窗口关闭事件
|
||||
|
||||
Reference in New Issue
Block a user