adjust for mobile

This commit is contained in:
2025-09-29 17:06:14 +02:00
parent c7d29cb2be
commit f1daa6b576
26 changed files with 386 additions and 271 deletions

View File

@ -1,4 +1,5 @@
//import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
import { breakpointsTailwind } from '@vueuse/core'
import de from './de.json'
import en from './en.json'
@ -15,6 +16,11 @@ export const useUiStore = defineStore('uiStore', () => {
breakpoints.active().value.length > 0 ? breakpoints.active().value : 'xs',
) */
const breakpoints = useBreakpoints(breakpointsTailwind)
// "smAndDown" gilt für sm, xs usw.
const isSmallScreen = breakpoints.smaller('sm')
const { $i18n } = useNuxtApp()
$i18n.setLocaleMessage('de', {
@ -70,5 +76,6 @@ export const useUiStore = defineStore('uiStore', () => {
currentTheme,
currentThemeName,
defaultTheme,
isSmallScreen,
}
})

View File

@ -40,21 +40,19 @@ export const useVaultStore = defineStore('vaultStore', () => {
password: string
}) => {
try {
const result = await invoke<string>('open_encrypted_database', {
path,
await invoke<string>('open_encrypted_database', {
vaultPath: path,
key: password,
})
if (result !== 'success') throw new Error(result)
const vaultId = await getVaultIdAsync(path)
const fileName = getFileName(path)
const fileName = getFileName(path) ?? path
openVaults.value = {
...openVaults.value,
[vaultId]: {
name: fileName ?? path,
name: fileName,
drizzle: drizzle<typeof schema>(
async (sql, params: unknown[], method) => {
let rows: any[] = []
@ -92,8 +90,6 @@ export const useVaultStore = defineStore('vaultStore', () => {
},
}
const { addVaultAsync } = useLastVaultStore()
await addVaultAsync({ path })
return vaultId
} catch (error) {
console.error('Error openAsync ', error)
@ -102,17 +98,17 @@ export const useVaultStore = defineStore('vaultStore', () => {
}
const createAsync = async ({
path,
vaultName,
password,
}: {
path: string
vaultName: string
password: string
}) => {
await invoke('create_encrypted_database', {
path,
const vaultPath = await invoke<string>('create_encrypted_database', {
vaultName,
key: password,
})
return await openAsync({ path, password })
return await openAsync({ path: vaultPath, password })
}
const closeAsync = async () => {
@ -147,17 +143,3 @@ const isSelectQuery = (sql: string) => {
const selectRegex = /^\s*SELECT\b/i
return selectRegex.test(sql)
}
/* const trackAllHaexTablesAsync = async (vaultId: string) => {
const { openVaults } = useVaultStore()
const promises = Object.values(schema)
.filter(isTable)
.map((table) => {
const stmt = `SELECT crsql_as_crr('${getTableConfig(table).name}');`
console.log('track table', getTableConfig(table).name)
return openVaults?.[vaultId]?.drizzle.run(sql`${stmt}`.getSQL())
})
await Promise.allSettled(promises)
} */

View File

@ -1,9 +1,16 @@
import { invoke } from '@tauri-apps/api/core'
import { load } from '@tauri-apps/plugin-store'
interface ILastVault {
/* interface ILastVault {
lastUsed: Date
name: string
path: string
} */
export interface IVaultInfo {
name: string
path: string
lastAccess: Date
}
export const useLastVaultStore = defineStore('lastVaultStore', () => {
@ -11,7 +18,7 @@ export const useLastVaultStore = defineStore('lastVaultStore', () => {
public: { haexVault },
} = useRuntimeConfig()
const lastVaults = ref<ILastVault[]>([])
const lastVaults = ref<IVaultInfo[]>([])
const keyName = 'lastVaults'
@ -20,15 +27,19 @@ export const useLastVaultStore = defineStore('lastVaultStore', () => {
}
const syncLastVaultsAsync = async () => {
const store = await getStoreAsync()
lastVaults.value =
(await store.get<ILastVault[]>(keyName))?.sort(
(a, b) => +new Date(b.lastUsed) - +new Date(a.lastUsed),
(await listVaultsAsync()).sort(
(a, b) => +new Date(b.lastAccess) - +new Date(a.lastAccess),
) ?? []
return lastVaults.value
}
const listVaultsAsync = async () => {
lastVaults.value = await invoke<IVaultInfo[]>('list_vaults')
return lastVaults.value
}
const addVaultAsync = async ({
name,
path,
@ -40,7 +51,7 @@ export const useLastVaultStore = defineStore('lastVaultStore', () => {
const saveName = name || getFileNameFromPath(path)
lastVaults.value = lastVaults.value.filter((vault) => vault.path !== path)
lastVaults.value.push({ lastUsed: new Date(), name: saveName, path })
lastVaults.value.push({ lastAccess: new Date(), name: saveName, path })
await saveLastVaultsAsync()
}