From 9b5f102d9f077ddf4e36e13a0a809ee3643b0541 Mon Sep 17 00:00:00 2001 From: Roe-xin Date: Tue, 3 Mar 2026 18:26:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E7=94=A8=E6=88=B7=E6=AC=A2=E8=BF=8E=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加试用到期时间检查 - 仅在试用未过期且有到期时间时显示欢迎弹窗 - 试用过期或无到期时间则显示邀请码弹窗 - 修复窗口重载后弹窗标记丢失问题 --- src/panels/ICHelperPanel.ts | 39 +++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/panels/ICHelperPanel.ts b/src/panels/ICHelperPanel.ts index 76899c0..7823193 100644 --- a/src/panels/ICHelperPanel.ts +++ b/src/panels/ICHelperPanel.ts @@ -539,25 +539,30 @@ export async function showICHelperPanel( // 检查是否需要显示欢迎弹窗 { console.log("[ICHelperPanel] 收到 checkWelcomeModal 消息"); - const showWelcome = context.globalState.get("showWelcomeModal"); - console.log( - "[ICHelperPanel] showWelcomeModal 标记值:", - showWelcome, - ); + const userInfo = getCachedUserInfo(); + const hasWelcomed = context.globalState.get("pluginTrialWelcomed"); - if (showWelcome) { - // 清除标记并显示欢迎弹窗 - await context.globalState.update("showWelcomeModal", undefined); - console.log( - "[ICHelperPanel] ✅ 发送 showWelcomeModal 命令到前端", - ); - panel.webview.postMessage({ - command: "showWelcomeModal", - }); + console.log("[ICHelperPanel] 用户信息:", userInfo); + console.log("[ICHelperPanel] isPluginTrial:", userInfo?.isPluginTrial); + console.log("[ICHelperPanel] pluginTrialExpiresAt:", userInfo?.pluginTrialExpiresAt); + console.log("[ICHelperPanel] hasWelcomed:", hasWelcomed); + + if (userInfo?.isPluginTrial === true && userInfo.pluginTrialExpiresAt !== null && userInfo.pluginTrialExpiresAt !== undefined) { + const now = Date.now(); + const isExpired = now >= userInfo.pluginTrialExpiresAt; + console.log("[ICHelperPanel] 是否过期:", isExpired); + + if (!isExpired && !hasWelcomed) { + await context.globalState.update("pluginTrialWelcomed", true); + console.log("[ICHelperPanel] ✅ 发送 showWelcomeModal 命令到前端"); + panel.webview.postMessage({ + command: "showWelcomeModal", + }); + } else { + console.log("[ICHelperPanel] 已过期或已显示过欢迎弹窗"); + } } else { - console.log( - "[ICHelperPanel] showWelcomeModal 标记为 false,不显示弹窗", - ); + console.log("[ICHelperPanel] 非试用用户或无过期时间"); } } break;