📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Complete rewrite of composable apis
Smaug673927a95b1d0ce6
diff --git a/frontend/app/App.vue b/frontend/app/App.vueindex 8b502897..bf50bc12 100644--- a/frontend/app/App.vue+++ b/frontend/app/App.vue@@ -12,6 +12,8 @@import 'virtual:svg-icons-register';const color = usePreferences().get('primaryColor').value;-setAppColor(Number(color));+const { setAppColor } = useAppColors();useFavicon();++setAppColor(Number(color));</script>diff --git a/frontend/app/components/AppColorPicker.vue b/frontend/app/components/AppColorPicker.vueindex d408dbdd..b041fceb 100644--- a/frontend/app/components/AppColorPicker.vue+++ b/frontend/app/components/AppColorPicker.vue@@ -46,6 +46,8 @@<script setup lang="ts">import { appColors } from '~/helpers/constants';+const { getAppColor } = useAppColors();+const props = defineProps<{ modelValue?: number; nullable?: boolean }>();const emit = defineEmits<{ (e: 'update:modelValue', color: number): void }>();diff --git a/frontend/app/components/AppSelect.vue b/frontend/app/components/AppSelect.vueindex e3462d76..2f33b39a 100644--- a/frontend/app/components/AppSelect.vue+++ b/frontend/app/components/AppSelect.vue@@ -2,7 +2,7 @@<div ref="trigger" class="app-select" :style="{ width: size || '100%' }"><!-- Desktop: inline search input --><input- v-if="open && searchable && !isMobile()"+ v-if="open && searchable && !isMobile"ref="searchInput"v-model="search"type="text"@@ -20,7 +20,7 @@<!-- Desktop dropdown --><Teleport to="body">- <ul v-if="open && !isMobile()" ref="portalList" class="dropdown" :style="dropdownStyle">+ <ul v-if="open && !isMobile" ref="portalList" class="dropdown" :style="dropdownStyle"><li v-if="nullable && selected" class="clear-option" @click="clearSelection"><Icon name="close" display="sm" fill="var(--font-color-light)" /><span>Clear selection</span>@@ -33,7 +33,7 @@<!-- Mobile: Bottom Sheet Modal --><Teleport to="body"><Transition name="mobile-sheet">- <div v-if="open && isMobile()" class="mobile-overlay" @click.self="toggleDropdown">+ <div v-if="open && isMobile" class="mobile-overlay" @click.self="toggleDropdown"><div class="mobile-sheet"><div class="mobile-sheet-header"><span class="mobile-sheet-title">{{ placeholder }}</span>@@ -94,6 +94,8 @@ const props = withDefaults(const emit = defineEmits(['update:modelValue']);+const { isMobile } = useDevice();+const selectedId = computed({get: () => props.modelValue ?? '',set: val => emit('update:modelValue', val),@@ -166,7 +168,7 @@ function toggleDropdown() {if (open.value) {search.value = '';nextTick(() => {- if (isMobile()) {+ if (isMobile) {// Lock body scroll on mobiledocument.body.style.overflow = 'hidden';mobileSearchInput.value?.focus();diff --git a/frontend/app/components/CommandCenter/QuickSearchTab.vue b/frontend/app/components/CommandCenter/QuickSearchTab.vueindex 9c8ce614..38d7cc37 100644--- a/frontend/app/components/CommandCenter/QuickSearchTab.vue+++ b/frontend/app/components/CommandCenter/QuickSearchTab.vue@@ -13,14 +13,11 @@import { quickActions, availablePages, type SearchResult, type BaseCommand } from '~/helpers/navigation';import SearchResultsList from './SearchResultsList.vue';-const props = defineProps<{- searchQuery: string;- selectedIndex: number;-}>();-const documentStore = useNodesStore();-+const props = defineProps<{ searchQuery: string; selectedIndex: number }>();defineEmits<{ updateSelectedIndex: [index: number] }>();+const documentStore = useNodesStore();+function tokenize(text: string) {return text.trim().toLowerCase().split(/\s+/).filter(Boolean);}diff --git a/frontend/app/components/CommandCenter/SearchResultsList.vue b/frontend/app/components/CommandCenter/SearchResultsList.vueindex 6d8d4c53..846a4606 100644--- a/frontend/app/components/CommandCenter/SearchResultsList.vue+++ b/frontend/app/components/CommandCenter/SearchResultsList.vue@@ -33,15 +33,9 @@<script setup lang="ts">import type { ItemCommand } from './types';-const props = defineProps<{- items: ItemCommand[];- selectedIndex: number;- query: string;-}>();--defineEmits<{- updateSelectedIndex: [index: number];-}>();++const props = defineProps<{ items: ItemCommand[]; selectedIndex: number; query: string }>();+defineEmits<{ updateSelectedIndex: [index: number] }>();const groupedItems = computed(() => {return props.items.reduce((acc, item) => {diff --git a/frontend/app/components/CommandCenter/TabNavigation.vue b/frontend/app/components/CommandCenter/TabNavigation.vueindex e1e305f0..08069585 100644--- a/frontend/app/components/CommandCenter/TabNavigation.vue+++ b/frontend/app/components/CommandCenter/TabNavigation.vue@@ -8,16 +8,17 @@</template><script setup lang="ts">+defineProps<{ activeTab: string }>();+const emit = defineEmits<{ 'change-tab': [tabId: string] }>();++const handleClick = (tabId: string) => emit('change-tab', tabId);+interface Tab {id: string;label: string;icon: string;}-defineProps<{ activeTab: string }>();-const emit = defineEmits<{ 'change-tab': [tabId: string] }>();-const handleClick = (tabId: string) => emit('change-tab', tabId);-const tabs: Tab[] = [{id: 'quick',diff --git a/frontend/app/components/CommandCenter/index.vue b/frontend/app/components/CommandCenter/index.vueindex fe2be7b9..278337d0 100644--- a/frontend/app/components/CommandCenter/index.vue+++ b/frontend/app/components/CommandCenter/index.vue@@ -60,7 +60,7 @@ import CreateCategoryModal from '~/pages/dashboard/categories/_modals/CreateCateimport TabNavigation from './TabNavigation.vue';import QuickSearchTab from './QuickSearchTab.vue';import AdvancedSearchTab from './AdvancedSearchTab.vue';-import { useModal, Modal } from '~/composables/ModalBus';+import { useModal, Modal } from '~/composables/useModal';import type { Node } from '~/stores';const router = useRouter();diff --git a/frontend/app/components/DocumentCard.vue b/frontend/app/components/DocumentCard.vueindex aa2be6a0..e27dc01d 100644--- a/frontend/app/components/DocumentCard.vue+++ b/frontend/app/components/DocumentCard.vue@@ -38,11 +38,16 @@ import NodeContextMenu from '~/components/Node/NodeContextMenu.vue';import type { Node } from '~/stores';const props = defineProps<{ document: Node }>();+const nodesStore = useNodesStore();+const userStore = useUserStore();++const { shortDate } = useDateFormatters();+const { getAppColor } = useAppColors();const category = computed(() => nodesStore.getById(props.document.parent_id || ''));-useUserStore().fetchPublicUser(props.document.user_id);-const user = computed(() => useUserStore().getById(props.document.user_id || ''));+userStore.fetchPublicUser(props.document.user_id);+const user = computed(() => userStore.getById(props.document.user_id || ''));const deleteDoc = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), { props: { node: props.document } }));function showContextMenu(event: MouseEvent) {diff --git a/frontend/app/components/DocumentLine.vue b/frontend/app/components/DocumentLine.vueindex ae282c83..3762581c 100644--- a/frontend/app/components/DocumentLine.vue+++ b/frontend/app/components/DocumentLine.vue@@ -27,15 +27,21 @@</template><script setup lang="ts">-import type { Node } from '~/stores';import DeleteDocumentModal from '~/components/Node/DeleteNodeModal.vue';import NodeContextMenu from '~/components/Node/NodeContextMenu.vue';+import type { Node } from '~/stores';const props = defineProps<{ document: Node }>();+const categoriesStore = useNodesStore();+const userStore = useUserStore();++const { shortDate } = useDateFormatters();+const { getAppColor } = useAppColors();+const category = computed(() => categoriesStore.getById(props.document.parent_id || ''));-useUserStore().fetchPublicUser(props.document.user_id);-const user = computed(() => useUserStore().getById(props.document.user_id || ''));+userStore.fetchPublicUser(props.document.user_id);+const user = computed(() => userStore.getById(props.document.user_id || ''));const deleteDoc = () => useModal().add(new Modal(shallowRef(DeleteDocumentModal), { props: { node: props.document } }));function showContextMenu(event: MouseEvent) {diff --git a/frontend/app/components/DocumentsGrid.vue b/frontend/app/components/DocumentsGrid.vueindex e499e018..432151fd 100644--- a/frontend/app/components/DocumentsGrid.vue+++ b/frontend/app/components/DocumentsGrid.vue@@ -6,6 +6,7 @@<script setup lang="ts">import type { Node } from '~/stores';+defineProps<{ documents: Node[] }>();</script>diff --git a/frontend/app/components/Kanban/KanbanColumn.vue b/frontend/app/components/Kanban/KanbanColumn.vueindex 0c5a97aa..cf9432ef 100644--- a/frontend/app/components/Kanban/KanbanColumn.vue+++ b/frontend/app/components/Kanban/KanbanColumn.vue@@ -64,6 +64,7 @@<script setup lang="ts">import KanbanCard from './KanbanCard.vue';import DeleteColumnModal from './DeleteColumn.modal.vue';+import { appColors } from '~/helpers/constants';import type { Node } from '~/stores';export interface KanbanColumnData {@@ -88,6 +89,8 @@ const emit = defineEmits<{cardDragEnd: [];}>();+const { getAppColor } = useAppColors();+const isDragOver = ref(false);const isEditing = ref(false);const editedTitle = ref(props.column.title);diff --git a/frontend/app/components/MediumView.vue b/frontend/app/components/MediumView.vueindex 1fadc605..88957486 100644--- a/frontend/app/components/MediumView.vue+++ b/frontend/app/components/MediumView.vue@@ -1,13 +1,14 @@<template>- <main ref="mediumContainer" class="medium-view" :style="{ paddingLeft: marginLeft, transition }">+ <main class="medium-view" :style="{ paddingLeft: marginLeft, transition }"><slot /></main></template><script setup lang="ts">const { isOpened, paneWidth, isResizing } = useSidebar();-const mediumContainer = ref<HTMLElement | null>(null);-const marginLeft = computed(() => (isMobile() || !isOpened.value ? '10px' : `${paneWidth.value + 20}px`));+const { isMobile } = useDevice();++const marginLeft = computed(() => (isMobile.value || !isOpened.value ? '10px' : `${paneWidth.value + 20}px`));const transition = computed(() => (isResizing.value ? 'none' : 'padding-left 0.3s'));</script>diff --git a/frontend/app/components/ModalManager.vue b/frontend/app/components/ModalManager.vueindex dce9104c..1ffc445a 100644--- a/frontend/app/components/ModalManager.vue+++ b/frontend/app/components/ModalManager.vue@@ -21,6 +21,7 @@<script setup lang="ts">const modalManager = useModal();+const modals = modalManager.modals;</script>diff --git a/frontend/app/components/Navbar.vue b/frontend/app/components/Navbar.vueindex 85700280..52faa428 100644--- a/frontend/app/components/Navbar.vue+++ b/frontend/app/components/Navbar.vue@@ -27,8 +27,10 @@<script lang="ts" setup>const { toggleSidebar, isOpened } = useSidebar();const preferences = usePreferences();+const openCommandCenter = () => window.dispatchEvent(new CustomEvent('command-center-open'));</script>+<style lang="scss" scoped>header {position: sticky;diff --git a/frontend/app/components/NoContent.vue b/frontend/app/components/NoContent.vueindex dc4ccd75..081e451c 100644--- a/frontend/app/components/NoContent.vue+++ b/frontend/app/components/NoContent.vue@@ -8,8 +8,9 @@</template><script setup lang="ts">-const colorMode = useColorMode();defineProps<{ title?: string; description?: string }>();++const colorMode = useColorMode();</script><style scoped lang="scss">diff --git a/frontend/app/components/Node/DeleteNodeModal.vue b/frontend/app/components/Node/DeleteNodeModal.vueindex 555b86b5..84daedc2 100644--- a/frontend/app/components/Node/DeleteNodeModal.vue+++ b/frontend/app/components/Node/DeleteNodeModal.vue@@ -15,17 +15,8 @@import type { Node } from '~/stores';const props = defineProps<{ node: Node }>();--const deleteDoc = () => {- useNodesStore()- .delete(props.node.id)- .then(() => {- emit('close');- useRouter().push('/dashboard');- })- .catch(e => useNotifications().add({ type: 'error', title: 'Error', message: e }));-};const emit = defineEmits(['close']);+const allChildren = useSidebarTree().getSubTreeById(props.node.id);const nodeType = computed(() => {switch (props.node.role) {@@ -41,6 +32,15 @@ const nodeType = computed(() => {return 'node';}});+const deleteDoc = () => {+ useNodesStore()+ .delete(props.node.id)+ .then(() => {+ emit('close');+ useRouter().push('/dashboard');+ })+ .catch(e => useNotifications().add({ type: 'error', title: 'Error', message: e }));+};</script><style scoped lang="scss">diff --git a/frontend/app/components/Node/Filter.vue b/frontend/app/components/Node/Filter.vueindex f98e110c..629b9c02 100644--- a/frontend/app/components/Node/Filter.vue+++ b/frontend/app/components/Node/Filter.vue@@ -53,6 +53,7 @@ import { useNodesStore } from '~/stores';import type { Node, SearchOptions } from '~/stores';const props = defineProps<{ nodes: Node[] }>();+const emit = defineEmits<{ (e: 'update:nodes', v: Node[]): void }>();const defaultOptions: SearchOptions = {query: '',@@ -78,8 +79,6 @@ const MATCH_OPTIONS = [{ id: 'exact', label: 'Exact' },];-const emit = defineEmits<{ (e: 'update:nodes', v: Node[]): void }>();-let outsideHandler: ((e: MouseEvent) => void) | null = null;const filtered = computed(() => store.search(options.value, props.nodes));diff --git a/frontend/app/components/Node/NodeContextMenu.vue b/frontend/app/components/Node/NodeContextMenu.vueindex f1e0c8d9..d62511b0 100644--- a/frontend/app/components/Node/NodeContextMenu.vue+++ b/frontend/app/components/Node/NodeContextMenu.vue@@ -1,7 +1,7 @@<template><div class="context-menu" :class="{ 'is-context-menu': props.contextMenu }"><div class="menu-header">- <img :src="useAvatar(user)" alt="" class="header-avatar" />+ <img :src="avatarURL(user)" alt="" class="header-avatar" /><div class="header-info"><span class="header-name">{{ node.name }}</span><span class="header-meta">{{ user?.username }} · {{ shortDate(node.updated_timestamp) }}</span>@@ -40,15 +40,20 @@ import NodePermissions from './NodePermissions.modal.vue';import NodeDeleteModal from './DeleteNodeModal.vue';import type { Node } from '~/stores';+const props = defineProps<{ node: Node; contextMenu?: boolean }>();+const emit = defineEmits(['close']);+const nodeStore = useNodesStore();+const userStore = useUserStore();+const preferences = usePreferences();-const emit = defineEmits(['close']);+const { shortDate } = useDateFormatters();+const { avatarURL } = useApi();+const dotMenu = ref();-const props = defineProps<{ node: Node; contextMenu?: boolean }>();-useUserStore().fetchPublicUser(props.node.user_id);-const user = computed(() => useUserStore().getById(props.node.user_id || ''));-defineExpose({ close: () => dotMenu.value?.close() });+userStore.fetchPublicUser(props.node.user_id);+const user = computed(() => userStore.getById(props.node.user_id || ''));async function action(name: string) {switch (name) {diff --git a/frontend/app/components/Node/NodeList.vue b/frontend/app/components/Node/NodeList.vueindex 918c752d..ac27344f 100644--- a/frontend/app/components/Node/NodeList.vue+++ b/frontend/app/components/Node/NodeList.vue@@ -17,7 +17,7 @@<NuxtLink v-if="view == 'kanban'" class="btn-icon no-mobile" @click="resetKanban"><Icon name="reset" display="lg" /></NuxtLink>- <NodeFilter v-show="!isMobile()" :nodes="nodes" @update:nodes="filteredNodes = $event" />+ <NodeFilter v-show="!isMobile" :nodes="nodes" @update:nodes="filteredNodes = $event" /><NuxtLink v-if="parent?.shared && parent.user_id != connectedId" class="btn-icon no-mobile" @click="openRemoveShareModal"><Icon name="group_off" display="lg" /></NuxtLink>@@ -79,10 +79,15 @@ import type { ViewMode } from '~/components/ViewSelection.vue';import type { Node } from '~/stores';const props = defineProps<{ parent?: Node; nodes: Node[]; parentId?: string }>();+const nodesStore = useNodesStore();+const router = useRouter();-const connectedId = useUserStore().user?.id;+const userStore = useUserStore();+const { isMobile } = useDevice();+const { getAppColor } = useAppColors();+const connectedId = userStore.user?.id;const view = ref<ViewMode>();const filteredNodes = ref<Node[]>(props.nodes);diff --git a/frontend/app/components/Node/NodeMetadata.modal.vue b/frontend/app/components/Node/NodeMetadata.modal.vueindex 43121acb..fb1a49bf 100644--- a/frontend/app/components/Node/NodeMetadata.modal.vue+++ b/frontend/app/components/Node/NodeMetadata.modal.vue@@ -45,9 +45,10 @@import { DOCUMENT_THEMES, CATEGORY_ROLES } from '~/helpers/constants';import type { Node } from '~/stores';+const props = defineProps<{ doc: Node }>();+const nodeStore = useNodesStore();-const props = defineProps<{ doc: Node }>();const node = ref<Node>(props.doc);const pinnedToggle = ref(node.value.order == -1);const parentsTree = computed(() => new TreeStructure(useSidebarTree().nodes.value.filter(n => n.data.role <= node.value.role)).generateTree());diff --git a/frontend/app/components/Node/NodePermissions.modal.vue b/frontend/app/components/Node/NodePermissions.modal.vueindex ac09f1d0..9645b681 100644--- a/frontend/app/components/Node/NodePermissions.modal.vue+++ b/frontend/app/components/Node/NodePermissions.modal.vue@@ -28,7 +28,7 @@<div v-for="user in users" :key="user.id" class="user-card"><div class="user-info-row"><span class="user-meta">- <img :src="useAvatar(user)" alt="avatar" class="avatar" />+ <img :src="avatarURL(user)" alt="avatar" class="avatar" /><span>{{ user.username }}</span></span><div class="user-actions">@@ -48,7 +48,7 @@<li v-for="perm in node.permissions" :key="perm.id" class="permission-item"><div class="user-info-row"><span class="user-meta">- <img :src="useAvatar(usersStore.getById(perm.user_id))" alt="avatar" class="avatar" />+ <img :src="avatarURL(usersStore.getById(perm.user_id))" alt="avatar" class="avatar" /><span>{{ usersStore.getById(perm.user_id)?.username }}</span></span>@@ -72,18 +72,20 @@ import type { Node, Permission, PublicUser } from '~/stores';const props = defineProps<{ node: Node }>();-const node = ref<Node>(props.node);-const usersStore = useUserStore();const nodesStore = useNodesStore();+const { avatarURL } = useApi();++const node = ref<Node>(props.node);const query = ref('');const users = ref<PublicUser[]>([]);const selectedPermission = ref(1);-const link = computed(() => `${window.location.origin}/doc/${node.value?.id}`);const searchError = ref<string | null>(null);const isLoading = ref(false);+const link = computed(() => `${window.location.origin}/doc/${node.value?.id}`);+watchEffect(() => {if (node.value.partial) nodesStore.fetch({ id: node.value.id }).then(fetched => (node.value = fetched));for (const perm of node.value.permissions) {diff --git a/frontend/app/components/Node/RemoveSharedNode.modal.vue b/frontend/app/components/Node/RemoveSharedNode.modal.vueindex f0d1f2b0..a796d1f1 100644--- a/frontend/app/components/Node/RemoveSharedNode.modal.vue+++ b/frontend/app/components/Node/RemoveSharedNode.modal.vue@@ -13,6 +13,10 @@<script setup lang="ts">const props = defineProps<{ nodeId: string }>();+const emit = defineEmits(['close']);++const allChildren = useSidebarTree().getSubTreeById(props.nodeId);+const removeDoc = () => {useNodesStore().removePermission(props.nodeId, useUserStore().user!.id)@@ -23,8 +27,6 @@ const removeDoc = () => {}).catch(e => useNotifications().add({ type: 'error', title: 'Error', message: e }));};-const emit = defineEmits(['close']);-const allChildren = useSidebarTree().getSubTreeById(props.nodeId);</script><style scoped lang="scss">diff --git a/frontend/app/components/NodeRecentCard.vue b/frontend/app/components/NodeRecentCard.vueindex a5077daa..5a15f3a4 100644--- a/frontend/app/components/NodeRecentCard.vue+++ b/frontend/app/components/NodeRecentCard.vue@@ -21,9 +21,12 @@import { resolveIcon } from '~/helpers/node';import type { Node } from '~/stores';+const props = defineProps<{ node: Node }>();+const nodesStore = useNodesStore();-const props = defineProps<{ node: Node }>();+const { relativeTime } = useDateFormatters();+const { getAppColor } = useAppColors();const category = nodesStore.getById(props.node.parent_id || '');const icon = resolveIcon(props.node);diff --git a/frontend/app/components/NodeWorkspaceCard.vue b/frontend/app/components/NodeWorkspaceCard.vueindex fa104afd..5309cb1b 100644--- a/frontend/app/components/NodeWorkspaceCard.vue+++ b/frontend/app/components/NodeWorkspaceCard.vue@@ -21,9 +21,11 @@<script setup lang="ts">import type { Node } from '~/stores';+defineProps<{ workspace: Node }>();+const nodesStore = useNodesStore();-defineProps<{ workspace: Node }>();+const { getAppColor } = useAppColors();// Get workspace categoriesconst getWorkspaceCategories = (workspaceId: string) => {diff --git a/frontend/app/components/Sidebar/CollapseItem.vue b/frontend/app/components/Sidebar/CollapseItem.vueindex d04e3b5d..dc7ec1b1 100644--- a/frontend/app/components/Sidebar/CollapseItem.vue+++ b/frontend/app/components/Sidebar/CollapseItem.vue@@ -17,8 +17,11 @@</template><script setup lang="ts">import type { DefaultItem } from './helpers';+const props = withDefaults(defineProps<{ item: Item | DefaultItem; level?: number }>(), { level: 0 });+const { getCollapseState, setCollapseState } = useCollapseStates();+const toggleShow = () => {setCollapseState(props.item.id, !props.item.show.value);};diff --git a/frontend/app/components/Sidebar/Dock.vue b/frontend/app/components/Sidebar/Dock.vueindex fa5c8fee..11189a94 100644--- a/frontend/app/components/Sidebar/Dock.vue+++ b/frontend/app/components/Sidebar/Dock.vue@@ -16,7 +16,7 @@<NuxtLink to="/dashboard/import"><Icon name="import" display="lg" /></NuxtLink>- <NuxtLink v-if="useUserStore().user?.role === 2" to="/dashboard/admin">+ <NuxtLink v-if="userStore.user?.role === 2" to="/dashboard/admin"><Icon name="users" display="lg" /></NuxtLink><div style="margin-top: auto">@@ -32,6 +32,9 @@<script setup lang="ts">import SettingsModal from '~/pages/dashboard/settings/modal.vue';++const userStore = useUserStore();+const openSettings = () => {useModal().add(new Modal(shallowRef(SettingsModal), { props: {}, size: 'large', noPadding: true }));};diff --git a/frontend/app/components/Sidebar/Sidebar.vue b/frontend/app/components/Sidebar/Sidebar.vueindex 0446fb11..562cf4f6 100644--- a/frontend/app/components/Sidebar/Sidebar.vue+++ b/frontend/app/components/Sidebar/Sidebar.vue@@ -1,7 +1,7 @@<template>- <div :class="{ 'sidebar-mask': isMobile() && isOpened }" />+ <div :class="{ 'sidebar-mask': isMobile && isOpened }" /><Resizable>- <Dock v-if="!isMobile() && preferences.get('view_dock').value" />+ <Dock v-if="!isMobile && preferences.get('view_dock').value" /><div class="sidebar" :class="{ compact: preferences.get('compactMode').value }"><section class="header"><span class="name">@@ -13,7 +13,7 @@<input v-model="filter" type="text" placeholder="Search or ctrl + q" /><div v-if="userStore.user" class="user">- <img :src="useAvatar(userStore.user)" alt="Avatar" style="width: 25px; height: 25px; border-radius: 50%" />+ <img :src="avatarURL(userStore.user)" alt="Avatar" style="width: 25px; height: 25px; border-radius: 50%" /><div class="details"><NuxtLink to="/dashboard/settings?p=profile"><div>{{ userStore.user.username }}</div>@@ -63,15 +63,19 @@ import { navigationItems } from './helpers';import NewCategoryModal from '~/pages/dashboard/categories/_modals/CreateCategoryModal.vue';import Dock from './Dock.vue';-const { isOpened, hasSidebar, filtered } = useSidebar();const nodesStore = useNodesStore();const preferences = usePreferences();const userStore = useUserStore();++const sidebarTree = useSidebarTree();+const { isOpened, hasSidebar, filtered } = useSidebar();+const { isMobile } = useDevice();+const { avatarURL } = useApi();+const filter = ref<string>('');const workspaces = computed(() => [...nodesStore.getAll.filter(c => c.role === 1).map(c => ({ text: c.name, value: c.id, meta: c }))]);const isLoading = computed(() => nodesStore.isFetching);-const sidebarTree = useSidebarTree();const toggleDock = () => preferences.set('view_dock', !preferences.get('view_dock').value);const filterItems = (items: Item[]): Item[] => {if (!filter.value.trim()) return items;@@ -88,12 +92,12 @@ const newCategory = () => {useModal().add(new Modal(shallowRef(NewCategoryModal), { props: { role: 2 } }));};const onClick = () => {- if (isMobile()) isOpened.value = false;+ if (isMobile.value) isOpened.value = false;};onMounted(() => {hasSidebar.value = true;- if (isMobile()) return document.addEventListener('click', handleClickOutside);+ if (isMobile.value) return document.addEventListener('click', handleClickOutside);// ELSE: DesktopisOpened.value = true;});diff --git a/frontend/app/components/Sidebar/SidebarItem.vue b/frontend/app/components/Sidebar/SidebarItem.vueindex 5aa06da5..27abfcfc 100644--- a/frontend/app/components/Sidebar/SidebarItem.vue+++ b/frontend/app/components/Sidebar/SidebarItem.vue@@ -35,6 +35,9 @@ import type { Node } from '~/stores';const nodesStore = useNodesStore();const { isOpened, workspaceId } = useSidebar();+const { getAppColor } = useAppColors();+const { isMobile } = useDevice();+const props = defineProps<{ item: Item | DefaultItem; level: number }>();const isDragOver = ref<boolean>(false);@@ -51,7 +54,7 @@ const icon = computed(() => {const onClick = (m: MouseEvent) => {// if element does not have the "close" class, don't close the sidebarif (!(m.target as HTMLElement).closest('.close')) return;- if (isMobile() && (props.item.route || props.item.onClick)) isOpened.value = false;+ if (isMobile.value && (props.item.route || props.item.onClick)) isOpened.value = false;};const contextMenu = useContextMenu();diff --git a/frontend/app/components/Sidebar/SidebarWorkspace.vue b/frontend/app/components/Sidebar/SidebarWorkspace.vueindex 860203e2..dfce1922 100644--- a/frontend/app/components/Sidebar/SidebarWorkspace.vue+++ b/frontend/app/components/Sidebar/SidebarWorkspace.vue@@ -1,7 +1,7 @@<template><div class="workspace-item"><span class="workspace-name">- <Icon :name="option.meta?.icon || 'workspace'" size="22" :class="[getAppColor(option.meta?.color), 'icon']" />+ <Icon :name="option.meta?.icon || 'workspace'" size="22" :class="[appColors.getAppColor(option.meta?.color), 'icon']" />{{ option.text }}</span><span>@@ -12,7 +12,10 @@<script setup lang="ts">import type { Workspace } from './helpers';+defineProps<{ option: Workspace }>();++const appColors = useAppColors();</script><style scoped lang="scss">diff --git a/frontend/app/components/Sidebar/helpers.ts b/frontend/app/components/Sidebar/helpers.tsindex 640dabaf..958df020 100644--- a/frontend/app/components/Sidebar/helpers.ts+++ b/frontend/app/components/Sidebar/helpers.ts@@ -7,6 +7,7 @@ export interface Workspace {value?: string;meta?: Partial<Node>;}+const { isMobile } = useDevice();const sidebarItemsPrefs = usePreferences().get('sidebarItems');export const navigationItems: DefaultItem[] = [{@@ -64,7 +65,7 @@ export const navigationItems: DefaultItem[] = [route: '',icon: 'user_settings',onClick: () => {- if (isMobile()) useRouter().push('/dashboard/settings');+ if (isMobile.value) useRouter().push('/dashboard/settings');else useModal().add(new Modal(shallowRef(SettingsModal), { props: {}, size: 'large', noPadding: true }));},data: {diff --git a/frontend/app/composables/Sidebar.ts b/frontend/app/composables/Sidebar.tsindex 120f6109..0f0bfce5 100644--- a/frontend/app/composables/Sidebar.ts+++ b/frontend/app/composables/Sidebar.ts@@ -3,9 +3,11 @@* Controls sidebar visibility, width, and content filtering*/+const { isMobile } = useDevice();+const isOpened = ref(false);const hasSidebar = ref(false);-const paneWidth = ref(isMobile() ? 350 : 390);+const paneWidth = ref(isMobile.value ? 350 : 390);const isResizing = ref(false);const workspaceId = ref<string | undefined>(undefined);const active_id = ref<string | null>(null);diff --git a/frontend/app/composables/useApi.ts b/frontend/app/composables/useApi.tsnew file mode 100644index 00000000..15a4c2c3--- /dev/null+++ b/frontend/app/composables/useApi.ts@@ -0,0 +1,13 @@+import type { PublicUser, User } from '~/stores';++export function useApi() {+ const config = useRuntimeConfig();+ const CDN = config.public.baseCdn;+ const API = `${config.public.baseApi}/api`;++ function avatarURL(user?: User | PublicUser | null): string {+ return user?.avatar ? CDN + '/' + user.id + `/avatar?v=${user.avatar}` : '/default_avatar.avif';+ }++ return { CDN, API, avatarURL };+}diff --git a/frontend/app/composables/colors.ts b/frontend/app/composables/useAppColors.tssimilarity index 81%rename from frontend/app/composables/colors.tsrename to frontend/app/composables/useAppColors.tsindex 32de39df..11f91884 100644--- a/frontend/app/composables/colors.ts+++ b/frontend/app/composables/useAppColors.ts@@ -1,14 +1,14 @@import { appColors } from '~/helpers/constants';/** Get theme color name by index (-2 = primary, -1 = none, 0+ = color index) */-export function getAppColor(index: number = 0, defaultPrimary?: boolean): string {+function getAppColor(index: number = 0, defaultPrimary?: boolean): string {if ((defaultPrimary && index < 0) || index == -2) return 'primary';if (index == -1) return '';return appColors[index % appColors.length] || 'primary';}/** Apply a theme color to CSS custom properties */-export function setAppColor(color: string | number) {+function setAppColor(color: string | number) {if (typeof color === 'number') {color = getAppColor(color);}@@ -22,3 +22,10 @@ export function setAppColor(color: string | number) {usePreferences().set('darkMode', colorMode.value === 'dark');document.body.style.colorScheme = colorMode.preference;}++export const useAppColors = () => {+ return {+ getAppColor,+ setAppColor,+ };+};diff --git a/frontend/app/composables/collapseStates.ts b/frontend/app/composables/useCollapseStates.tssimilarity index 78%rename from frontend/app/composables/collapseStates.tsrename to frontend/app/composables/useCollapseStates.tsindex aabad8f6..40522cf0 100644--- a/frontend/app/composables/collapseStates.ts+++ b/frontend/app/composables/useCollapseStates.ts@@ -22,30 +22,35 @@ function saveStates() {}/** Get collapse state for an item (defaults to expanded) */-export function getCollapseState(id: string): boolean {+function getCollapseState(id: string): boolean {if (!(id in states)) states[id] = true;return states[id] ?? true;}/** Set collapse state for an item */-export function setCollapseState(id: string, value: boolean) {+function setCollapseState(id: string, value: boolean) {states[id] = value;saveStates();}/** Toggle collapse state for an item */-export function toggleCollapseState(id: string) {+function toggleCollapseState(id: string) {states[id] = !getCollapseState(id);saveStates();}/** Collapse all items */-export function collapseAllStates() {+function collapseAllStates() {Object.keys(states).forEach(key => (states[key] = false));saveStates();}/** Access the raw reactive states object */export function useCollapseStates() {- return states;+ return {+ getCollapseState,+ setCollapseState,+ toggleCollapseState,+ collapseAllStates,+ };}diff --git a/frontend/app/composables/formatters.ts b/frontend/app/composables/useDateFormatters.tssimilarity index 74%rename from frontend/app/composables/formatters.tsrename to frontend/app/composables/useDateFormatters.tsindex 6eac83f8..eb4545a9 100644--- a/frontend/app/composables/formatters.ts+++ b/frontend/app/composables/useDateFormatters.ts@@ -1,13 +1,13 @@const locale = 'en-US';/** Format a timestamp to a readable date string (e.g., "15 Dec 2024") */-export function shortDate(timestamp: number | undefined): string {+function shortDate(timestamp: number | undefined): string {const date = new Date(timestamp || 0);return `${date.getDate()} ${date.toLocaleString('default', { month: 'short' })} ${date.getFullYear()}`;}/** Format a timestamp to a numeric date string (e.g., "12/15/2024") */-export function numericDate(timestamp: number): string {+function numericDate(timestamp: number): string {return new Date(timestamp).toLocaleDateString(locale, {year: 'numeric',month: '2-digit',@@ -16,7 +16,7 @@ export function numericDate(timestamp: number): string {}/** Format a timestamp to a relative time string (e.g., "2h ago") */-export const relativeTime = (timestamp: number) => {+const relativeTime = (timestamp: number) => {const diff = Date.now() - timestamp;const minutes = Math.floor(diff / 60000);const hours = Math.floor(diff / 3600000);@@ -31,7 +31,7 @@ export const relativeTime = (timestamp: number) => {return shortDate(timestamp);};-export const formatRelativeDate = (timestamp?: number) => {+const formatRelativeDate = (timestamp?: number) => {if (!timestamp) return '';const now = Date.now();const diff = now - timestamp;@@ -40,10 +40,10 @@ export const formatRelativeDate = (timestamp?: number) => {if (days === 1) return 'yesterday';if (days < 7) return `${days} days ago`;if (days < 30) return `${Math.floor(days / 7)} weeks ago`;- return new Date(timestamp).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });+ return new Date(timestamp).toLocaleDateString(locale, { month: 'short', day: 'numeric', year: 'numeric' });};-export const shortDateLabel = (timestamp: number) => {+const shortDateLabel = (timestamp: number) => {const date = new Date(timestamp);const today = new Date();const yesterday = new Date(today);@@ -54,14 +54,26 @@ export const shortDateLabel = (timestamp: number) => {return date.toLocaleDateString(locale, { weekday: 'long', day: 'numeric', month: 'long' });};-export const formatTime = (timestamp: number) => {+const formatTime = (timestamp: number) => {return new Date(timestamp).toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' });};-export const todayFormatted = computed(() => {+const todayFormatted = computed(() => {return new Date().toLocaleDateString(locale, {weekday: 'long',day: 'numeric',month: 'long',});});++export const useDateFormatters = () => {+ return {+ shortDate,+ numericDate,+ relativeTime,+ formatRelativeDate,+ shortDateLabel,+ formatTime,+ todayFormatted,+ };+};diff --git a/frontend/app/composables/useDevise.ts b/frontend/app/composables/useDevise.tsnew file mode 100644index 00000000..658e631f--- /dev/null+++ b/frontend/app/composables/useDevise.ts@@ -0,0 +1,20 @@+const width = ref(window.innerWidth);++const updateWidth = () => {+ width.value = window.innerWidth;+};++let isListening = false;++export function useDevice() {+ if (!isListening) {+ window.addEventListener('resize', updateWidth);+ isListening = true;+ }++ const isMobile = computed(() => width.value < 768);+ const isTablet = computed(() => width.value >= 768 && width.value < 1024);+ const isDesktop = computed(() => width.value >= 1024);++ return { width, isMobile, isTablet, isDesktop };+}diff --git a/frontend/app/composables/ModalBus.ts b/frontend/app/composables/useModal.tssimilarity index 100%rename from frontend/app/composables/ModalBus.tsrename to frontend/app/composables/useModal.tsdiff --git a/frontend/app/composables/useNodesTree.ts b/frontend/app/composables/useNodesTree.tsindex d9395ba4..70c6eb10 100644--- a/frontend/app/composables/useNodesTree.ts+++ b/frontend/app/composables/useNodesTree.ts@@ -1,6 +1,8 @@import { resolveIcon, resolveNodeLink } from '~/helpers/node';import type { Node } from '~/stores';+const collapse = useCollapseStates();+let nodes: ComputedRef<Item<Node>[]> | Ref<Item<Node>[]> = ref([]);const structure = computed(() => new TreeStructure(nodes.value));@@ -9,7 +11,7 @@ const tree = computed(() => {return structure.value.generateTree();});-const collapseAll = collapseAllStates;+const collapseAll = collapse.collapseAllStates;const getSubTreeById = (id: string) => {return structure.value.treeToArray(structure.value.getSubTreeById(id)?.childrens || []);};@@ -31,7 +33,7 @@ function useSidebarTree() {route: resolveNodeLink(node),icon: ref(resolveIcon(node)).value,data: node,- show: ref(getCollapseState(node.id)),+ show: ref(collapse.getCollapseState(node.id)),})).sort((a, b) => (a.data.order ?? 0) - (b.data.order ?? 0) || a.data.name.localeCompare(b.data.name)): [],@@ -49,7 +51,7 @@ function useSidebarTree() {route: `/dashboard/categories/${c.id}`,icon: c.icon || 'folder',data: c,- show: ref(getCollapseState(c.id)),+ show: ref(collapse.getCollapseState(c.id)),})),];diff --git a/frontend/app/composables/utils.ts b/frontend/app/composables/utils.tsindex 9a66065c..1c57d120 100644--- a/frontend/app/composables/utils.ts+++ b/frontend/app/composables/utils.ts@@ -1,26 +1,4 @@-/**- * Core application utilities- * Contains API configuration, screen size helpers, colors, and debounce functions- */-import type { PublicUser, User } from '~/stores/db_strustures';--/** Provides API and CDN base URLs from runtime config */-export function useApi() {- const config = useRuntimeConfig();- const CDN = config.public.baseCdn;- const API = `${config.public.baseApi}/api`;- return { CDN, API };-}--// Screen size breakpoints-export const isMobile = () => (import.meta.client ? window.innerWidth <= 768 : false);-export const isTablet = () => (import.meta.client ? window.innerWidth <= 1280 : false);-/** Get user avatar URL or fallback to default */-export function useAvatar(user?: User | PublicUser | null): string {- const { CDN } = useApi();- return user?.avatar ? CDN + '/' + user.id + `/avatar?v=${user.avatar}` : '/default_avatar.avif';-}export function debounce<T extends (...args: unknown[]) => void>(fn: T, delay = 500) {let timeout: ReturnType<typeof setTimeout> | null = null;diff --git a/frontend/app/pages/(public)/doc/[id]/edit.vue b/frontend/app/pages/(public)/doc/[id]/edit.vueindex 570d9e45..1e22e384 100644--- a/frontend/app/pages/(public)/doc/[id]/edit.vue+++ b/frontend/app/pages/(public)/doc/[id]/edit.vue@@ -1,33 +1,34 @@<template>- <MarkdownEditor v-if="document && !error" ref="editor" :doc="document" @save="data => save(data)" @auto-save="data => autoSave(data)" @exit="exit" />+ <MarkdownEditor v-if="document && !error" :doc="document" @save="data => save(data)" @auto-save="data => autoSave(data)" @exit="exit" /></template><script lang="ts" setup>-import type { Node } from '~/stores';import MarkdownEditor from '~/components/MarkdownEditor/LazyMarkdownEditor.vue';+import type { Node } from '~/stores';+const store = useNodesStore();+const route = useRoute();+const notifications = useNotifications();-const editor = ref();-const doc_id = route.params.id as string;+const nodeId = route.params.id as string;const document = ref<Node | undefined>(undefined);-const notifications = useNotifications();const error: Ref<string> = ref('');watchEffect(async () => {- const docFromStore = store.getById(doc_id);- if (!docFromStore) {+ const storedNode = store.getById(nodeId);+ if (!storedNode) {try {- document.value = await store.fetchPublic(doc_id);+ document.value = await store.fetchPublic(nodeId);} catch {error.value = 'Document not found';}- } else if (docFromStore?.partial) {+ } else if (storedNode?.partial) {try {- document.value = await store.fetch({ id: doc_id });+ document.value = await store.fetch({ id: nodeId });} catch {error.value = 'Document not found';}- } else document.value = docFromStore;+ } else document.value = storedNode;});definePageMeta({ breadcrumb: 'Edit' });@@ -43,5 +44,5 @@ function autoSave(doc: Node) {store.update(doc);}-const exit = () => useRouter().push(`/doc/${doc_id}`);+const exit = () => useRouter().push(`/doc/${nodeId}`);</script>diff --git a/frontend/app/pages/(public)/doc/[id]/index.vue b/frontend/app/pages/(public)/doc/[id]/index.vueindex e831a5f7..9b3bb534 100644--- a/frontend/app/pages/(public)/doc/[id]/index.vue+++ b/frontend/app/pages/(public)/doc/[id]/index.vue@@ -6,7 +6,7 @@v-if="!error"class="reader":style="{- marginRight: !isTablet() && preferencesStore.get('hideTOC').value && useSidebar().isOpened.value ? '200px' : '0px',+ marginRight: !devise.isTablet.value && preferencesStore.get('hideTOC').value && sidebar.isOpened.value ? '200px' : '0px',transition: 'margin 0.3s',}">@@ -24,7 +24,7 @@</div><!-- ⬇️ retire le style inline (width/margin-left), on gère en CSS -->- <div v-if="!isTablet() && !preferencesStore.get('hideTOC').value" class="toc">+ <div v-if="!devise.isTablet.value && !preferencesStore.get('hideTOC').value" class="toc"><TableOfContent :doc="article" :element="element" /></div></div>@@ -39,9 +39,13 @@ import DocumentSkeleton from '~/pages/dashboard/docs/_components/DocumentSkeletoimport DocumentCardHeader from '~/pages/dashboard/docs/_components/DocumentCardHeader.vue';import type { Node } from '~/stores';-const route = useRoute();const documentsStore = useNodesStore();const preferencesStore = usePreferences();++const route = useRoute();+const sidebar = useSidebar();+const devise = useDevice();+const element = ref<HTMLElement>();const article = ref<Node | undefined>();diff --git a/frontend/app/pages/dashboard/admin/users/[id]/documents/[doc_id].vue b/frontend/app/pages/dashboard/admin/users/[id]/documents/[doc_id].vueindex f264a2ef..a3d0ff24 100644--- a/frontend/app/pages/dashboard/admin/users/[id]/documents/[doc_id].vue+++ b/frontend/app/pages/dashboard/admin/users/[id]/documents/[doc_id].vue@@ -36,9 +36,9 @@<input id="size" v-model="document.size" /><label for="content">Content</label><div style="display: flex; width: 100%; height: 500px; flex: 1; gap: 10px">- <textarea v-model="document.content" style=" height: 500px;flex: 1; overflow: auto"></textarea>+ <textarea v-model="document.content" style="height: 500px; flex: 1; overflow: auto"></textarea><!-- eslint-disable-next-line vue/no-v-html -->- <div style=" height: 500px;flex: 1; overflow: auto" class="alexandrie-theme" v-html="document.content_compiled" />+ <div style="height: 500px; flex: 1; overflow: auto" class="alexandrie-theme" v-html="document.content_compiled" /></div></div>@@ -50,10 +50,13 @@import type { Node } from '~/stores';definePageMeta({ breadcrumb: 'Document view' });-const document = ref<Node | undefined>();-const route = useRoute();+const store = useAdminStore();+const route = useRoute();++const document = ref<Node | undefined>();+document.value = await store.fetchUserDocument(route.params.id as string, route.params.doc_id as string);</script>diff --git a/frontend/app/pages/dashboard/admin/users/[id]/documents/index.vue b/frontend/app/pages/dashboard/admin/users/[id]/documents/index.vueindex 8b5434bc..9a30a89a 100644--- a/frontend/app/pages/dashboard/admin/users/[id]/documents/index.vue+++ b/frontend/app/pages/dashboard/admin/users/[id]/documents/index.vue@@ -11,17 +11,21 @@<script setup lang="ts">import type { Node } from '~/stores';+definePageMeta({ breadcrumb: 'Nodes' });-const nodes = ref<Node[]>([]);-const route = useRoute();+const categoriesStore = useNodesStore();const store = useAdminStore();+const route = useRoute();+const { numericDate } = useDateFormatters();++const nodes = ref<Node[]>([]);+watchEffect(async () => {nodes.value = (await store.fetchUserDocuments(route.params.id as string)) || [];});-const categoriesStore = useNodesStore();const headers = [{ label: 'Name', key: 'name' },{ label: 'Category', key: 'category' },diff --git a/frontend/app/pages/dashboard/admin/users/[id]/index.vue b/frontend/app/pages/dashboard/admin/users/[id]/index.vueindex a27a51d2..1ea53b19 100644--- a/frontend/app/pages/dashboard/admin/users/[id]/index.vue+++ b/frontend/app/pages/dashboard/admin/users/[id]/index.vue@@ -1,7 +1,7 @@<template><div class="card-component"><h2 style="display: flex; align-items: center; justify-content: space-between">- User Details <img v-if="user" style="width: 40px; height: 40px; border-radius: 50%" :src="useAvatar(user)" />+ User Details <img v-if="user" style="width: 40px; height: 40px; border-radius: 50%" :src="avatarURL(user)" /></h2><div v-if="user" style="width: 100%"><div class="user-details">@@ -52,11 +52,15 @@ import type { User } from '~/stores';definePageMeta({ breadcrumb: 'User Details' });+const store = useAdminStore();+const route = useRoute();const router = useRouter();+const { avatarURL } = useApi();+const { numericDate } = useDateFormatters();const user = ref<User | undefined>(undefined);-const store = useAdminStore();+watchEffect(async () => {user.value = await store.fetchById(route.params.id as string);});diff --git a/frontend/app/pages/dashboard/admin/users/index.vue b/frontend/app/pages/dashboard/admin/users/index.vueindex cb6451c1..3bf81796 100644--- a/frontend/app/pages/dashboard/admin/users/index.vue+++ b/frontend/app/pages/dashboard/admin/users/index.vue@@ -16,6 +16,10 @@ import { useAdminStore } from '~/stores/admin.store';import type { User } from '~/stores';const adminStore = useAdminStore();++const { avatarURL } = useApi();+const { numericDate } = useDateFormatters();+adminStore.fetchAll();const headers = [@@ -32,7 +36,7 @@ const rows = computed(() =>adminStore.users?.map(u => {return {username: {- content: `<img style="border-radius:50%;width:25px;height:25px;" src="${useAvatar(u)}"/> ${u.username}`,+ content: `<img style="border-radius:50%;width:25px;height:25px;" src="${avatarURL(u)}"/> ${u.username}`,type: 'html' as const,},firstname: { content: u.firstname, type: 'text' as const },diff --git a/frontend/app/pages/dashboard/categories/[id]/edit.vue b/frontend/app/pages/dashboard/categories/[id]/edit.vueindex bad5fea7..d94e5d4d 100644--- a/frontend/app/pages/dashboard/categories/[id]/edit.vue+++ b/frontend/app/pages/dashboard/categories/[id]/edit.vue@@ -46,13 +46,14 @@import { CATEGORY_ROLES } from '~/helpers/constants';import DeleteModal from '../_modals/DeleteCategoryModal.vue';+definePageMeta({ breadcrumb: 'Edit' });+const nodesStore = useNodesStore();const route = useRoute();+const category = computed(() => nodesStore.getById(route.params.id as string));const categoriesItem = computed(() => new TreeStructure(useSidebarTree().nodes.value.filter(i => i.data.role <= 2)).generateTree());-definePageMeta({ breadcrumb: 'Edit' });-const updateCategory = async () => {if (category.value)nodesStorediff --git a/frontend/app/pages/dashboard/categories/[id]/index.vue b/frontend/app/pages/dashboard/categories/[id]/index.vueindex a99d3ad6..23273206 100644--- a/frontend/app/pages/dashboard/categories/[id]/index.vue+++ b/frontend/app/pages/dashboard/categories/[id]/index.vue@@ -6,14 +6,14 @@import NodeList from '~/components/Node/NodeList.vue';import type { Node } from '~/stores';+definePageMeta({ breadcrumb: () => useNodesStore().getById(useRoute().params.id as string)?.name || '' });+const route = useRoute();const nodesStore = useNodesStore();const parentId = route.params.id as string;const parent = ref<Node | undefined>();-definePageMeta({ breadcrumb: () => useNodesStore().getById(useRoute().params.id as string)?.name || '' });-watchEffect(() => {parent.value = nodesStore.getById(parentId);});diff --git a/frontend/app/pages/dashboard/categories/_components/WorkspaceTree.vue b/frontend/app/pages/dashboard/categories/_components/WorkspaceTree.vueindex c837644e..59f669ed 100644--- a/frontend/app/pages/dashboard/categories/_components/WorkspaceTree.vue+++ b/frontend/app/pages/dashboard/categories/_components/WorkspaceTree.vue@@ -21,7 +21,6 @@import type { Node } from '~/stores';defineProps<{ node: Item<Node> }>();-defineEmits(['edit', 'delete']);</script>diff --git a/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue b/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vueindex d980c716..4c862add 100644--- a/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue+++ b/frontend/app/pages/dashboard/categories/_modals/CreateCategoryModal.vue@@ -27,11 +27,15 @@<script setup lang="ts">import type { Node } from '~/stores';+const props = defineProps<{ role: 1 | 2 }>();+const emit = defineEmits(['close']);+const categoriesStore = useNodesStore();+const sidebarTree = useSidebarTree();const sidebar = useSidebar();+const categoriesItem = computed(() => new TreeStructure(sidebarTree.nodes.value.filter(c => c.data.role == 1 || c.data.role == 2)).generateTree());-const props = defineProps<{ role: 1 | 2 }>();const category = ref<Partial<Node>>({name: '',@@ -39,7 +43,6 @@ const category = ref<Partial<Node>>({accessibility: 1,parent_id: sidebarTree.getCategoryFromNode(sidebar.active_id.value)?.id || sidebar.workspaceId.value,});-const emit = defineEmits(['close']);const createCategory = () => {categoriesStorediff --git a/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue b/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vueindex 03027d1e..5a3bf249 100644--- a/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue+++ b/frontend/app/pages/dashboard/categories/_modals/DeleteCategoryModal.vue@@ -14,6 +14,8 @@<script setup lang="ts">const props = defineProps<{ categoryId: string }>();+const emit = defineEmits(['close']);+const deleteDoc = () => {useNodesStore().delete(props.categoryId)@@ -26,7 +28,6 @@ const deleteDoc = () => {useNotifications().add({ type: 'error', title: 'Error during deletion', message: e });});};-const emit = defineEmits(['close']);const allChildren = useSidebarTree().getSubTreeById(props.categoryId);</script>diff --git a/frontend/app/pages/dashboard/cdn/[id]/index.vue b/frontend/app/pages/dashboard/cdn/[id]/index.vueindex 7a59ed12..a41766aa 100644--- a/frontend/app/pages/dashboard/cdn/[id]/index.vue+++ b/frontend/app/pages/dashboard/cdn/[id]/index.vue@@ -51,12 +51,15 @@<script lang="ts" setup>import DeleteRessourceModal from '../_modals/DeleteRessourceModal.vue';import { readableFileSize } from '~/helpers/ressources';+definePageMeta({ breadcrumb: 'Edit' });+const nodeStore = useNodesStore();const route = useRoute();-const ressource = computed(() => nodeStore.getById(route.params.id as string));const { CDN } = useApi();+const ressource = computed(() => nodeStore.getById(route.params.id as string));+const defaultItem: ANode = {id: '',label: 'None',diff --git a/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue b/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vueindex 24d35d8c..bb7b1205 100644--- a/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue+++ b/frontend/app/pages/dashboard/cdn/_modals/DeleteRessourceModal.vue@@ -17,7 +17,9 @@<script setup lang="ts">const props = defineProps<{ ressources: string[] }>();+const emit = defineEmits(['close']);+const deleteRessource = async () => {await useNodesStore().bulkDelete(props.ressources)diff --git a/frontend/app/pages/dashboard/cdn/index.vue b/frontend/app/pages/dashboard/cdn/index.vueindex d1ffd316..44b1be37 100644--- a/frontend/app/pages/dashboard/cdn/index.vue+++ b/frontend/app/pages/dashboard/cdn/index.vue@@ -3,7 +3,7 @@<header><h1>File manager</h1><div class="action-row">- <NodeFilter v-show="!isMobile()" :nodes="nodes" @update:nodes="filteredRessources = $event" />+ <NodeFilter v-show="!device.isMobile" :nodes="nodes" @update:nodes="filteredRessources = $event" /><ViewSelection v-model="view" /></div></header>@@ -84,6 +84,10 @@ const router = useRouter();const ressourcesStore = useRessourcesStore();const nodesStore = useNodesStore();+const device = useDevice();+const appColors = useAppColors();+const { numericDate } = useDateFormatters();+const view = ref<'table' | 'list'>('list');const selectedFiles = ref<File[]>([]);const fileLinks = ref<string[]>([]);@@ -162,7 +166,7 @@ const rows: ComputedRef<Field[]> = computed(() =>name: { content: res.name, type: 'text' },size: { content: readableFileSize(res.size ?? 0), type: 'text' },type: { content: `<tag class="${color(res.metadata?.filetype as string)}">${res.metadata?.filetype as string}</tag>`, type: 'html' },- parent: { content: category ? `<tag class="${getAppColor(category.color)}">${parent?.name}</tag>` : '', type: 'html' },+ parent: { content: category ? `<tag class="${appColors.getAppColor(category.color)}">${parent?.name}</tag>` : '', type: 'html' },date: { content: numericDate(res.created_timestamp), type: 'text' },action: { type: 'slot', data: res },};diff --git a/frontend/app/pages/dashboard/docs/[id].vue b/frontend/app/pages/dashboard/docs/[id].vueindex 6bc3759b..41daafc9 100644--- a/frontend/app/pages/dashboard/docs/[id].vue+++ b/frontend/app/pages/dashboard/docs/[id].vue@@ -5,7 +5,6 @@<div :style="{ maxWidth: width }" class="doc-container"><DocumentCardHeader :doc="node" style="margin-bottom: 20px" />- <!-- eslint-disable-next-line vue/no-v-html --><articlev-if="node"ref="element"@@ -17,14 +16,14 @@<DocumentCardFooter :document="node" :next="next" :previous="previous" /></div>- <div v-if="!isTablet() && !preferencesStore.get('hideTOC').value" class="toc">+ <div v-if="!devise.isTablet.value && !preferencesStore.get('hideTOC').value" class="toc"><TableOfContent :doc="node" :element="element" style="width: 320px; margin-left: 20px" /></div><divclass="no-print":style="{- marginRight: !isTablet() && preferencesStore.get('hideTOC').value && useSidebar().isOpened.value ? '200px' : '0px',+ marginRight: !devise.isTablet.value && preferencesStore.get('hideTOC').value && sidebar.isOpened.value ? '200px' : '0px',transition: 'margin 0.3s',}"/>@@ -43,8 +42,11 @@ import NodeContextMenu from '~/components/Node/NodeContextMenu.vue';const route = useRoute();const documentsStore = useNodesStore();const preferencesStore = usePreferences();-const element = ref<HTMLElement>();+const devise = useDevice();+const sidebar = useSidebar();++const element = ref<HTMLElement>();const node = ref<Node | undefined>();const error = ref<false | string>(false);diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardFooter.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardFooter.vueindex df773e76..06a3dc31 100644--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardFooter.vue+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardFooter.vue@@ -27,7 +27,10 @@<script lang="ts" setup>import type { Node } from '~/stores';+defineProps<{ document?: Node; next?: Node; previous?: Node }>();++const { formatRelativeDate } = useDateFormatters();</script><style scoped lang="scss">diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vueindex 5b678c2e..76831fe7 100644--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue@@ -7,7 +7,7 @@<template v-else><p class="top-row"><span style="display: flex; align-items: center; gap: 12px"- ><img v-if="user" :src="useAvatar(user)" class="avatar" />+ ><img v-if="user" :src="api.avatarURL(user)" class="avatar" /><span style="font-size: 16px; color: var(--font-color-light)">{{ user?.username }}</span></span><DocumentCardHeaderActionRow :doc="doc" class="no-print" />@@ -33,6 +33,8 @@ import DocumentCardHeaderSkeleton from './DocumentCardHeaderSkeleton.vue';import type { Node, PublicUser } from '~/stores';const preferences = usePreferences();+const api = useApi();+const props = defineProps<{ doc?: Node; public?: boolean }>();const category = computed(() => useSidebarTree().getCategoryFromNode(props.doc?.parent_id)?.data);const store = useUserStore();diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vueindex 31430d1d..a21263b9 100644--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue@@ -37,6 +37,7 @@ import type { Node } from '~/stores';const nodeStore = useNodesStore();const props = defineProps<{ doc: Node }>();+const print = () => window.print();const openDeleteModal = () => useModal().add(new Modal(shallowRef(DeleteNodeModal), { props: { node: props.doc } }));const openEditModal = () => useModal().add(new Modal(shallowRef(DocumentMeta), { props: { doc: props.doc }, size: 'small' }));diff --git a/frontend/app/pages/dashboard/docs/_components/table-of-content/NodeTree.vue b/frontend/app/pages/dashboard/docs/_components/table-of-content/NodeTree.vueindex 860520f8..06349954 100644--- a/frontend/app/pages/dashboard/docs/_components/table-of-content/NodeTree.vue+++ b/frontend/app/pages/dashboard/docs/_components/table-of-content/NodeTree.vue@@ -1,6 +1,6 @@<template><li>- <a :href="node.link">{{ node.title }}</a>+ <NuxtLink :to="node.link">{{ node.title }}</NuxtLink><ul v-if="node.childrens?.length"><NodeTree v-for="child in node.childrens" :key="child.link" :node="child" /></ul>diff --git a/frontend/app/pages/dashboard/docs/edit/[id].vue b/frontend/app/pages/dashboard/docs/edit/[id].vueindex bab90f08..a7ad3083 100644--- a/frontend/app/pages/dashboard/docs/edit/[id].vue+++ b/frontend/app/pages/dashboard/docs/edit/[id].vue@@ -1,5 +1,5 @@<template>- <MarkdownEditor v-if="node" ref="editor" :doc="node" @save="data => save(data)" @auto-save="autoSave" @exit="exit" />+ <MarkdownEditor v-if="node" :doc="node" @save="data => save(data)" @auto-save="autoSave" @exit="exit" /></template><script lang="ts" setup>import type { Node } from '~/stores';@@ -8,16 +8,15 @@ import MarkdownEditor from '~/components/MarkdownEditor/LazyMarkdownEditor.vue';const store = useNodesStore();const route = useRoute();-const editor = ref();-const doc_id = route.params.id as string;+const nodeId = route.params.id as string;const node = ref<Node | undefined>(undefined);const notifications = useNotifications();watchEffect(async () => {- const docFromStore = store.getById(doc_id);+ const docFromStore = store.getById(nodeId);if (docFromStore?.partial) {try {- node.value = await store.fetch({ id: doc_id });+ node.value = await store.fetch({ id: nodeId });} catch (error) {console.error('Error fetching node:', error);}@@ -38,6 +37,6 @@ function autoSave(doc: Node) {}function exit() {- useRouter().push(`/dashboard/docs/${doc_id}`);+ useRouter().push(`/dashboard/docs/${nodeId}`);}</script>diff --git a/frontend/app/pages/dashboard/docs/index.vue b/frontend/app/pages/dashboard/docs/index.vueindex 8c428410..eb48aba6 100644--- a/frontend/app/pages/dashboard/docs/index.vue+++ b/frontend/app/pages/dashboard/docs/index.vue@@ -10,9 +10,7 @@ const nodesStore = useNodesStore();const { filtered, workspaceId } = useSidebar();const parent = computed(() => nodesStore.getById(workspaceId.value || ''));-definePageMeta({- breadcrumb: () => 'All',-});+definePageMeta({ breadcrumb: () => 'All' });const nodes = computed(() => {const result: Node[] = [];diff --git a/frontend/app/pages/dashboard/home.vue b/frontend/app/pages/dashboard/home.vueindex fe520af4..be99f822 100644--- a/frontend/app/pages/dashboard/home.vue+++ b/frontend/app/pages/dashboard/home.vue@@ -148,6 +148,9 @@ const router = useRouter();const nodesStore = useNodesStore();const userStore = useUserStore();+const { todayFormatted, formatTime, shortDateLabel } = useDateFormatters();+const { getAppColor } = useAppColors();+// Search stateconst searchQuery = ref('');const isSearchFocused = ref(false);diff --git a/frontend/app/pages/dashboard/import.vue b/frontend/app/pages/dashboard/import.vueindex 237ca3d7..71287106 100644--- a/frontend/app/pages/dashboard/import.vue+++ b/frontend/app/pages/dashboard/import.vue@@ -11,9 +11,9 @@<div class="submit"><AppButton type="primary" :disabled="!selectedFile" @click="submit">Analyse file</AppButton></div>- <div v-if="files_to_import.length">+ <div v-if="filesToImport.length"><h2>Files to import</h2>- <div v-for="file in files_to_import" :key="file.id" class="card-component" style="padding: 15px">+ <div v-for="file in filesToImport" :key="file.id" class="card-component" style="padding: 15px"><div style="display: flex; align-items: center"><Icon name="file" /> {{ file.name }}@@ -35,13 +35,17 @@<script setup lang="ts">import { analyseFile, validateFileStructure, compareDocumentsAndLocal, prepareNewDocuments } from '~/helpers/node';import type { DB_Node } from '~/stores';+definePageMeta({ breadcrumb: 'Importations' });+const { numericDate } = useDateFormatters();+const selectedFile: Ref<File | undefined> = ref();-const handleFileSelect = (file?: File) => (selectedFile.value = file);+const filesToImport = ref<DB_Node[]>([]);const dropComponent = ref();-const files_to_import = ref<DB_Node[]>([]);+const handleFileSelect = (file?: File) => (selectedFile.value = file);+async function submit() {try {if (!selectedFile.value) return;@@ -49,7 +53,7 @@ async function submit() {const valid = validateFileStructure(fileContent);if (!valid) useNotifications().add({ type: 'error', title: 'Invalid file structure' });else useNotifications().add({ type: 'success', title: 'File structure is valid' });- files_to_import.value = compareDocumentsAndLocal(fileContent);+ filesToImport.value = compareDocumentsAndLocal(fileContent);} catch (e) {if (e instanceof Error) useNotifications().add({ type: 'error', title: 'Error while analysing file', message: e.message });else useNotifications().add({ type: 'error', title: 'Error while analysing file', message: 'Unknown error' });@@ -71,24 +75,24 @@ async function uploadDocuments(documents: DB_Node[]) {}function importDoc(file: DB_Node) {- const fileContent = files_to_import.value.find(i => i.id === file.id);+ const fileContent = filesToImport.value.find(i => i.id === file.id);if (!fileContent) return useNotifications().add({ type: 'error', title: 'File not found' });prepareNewDocuments([fileContent]);uploadDocument(fileContent).then(() => {useNotifications().add({ type: 'success', title: 'Document imported successfully' });- files_to_import.value = files_to_import.value.filter(i => i.id !== file.id);+ filesToImport.value = filesToImport.value.filter(i => i.id !== file.id);}).catch(e => useNotifications().add({ type: 'error', title: 'Error while importing document', message: e }));}function importAllDocs() {- if (!files_to_import.value.length) return;- const files = [...files_to_import.value];+ if (!filesToImport.value.length) return;+ const files = [...filesToImport.value];prepareNewDocuments(files);uploadDocuments(files).then(() => {useNotifications().add({ type: 'success', title: 'Documents imported successfully' });- files_to_import.value = [];+ filesToImport.value = [];}).catch(e => useNotifications().add({ type: 'error', title: 'Error while importing documents', message: e }));}diff --git a/frontend/app/pages/dashboard/settings/_views/advanced.vue b/frontend/app/pages/dashboard/settings/_views/advanced.vueindex 6528f8d2..406c06a7 100644--- a/frontend/app/pages/dashboard/settings/_views/advanced.vue+++ b/frontend/app/pages/dashboard/settings/_views/advanced.vue@@ -8,7 +8,7 @@<div class="setting"><h4>Reset all preferences</h4><p>This will reset all your preferences to their default values. This action cannot be undone.</p>- <AppButton type="danger" @click="usePreferences().reset">Reset preferences</AppButton>+ <AppButton type="danger" @click="preferences.reset">Reset preferences</AppButton></div><div class="setting"><h4>Reset local storage</h4>@@ -20,6 +20,8 @@</template><script setup lang="ts">+const preferences = usePreferences();+const deleteLocalStorage = () => {localStorage.clear();location.reload();diff --git a/frontend/app/pages/dashboard/settings/_views/backups.vue b/frontend/app/pages/dashboard/settings/_views/backups.vueindex ecd40e2c..d7616ab3 100644--- a/frontend/app/pages/dashboard/settings/_views/backups.vue+++ b/frontend/app/pages/dashboard/settings/_views/backups.vue@@ -20,16 +20,14 @@</template><script setup lang="ts">-const route = useRoute();-const currentPage = ref(route.query.p || 'profile');--watchEffect(() => (currentPage.value = route.query.p || 'profile'));+const { CDN } = useApi();const downloadLink = ref<string | null>(null);-const copyLink = () => navigator.clipboard.writeText(downloadLink.value!);const isLoading = ref(false);++const copyLink = () => navigator.clipboard.writeText(downloadLink.value!);const fileName = () => `backup-${new Date().toISOString().split('T')[0]}.json`;-const { CDN } = useApi();+async function submitFile() {isLoading.value = true;const result = await makeRequest<{ link: string }>('ressources/backup', 'GET', {});@@ -37,8 +35,6 @@ async function submitFile() {if (result.status != 'success') return useNotifications().add({ type: 'error', title: 'Error', message: result.message });downloadLink.value = `${CDN}/${result.result?.link || ''}`;}--watchEffect(() => (currentPage.value = route.query.p || 'profile'));</script><style scoped lang="scss">diff --git a/frontend/app/pages/dashboard/settings/_views/preferences.vue b/frontend/app/pages/dashboard/settings/_views/preferences.vueindex 640524ef..5c53496c 100644--- a/frontend/app/pages/dashboard/settings/_views/preferences.vue+++ b/frontend/app/pages/dashboard/settings/_views/preferences.vue@@ -64,7 +64,10 @@<script setup lang="ts">import { DOCUMENT_SIZES, DOCUMENT_THEMES, EDITOR_FONTS } from '~/helpers/constants';+const preferencesStore = usePreferences();+const appColors = useAppColors();+// @ts-expect-error unknown typeconst p = preferencesStore.get as <K extends PreferenceKey>(key: K) => ReturnType<unknown>;@@ -93,7 +96,7 @@ const options: Array<{ label: string; options: InterfaceOption[] }> = [key: 'primaryColor',// @ts-expect-error -> specific typeonChange: (option: number) => {- setAppColor(option);+ appColors.setAppColor(option);},},],diff --git a/frontend/app/pages/dashboard/settings/_views/profile.vue b/frontend/app/pages/dashboard/settings/_views/profile.vueindex 1922c23c..6281e24e 100644--- a/frontend/app/pages/dashboard/settings/_views/profile.vue+++ b/frontend/app/pages/dashboard/settings/_views/profile.vue@@ -35,11 +35,15 @@<script setup lang="ts">const userStore = useUserStore();const ressourcesStore = useRessourcesStore();-const avatarInput = ref<HTMLInputElement | null>(null);-const selectAvatar = () => avatarInput.value?.click();+const api = useApi();+const { shortDate } = useDateFormatters();++const avatarInput = ref<HTMLInputElement | null>(null);const avatarPreview = ref('');-const avatarDisplayed = computed(() => avatarPreview.value || useAvatar(userStore.user));+const avatarDisplayed = computed(() => avatarPreview.value || api.avatarURL(userStore.user));++const selectAvatar = () => avatarInput.value?.click();const uploadAvatar = async () => {if (!userStore.user) return;diff --git a/frontend/app/pages/dashboard/settings/_views/security.vue b/frontend/app/pages/dashboard/settings/_views/security.vueindex 214e9887..42da9c3e 100644--- a/frontend/app/pages/dashboard/settings/_views/security.vue+++ b/frontend/app/pages/dashboard/settings/_views/security.vue@@ -47,7 +47,7 @@</div><div class="form-group"><span style="display: flex; align-items: center"- ><label for="password_confirm">Confirm password</label> <span v-if="err_password_not_match" class="err"> Password do not match !</span></span+ ><label for="password_confirm">Confirm password</label> <span v-if="errPasswordNotMatch" class="err"> Password do not match !</span></span><input id="password_confirm" v-model="passwordConfirmValue" type="password" required /></div>@@ -85,22 +85,25 @@import DeleteAccountModal from '../_modals/DeleteAccountModal.vue';import { parseUserAgent } from '~/helpers/utils';-const store = useUserStore();const emit = defineEmits(['close']);+const store = useUserStore();++const { numericDate } = useDateFormatters();+const passwordValue = ref('');const passwordConfirmValue = ref('');-const err_password_not_match = ref(false);+const errPasswordNotMatch = ref(false);const changePassword = async () => {if (!store.user) return;- if (passwordValue.value !== passwordConfirmValue.value) return (err_password_not_match.value = true);+ if (passwordValue.value !== passwordConfirmValue.value) return (errPasswordNotMatch.value = true);store.updatePassword(passwordValue.value).then(() => {passwordValue.value = '';passwordConfirmValue.value = '';- err_password_not_match.value = false;+ errPasswordNotMatch.value = false;useNotifications().add({ type: 'success', title: 'Password changed successfully' });}).catch(e => useNotifications().add({ type: 'error', title: 'Error during password saving', message: e.message }));diff --git a/frontend/app/pages/dashboard/settings/index.vue b/frontend/app/pages/dashboard/settings/index.vueindex 9256b1a6..3359fb1a 100644--- a/frontend/app/pages/dashboard/settings/index.vue+++ b/frontend/app/pages/dashboard/settings/index.vue@@ -3,7 +3,7 @@<nav><span v-if="isModal">Account settings</span><div v-if="isModal && store.user" class="user">- <img :src="useAvatar(store.user)" alt="Avatar" style="width: 25px; height: 25px; border-radius: 50%" />+ <img :src="api.avatarURL(store.user)" alt="Avatar" style="width: 25px; height: 25px; border-radius: 50%" /><div><div class="username">{{ store.user.username }}</div><div class="email">{{ store.user.email }}</div>@@ -53,11 +53,15 @@ import MarkdownView from './_views/markdown.vue';import AboutView from './_views/about.vue';import AdvancedView from './_views/advanced.vue';+defineProps<{ isModal?: boolean }>();+const emit = defineEmits<{ (e: 'close'): void }>();+const route = useRoute();const router = useRouter();const store = useUserStore();-defineProps<{ isModal?: boolean }>();-const emit = defineEmits<{ (e: 'close'): void }>();++const api = useApi();+const currentPage = ref(route.query.p || 'profile');const setPage = (p: string) => {