feat(webui): perfect-design app shell, command palette and theme boot

This commit is contained in:
2026-11-25 11:52:35 +00:00
parent c6da612215
commit 5177b2209c
33 changed files with 898 additions and 462 deletions
+8 -5
View File
@@ -20,10 +20,10 @@ import { useNavStore } from '@/stores/nav'
* design (stores/nav.ts's own doc comment).
* - A single computed re-derives the hash from filters' current state
* plus nav.page/nav.params, and writes it back via history.
* replaceState whenever it changes — never pushState (one browser-
* history entry per admin session, not per click) and never a bare
* `location.hash =` assignment (which would also jump scroll position
* to any element whose id happens to match).
* replaceState whenever it changes, except when nav.pushPending is set
* (nav.openPanel): then pushState, so Back closes the panel. Never a
* bare `location.hash =` assignment (which would also jump scroll
* position to any element whose id happens to match).
* - It listens for the browser's own `hashchange` event (back/forward
* navigation, or a hand-edited URL) and re-parses from scratch,
* reapplying the same restore path as the initial read.
@@ -86,9 +86,12 @@ export function useHashState(): void {
watch(
currentHash,
(hash) => {
const push = nav.pushPending
nav.pushPending = false
if (!hasWindow) return
if (window.location.hash === hash) return
window.history.replaceState(null, '', hash)
if (push) window.history.pushState(null, '', hash)
else window.history.replaceState(null, '', hash)
},
{ immediate: true },
)
+7 -8
View File
@@ -10,10 +10,9 @@ import { onBeforeUnmount, onMounted, ref } from 'vue'
* only ones this admin panel targets — see vite.config.ts's
* modulePreload note for the same reasoning), so no conversion is needed.
*
* Re-reads on a `prefers-color-scheme` change so an open Charts view
* repaints if the OS theme flips while it's on screen — main.css's own
* dark-mode block is a plain media query, not a class toggle, so this is
* the only way a chart already on screen learns about it.
* Re-reads when the `class` of <html> changes (perfect-design's theme
* store toggles `.dark` there, including on an OS flip in "system" mode),
* so an open chart repaints on a theme switch.
*/
export function useThemeColors() {
const foreground = ref('')
@@ -27,14 +26,14 @@ export function useThemeColors() {
border.value = style.getPropertyValue('--border').trim()
}
let media: MediaQueryList | undefined
let observer: MutationObserver | undefined
onMounted(() => {
sync()
media = window.matchMedia('(prefers-color-scheme: dark)')
media.addEventListener('change', sync)
observer = new MutationObserver(sync)
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] })
})
onBeforeUnmount(() => {
media?.removeEventListener('change', sync)
observer?.disconnect()
})
return { foreground, mutedForeground, border }