feat: 添加设置页面布局和导航功能,重构页面结构
This commit is contained in:
24
src/routes/settings/+layout.svelte
Normal file
24
src/routes/settings/+layout.svelte
Normal file
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { currentActivate } from '$lib/stores/navigate';
|
||||
|
||||
let { children, data }: { data: { activePath: string } } = $props();
|
||||
afterNavigate(() => {
|
||||
currentActivate.set('settings');
|
||||
});
|
||||
</script>
|
||||
|
||||
<main class="px-4 py-4 size-full flex flex-row items-stretch gap-0 overflow-hidden">
|
||||
<nav class="max-w-[12em] grow flex flex-col items-stretch gap-2">
|
||||
<a
|
||||
href="/settings/proxy"
|
||||
class={[
|
||||
'inline-block px-4 py-2 rounded-md hover:bg-cyan-700',
|
||||
data.activePath === '/settings/proxy' && 'bg-cyan-900',
|
||||
]}>Proxy</a>
|
||||
</nav>
|
||||
<div class="divider divider-horizontal mx-2"></div>
|
||||
<div class="grow">
|
||||
{@render children?.()}
|
||||
</div>
|
||||
</main>
|
||||
6
src/routes/settings/+layout.ts
Normal file
6
src/routes/settings/+layout.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load = (async ({ url }) => {
|
||||
const path = url.pathname;
|
||||
return { activePath: path };
|
||||
}) satisfies LayoutLoad;
|
||||
@@ -1,8 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { currentActivate } from '$lib/stores/navigate';
|
||||
|
||||
afterNavigate(() => {
|
||||
currentActivate.set('settings');
|
||||
});
|
||||
</script>
|
||||
6
src/routes/settings/+page.ts
Normal file
6
src/routes/settings/+page.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { redirect } from "@sveltejs/kit";
|
||||
import type { PageLoad } from "./$types";
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(307, "/settings/proxy");
|
||||
};
|
||||
0
src/routes/settings/proxy/+page.svelte
Normal file
0
src/routes/settings/proxy/+page.svelte
Normal file
Reference in New Issue
Block a user