refactor: 提取 Button 组件,统一按钮变体、尺寸和加载状态

新增 Button.tsx 支持 5 种变体(primary/secondary/danger/ghost/purple)、
3 种尺寸(sm/md/lg)、pill/rounded 形状及内置 loading 状态,
替换 8 个文件中 16 处重复的按钮样板代码。
This commit is contained in:
2026-02-26 18:39:14 +08:00
parent 19edcaeeb5
commit 455b9e04d8
9 changed files with 178 additions and 115 deletions
+5 -12
View File
@@ -3,6 +3,7 @@
import { useEffect } from "react";
import { motion } from "framer-motion";
import { AlertTriangle, RotateCcw, Home } from "lucide-react";
import Button from "@/components/Button";
export default function Error({
error,
@@ -37,20 +38,12 @@ export default function Error({
</p>
<div className="mt-8 flex gap-3">
<button
onClick={reset}
className="flex items-center gap-1.5 rounded-xl bg-rose-600 px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-rose-500"
>
<RotateCcw size={15} />
<Button onClick={reset} variant="danger" icon={<RotateCcw size={15} />}>
</button>
<a
href="/"
className="flex items-center gap-1.5 rounded-xl bg-surface px-5 py-2.5 text-sm font-semibold text-secondary ring-1 ring-border transition-colors hover:bg-elevated"
>
<Home size={15} />
</Button>
<Button onClick={() => window.location.href = "/"} variant="secondary" icon={<Home size={15} />}>
</a>
</Button>
</div>
</motion.div>
</div>