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

+1 -1
View File
@@ -24,7 +24,7 @@ services:
# 环境变量文件 # 环境变量文件
- ./.env:/app/.env:ro - ./.env:/app/.env:ro
# SSH 密钥(用于 git push) # SSH 密钥(用于 git push)
- /root/.ssh:/home/nextjs/.ssh:ro - /root/.ssh:/home/nextjs/.ssh
environment: environment:
- NODE_ENV=production - NODE_ENV=production
- PORT=8016 - PORT=8016
+3
View File
@@ -9,6 +9,9 @@ mkdir -p /app/recycle/posts /app/recycle/meta /app/logs /app/backups
chown -R nextjs:nodejs /app/recycle /app/logs /app/backups chown -R nextjs:nodejs /app/recycle /app/logs /app/backups
# 修复博客目录权限(让 nextjs 用户可写) # 修复博客目录权限(让 nextjs 用户可写)
if [ -d "/blog" ]; then
chown nextjs:nodejs /blog
fi
if [ -d "/blog/content" ]; then if [ -d "/blog/content" ]; then
chown -R nextjs:nodejs /blog/content chown -R nextjs:nodejs /blog/content
fi fi
+20 -4
View File
@@ -71,11 +71,27 @@ export default function EditPostPage({
</div> </div>
<button <button
type="button" type="button"
onClick={async () => { onClick={async (e) => {
await fetch("/api/hugo"); const btn = e.currentTarget;
window.open(`/preview/${post.frontMatter.slug}.html`, "_blank"); 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="预览" title="预览"
> >
<Eye size={13} /> 预览 <Eye size={13} /> 预览
+17 -5
View File
@@ -76,9 +76,21 @@ export default function HomePage() {
} }
}; };
const handlePreview = async (slug: string) => { const handlePreview = async (slug: string, btn?: HTMLButtonElement) => {
await fetch("/api/hugo"); if (btn) { btn.disabled = true; btn.textContent = "启动中..."; }
window.open(`/preview/${slug}.html`, "_blank"); try {
const res = await fetch("/api/hugo");
const data = await res.json();
if (data.running) {
window.open(`/preview/${slug}.html`, "_blank");
} else {
alert("Hugo 预览启动失败,请稍后再试");
}
} catch {
alert("Hugo 预览启动失败");
} finally {
if (btn) { btn.disabled = false; btn.textContent = ""; }
}
}; };
const toggleSelect = (slug: string) => { const toggleSelect = (slug: string) => {
@@ -304,8 +316,8 @@ export default function HomePage() {
{!selectMode && ( {!selectMode && (
<div className="flex items-center gap-0.5 md:opacity-0 md:group-hover:opacity-100 transition-opacity"> <div className="flex items-center gap-0.5 md:opacity-0 md:group-hover:opacity-100 transition-opacity">
<button type="button" onClick={() => handlePreview(post.slug)} <button type="button" onClick={(e) => handlePreview(post.slug, e.currentTarget)}
className="p-1.5 rounded hover:bg-accent/8 text-muted hover:text-accent transition-colors" title="预览"><Eye size={14} /></button> className="p-1.5 rounded hover:bg-accent/8 text-muted hover:text-accent transition-colors disabled:opacity-50" title="预览"><Eye size={14} /></button>
<button type="button" onClick={() => router.push(`/edit/${post.slug}`)} <button type="button" onClick={() => router.push(`/edit/${post.slug}`)}
className="p-1.5 rounded hover:bg-accent/8 text-muted hover:text-accent transition-colors" title="编辑"><Edit size={14} /></button> className="p-1.5 rounded hover:bg-accent/8 text-muted hover:text-accent transition-colors" title="编辑"><Edit size={14} /></button>
<button type="button" onClick={() => handleDelete(post.slug, post.title)} <button type="button" onClick={() => handleDelete(post.slug, post.title)}