mirror of
https://litchi.icu/ngc2207/judge4c-demo.git
synced 2025-05-18 16:46:49 +00:00
feat: 在删除和创建代码片段功能中添加路径重新验证,避免使用缓存界面
This commit is contained in:
parent
8e869954f3
commit
136425a0ea
@ -1,6 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import { db } from "@/db";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export async function editSnippet(id: number, code: string) {
|
||||
@ -15,6 +16,7 @@ export async function editSnippet(id: number, code: string) {
|
||||
export async function deleteSnippet(id: number) {
|
||||
await db.snippet.delete({ where: { id } });
|
||||
|
||||
revalidatePath("/");
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
@ -54,6 +56,7 @@ export async function createSnippet(
|
||||
};
|
||||
}
|
||||
}
|
||||
revalidatePath("/");
|
||||
// Redirect the user back to the root route
|
||||
redirect("/");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user