fix window on workspace rendering

This commit is contained in:
2025-10-25 08:09:15 +02:00
parent 9281a85deb
commit cb0c8d71f4
12 changed files with 424 additions and 640 deletions

View File

@ -7,7 +7,7 @@ import type {
import de from './de.json'
import en from './en.json'
export type DesktopItemType = 'extension' | 'file' | 'folder'
export type DesktopItemType = 'extension' | 'file' | 'folder' | 'system'
export interface IDesktopItem extends SelectHaexDesktopItems {
label?: string
@ -57,18 +57,20 @@ export const useDesktopStore = defineStore('desktopStore', () => {
referenceId: string,
positionX: number = 0,
positionY: number = 0,
workspaceId?: string,
) => {
if (!currentVault.value?.drizzle) {
throw new Error('Kein Vault geöffnet')
}
if (!currentWorkspace.value) {
const targetWorkspaceId = workspaceId || currentWorkspace.value?.id
if (!targetWorkspaceId) {
throw new Error('Kein Workspace aktiv')
}
try {
const newItem: InsertHaexDesktopItems = {
workspaceId: currentWorkspace.value.id,
workspaceId: targetWorkspaceId,
itemType: itemType,
referenceId: referenceId,
positionX: positionX,
@ -85,7 +87,19 @@ export const useDesktopStore = defineStore('desktopStore', () => {
return result[0]
}
} catch (error) {
console.error('Fehler beim Hinzufügen des Desktop-Items:', error)
console.error('Fehler beim Hinzufügen des Desktop-Items:', {
error,
itemType,
referenceId,
workspaceId: targetWorkspaceId,
position: { x: positionX, y: positionY }
})
// Log full error details
if (error && typeof error === 'object') {
console.error('Full error object:', JSON.stringify(error, null, 2))
}
throw error
}
}
@ -154,8 +168,23 @@ export const useDesktopStore = defineStore('desktopStore', () => {
referenceId: string,
sourcePosition?: { x: number; y: number; width: number; height: number },
) => {
if (itemType === 'extension') {
const windowManager = useWindowManagerStore()
const windowManager = useWindowManagerStore()
if (itemType === 'system') {
const systemWindow = windowManager.getAllSystemWindows().find(
(win) => win.id === referenceId,
)
if (systemWindow) {
windowManager.openWindowAsync({
sourceId: systemWindow.id,
type: 'system',
icon: systemWindow.icon,
title: systemWindow.name,
sourcePosition,
})
}
} else if (itemType === 'extension') {
const extensionsStore = useExtensionsStore()
const extension = extensionsStore.availableExtensions.find(

View File

@ -1,4 +1,4 @@
import { eq } from 'drizzle-orm'
import { asc, eq } from 'drizzle-orm'
import {
haexWorkspaces,
type SelectHaexWorkspaces,
@ -32,18 +32,18 @@ export const useWorkspaceStore = defineStore('workspaceStore', () => {
}
try {
/* const items = await currentVault.value.drizzle
const items = await currentVault.value.drizzle
.select()
.from(haexWorkspaces)
.orderBy(asc(haexWorkspaces.position))
console.log('loadWorkspacesAsync', items)
workspaces.value = items */
workspaces.value = items
// Create default workspace if none exist
/* if (items.length === 0) { */
await addWorkspaceAsync('Workspace 1')
/* } */
if (items.length === 0) {
await addWorkspaceAsync('Workspace 1')
}
} catch (error) {
console.error('Fehler beim Laden der Workspaces:', error)
throw error
@ -61,15 +61,12 @@ export const useWorkspaceStore = defineStore('workspaceStore', () => {
try {
const newIndex = workspaces.value.length + 1
const newWorkspace: SelectHaexWorkspaces = {
id: crypto.randomUUID(),
const newWorkspace = {
name: name || `Workspace ${newIndex}`,
position: workspaces.value.length,
haexTimestamp: '',
}
workspaces.value.push(newWorkspace)
currentWorkspaceIndex.value = workspaces.value.length - 1
/* const result = await currentVault.value.drizzle
const result = await currentVault.value.drizzle
.insert(haexWorkspaces)
.values(newWorkspace)
.returning()
@ -78,7 +75,7 @@ export const useWorkspaceStore = defineStore('workspaceStore', () => {
workspaces.value.push(result[0])
currentWorkspaceIndex.value = workspaces.value.length - 1
return result[0]
} */
}
} catch (error) {
console.error('Fehler beim Hinzufügen des Workspace:', error)
throw error
@ -106,27 +103,27 @@ export const useWorkspaceStore = defineStore('workspaceStore', () => {
const index = workspaces.value.findIndex((ws) => ws.id === workspaceId)
if (index === -1) return
workspaces.value.splice(index, 1)
workspaces.value.forEach((workspace, index) => (workspace.position = index))
try {
/* await currentVault.value.drizzle.transaction(async (tx) => {
await currentVault.value.drizzle.transaction(async (tx) => {
// Delete workspace
await tx
.delete(haexWorkspaces)
.where(eq(haexWorkspaces.id, workspaceId))
// Update local state
workspaces.value.splice(index, 1)
workspaces.value.forEach(
(workspace, index) => (workspace.position = index),
)
workspaces.value.forEach((workspace, idx) => {
workspace.position = idx
})
// Update positions in database
for (const workspace of workspaces.value) {
await tx
.update(haexWorkspaces)
.set({ position: index })
.where(eq(haexWorkspaces.position, workspace.position))
.set({ position: workspace.position })
.where(eq(haexWorkspaces.id, workspace.id))
}
}) */
})
// Adjust current index if needed
if (currentWorkspaceIndex.value >= workspaces.value.length) {