fix(bpm): persist encrypted sessions without file renames

This commit is contained in:
阿白叔 committed 2026-10-17 18:57:43 +08:00
1 parent a785fa73d4
commit 607b240aa3
5 files changed
+78 -21

No files matched your search

+11 -3
View File
@@ -264,11 +264,16 @@ class BpmSessionManager {
};
lease.network.on('Page.frameRequestedNavigation',started);
lease.network.on('Page.frameStartedLoading',started);
lease.network.on('Page.frameStoppedLoading',event=>{
const finished=event=>{
if (event.frameId!==lease.mainFrameId) return;
lease.finishNavigation?.(); lease.pendingNavigation=null; lease.finishNavigation=null;
});
};
lease.network.on('Page.frameStoppedLoading',finished);
// Portal images/widgets can stall after its document is ready. Login
// verification needs the committed document, not every subresource.
lease.network.on('Page.lifecycleEvent',event=>{if(event.name==='DOMContentLoaded')finished(event);});
await lease.network.send('Page.enable');
await lease.network.send('Page.setLifecycleEventsEnabled',{enabled:true});
lease.network.on('Fetch.requestPaused', async event => {
try {
if (this.allowed(event.request.url)) await lease.network.send('Fetch.continueRequest',{requestId:event.requestId});
@@ -327,8 +332,11 @@ class BpmSessionManager {
});
}
async defaultProbe(page) {
// A visible company SSO form is an explicit login state. The authenticated
// portal renders its user menu asynchronously after DOMContentLoaded.
if(new URL(page.url()).origin==='https://sso.skyworthdigital.com' && await page.locator('#kc-form-login').isVisible().catch(()=>false))return {ok:false};
const marker=page.locator('a.yz-btn-signinuser .x-btn-inner').first();
await marker.waitFor({state:'visible',timeout:4000}).catch(()=>{});
await marker.waitFor({state:'visible',timeout:15000}).catch(()=>{});
if (!await marker.isVisible().catch(()=>false)) return {ok:false};
const identity=(await marker.innerText()).trim();
return {ok:!!identity && !/^(登录|请登录|未登录|sign\s*in|login)$/i.test(identity),identity};