From 8aec1d05cfa75e01c23ec13b58c8412e0fb12ba6 Mon Sep 17 00:00:00 2001 From: dudu Date: Tue, 29 Jul 2025 21:54:51 +0800 Subject: [PATCH] fix: check null categories --- src/service/post/post-cat.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/service/post/post-cat.ts b/src/service/post/post-cat.ts index 0fb32245..2578d515 100644 --- a/src/service/post/post-cat.ts +++ b/src/service/post/post-cat.ts @@ -21,6 +21,7 @@ export namespace PostCatService { try { const resp = await req.getAll() const { categories } = <{ categories: PostCat[] }>JSON.parse(resp) + if (categories == null) return [] return categories.map(x => Object.assign(new PostCat(), x)) } catch (e) { if (await UserService.hasBlog()) void Alert.err(`查询随笔分类失败: ${e}`) @@ -60,6 +61,7 @@ export namespace PostCatService { try { const resp = await req.getOne(parentId) const { categories } = <{ categories: PostCat[] }>JSON.parse(resp) + if (categories == null) return [] return categories.map(x => Object.assign(new PostCat(), x)) } catch (e) { if (await UserService.hasBlog()) void Alert.err(`查询随笔分类失败: ${e}`)