From 76817675f1197cc1c3b11197834c9ae7a352f31a Mon Sep 17 00:00:00 2001 From: Roe-xin Date: Tue, 3 Mar 2026 19:06:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=AC=A2=E8=BF=8E=E5=BC=B9=E7=AA=97=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 userService 中 null 值未正确赋值的问题 - 优化欢迎弹窗判断逻辑:null=长期有效,undefined=无效 - 添加测试命令 resetWelcomeModal 用于清除弹窗标记 --- src/panels/ICHelperPanel.ts | 13 ++++++++++--- src/services/userService.ts | 10 +++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/panels/ICHelperPanel.ts b/src/panels/ICHelperPanel.ts index db6c137..71287d2 100644 --- a/src/panels/ICHelperPanel.ts +++ b/src/panels/ICHelperPanel.ts @@ -548,8 +548,15 @@ export async function showICHelperPanel( console.log("[ICHelperPanel] hasWelcomed:", hasWelcomed); if (userInfo?.isPluginTrial === true) { - // 如果有过期时间,检查是否过期 - if (userInfo.pluginTrialExpiresAt) { + // undefined 表示无效,不显示 + if (userInfo.pluginTrialExpiresAt === undefined) { + console.log("[ICHelperPanel] pluginTrialExpiresAt 未设置,不显示欢迎弹窗"); + break; + } + + // null 表示长期有效,显示弹窗 + // 有值则检查是否过期 + if (userInfo.pluginTrialExpiresAt !== null) { const now = Date.now(); const isExpired = now >= userInfo.pluginTrialExpiresAt; console.log("[ICHelperPanel] 是否过期:", isExpired); @@ -560,7 +567,7 @@ export async function showICHelperPanel( } } - // 未过期或无过期时间,且未显示过欢迎弹窗 + // 未过期或长期有效(null),且未显示过欢迎弹窗 if (!hasWelcomed) { await context.globalState.update("pluginTrialWelcomed", true); console.log("[ICHelperPanel] ✅ 发送 showWelcomeModal 命令到前端"); diff --git a/src/services/userService.ts b/src/services/userService.ts index 30c3bf4..3d335d1 100644 --- a/src/services/userService.ts +++ b/src/services/userService.ts @@ -162,10 +162,14 @@ export async function getUserInfo(token: string): Promise { console.log('[UserService] 从 getInfo 接口获取到 isPluginTrial: true'); } - // 获取试用到期时间 - if (response.enterpriseTrialExpires) { + // 获取试用到期时间(null 表示长期有效) + if (response.enterpriseTrialExpires !== undefined) { userInfo.pluginTrialExpiresAt = response.enterpriseTrialExpires; - console.log('[UserService] 试用到期时间:', new Date(response.enterpriseTrialExpires).toLocaleString()); + if (response.enterpriseTrialExpires === null) { + console.log('[UserService] 试用长期有效'); + } else { + console.log('[UserService] 试用到期时间:', new Date(response.enterpriseTrialExpires).toLocaleString()); + } } return userInfo;