/// import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'; import { RouterLink, RouterView } from 'vue-router'; import AppHeader from '@/components/AppHeader.vue'; import AppDrawer from '@/components/AppDrawer.vue'; import ToastNotification from '@/components/ToastNotification.vue'; import { meteoApi } from '@/api/meteo'; import { settingsApi } from '@/api/settings'; import { applyUiSizesToRoot } from '@/utils/uiSizeDefaults'; const drawerOpen = ref(false); const debugMode = ref(localStorage.getItem('debug_mode') === '1'); const debugStats = ref(null); let debugTimer = null; function prefetchMeteoInBackground() { // Préchargement du chunk route + données pour accélérer l'ouverture de /meteo void import('@/views/CalendrierView.vue'); void meteoApi.preloadForMeteoView(); } function toBool(value) { if (typeof value === 'boolean') return value; const s = String(value ?? '').toLowerCase().trim(); return s === '1' || s === 'true' || s === 'yes' || s === 'on'; } function formatBytes(value) { if (value == null || Number.isNaN(value)) return '—'; const units = ['B', 'KB', 'MB', 'GB', 'TB']; let n = value; let i = 0; while (n >= 1024 && i < units.length - 1) { n /= 1024; i += 1; } return `${n.toFixed(n >= 100 ? 0 : n >= 10 ? 1 : 2)}${units[i]}`; } const debugCpuLabel = computed(() => { const pct = debugStats.value?.cpu?.used_pct; return pct != null ? `${pct.toFixed(1)}%` : '—'; }); const debugMemLabel = computed(() => { const used = debugStats.value?.memory?.used_bytes; const pct = debugStats.value?.memory?.used_pct; if (used == null) return '—'; return pct != null ? `${formatBytes(used)} (${pct.toFixed(1)}%)` : formatBytes(used); }); const debugDiskLabel = computed(() => { const used = debugStats.value?.disk?.used_bytes; const pct = debugStats.value?.disk?.used_pct; if (used == null) return '—'; return pct != null ? `${formatBytes(used)} (${pct.toFixed(1)}%)` : formatBytes(used); }); async function fetchDebugStats() { try { debugStats.value = await settingsApi.getDebugSystemStats(); } catch { debugStats.value = null; } } function stopDebugPolling() { if (debugTimer != null) { window.clearInterval(debugTimer); debugTimer = null; } } function startDebugPolling() { stopDebugPolling(); void fetchDebugStats(); debugTimer = window.setInterval(() => { void fetchDebugStats(); }, 10000); } function applyUiSizesFromSettings(data) { applyUiSizesToRoot(data); } async function loadDebugModeFromApi() { try { const data = await settingsApi.get(); debugMode.value = toBool(data.debug_mode); localStorage.setItem('debug_mode', debugMode.value ? '1' : '0'); applyUiSizesFromSettings(data); } catch { // On garde la valeur locale. } } function handleSettingsUpdated(event) { const ce = event; if (!ce.detail || ce.detail.debug_mode == null) return; debugMode.value = toBool(ce.detail.debug_mode); localStorage.setItem('debug_mode', debugMode.value ? '1' : '0'); } function handleStorage(event) { if (event.key !== 'debug_mode') return; debugMode.value = event.newValue === '1'; } onMounted(() => { const ric = window.requestIdleCallback; if (ric) { ric(() => prefetchMeteoInBackground(), { timeout: 1500 }); } else { window.setTimeout(prefetchMeteoInBackground, 500); } void loadDebugModeFromApi(); window.addEventListener('settings-updated', handleSettingsUpdated); window.addEventListener('storage', handleStorage); }); watch(debugMode, (enabled) => { if (enabled) startDebugPolling(); else { stopDebugPolling(); debugStats.value = null; } }, { immediate: true }); onBeforeUnmount(() => { stopDebugPolling(); window.removeEventListener('settings-updated', handleSettingsUpdated); window.removeEventListener('storage', handleStorage); }); const links = [ { to: '/', label: 'Dashboard', icon: '🏠' }, { to: '/jardins', label: 'Jardins', icon: '🪴' }, { to: '/plantes', label: 'Plantes', icon: '🌱' }, { to: '/bibliotheque', label: 'Bibliothèque', icon: '📷' }, { to: '/outils', label: 'Outils', icon: '🔧' }, { to: '/plantations', label: 'Plantations', icon: '🥕' }, { to: '/taches', label: 'Tâches', icon: '✅' }, { to: '/planning', label: 'Planning', icon: '📆' }, { to: '/meteo', label: 'Météo', icon: '🌦️' }, { to: '/astuces', label: 'Astuces', icon: '💡' }, { to: '/reglages', label: 'Réglages', icon: '⚙️' }, ]; debugger; /* PartiallyEnd: #3632/scriptSetup.vue */ const __VLS_ctx = {}; let __VLS_components; let __VLS_directives; if (__VLS_ctx.debugMode) { __VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({ ...{ class: "fixed top-2 right-2 z-[70] bg-bg-hard/95 border border-bg-soft rounded-lg px-3 py-1.5 text-[11px] text-text-muted shadow-lg" }, }); __VLS_asFunctionalElement(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({ ...{ class: "text-aqua font-semibold mr-2" }, }); __VLS_asFunctionalElement(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({ ...{ class: "mr-2" }, }); (__VLS_ctx.debugCpuLabel); __VLS_asFunctionalElement(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({ ...{ class: "mr-2" }, }); (__VLS_ctx.debugMemLabel); __VLS_asFunctionalElement(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({}); (__VLS_ctx.debugDiskLabel); } /** @type {[typeof ToastNotification, ]} */ ; // @ts-ignore const __VLS_0 = __VLS_asFunctionalComponent(ToastNotification, new ToastNotification({})); const __VLS_1 = __VLS_0({}, ...__VLS_functionalComponentArgsRest(__VLS_0)); /** @type {[typeof AppHeader, ]} */ ; // @ts-ignore const __VLS_3 = __VLS_asFunctionalComponent(AppHeader, new AppHeader({ ...{ 'onToggleDrawer': {} }, ...{ class: "lg:hidden" }, })); const __VLS_4 = __VLS_3({ ...{ 'onToggleDrawer': {} }, ...{ class: "lg:hidden" }, }, ...__VLS_functionalComponentArgsRest(__VLS_3)); let __VLS_6; let __VLS_7; let __VLS_8; const __VLS_9 = { onToggleDrawer: (...[$event]) => { __VLS_ctx.drawerOpen = !__VLS_ctx.drawerOpen; } }; var __VLS_5; /** @type {[typeof AppDrawer, ]} */ ; // @ts-ignore const __VLS_10 = __VLS_asFunctionalComponent(AppDrawer, new AppDrawer({ ...{ 'onClose': {} }, open: (__VLS_ctx.drawerOpen), })); const __VLS_11 = __VLS_10({ ...{ 'onClose': {} }, open: (__VLS_ctx.drawerOpen), }, ...__VLS_functionalComponentArgsRest(__VLS_10)); let __VLS_13; let __VLS_14; let __VLS_15; const __VLS_16 = { onClose: (...[$event]) => { __VLS_ctx.drawerOpen = false; } }; var __VLS_12; __VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({ ...{ class: "lg:flex" }, }); __VLS_asFunctionalElement(__VLS_intrinsicElements.aside, __VLS_intrinsicElements.aside)({ ...{ class: "hidden lg:flex lg:flex-col lg:fixed lg:inset-y-0 lg:w-60 bg-bg-hard border-r border-bg-soft z-30" }, }); __VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({ ...{ class: "px-5 pt-6 pb-4 border-b border-bg-soft" }, }); const __VLS_17 = {}.RouterLink; /** @type {[typeof __VLS_components.RouterLink, typeof __VLS_components.RouterLink, ]} */ ; // @ts-ignore const __VLS_18 = __VLS_asFunctionalComponent(__VLS_17, new __VLS_17({ to: "/", ...{ class: "text-green font-bold text-xl tracking-wide flex items-center gap-2" }, })); const __VLS_19 = __VLS_18({ to: "/", ...{ class: "text-green font-bold text-xl tracking-wide flex items-center gap-2" }, }, ...__VLS_functionalComponentArgsRest(__VLS_18)); __VLS_20.slots.default; __VLS_asFunctionalElement(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({}); var __VLS_20; __VLS_asFunctionalElement(__VLS_intrinsicElements.nav, __VLS_intrinsicElements.nav)({ ...{ class: "flex-1 py-4 px-3 flex flex-col gap-0.5 overflow-y-auto" }, }); for (const [l] of __VLS_getVForSourceType((__VLS_ctx.links))) { const __VLS_21 = {}.RouterLink; /** @type {[typeof __VLS_components.RouterLink, typeof __VLS_components.RouterLink, ]} */ ; // @ts-ignore const __VLS_22 = __VLS_asFunctionalComponent(__VLS_21, new __VLS_21({ key: (l.to), to: (l.to), ...{ class: "flex items-center gap-3 text-text-muted hover:text-text py-2 px-3 rounded-lg text-sm transition-colors group" }, activeClass: "bg-bg-soft text-green font-medium", })); const __VLS_23 = __VLS_22({ key: (l.to), to: (l.to), ...{ class: "flex items-center gap-3 text-text-muted hover:text-text py-2 px-3 rounded-lg text-sm transition-colors group" }, activeClass: "bg-bg-soft text-green font-medium", }, ...__VLS_functionalComponentArgsRest(__VLS_22)); __VLS_24.slots.default; __VLS_asFunctionalElement(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({ ...{ style: (`font-size: var(--ui-menu-icon-size, 18px); line-height: 1`) }, }); (l.icon); __VLS_asFunctionalElement(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({ ...{ style: (`font-size: var(--ui-menu-font-size, 13px)`) }, }); (l.label); var __VLS_24; } __VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({ ...{ class: "px-4 py-4 border-t border-bg-soft text-text-muted text-xs" }, }); __VLS_asFunctionalElement(__VLS_intrinsicElements.main, __VLS_intrinsicElements.main)({ ...{ class: "pt-14 lg:pt-0 lg:pl-60 min-h-screen w-full bg-bg" }, }); const __VLS_25 = {}.RouterView; /** @type {[typeof __VLS_components.RouterView, typeof __VLS_components.routerView, typeof __VLS_components.RouterView, typeof __VLS_components.routerView, ]} */ ; // @ts-ignore const __VLS_26 = __VLS_asFunctionalComponent(__VLS_25, new __VLS_25({})); const __VLS_27 = __VLS_26({}, ...__VLS_functionalComponentArgsRest(__VLS_26)); { const { default: __VLS_thisSlot } = __VLS_28.slots; const [{ Component }] = __VLS_getSlotParams(__VLS_thisSlot); const __VLS_29 = {}.transition; /** @type {[typeof __VLS_components.Transition, typeof __VLS_components.transition, typeof __VLS_components.Transition, typeof __VLS_components.transition, ]} */ ; // @ts-ignore const __VLS_30 = __VLS_asFunctionalComponent(__VLS_29, new __VLS_29({ name: "fade", mode: "out-in", })); const __VLS_31 = __VLS_30({ name: "fade", mode: "out-in", }, ...__VLS_functionalComponentArgsRest(__VLS_30)); __VLS_32.slots.default; const __VLS_33 = ((Component)); // @ts-ignore const __VLS_34 = __VLS_asFunctionalComponent(__VLS_33, new __VLS_33({})); const __VLS_35 = __VLS_34({}, ...__VLS_functionalComponentArgsRest(__VLS_34)); var __VLS_32; __VLS_28.slots['' /* empty slot name completion */]; } var __VLS_28; /** @type {__VLS_StyleScopedClasses['fixed']} */ ; /** @type {__VLS_StyleScopedClasses['top-2']} */ ; /** @type {__VLS_StyleScopedClasses['right-2']} */ ; /** @type {__VLS_StyleScopedClasses['z-[70]']} */ ; /** @type {__VLS_StyleScopedClasses['bg-bg-hard/95']} */ ; /** @type {__VLS_StyleScopedClasses['border']} */ ; /** @type {__VLS_StyleScopedClasses['border-bg-soft']} */ ; /** @type {__VLS_StyleScopedClasses['rounded-lg']} */ ; /** @type {__VLS_StyleScopedClasses['px-3']} */ ; /** @type {__VLS_StyleScopedClasses['py-1.5']} */ ; /** @type {__VLS_StyleScopedClasses['text-[11px]']} */ ; /** @type {__VLS_StyleScopedClasses['text-text-muted']} */ ; /** @type {__VLS_StyleScopedClasses['shadow-lg']} */ ; /** @type {__VLS_StyleScopedClasses['text-aqua']} */ ; /** @type {__VLS_StyleScopedClasses['font-semibold']} */ ; /** @type {__VLS_StyleScopedClasses['mr-2']} */ ; /** @type {__VLS_StyleScopedClasses['mr-2']} */ ; /** @type {__VLS_StyleScopedClasses['mr-2']} */ ; /** @type {__VLS_StyleScopedClasses['lg:hidden']} */ ; /** @type {__VLS_StyleScopedClasses['lg:flex']} */ ; /** @type {__VLS_StyleScopedClasses['hidden']} */ ; /** @type {__VLS_StyleScopedClasses['lg:flex']} */ ; /** @type {__VLS_StyleScopedClasses['lg:flex-col']} */ ; /** @type {__VLS_StyleScopedClasses['lg:fixed']} */ ; /** @type {__VLS_StyleScopedClasses['lg:inset-y-0']} */ ; /** @type {__VLS_StyleScopedClasses['lg:w-60']} */ ; /** @type {__VLS_StyleScopedClasses['bg-bg-hard']} */ ; /** @type {__VLS_StyleScopedClasses['border-r']} */ ; /** @type {__VLS_StyleScopedClasses['border-bg-soft']} */ ; /** @type {__VLS_StyleScopedClasses['z-30']} */ ; /** @type {__VLS_StyleScopedClasses['px-5']} */ ; /** @type {__VLS_StyleScopedClasses['pt-6']} */ ; /** @type {__VLS_StyleScopedClasses['pb-4']} */ ; /** @type {__VLS_StyleScopedClasses['border-b']} */ ; /** @type {__VLS_StyleScopedClasses['border-bg-soft']} */ ; /** @type {__VLS_StyleScopedClasses['text-green']} */ ; /** @type {__VLS_StyleScopedClasses['font-bold']} */ ; /** @type {__VLS_StyleScopedClasses['text-xl']} */ ; /** @type {__VLS_StyleScopedClasses['tracking-wide']} */ ; /** @type {__VLS_StyleScopedClasses['flex']} */ ; /** @type {__VLS_StyleScopedClasses['items-center']} */ ; /** @type {__VLS_StyleScopedClasses['gap-2']} */ ; /** @type {__VLS_StyleScopedClasses['flex-1']} */ ; /** @type {__VLS_StyleScopedClasses['py-4']} */ ; /** @type {__VLS_StyleScopedClasses['px-3']} */ ; /** @type {__VLS_StyleScopedClasses['flex']} */ ; /** @type {__VLS_StyleScopedClasses['flex-col']} */ ; /** @type {__VLS_StyleScopedClasses['gap-0.5']} */ ; /** @type {__VLS_StyleScopedClasses['overflow-y-auto']} */ ; /** @type {__VLS_StyleScopedClasses['flex']} */ ; /** @type {__VLS_StyleScopedClasses['items-center']} */ ; /** @type {__VLS_StyleScopedClasses['gap-3']} */ ; /** @type {__VLS_StyleScopedClasses['text-text-muted']} */ ; /** @type {__VLS_StyleScopedClasses['hover:text-text']} */ ; /** @type {__VLS_StyleScopedClasses['py-2']} */ ; /** @type {__VLS_StyleScopedClasses['px-3']} */ ; /** @type {__VLS_StyleScopedClasses['rounded-lg']} */ ; /** @type {__VLS_StyleScopedClasses['text-sm']} */ ; /** @type {__VLS_StyleScopedClasses['transition-colors']} */ ; /** @type {__VLS_StyleScopedClasses['group']} */ ; /** @type {__VLS_StyleScopedClasses['px-4']} */ ; /** @type {__VLS_StyleScopedClasses['py-4']} */ ; /** @type {__VLS_StyleScopedClasses['border-t']} */ ; /** @type {__VLS_StyleScopedClasses['border-bg-soft']} */ ; /** @type {__VLS_StyleScopedClasses['text-text-muted']} */ ; /** @type {__VLS_StyleScopedClasses['text-xs']} */ ; /** @type {__VLS_StyleScopedClasses['pt-14']} */ ; /** @type {__VLS_StyleScopedClasses['lg:pt-0']} */ ; /** @type {__VLS_StyleScopedClasses['lg:pl-60']} */ ; /** @type {__VLS_StyleScopedClasses['min-h-screen']} */ ; /** @type {__VLS_StyleScopedClasses['w-full']} */ ; /** @type {__VLS_StyleScopedClasses['bg-bg']} */ ; var __VLS_dollars; const __VLS_self = (await import('vue')).defineComponent({ setup() { return { RouterLink: RouterLink, RouterView: RouterView, AppHeader: AppHeader, AppDrawer: AppDrawer, ToastNotification: ToastNotification, drawerOpen: drawerOpen, debugMode: debugMode, debugCpuLabel: debugCpuLabel, debugMemLabel: debugMemLabel, debugDiskLabel: debugDiskLabel, links: links, }; }, }); export default (await import('vue')).defineComponent({ setup() { return {}; }, }); ; /* PartiallyEnd: #4569/main.vue */