diff --git a/src/App.vue b/src/App.vue index a7c11376..226ceba6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -28,6 +28,13 @@ const previewOptions = { const initialUserOptions: UserOptions = {} +const dark = useDark() + +const theme = new URLSearchParams(location.search).get('theme') +if (theme === 'dark') { + dark.value = true +} + const pr = new URLSearchParams(location.search).get('pr') if (pr) { initialUserOptions.showHidden = true @@ -48,6 +55,9 @@ if (pr) { }, } store.state.files[IMPORT_MAP].code = JSON.stringify(map, undefined, 2) +} + +if (pr || dark.value) { const url = `${location.origin}${location.pathname}#${store.serialize()}` history.replaceState({}, '', url) } @@ -72,8 +82,6 @@ const handleKeydown = (evt: KeyboardEvent) => { } } -const dark = useDark() - // persist state watchEffect(() => history.replaceState({}, '', `#${store.serialize()}`))