This commit is contained in:
Vaica committed 2026-06-22 00:41:05 +08:00
1 parent ed14361e7b
commit d664326648
8 files changed
+39 -14

No files matched your search

+13 -4
View File
@@ -8,7 +8,6 @@ import {
FileText as PostIcon, Rss, Link2, GripVertical, X, CheckSquare, Square,
} from "lucide-react";
import Pagination from "@/components/Pagination";
import { HUGO_PREVIEW } from "@/lib/config";
interface PostItem {
slug: string;
@@ -64,13 +63,23 @@ export default function HomePage() {
const handleDelete = async (slug: string, title: string) => {
if (!confirm(`确定删除「${title}」吗?`)) return;
await fetch(`/api/posts/${slug}`, { method: "DELETE" });
fetchPosts();
try {
const res = await fetch(`/api/posts/${slug}`, { method: "DELETE" });
const data = await res.json();
if (!res.ok) {
alert("删除失败:" + (data.error || "未知错误"));
return;
}
fetchPosts();
} catch (e) {
alert("删除失败:" + (e instanceof Error ? e.message : String(e)));
}
};
const handlePreview = async (slug: string) => {
await fetch("/api/hugo");
window.open(`${HUGO_PREVIEW}/${slug}.html`, "_blank");
const previewBase = `${location.protocol}//${location.hostname}:1313`;
window.open(`${previewBase}/${slug}.html`, "_blank");
};
const toggleSelect = (slug: string) => {