feat(应用): 实现带可折叠侧边栏的仪表盘布局
添加从根路径到/app/dashboard的服务器端重定向 创建包含主内容容器的应用布局组件 实现带响应式侧边栏和顶栏的仪表盘页面 添加带平滑过渡效果的侧边栏切换功能 设置基础用户状态管理仓库 使用对等依赖标志更新package-lock.json中的依赖项 从锁定文件中移除冗余的picomatch条目 添加带路径解析导入的登录页面组件
This commit is contained in:
@@ -1,4 +1,43 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
|
||||
import { authService } from '$lib/api/services/authService.ts';
|
||||
import type { LoginPayload } from '$lib/types/auth.ts';
|
||||
import { goto } from '$app/navigation';
|
||||
import { resolve } from '$app/paths';
|
||||
import { get } from 'svelte/store';
|
||||
import { authStore } from '$lib/stores/authStore.ts';
|
||||
|
||||
const loginPayload:LoginPayload = {
|
||||
username: '',
|
||||
password: ''
|
||||
}
|
||||
const handleSubmit = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
try{
|
||||
await authService.login(loginPayload);
|
||||
if(get(authStore).isAuthenticated){
|
||||
await goto(resolve('/'));
|
||||
}
|
||||
}catch (e){
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
const handleChange = (e: Event) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
loginPayload[target.name] = target.value;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="h-screen w-screen">
|
||||
<form id="loginForm">
|
||||
<div>
|
||||
<label class="" for="username" > username </label>
|
||||
<input type="text" name="username" on:change={handleChange} placeholder="username">
|
||||
</div>
|
||||
<div>
|
||||
<label class="" for="password" > password </label>
|
||||
<input type="password" name="password" on:change={handleChange} placeholder="password">
|
||||
</div>
|
||||
<button class="" type="submit" on:click="{handleSubmit}" > 登录</button>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user