feat: 完善企业试用用户欢迎弹窗逻辑

- 添加试用到期时间检查

- 仅在试用未过期且有到期时间时显示欢迎弹窗

- 试用过期或无到期时间则显示邀请码弹窗

- 修复窗口重载后弹窗标记丢失问题
This commit is contained in:
Roe-xin
2026-03-03 18:26:27 +08:00
parent 68de33165e
commit 9b5f102d9f

View File

@ -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;