fix: 修复登出按钮无效 — 同时清除磁盘 cookie 和浏览器内存 context
- BrowserManager 新增 clearContext() 方法,关闭并丢弃平台 context - deleteCookies 同时调用 cookieStore.delete + browser.clearContext - 前端登出后直接 resetStatus,不再触发浏览器请求检查状态
This commit is contained in:
@@ -193,6 +193,21 @@ export class BrowserManager {
|
||||
logger.debug({ platform }, 'Cookies saved');
|
||||
}
|
||||
|
||||
/**
|
||||
* Close and discard the browser context for a platform so the next
|
||||
* operation creates a fresh one (without any cookies or storage).
|
||||
*/
|
||||
async clearContext(platform: string): Promise<void> {
|
||||
const ctx = this.contexts.get(platform);
|
||||
if (!ctx) return;
|
||||
|
||||
this.contexts.delete(platform);
|
||||
await ctx.close().catch((err: unknown) => {
|
||||
logger.warn({ err, platform }, 'Error closing context during clearContext');
|
||||
});
|
||||
logger.info({ platform }, 'Browser context cleared');
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for every in-flight platform queue to settle. Useful during
|
||||
* graceful shutdown so that running operations finish before teardown.
|
||||
|
||||
Reference in New Issue
Block a user