mirror of
https://github.com/imputnet/cobalt.git
synced 2024-12-29 11:06:10 +00:00
web/settings: redirect invalid settings paths to default settings page
This commit is contained in:
parent
e98f76c8ee
commit
16c76e7e92
|
@ -1,3 +1,4 @@
|
|||
import { browser } from "$app/environment";
|
||||
import { defaultLocale } from "$lib/i18n/translations";
|
||||
import type { CobaltSettings } from "$lib/types/settings";
|
||||
|
||||
|
@ -35,4 +36,15 @@ const defaultSettings: CobaltSettings = {
|
|||
},
|
||||
}
|
||||
|
||||
const defaultSettingsPage = () => {
|
||||
if (browser) {
|
||||
if (window.innerWidth <= 750) {
|
||||
return "/settings";
|
||||
}
|
||||
}
|
||||
|
||||
return "/settings/general/appearance";
|
||||
}
|
||||
|
||||
export default defaultSettings;
|
||||
export { defaultSettingsPage };
|
17
web/src/routes/+error.svelte
Normal file
17
web/src/routes/+error.svelte
Normal file
|
@ -0,0 +1,17 @@
|
|||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { defaultSettingsPage } from '$lib/settings/defaults';
|
||||
|
||||
$: {
|
||||
if (
|
||||
$page.error?.message === 'Not Found'
|
||||
&& $page.url.pathname.startsWith('/settings')
|
||||
) {
|
||||
goto(defaultSettingsPage(), { replaceState: true });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- TODO: nicer errors -->
|
||||
<h1>{$page.status}: {$page.error?.message}</h1>
|
Loading…
Reference in a new issue