fix launcher

This commit is contained in:
2025-10-20 22:44:35 +02:00
parent 57fb496fca
commit df97a3cb8b
5 changed files with 132 additions and 152 deletions

View File

@ -123,7 +123,7 @@
const props = defineProps<{
id: string
title: string
icon?: string
icon?: string | null
initialX?: number
initialY?: number
initialWidth?: number

View File

@ -51,13 +51,9 @@
</template>
<script setup lang="ts">
import type { SystemWindowDefinition } from '@/stores/desktop/windowManager'
const extensionStore = useExtensionsStore()
const windowManagerStore = useWindowManagerStore()
const router = useRouter()
const route = useRoute()
const localePath = useLocalePath()
const { t } = useI18n()
const open = ref(false)
@ -107,35 +103,21 @@ const disabledExtensions = computed(() => {
return extensionStore.availableExtensions.filter((ext) => !ext.enabled)
})
const { currentWorkspace } = storeToRefs(useWorkspaceStore())
// Open launcher item (system window or extension)
const openItem = async (item: LauncherItem) => {
// Check if we're on the desktop page
const isOnDesktop = route.name === 'desktop'
try {
// Open the window with correct type and sourceId
await windowManagerStore.openWindowAsync({
sourceId: item.id,
type: item.type,
icon: item.icon,
title: item.name,
})
console.log('currentWorkspace', currentWorkspace.value, route.name)
/* if (!isOnDesktop) {
// Navigate to desktop first
await router.push(
localePath({
name: 'desktop',
}),
)
// Wait for navigation and DOM update
await nextTick()
} */
// Open the window with correct type and sourceId
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
open.value = false
} catch (error) {
console.log(error)
}
}
</script>

View File

@ -1,10 +1,10 @@
<template>
<div class="w-full h-full flex flex-col bg-white dark:bg-gray-900">
<!-- Settings Header -->
<div class="flex-shrink-0 border-b border-gray-200 dark:border-gray-700 p-6">
<h1 class="text-2xl font-bold text-gray-900 dark:text-white">
Settings
</h1>
<div
class="flex-shrink-0 border-b border-gray-200 dark:border-gray-700 p-6"
>
<h1 class="text-2xl font-bold text-gray-900 dark:text-white">Settings</h1>
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
Manage your HaexHub preferences and configuration
</p>
@ -21,9 +21,7 @@
<div class="space-y-4 bg-gray-50 dark:bg-gray-800 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="font-medium text-gray-900 dark:text-white">
Theme
</p>
<p class="font-medium text-gray-900 dark:text-white">Theme</p>
<p class="text-sm text-gray-600 dark:text-gray-400">
Choose your preferred theme
</p>
@ -65,7 +63,6 @@
Lock vault after inactivity
</p>
</div>
<UToggle />
</div>
</div>
</section>
@ -77,12 +74,20 @@
</h2>
<div class="space-y-2 bg-gray-50 dark:bg-gray-800 rounded-lg p-4">
<div class="flex justify-between">
<span class="text-sm text-gray-600 dark:text-gray-400">Version</span>
<span class="text-sm font-medium text-gray-900 dark:text-white">0.1.0</span>
<span class="text-sm text-gray-600 dark:text-gray-400"
>Version</span
>
<span class="text-sm font-medium text-gray-900 dark:text-white"
>0.1.0</span
>
</div>
<div class="flex justify-between">
<span class="text-sm text-gray-600 dark:text-gray-400">Platform</span>
<span class="text-sm font-medium text-gray-900 dark:text-white">Tauri + Vue</span>
<span class="text-sm text-gray-600 dark:text-gray-400"
>Platform</span
>
<span class="text-sm font-medium text-gray-900 dark:text-white"
>Tauri + Vue</span
>
</div>
</div>
</section>

View File

@ -163,15 +163,13 @@ export const useDesktopStore = defineStore('desktopStore', () => {
)
if (extension) {
windowManager.openWindow(
'extension',
extension.id,
extension.name,
extension.icon || undefined,
undefined, // Use default viewport-aware width
undefined, // Use default viewport-aware height
windowManager.openWindowAsync({
sourceId: extension.id,
type: 'extension',
icon: extension.icon,
title: extension.name,
sourcePosition,
)
})
}
}
// Für später: file und folder handling

View File

@ -6,7 +6,7 @@ export interface IWindow {
type: 'system' | 'extension'
sourceId: string // extensionId or systemWindowId (depends on type)
title: string
icon?: string
icon?: string | null
x: number
y: number
width: number
@ -35,9 +35,6 @@ export interface SystemWindowDefinition {
}
export const useWindowManagerStore = defineStore('windowManager', () => {
const workspaceStore = useWorkspaceStore()
const { currentWorkspace, workspaces } = storeToRefs(workspaceStore)
const windows = ref<IWindow[]>([])
const activeWindowId = ref<string | null>(null)
const nextZIndex = ref(100)
@ -83,9 +80,9 @@ export const useWindowManagerStore = defineStore('windowManager', () => {
// Get windows for current workspace only
const currentWorkspaceWindows = computed(() => {
if (!currentWorkspace.value) return []
if (!useWorkspaceStore().currentWorkspace) return []
return windows.value.filter(
(w) => w.workspaceId === currentWorkspace.value?.id,
(w) => w.workspaceId === useWorkspaceStore().currentWorkspace?.id,
)
})
@ -102,18 +99,18 @@ export const useWindowManagerStore = defineStore('windowManager', () => {
windowsFrom.value.forEach((window) => (window.workspaceId = toWorkspaceId))
}
const openWindow = ({
height,
icon,
const openWindowAsync = async ({
height = 800,
icon = '',
sourceId,
sourcePosition,
title,
type,
width,
width = 600,
workspaceId,
}: {
height?: number
icon?: string
icon?: string | null
sourceId: string
sourcePosition?: { x: number; y: number; width: number; height: number }
title?: string
@ -121,107 +118,105 @@ export const useWindowManagerStore = defineStore('windowManager', () => {
width?: number
workspaceId?: string
}) => {
// Wenn kein workspaceId angegeben ist, nutze die current workspace
const targetWorkspaceId = workspaceId || currentWorkspace.value?.id
try {
// Wenn kein workspaceId angegeben ist, nutze die current workspace
const targetWorkspaceId =
workspaceId || useWorkspaceStore().currentWorkspace?.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)
if (!systemWindowDef) {
console.error(`System window '${sourceId}' not found in registry`)
if (!targetWorkspaceId) {
console.error('Cannot open window: No active workspace')
return
}
// Singleton check: If already open, activate existing window
if (systemWindowDef.singleton) {
const existingWindow = windows.value.find(
(w) => w.type === 'system' && w.sourceId === sourceId,
)
if (existingWindow) {
activateWindow(existingWindow.id)
return existingWindow.id
const workspace = useWorkspaceStore().workspaces?.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)
if (!systemWindowDef) {
console.error(`System window '${sourceId}' not found in registry`)
return
}
// Singleton check: If already open, activate existing window
if (systemWindowDef.singleton) {
const existingWindow = windows.value.find(
(w) => w.type === 'system' && w.sourceId === sourceId,
)
if (existingWindow) {
activateWindow(existingWindow.id)
return existingWindow.id
}
}
// Use system window defaults
title = title ?? systemWindowDef.name
icon = icon ?? systemWindowDef.icon
width = width ?? systemWindowDef.defaultWidth
height = height ?? systemWindowDef.defaultHeight
}
// Use system window defaults
title = title ?? systemWindowDef.name
icon = icon ?? systemWindowDef.icon
width = width ?? systemWindowDef.defaultWidth
height = height ?? systemWindowDef.defaultHeight
}
// Create new window
const windowId = crypto.randomUUID()
// Create new window
const windowId = crypto.randomUUID()
// Calculate viewport-aware size
const viewportWidth = window.innerWidth
const viewportHeight = window.innerHeight
// Calculate viewport-aware size
const viewportWidth = window.innerWidth
const viewportHeight = window.innerHeight
const isMobile = viewportWidth < 768 // Tailwind md breakpoint
const windowWidth = width > viewportWidth ? viewportWidth : width
const windowHeight = height > viewportHeight ? viewportHeight : height
// Default size based on viewport
const defaultWidth = isMobile ? Math.floor(viewportWidth * 0.95) : 800
const defaultHeight = isMobile ? Math.floor(viewportHeight * 0.85) : 600
// Calculate centered position with cascading offset (only count windows in current workspace)
const offset = currentWorkspaceWindows.value.length * 30
const centerX = Math.max(0, (viewportWidth - windowWidth) / 1 / 3)
const centerY = Math.max(0, (viewportHeight - windowHeight) / 1 / 3)
const x = Math.min(centerX + offset, viewportWidth - windowWidth)
const y = Math.min(centerY + offset, viewportHeight - windowHeight)
const windowWidth = width ?? defaultWidth
const windowHeight = height ?? defaultHeight
// Calculate centered position with cascading offset (only count windows in current workspace)
const offset = currentWorkspaceWindows.value.length * 30
const centerX = Math.max(0, (viewportWidth - windowWidth) / 2)
const centerY = Math.max(0, (viewportHeight - windowHeight) / 2)
const x = Math.min(centerX + offset, viewportWidth - windowWidth)
const y = Math.min(centerY + offset, viewportHeight - windowHeight)
const newWindow: IWindow = {
id: windowId,
workspaceId: workspace.id,
type,
sourceId,
title: title!,
icon,
x,
y,
width: windowWidth,
height: windowHeight,
isMinimized: false,
zIndex: nextZIndex.value++,
sourceX: sourcePosition?.x,
sourceY: sourcePosition?.y,
sourceWidth: sourcePosition?.width,
sourceHeight: sourcePosition?.height,
isOpening: true,
isClosing: false,
}
windows.value.push(newWindow)
activeWindowId.value = windowId
// Remove opening flag after animation
setTimeout(() => {
const window = windows.value.find((w) => w.id === windowId)
if (window) {
window.isOpening = false
const newWindow: IWindow = {
id: windowId,
workspaceId: workspace.id,
type,
sourceId,
title: title!,
icon,
x,
y,
width: windowWidth,
height: windowHeight,
isMinimized: false,
zIndex: nextZIndex.value++,
sourceX: sourcePosition?.x,
sourceY: sourcePosition?.y,
sourceWidth: sourcePosition?.width,
sourceHeight: sourcePosition?.height,
isOpening: true,
isClosing: false,
}
}, windowAnimationDuration.value)
return windowId
windows.value.push(newWindow)
activeWindowId.value = windowId
// Remove opening flag after animation
setTimeout(() => {
const window = windows.value.find((w) => w.id === windowId)
if (window) {
window.isOpening = false
}
}, windowAnimationDuration.value)
return windowId
} catch (error) {
console.error('Error opening window:', error)
// Optional: Fehler weiterwerfen wenn nötig
throw error
}
}
/*****************************************************************************************************
@ -324,7 +319,7 @@ export const useWindowManagerStore = defineStore('windowManager', () => {
isWindowActive,
minimizeWindow,
moveWindowsToWorkspace,
openWindow,
openWindowAsync,
restoreWindow,
updateWindowPosition,
updateWindowSize,