优化github action 逻辑

This commit is contained in:
Vaica committed 2026-06-02 10:56:59 +08:00
1 parent 7aa7e684ac
commit 05bf116c20
12 files changed
+118 -775

No files matched your search

+1 -8
View File
@@ -28,7 +28,6 @@ export default function PostEditor({ initialData, isEditing }: PostEditorProps)
categories: initialData?.frontMatter.categories?.join("、") || "",
tags: initialData?.frontMatter.tags?.join("、") || "",
author: initialData?.frontMatter.author || "小赵",
ai_comment: initialData?.frontMatter.ai_comment || "",
});
const [content, setContent] = useState(initialData?.content || "");
const [uploading, setUploading] = useState(false);
@@ -61,7 +60,7 @@ export default function PostEditor({ initialData, isEditing }: PostEditorProps)
if (!form.title && !content) return;
try {
localStorage.setItem(cacheKey, JSON.stringify({
form: { title: form.title, slug: form.slug, date: form.date, categories: form.categories, tags: form.tags, author: form.author, ai_comment: form.ai_comment },
form: { title: form.title, slug: form.slug, date: form.date, categories: form.categories, tags: form.tags, author: form.author },
content,
dirPath,
savedAt: Date.now(),
@@ -174,7 +173,6 @@ export default function PostEditor({ initialData, isEditing }: PostEditorProps)
author: form.author,
layout: "post",
};
if (form.ai_comment) frontMatter.ai_comment = form.ai_comment;
const url = isEditing ? `/api/posts/${initialData!.frontMatter.slug}` : "/api/posts";
const method = isEditing ? "PUT" : "POST";
@@ -257,7 +255,6 @@ export default function PostEditor({ initialData, isEditing }: PostEditorProps)
const handleApplyMeta = (data: { summary?: string; tags?: string }) => {
if (data.tags) setForm((f) => ({ ...f, tags: data.tags || "" }));
if (data.summary) setForm((f) => ({ ...f, ai_comment: data.summary || "" }));
};
const inputCls =
@@ -332,10 +329,6 @@ export default function PostEditor({ initialData, isEditing }: PostEditorProps)
<label className="block text-[12px] font-medium text-text/70 mb-1.5">标签</label>
<input type="text" value={form.tags} onChange={(e) => setForm({ ...form, tags: e.target.value })} className={inputCls} placeholder="用顿号分隔" />
</div>
<div className="flex-1">
<label className="block text-[12px] font-medium text-text/70 mb-1.5">AI 评论</label>
<input type="text" value={form.ai_comment} onChange={(e) => setForm({ ...form, ai_comment: e.target.value })} className={inputCls} placeholder="可选" />
</div>
</div>
{/* Folder name preview */}
-7
View File
@@ -13,7 +13,6 @@ export interface PostFrontMatter {
tags?: string[];
author?: string;
layout?: string;
ai_comment?: string;
[key: string]: unknown;
}
@@ -181,10 +180,6 @@ export function createPost(frontMatter: PostFrontMatter, content: string): strin
layout: frontMatter.layout || "post",
};
if (frontMatter.ai_comment) {
fm.ai_comment = frontMatter.ai_comment;
}
const fileContent = matter.stringify(content, fm);
const indexPath = path.join(dirPath, "index.md");
fs.writeFileSync(indexPath, fileContent, "utf-8");
@@ -227,7 +222,6 @@ export function updatePost(
author: merged.author || "",
layout: merged.layout || "post",
};
if (merged.ai_comment) fm.ai_comment = merged.ai_comment;
const fileContent = matter.stringify(content ?? post.content, fm);
fs.writeFileSync(path.join(newDirPath, "index.md"), fileContent, "utf-8");
@@ -245,7 +239,6 @@ export function updatePost(
author: merged.author || "",
layout: merged.layout || "post",
};
if (merged.ai_comment) fm.ai_comment = merged.ai_comment;
const fileContent = matter.stringify(content ?? post.content, fm);
fs.writeFileSync(post.filePath, fileContent, "utf-8");