From 9f707db9f718746731b7c2b4fbc87bced8b39b9e Mon Sep 17 00:00:00 2001 From: BTMuli Date: Wed, 11 Mar 2026 11:26:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DSentry=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cannot read properties of undefined (reading 'upvote_type') --- src/components/userScripts/tus-mission.vue | 2 +- src/types/BBS/Post.d.ts | 6 +++--- src/views/t-post.vue | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/userScripts/tus-mission.vue b/src/components/userScripts/tus-mission.vue index b7a32088..3d0e19c5 100644 --- a/src/components/userScripts/tus-mission.vue +++ b/src/components/userScripts/tus-mission.vue @@ -226,7 +226,7 @@ async function tryAuto(skip: boolean = false): Promise { } viewCnt++; if (likeCnt < 5) { - const isLike = detailResp.self_operation.upvote_type === 1; + const isLike = (detailResp.self_operation?.upvote_type ?? 0) > 0; if (isLike) { await TGLogger.Script(`[米游币任务]帖子${post.post.post_id}已点赞,跳过`); continue; diff --git a/src/types/BBS/Post.d.ts b/src/types/BBS/Post.d.ts index 49ac64fd..6d142e0f 100644 --- a/src/types/BBS/Post.d.ts +++ b/src/types/BBS/Post.d.ts @@ -1,6 +1,6 @@ /** * 帖子类型定义文件 - * @since Beta v0.8.6 + * @since Beta v0.9.8 */ declare namespace TGApp.BBS.Post { @@ -124,7 +124,7 @@ declare namespace TGApp.BBS.Post { /** * 帖子数据 - * @since Beta v0.7.2 + * @since Beta v0.9.8 */ type FullData = { /** 帖子信息 */ @@ -136,7 +136,7 @@ declare namespace TGApp.BBS.Post { /** 发帖人,可能为 null */ user: User | null; /** 当前用户操作 */ - self_operation: TGApp.BBS.User.SelfOperation; + self_operation: TGApp.BBS.User.SelfOperation | null; /** 帖子统计,可能为 null */ stat: Stat | null; /** 帮助系统,可能为 null */ diff --git a/src/views/t-post.vue b/src/views/t-post.vue index 3a0ba85c..0b637d4d 100644 --- a/src/views/t-post.vue +++ b/src/views/t-post.vue @@ -245,7 +245,7 @@ onMounted(async () => { } postData.value = resp; console.log(resp); - isLike.value = postData.value.self_operation.upvote_type !== 0; + isLike.value = (postData.value.self_operation?.upvote_type ?? 0) > 0; await showLoading.update("正在渲染数据"); renderPost.value = await getRenderPost(postData.value); await webviewWindow