This commit is contained in:
2026-02-05 18:12:49 +08:00
commit 7ea280beb2
520 changed files with 169373 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { useMutation } from "@tanstack/react-query";
import { modifyFile, createFile } from "@/apis/file";
import { toast } from "sonner";
export const useSaveFile = (mutationOptions?: any) => {
const { mutateAsync: saveMutateAsync, isPending: saveIsPending } =
useMutation({
mutationFn: (values: any) => {
if (values.id) {
return modifyFile(values);
}
return createFile(values);
},
...(mutationOptions || {}),
});
const save = (values: any) => {
toast.promise(saveMutateAsync(values), {
loading: "提交中...",
success: "操作成功",
});
};
return {
save,
saveIsPending,
};
};