feat: 实现试用用户欢迎引导和过期检测功能

- 新增试用用户首次登录欢迎弹窗,展示使用教程
- 新增试用期过期检测服务和过期提醒弹窗
- 从 JWT token 中提取 ispluginTrial 标识判断用户类型
- 试用用户跳过邀请码验证流程
- 在消息发送前检查试用期是否过期
- 新增 ExpiredPanel 和 WelcomePanel 面板组件
- 新增 expiredModal 和 welcomeModal 视图组件
- 优化用户登录流程,根据用户类型显示不同引导
This commit is contained in:
Roe-xin
2026-02-26 15:42:18 +08:00
parent 316c784bde
commit 208c24682b
12 changed files with 924 additions and 7 deletions

View File

@ -426,12 +426,55 @@ export async function showICHelperPanel(
case "checkInvitationCode":
// 检查邀请码验证状态
{
const { InvitationService } = require("../services/invitationService");
const isVerified = await InvitationService.isVerified(context);
panel.webview.postMessage({
command: "invitationCodeStatus",
verified: isVerified
});
// 先检查是否是试用用户
const { getCachedUserInfo } = require("../services/userService");
const userInfo = getCachedUserInfo();
if (userInfo?.isPluginTrial === true) {
// 试用用户,跳过邀请码验证,直接返回已验证
console.log('[ICHelperPanel] 试用用户,跳过邀请码验证');
panel.webview.postMessage({
command: "invitationCodeStatus",
verified: true
});
} else {
// 正式用户,检查邀请码
const { InvitationService } = require("../services/invitationService");
const isVerified = await InvitationService.isVerified(context);
panel.webview.postMessage({
command: "invitationCodeStatus",
verified: isVerified
});
}
}
break;
case "checkWelcomeModal":
// 检查是否需要显示欢迎弹窗
{
console.log('[ICHelperPanel] 收到 checkWelcomeModal 消息');
const showWelcome = context.globalState.get('showWelcomeModal');
console.log('[ICHelperPanel] showWelcomeModal 标记值:', showWelcome);
if (showWelcome) {
// 清除标记并显示欢迎弹窗
await context.globalState.update('showWelcomeModal', undefined);
console.log('[ICHelperPanel] ✅ 发送 showWelcomeModal 命令到前端');
panel.webview.postMessage({
command: "showWelcomeModal"
});
} else {
console.log('[ICHelperPanel] showWelcomeModal 标记为 false不显示弹窗');
}
}
break;
case "checkTrialExpiration":
// 检查试用期是否过期
{
console.log('[ICHelperPanel] 收到 checkTrialExpiration 消息');
const { TrialExpirationService } = require("../services/trialExpirationService");
const trialService = new TrialExpirationService(context, panel);
const isExpired = await trialService.checkExpiration();
console.log('[ICHelperPanel] 试用期过期状态:', isExpired);
}
break;
case "verifyInvitationCode":