fix:修复企业试用用户仍弹出邀请码的问题
This commit is contained in:
@ -335,28 +335,38 @@ export async function onTokenReceived(token: string): Promise<UserInfo | null> {
|
|||||||
console.log('[UserService] 检查用户类型,isPluginTrial:', userInfo.isPluginTrial);
|
console.log('[UserService] 检查用户类型,isPluginTrial:', userInfo.isPluginTrial);
|
||||||
console.log('[UserService] extensionContext 是否存在:', !!extensionContext);
|
console.log('[UserService] extensionContext 是否存在:', !!extensionContext);
|
||||||
|
|
||||||
if (userInfo.isPluginTrial === true) {
|
if (userInfo.isPluginTrial === true && userInfo.pluginTrialExpiresAt !== null && userInfo.pluginTrialExpiresAt !== undefined) {
|
||||||
// 插件试用用户:标记需要显示欢迎弹窗
|
// 检查是否过期
|
||||||
const hasWelcomed = extensionContext?.globalState.get('pluginTrialWelcomed');
|
const now = Date.now();
|
||||||
console.log('[UserService] 是否已显示过欢迎弹窗:', hasWelcomed);
|
const isExpired = now >= userInfo.pluginTrialExpiresAt;
|
||||||
|
console.log('[UserService] 试用到期时间:', new Date(userInfo.pluginTrialExpiresAt).toLocaleString());
|
||||||
|
console.log('[UserService] 当前时间:', new Date(now).toLocaleString());
|
||||||
|
console.log('[UserService] 是否过期:', isExpired);
|
||||||
|
|
||||||
if (!hasWelcomed && extensionContext) {
|
if (isExpired) {
|
||||||
// 设置标记,让聊天面板显示欢迎弹窗
|
// 已过期:显示邀请码弹窗
|
||||||
await extensionContext.globalState.update('showWelcomeModal', true);
|
console.log('[UserService] 试用已过期,将显示邀请码弹窗');
|
||||||
await extensionContext.globalState.update('pluginTrialWelcomed', true);
|
|
||||||
console.log('[UserService] ✅ 已设置欢迎弹窗标记 showWelcomeModal=true');
|
|
||||||
|
|
||||||
// 验证标记是否设置成功
|
|
||||||
const checkMark = extensionContext.globalState.get('showWelcomeModal');
|
|
||||||
console.log('[UserService] 验证标记:', checkMark);
|
|
||||||
} else if (!extensionContext) {
|
|
||||||
console.error('[UserService] ❌ extensionContext 为 null,无法设置标记');
|
|
||||||
} else {
|
} else {
|
||||||
console.log('[UserService] 已经显示过欢迎弹窗,跳过');
|
// 未过期:显示欢迎弹窗
|
||||||
|
const hasWelcomed = extensionContext?.globalState.get('pluginTrialWelcomed');
|
||||||
|
console.log('[UserService] 是否已显示过欢迎弹窗:', hasWelcomed);
|
||||||
|
|
||||||
|
if (!hasWelcomed && extensionContext) {
|
||||||
|
await extensionContext.globalState.update('showWelcomeModal', true);
|
||||||
|
await extensionContext.globalState.update('pluginTrialWelcomed', true);
|
||||||
|
console.log('[UserService] ✅ 已设置欢迎弹窗标记 showWelcomeModal=true');
|
||||||
|
|
||||||
|
const checkMark = extensionContext.globalState.get('showWelcomeModal');
|
||||||
|
console.log('[UserService] 验证标记:', checkMark);
|
||||||
|
} else if (!extensionContext) {
|
||||||
|
console.error('[UserService] ❌ extensionContext 为 null,无法设置标记');
|
||||||
|
} else {
|
||||||
|
console.log('[UserService] 已经显示过欢迎弹窗,跳过');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 正式用户:显示邀请码弹窗(现有逻辑)
|
// isPluginTrial=false 或 enterpriseTrialExpires 为 null:显示邀请码弹窗
|
||||||
console.log('[UserService] 正式用户登录,将在面板中检查邀请码');
|
console.log('[UserService] 非试用用户或无过期时间,将显示邀请码弹窗');
|
||||||
}
|
}
|
||||||
|
|
||||||
return userInfo;
|
return userInfo;
|
||||||
|
|||||||
Reference in New Issue
Block a user