优化脚本
This commit is contained in:
@@ -5,10 +5,12 @@ import {
|
||||
FolderKanban,
|
||||
Replace,
|
||||
ScanSearch,
|
||||
Trash2,
|
||||
WandSparkles,
|
||||
} from "lucide-react";
|
||||
import type { BillingSummary, Product, Project } from "../types";
|
||||
import type { NavigateFn, Page } from "./route-config";
|
||||
import { ConfirmModal } from "../components/overlays";
|
||||
|
||||
type DashTab = "all" | "wip" | "done";
|
||||
type EntryTone = "primary" | "subtle";
|
||||
@@ -100,6 +102,7 @@ export function Dashboard({
|
||||
userName,
|
||||
loading: _loading = false,
|
||||
navigate,
|
||||
onDelete,
|
||||
}: {
|
||||
products: Product[];
|
||||
projects: Project[];
|
||||
@@ -109,8 +112,10 @@ export function Dashboard({
|
||||
userName?: string;
|
||||
loading?: boolean;
|
||||
navigate: NavigateFn;
|
||||
onDelete: (projectId: string) => Promise<unknown> | void;
|
||||
}) {
|
||||
const [tab, setTab] = useState<DashTab>("all");
|
||||
const [deleteTarget, setDeleteTarget] = useState<Project | null>(null);
|
||||
const projCount = projectTotal ?? projects.length;
|
||||
const completed = projects.filter((project) => project.status === "completed").length;
|
||||
const running = projects.filter((project) => !["completed", "failed"].includes(project.status)).length;
|
||||
@@ -253,13 +258,24 @@ export function Dashboard({
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
className="continue-button"
|
||||
type="button"
|
||||
onClick={(event) => { event.stopPropagation(); openProject(); }}
|
||||
>
|
||||
{project.status === "completed" ? "查看" : "继续"}
|
||||
</button>
|
||||
<div className="project-actions">
|
||||
<button
|
||||
className="project-del"
|
||||
type="button"
|
||||
title="删除项目"
|
||||
aria-label={`删除「${project.name}」`}
|
||||
onClick={(event) => { event.stopPropagation(); setDeleteTarget(project); }}
|
||||
>
|
||||
<Trash2 />
|
||||
</button>
|
||||
<button
|
||||
className="continue-button"
|
||||
type="button"
|
||||
onClick={(event) => { event.stopPropagation(); openProject(); }}
|
||||
>
|
||||
{project.status === "completed" ? "查看" : "继续"}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
@@ -267,6 +283,20 @@ export function Dashboard({
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<ConfirmModal
|
||||
open={Boolean(deleteTarget)}
|
||||
title="删除项目"
|
||||
icon={<Trash2 size={16} />}
|
||||
detail={`确定删除「${deleteTarget?.name || ""}」?将移至「垃圾桶」,可在垃圾桶里恢复或彻底删除。`}
|
||||
confirmText="删除"
|
||||
onCancel={() => setDeleteTarget(null)}
|
||||
onConfirm={async () => {
|
||||
if (!deleteTarget) return;
|
||||
await onDelete(deleteTarget.id);
|
||||
setDeleteTarget(null);
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user