feat: 移除用户信息、余额检查和登录过期提示
- 隐藏用户信息显示和退出登录按钮 - 删除发送消息前的余额检查逻辑 - 删除对话完成后的余额更新逻辑 - 注释掉所有登录过期弹窗提示 - 移除用户服务和余额服务的初始化调用
This commit is contained in:
@ -5,8 +5,6 @@ import { VCDViewerPanel, VCDViewerEditorProvider } from "./panels/VCDViewerPanel
|
||||
import { ChatHistoryManager } from "./utils/chatHistoryManager";
|
||||
import { ICCoderAuthenticationProvider } from "./services/icCoderAuthProvider";
|
||||
import { VCDFileServer } from "./services/vcdFileServer";
|
||||
import { initUserService } from "./services/userService";
|
||||
import { initCreditsService } from "./services/creditsService";
|
||||
import { isTokenExpired } from "./utils/jwtUtils";
|
||||
import { NotificationService } from "./services/notificationService";
|
||||
import { InvitationService } from "./services/invitationService";
|
||||
@ -50,33 +48,26 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
const notificationService = NotificationService.getInstance(context);
|
||||
console.log('[Extension] 通知服务已初始化');
|
||||
|
||||
// 【关键】在创建 AuthProvider 之前,先检查并清除过期的 session
|
||||
const storedSessions = context.globalState.get<any[]>('icCoderSessions', []);
|
||||
console.log('[Extension] 检查 sessions 数量:', storedSessions.length);
|
||||
|
||||
if (storedSessions.length > 0) {
|
||||
const session = storedSessions[0];
|
||||
const token = session.accessToken;
|
||||
console.log('[Extension] 检查 token 是否过期...');
|
||||
|
||||
if (token) {
|
||||
const expired = isTokenExpired(token);
|
||||
console.log('[Extension] token 过期检查结果:', expired);
|
||||
|
||||
if (expired) {
|
||||
// 必须等待清除完成后再创建 AuthProvider
|
||||
await context.globalState.update('icCoderSessions', []);
|
||||
await context.globalState.update('icCoderUserInfo', undefined);
|
||||
console.log('[Extension] Token 已过期,已清除所有登录状态');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化用户服务
|
||||
initUserService(context);
|
||||
|
||||
// 初始化 Credits 服务
|
||||
initCreditsService(context);
|
||||
// 【已禁用】登录和 token 验证 - 无需登录即可使用
|
||||
// const storedSessions = context.globalState.get<any[]>('icCoderSessions', []);
|
||||
// console.log('[Extension] 检查 sessions 数量:', storedSessions.length);
|
||||
//
|
||||
// if (storedSessions.length > 0) {
|
||||
// const session = storedSessions[0];
|
||||
// const token = session.accessToken;
|
||||
// console.log('[Extension] 检查 token 是否过期...');
|
||||
//
|
||||
// if (token) {
|
||||
// const expired = isTokenExpired(token);
|
||||
// console.log('[Extension] token 过期检查结果:', expired);
|
||||
//
|
||||
// if (expired) {
|
||||
// await context.globalState.update('icCoderSessions', []);
|
||||
// await context.globalState.update('icCoderUserInfo', undefined);
|
||||
// console.log('[Extension] Token 已过期,已清除所有登录状态');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 初始化 VCD 文件服务器
|
||||
const vcdFileServer = new VCDFileServer(context.extensionUri);
|
||||
@ -91,25 +82,18 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
dispose: () => vcdFileServer.stop()
|
||||
});
|
||||
|
||||
// 注册 Authentication Provider(此时 icCoderSessions 已经被清除)
|
||||
const authProvider = new ICCoderAuthenticationProvider(context);
|
||||
context.subscriptions.push(
|
||||
vscode.authentication.registerAuthenticationProvider(
|
||||
"iccoder",
|
||||
"IC Coder",
|
||||
authProvider
|
||||
)
|
||||
);
|
||||
// 【已禁用】Authentication Provider 注册 - 无需登录
|
||||
// const authProvider = new ICCoderAuthenticationProvider(context);
|
||||
// context.subscriptions.push(
|
||||
// vscode.authentication.registerAuthenticationProvider(
|
||||
// "iccoder",
|
||||
// "IC Coder",
|
||||
// authProvider
|
||||
// )
|
||||
// );
|
||||
|
||||
// 检查登录状态,如果已登录则自动打开聊天面板
|
||||
vscode.authentication.getSession("iccoder", [], { createIfNone: false })
|
||||
.then((session) => {
|
||||
if (session) {
|
||||
vscode.commands.executeCommand("ic-coder.openChat");
|
||||
}
|
||||
}, () => {
|
||||
// 未登录,不做任何操作
|
||||
});
|
||||
// 【已禁用】登录状态检查 - 直接打开聊天面板
|
||||
vscode.commands.executeCommand("ic-coder.openChat");
|
||||
|
||||
// 注册命令:打开助手面板
|
||||
const openPanelCommand = vscode.commands.registerCommand(
|
||||
|
||||
Reference in New Issue
Block a user