修复若干问题

This commit is contained in:
zqlit committed 2026-05-21 13:35:18 +08:00
1 parent c8cdf9a7bc
commit bf083523c8
12 files changed
+581 -40

No files matched your search

+6 -11
View File
@@ -44,17 +44,12 @@ export async function PUT(request: NextRequest) {
if (!oldUrl) {
return NextResponse.json({ error: "oldUrl is required" }, { status: 400 });
}
// If URL changed, delete old and create new
if (newUrl && newUrl !== oldUrl) {
await deleteLink(oldUrl);
await addLink({ name: name || "", url: newUrl, description, hidden });
} else {
const data: Record<string, unknown> = {};
if (name !== undefined) data.name = name;
if (description !== undefined) data.description = description;
if (hidden !== undefined) data.hidden = hidden;
await updateLink(oldUrl, data);
}
const data: Record<string, unknown> = {};
if (name !== undefined) data.name = name;
if (description !== undefined) data.description = description;
if (hidden !== undefined) data.hidden = hidden;
if (newUrl !== undefined) data.url = newUrl;
await updateLink(oldUrl, data);
return NextResponse.json({ success: true });
} catch (error: unknown) {
return NextResponse.json(