feat(toast): 使用SVG图标替换字符图标并优化样式

- 新增四种SVG图标:info、success、warning、error
- 修改Toast组件使用SVG图标替代字符图标
- 更新图标映射逻辑,使用IconId类型定义图标标识
- 调整Toast样式类,使用更具体的Tailwind类名
- 移除旧的alertStyles对象和字符图标映射
- 登录页面增加错误处理和Toast提示
- 布局文件微调菜单样式,增加顶部内边距
This commit is contained in:
Chaos
2025-11-23 21:59:47 +08:00
parent a71622f797
commit 71f19b658c
5 changed files with 42 additions and 22 deletions

View File

@@ -1,22 +1,15 @@
<script lang="ts">
import { toast } from '$lib/stores/toastStore';
import { toast, type ToastType } from '$lib/stores/toastStore';
import { fly } from 'svelte/transition';
import { flip } from 'svelte/animate';
import Icon from '$lib/components/icon/Icon.svelte';
import type { IconId } from '$lib/types/icon-ids.ts';
// 映射 Toast 类型到 daisyUI 的 alert 样式类
const alertStyles = {
info: 'alert-info',
success: 'alert-success',
warning: 'alert-warning',
error: 'alert-error'
};
// 映射 Toast 类型到图标 (可选,为了更像 AntD)
const icons = {
info: '',
success: '✅',
warning: '⚠️',
error: '❌'
const toastIconMap: Record<ToastType, IconId> = {
success: 'success',
error: 'error',
warning: 'warning',
info: 'info'
};
</script>
@@ -25,9 +18,9 @@
<div
animate:flip={{ duration: 300 }}
transition:fly={{ x: 100, duration: 300 }}
class="alert {alertStyles[t.type]} shadow-lg min-w-[200px] flex justify-start"
class="alert bg-base-100 text-base-content border-0 shadow-base-300/50 shadow-lg min-w-[200px] flex justify-start"
>
<span>{icons[t.type]}</span>
<span><Icon id={toastIconMap[t.type]} size="24"></Icon></span>
<span>{t.message}</span>
</div>
{/each}