diff --git a/src/components/haex/extension/launcher.vue b/src/components/haex/extension/launcher.vue index 20da95b..a7336b1 100644 --- a/src/components/haex/extension/launcher.vue +++ b/src/components/haex/extension/launcher.vue @@ -113,8 +113,8 @@ const openItem = async (item: LauncherItem) => { // Check if we're on the desktop page const isOnDesktop = route.name === 'desktop' - console.log('currentWorkspace', currentWorkspace.value) - if (!isOnDesktop) { + console.log('currentWorkspace', currentWorkspace.value, route.name) + /* if (!isOnDesktop) { // Navigate to desktop first await router.push( localePath({ @@ -124,15 +124,16 @@ const openItem = async (item: LauncherItem) => { // Wait for navigation and DOM update await nextTick() - } + } */ // Open the window with correct type and sourceId - windowManagerStore.openWindow( - item.type, // 'system' or 'extension' - item.id, // systemWindowId or extensionId - item.name, - item.icon, - ) + windowManagerStore.openWindow({ + sourceId: item.id, + type: item.type, // 'system' or 'extension' + icon: item.icon, // systemWindowId or extensionId + title: item.name, + workspaceId: currentWorkspace.value?.id, + }) open.value = false } diff --git a/src/stores/desktop/windowManager.ts b/src/stores/desktop/windowManager.ts index c3eae1d..73974f3 100644 --- a/src/stores/desktop/windowManager.ts +++ b/src/stores/desktop/windowManager.ts @@ -102,22 +102,45 @@ export const useWindowManagerStore = defineStore('windowManager', () => { windowsFrom.value.forEach((window) => (window.workspaceId = toWorkspaceId)) } - const openWindow = ( - type: 'system' | 'extension', - sourceId: string, - workspaceId: string, - title?: string, - icon?: string, - width?: number, - height?: number, - sourcePosition?: { x: number; y: number; width: number; height: number }, - ) => { - const workspace = workspaces.value.find((w) => w.id === workspaceId) - if (!workspace) { + const openWindow = ({ + height, + icon, + sourceId, + sourcePosition, + title, + type, + width, + workspaceId, + }: { + height?: number + icon?: string + sourceId: string + sourcePosition?: { x: number; y: number; width: number; height: number } + title?: string + type: 'system' | 'extension' + width?: number + workspaceId?: string + }) => { + // Wenn kein workspaceId angegeben ist, nutze die current workspace + const targetWorkspaceId = workspaceId || currentWorkspace.value?.id + + if (!targetWorkspaceId) { console.error('Cannot open window: No active workspace') return } + // Sicherheitscheck + if (!targetWorkspaceId) { + console.error('Cannot open window: No workspace available') + return + } + + const workspace = workspaces.value?.find((w) => w.id === targetWorkspaceId) + if (!workspace) { + console.error('Cannot open window: Invalid workspace') + return + } + // System Window specific handling if (type === 'system') { const systemWindowDef = getSystemWindow(sourceId)