From a71622f7974e4e0df3fa7def2d4706aa63c2f462 Mon Sep 17 00:00:00 2001 From: Chaos Date: Sun, 23 Nov 2025 07:43:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(auth):=20=E9=87=8D=E6=9E=84=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=A1=B5=E9=9D=A2=E5=B9=B6=E6=B7=BB=E5=8A=A0=E5=BF=98?= =?UTF-8?q?=E8=AE=B0=E5=AF=86=E7=A0=81=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重构登录表单 UI,使用 DaisyUI 组件美化界面 - 添加记住我功能和加载状态提示 - 集成 Toast 提示组件用于显示登录结果 - 新增忘记密码页面路由 - 实现全局 Toast 消息提醒功能 - 在根布局中引入 ToastContainer 组件 --- src/lib/components/ToastContainer.svelte | 34 +++++ src/lib/stores/toastStore.ts | 39 ++++++ src/routes/+layout.svelte | 2 + src/routes/auth/forgetPassword/+page.svelte | 7 + src/routes/auth/login/+page.svelte | 140 +++++++++++++++----- 5 files changed, 190 insertions(+), 32 deletions(-) create mode 100644 src/lib/components/ToastContainer.svelte create mode 100644 src/lib/stores/toastStore.ts create mode 100644 src/routes/auth/forgetPassword/+page.svelte diff --git a/src/lib/components/ToastContainer.svelte b/src/lib/components/ToastContainer.svelte new file mode 100644 index 0000000..b568369 --- /dev/null +++ b/src/lib/components/ToastContainer.svelte @@ -0,0 +1,34 @@ + + +
+ {#each $toast as t (t.id)} +
+ {icons[t.type]} + {t.message} +
+ {/each} +
\ No newline at end of file diff --git a/src/lib/stores/toastStore.ts b/src/lib/stores/toastStore.ts new file mode 100644 index 0000000..5502b11 --- /dev/null +++ b/src/lib/stores/toastStore.ts @@ -0,0 +1,39 @@ +import { writable } from 'svelte/store'; + +export type ToastType = 'success' | 'error' | 'warning' | 'info'; + +export interface ToastMessage { + id: string; + type: ToastType; + message: string; + duration?: number; +} + +const createToastStore = () => { + + const {subscribe, update} = writable([]); + const send = (message:string, type:ToastType = 'info',duration = 3000)=> { + const id = crypto.randomUUID(); + update((toasts) => [...toasts,{id,type,message,duration}]) + if (duration > 0){ + setTimeout(()=>{ + remove(id); + },duration) + } + } + const remove = (id:string) => { + update((toasts) => toasts.filter(toast => toast.id !== id)) + } + + return { + subscribe, + success: (msg: string, duration = 3000) => send(msg, 'success', duration), + error: (msg: string, duration = 3000) => send(msg, 'error', duration), + warning: (msg: string, duration = 3000) => send(msg, 'warning', duration), + info: (msg: string, duration = 3000) => send(msg, 'info', duration), + remove + }; +}; + + +export const toast = createToastStore(); \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index c1f5754..86c9344 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -7,6 +7,7 @@ import { onMount } from 'svelte'; import { sidebarStore } from '$lib/stores/sidebarStore.ts'; import Sprite from '$lib/components/icon/Sprite.svelte'; + import ToastContainer from '$lib/components/ToastContainer.svelte'; const MD_BREAKPOINT = '(min-width: 768px)'; @@ -69,5 +70,6 @@
+ {@render children()}
diff --git a/src/routes/auth/forgetPassword/+page.svelte b/src/routes/auth/forgetPassword/+page.svelte new file mode 100644 index 0000000..d07b789 --- /dev/null +++ b/src/routes/auth/forgetPassword/+page.svelte @@ -0,0 +1,7 @@ + + + +
+123 +
\ No newline at end of file diff --git a/src/routes/auth/login/+page.svelte b/src/routes/auth/login/+page.svelte index e92f864..4124df8 100644 --- a/src/routes/auth/login/+page.svelte +++ b/src/routes/auth/login/+page.svelte @@ -1,43 +1,119 @@ -
-
+
- - +
+
+
+

+ + IT DTMS登录 +

+
- - + - - +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+ +
+ +
+ + +
+ +
+ +
+ + +
+
\ No newline at end of file