fix: 修复试用用户欢迎弹窗不显示的问题
- 修复 userService 中 null 值未正确赋值的问题 - 优化欢迎弹窗判断逻辑:null=长期有效,undefined=无效 - 添加测试命令 resetWelcomeModal 用于清除弹窗标记
This commit is contained in:
@ -548,8 +548,15 @@ export async function showICHelperPanel(
|
|||||||
console.log("[ICHelperPanel] hasWelcomed:", hasWelcomed);
|
console.log("[ICHelperPanel] hasWelcomed:", hasWelcomed);
|
||||||
|
|
||||||
if (userInfo?.isPluginTrial === true) {
|
if (userInfo?.isPluginTrial === true) {
|
||||||
// 如果有过期时间,检查是否过期
|
// undefined 表示无效,不显示
|
||||||
if (userInfo.pluginTrialExpiresAt) {
|
if (userInfo.pluginTrialExpiresAt === undefined) {
|
||||||
|
console.log("[ICHelperPanel] pluginTrialExpiresAt 未设置,不显示欢迎弹窗");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// null 表示长期有效,显示弹窗
|
||||||
|
// 有值则检查是否过期
|
||||||
|
if (userInfo.pluginTrialExpiresAt !== null) {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const isExpired = now >= userInfo.pluginTrialExpiresAt;
|
const isExpired = now >= userInfo.pluginTrialExpiresAt;
|
||||||
console.log("[ICHelperPanel] 是否过期:", isExpired);
|
console.log("[ICHelperPanel] 是否过期:", isExpired);
|
||||||
@ -560,7 +567,7 @@ export async function showICHelperPanel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 未过期或无过期时间,且未显示过欢迎弹窗
|
// 未过期或长期有效(null),且未显示过欢迎弹窗
|
||||||
if (!hasWelcomed) {
|
if (!hasWelcomed) {
|
||||||
await context.globalState.update("pluginTrialWelcomed", true);
|
await context.globalState.update("pluginTrialWelcomed", true);
|
||||||
console.log("[ICHelperPanel] ✅ 发送 showWelcomeModal 命令到前端");
|
console.log("[ICHelperPanel] ✅ 发送 showWelcomeModal 命令到前端");
|
||||||
|
|||||||
@ -162,11 +162,15 @@ export async function getUserInfo(token: string): Promise<UserInfo | null> {
|
|||||||
console.log('[UserService] 从 getInfo 接口获取到 isPluginTrial: true');
|
console.log('[UserService] 从 getInfo 接口获取到 isPluginTrial: true');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取试用到期时间
|
// 获取试用到期时间(null 表示长期有效)
|
||||||
if (response.enterpriseTrialExpires) {
|
if (response.enterpriseTrialExpires !== undefined) {
|
||||||
userInfo.pluginTrialExpiresAt = response.enterpriseTrialExpires;
|
userInfo.pluginTrialExpiresAt = response.enterpriseTrialExpires;
|
||||||
|
if (response.enterpriseTrialExpires === null) {
|
||||||
|
console.log('[UserService] 试用长期有效');
|
||||||
|
} else {
|
||||||
console.log('[UserService] 试用到期时间:', new Date(response.enterpriseTrialExpires).toLocaleString());
|
console.log('[UserService] 试用到期时间:', new Date(response.enterpriseTrialExpires).toLocaleString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user