This commit is contained in:
Vaica committed 2026-06-22 12:14:53 +08:00
1 parent fd200e018d
commit a1dd087bcc
4 files changed
+41 -10

No files matched your search

+20 -4
View File
@@ -71,11 +71,27 @@ export default function EditPostPage({
</div>
<button
type="button"
onClick={async () => {
await fetch("/api/hugo");
window.open(`/preview/${post.frontMatter.slug}.html`, "_blank");
onClick={async (e) => {
const btn = e.currentTarget;
const orig = btn.innerHTML;
btn.disabled = true;
btn.textContent = "⏳ 启动中...";
try {
const res = await fetch("/api/hugo");
const data = await res.json();
if (data.running) {
window.open(`/preview/${post.frontMatter.slug}.html`, "_blank");
} else {
alert("Hugo 预览启动失败");
}
} catch {
alert("Hugo 预览启动失败");
} finally {
btn.disabled = false;
btn.innerHTML = orig;
}
}}
className="flex items-center gap-1.5 px-3 py-1.5 text-[12px] rounded-md border border-line text-muted hover:text-accent hover:border-accent/30 transition-colors"
className="flex items-center gap-1.5 px-3 py-1.5 text-[12px] rounded-md border border-line text-muted hover:text-accent hover:border-accent/30 transition-colors disabled:opacity-50"
title="预览"
>
<Eye size={13} /> 预览