diff --git a/tone-page-web/app/console/(with-menu)/web/resource/components/ResourceEdit.tsx b/tone-page-web/app/console/(with-menu)/web/resource/components/ResourceEdit.tsx index 10ecd53..514e258 100644 --- a/tone-page-web/app/console/(with-menu)/web/resource/components/ResourceEdit.tsx +++ b/tone-page-web/app/console/(with-menu)/web/resource/components/ResourceEdit.tsx @@ -22,6 +22,18 @@ import { AdminApi } from "@/lib/api" import useSWR from "swr" import { ApiError } from "next/dist/server/api-utils" import { Skeleton } from "@/components/ui/skeleton" +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/alert-dialog" + interface ResourceEditProps { children: React.ReactNode id: string; @@ -60,6 +72,17 @@ export default function ResourceEdit({ children, id, onRefresh }: ResourceEditPr } } + const handleRemove = async (id: string) => { + try { + await AdminApi.web.resource.remove(id); + toast.success("资源删除成功"); + onRefresh(); + setOpen(false); + } catch (error) { + toast.error((error as ApiError).message || "资源删除失败"); + } + } + return ( @@ -154,7 +177,29 @@ export default function ResourceEdit({ children, id, onRefresh }: ResourceEditPr - +
+ + + + + + + 是否要删除该资源? + + 该操作不可逆,删除后将无法恢复该资源 + + + + 取消 + handleRemove(id)}>删除 + + + +
+ + +
+
)}