feat: 继续完成...

This commit is contained in:
539943419 committed 2025-01-15 07:39:03 +08:00
1 parent 31e253eaef
commit d7f1bf7d49
8 files changed
+270 -122

No files matched your search

+1 -1
View File
@@ -30,6 +30,6 @@ export default defineEventHandler(async (event) => {
return {
code: 200,
data: posts
data: posts.reverse()
};
});
+5 -1
View File
@@ -42,6 +42,7 @@ export default defineEventHandler(async (event) => {
const tags = tagsArray.slice(0, 15).concat(new Array(15 - tagsArray.length).fill(null));
try {
let id = -1
db.transaction(() => {
// 插入tags表
const tagResult = insertTagsStmt.run(...tags);
@@ -51,13 +52,16 @@ export default defineEventHandler(async (event) => {
const postResult = insertPostStmt.run(title, summary, type, url, date, tagId);
const postId = postResult.lastInsertRowid;
id = postId as number;
// 插入postContent表
insertContentStmt.run(postId, content);
})();
return {
code: 200,
msg: '插入成功'
msg: '插入成功',
id
};
} catch (error) {
console.error('插入数据时出错:', error);