Skip to content

Commit

Permalink
🐛 修复特定情况下的数据缺失导致的异常
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Sep 3, 2024
1 parent 0f0e584 commit cceeed9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/pages/common/PostCollect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,11 @@ function getPageItems(): TGApp.Plugins.Mys.Post.FullData[] {
card.push(JSON.parse(post.content));
} catch (e) {
TGLogger.Error("[PostCollect] getPageItems");
TGLogger.Error(<string>e);
if (typeof e === "string") {
TGLogger.Error(e);
} else if (e instanceof Error) {
TGLogger.Error(e.message);
}
}
}
return card;
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/Sqlite/modules/userCollect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file plugins/Sqlite/modules/userCollect.ts
* @description 用户收藏模块
* @since Beta v0.5.1
* @since Beta v0.5.5
*/

import TGSqlite from "../index.js";
Expand Down Expand Up @@ -41,7 +41,7 @@ async function getCollectList(): Promise<TGApp.Sqlite.UserCollection.UFCollectio

/**
* @description 获取收藏合集中的帖子列表
* @since Beta v0.4.5
* @since Beta v0.5.5
* @param {string} collection 收藏合集标题
* @return {Promise<TGApp.Sqlite.UserCollection.UFPost[]>} 返回收藏合集中的帖子列表
*/
Expand All @@ -55,7 +55,7 @@ async function getCollectPostList(
for (let i = 0; i < res.length; i++) {
const postSql = "SELECT * FROM UFPost WHERE id = ?";
const postRes: TGApp.Sqlite.UserCollection.UFPost[] = await db.select(postSql, [res[i].postId]);
postList.push(postRes[0]);
if (postRes.length > 0) postList.push(postRes[0]);
}
return postList;
}
Expand Down

0 comments on commit cceeed9

Please sign in to comment.