1214
This commit is contained in:
1 parent
f0e9be8343
commit
9f3bfdee6f
4 files changed
+41
-10
No files matched your search
@@ -24,7 +24,7 @@ services:
|
||||
# 环境变量文件
|
||||
- ./.env:/app/.env:ro
|
||||
# SSH 密钥(用于 git push)
|
||||
- /root/.ssh:/home/nextjs/.ssh:ro
|
||||
- /root/.ssh:/home/nextjs/.ssh
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=8016
|
||||
|
||||
@@ -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
|
||||
|
||||
# 修复博客目录权限(让 nextjs 用户可写)
|
||||
if [ -d "/blog" ]; then
|
||||
chown nextjs:nodejs /blog
|
||||
fi
|
||||
if [ -d "/blog/content" ]; then
|
||||
chown -R nextjs:nodejs /blog/content
|
||||
fi
|
||||
|
||||
@@ -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} /> 预览
|
||||
|
||||
@@ -76,9 +76,21 @@ export default function HomePage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handlePreview = async (slug: string) => {
|
||||
await fetch("/api/hugo");
|
||||
window.open(`/preview/${slug}.html`, "_blank");
|
||||
const handlePreview = async (slug: string, btn?: HTMLButtonElement) => {
|
||||
if (btn) { btn.disabled = true; btn.textContent = "启动中..."; }
|
||||
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) => {
|
||||
@@ -304,8 +316,8 @@ export default function HomePage() {
|
||||
|
||||
{!selectMode && (
|
||||
<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)}
|
||||
className="p-1.5 rounded hover:bg-accent/8 text-muted hover:text-accent transition-colors" title="预览"><Eye size={14} /></button>
|
||||
<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 disabled:opacity-50" title="预览"><Eye size={14} /></button>
|
||||
<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>
|
||||
<button type="button" onClick={() => handleDelete(post.slug, post.title)}
|
||||
|
||||
Reference in new issue
Block a user