feat(erp): conditionally enable Playwright video recording on login
When recordVideo and videoDir are set in ErpConfig, pass Playwright's recordVideo option to browser.newContext() so sessions are automatically captured on context close. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -47,13 +47,23 @@ export class ErpAuthService {
|
|||||||
|
|
||||||
log.debug('浏览器已启动', { headless: this.config.headless ?? false })
|
log.debug('浏览器已启动', { headless: this.config.headless ?? false })
|
||||||
|
|
||||||
const context = await browser.newContext({
|
const contextOptions: Parameters<typeof browser.newContext>[0] = {
|
||||||
acceptDownloads: true,
|
acceptDownloads: true,
|
||||||
viewport: { width: 1920, height: 1080 },
|
viewport: { width: 1920, height: 1080 },
|
||||||
ignoreHTTPSErrors: true, // Ignore SSL certificate errors
|
ignoreHTTPSErrors: true, // Ignore SSL certificate errors
|
||||||
// Disable web security for internal VPN
|
// Disable web security for internal VPN
|
||||||
javaScriptEnabled: true
|
javaScriptEnabled: true
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if (this.config.recordVideo && this.config.videoDir) {
|
||||||
|
contextOptions.recordVideo = {
|
||||||
|
dir: this.config.videoDir,
|
||||||
|
size: { width: 1920, height: 1080 }
|
||||||
|
}
|
||||||
|
log.info('Video recording enabled', { dir: this.config.videoDir })
|
||||||
|
}
|
||||||
|
|
||||||
|
const context = await browser.newContext(contextOptions)
|
||||||
|
|
||||||
const page = await context.newPage()
|
const page = await context.newPage()
|
||||||
attachPageDiagnostics(page)
|
attachPageDiagnostics(page)
|
||||||
|
|||||||
Reference in New Issue
Block a user