fix:解决登录过期点击重新登录失败的bug

This commit is contained in:
Roe-xin
2026-03-03 14:19:00 +08:00
parent 8f305033f7
commit 3458f6fe23
5 changed files with 41 additions and 19 deletions

View File

@ -159,8 +159,9 @@ export async function activate(context: vscode.ExtensionContext) {
// 注册命令:用户登录
const loginCommand = vscode.commands.registerCommand(
"ic-coder.login",
async () => {
async (options?: { forceReauth?: boolean }) => {
try {
const forceReauth = options?.forceReauth === true;
const session = await vscode.authentication.getSession("iccoder", [], {
createIfNone: false,
});
@ -169,7 +170,7 @@ export async function activate(context: vscode.ExtensionContext) {
: null;
// 会话仍有效时,直接打开聊天面板
if (session && expired !== true) {
if (session && expired === false && !forceReauth) {
vscode.commands.executeCommand("ic-coder.openChat");
return;
}

View File

@ -91,7 +91,9 @@ export async function showICHelperPanel(
"立即登录",
);
if (action === "立即登录") {
vscode.commands.executeCommand("ic-coder.login");
vscode.commands.executeCommand("ic-coder.login", {
forceReauth: true,
});
}
return;
}
@ -106,7 +108,9 @@ export async function showICHelperPanel(
.showWarningMessage("请先登录后再使用 IC Coder", "立即登录")
.then((selection) => {
if (selection === "立即登录") {
vscode.commands.executeCommand("ic-coder.login");
vscode.commands.executeCommand("ic-coder.login", {
forceReauth: true,
});
}
});
return;
@ -116,7 +120,9 @@ export async function showICHelperPanel(
.showWarningMessage("请先登录后再使用 IC Coder", "立即登录")
.then((selection) => {
if (selection === "立即登录") {
vscode.commands.executeCommand("ic-coder.login");
vscode.commands.executeCommand("ic-coder.login", {
forceReauth: true,
});
}
});
return;

View File

@ -449,7 +449,9 @@ export class DialogSession {
.showErrorMessage("登录已过期,请重新登录", "重新登录")
.then((selection) => {
if (selection === "重新登录") {
vscode.commands.executeCommand("iccoder.login");
vscode.commands.executeCommand("ic-coder.login", {
forceReauth: true,
});
}
});
throw new Error("登录已过期,请重新登录");
@ -894,7 +896,9 @@ export class DialogSession {
.showErrorMessage("登录状态已过期,请重新登录", "重新登录")
.then((selection) => {
if (selection === "重新登录") {
vscode.commands.executeCommand("ic-coder.login");
vscode.commands.executeCommand("ic-coder.login", {
forceReauth: true,
});
}
});
// 登录过期错误已处理,不再传递给外部

View File

@ -92,7 +92,9 @@ export async function handleUserMessage(
);
if (action === '立即登录') {
vscode.commands.executeCommand("ic-coder.login");
vscode.commands.executeCommand("ic-coder.login", {
forceReauth: true,
});
}
// 恢复输入状态
@ -126,7 +128,9 @@ export async function handleUserMessage(
);
if (action === '立即登录') {
vscode.commands.executeCommand("ic-coder.login");
vscode.commands.executeCommand("ic-coder.login", {
forceReauth: true,
});
}
// 恢复输入状态