fix: reset QQLoginStatus on KickedOffLine to prevent WebUI re-login block (#1896)
When QQ kicks the bot offline, the WebUI incorrectly shows the account as still logged in, blocking users from re-login via QR code or password until NapCat is restarted. Root cause: The KickedOffLine event handlers in both the shell (base.ts) and framework (napcat.ts) only set the error message without resetting QQLoginStatus. The QQGetQRcodeHandler and other login endpoints check getQQLoginStatus() and reject all re-login attempts when it remains true. Fix: Set QQLoginStatus to false in both event handlers, ensuring the WebUI state syncs with the actual account status when kicked offline. Two changes: - napcat-shell/base.ts: add setQQLoginStatus(false) before setQQLoginError() - napcat-framework/napcat.ts: register a KickedOffLine listener that resets the login status (the framework previously had no KickedOffLine listener) Fixes: #508, #1818
This commit is contained in:
1 parent
c405b6d0a4
commit
fbd70bbb04
2 files changed
+6
No files matched your search
@@ -195,6 +195,11 @@ export async function NCoreInitFramework (
|
||||
if (oneBotAdapter) {
|
||||
WebUiDataRuntime.setOneBotContext(oneBotAdapter);
|
||||
}
|
||||
|
||||
// 监听下线通知并同步到 WebUI(兜底保障,防止 WebUI 状态不同步)
|
||||
loaderObject.core.event.on('KickedOffLine', () => {
|
||||
WebUiDataRuntime.setQQLoginStatus(false);
|
||||
});
|
||||
}
|
||||
|
||||
function registerWebUiLoginCallbacks (
|
||||
|
||||
@@ -794,6 +794,7 @@ export class NapCatShell {
|
||||
|
||||
// 监听下线通知并同步到 WebUI
|
||||
this.core.event.on('KickedOffLine', (tips: string) => {
|
||||
WebUiDataRuntime.setQQLoginStatus(false);
|
||||
WebUiDataRuntime.setQQLoginError(tips);
|
||||
});
|
||||
// 使用 NapCatAdapterManager 统一管理协议适配器
|
||||
|
||||
Reference in new issue
Block a user