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;