feat(extraction): read headless mode from config instead of hardcoding

Add headless field to extraction config schema (default: true).
Extractor handler now reads globalConfig.extraction.headless instead
of hardcoding true. Users can set headless: false in config.yaml
to show the browser window during extraction for debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-04-03 21:53:21 +08:00
parent 6413eef5b8
commit ba436cf374
4 changed files with 10 additions and 3 deletions

View File

@@ -40,6 +40,7 @@ extraction:
autoConvert: true
mergeBatches: true
enableDbPersistence: true
headless: true # 浏览器无头模式true=后台运行false=显示浏览器窗口(调试用)
validation:
dataSource: database_full

View File

@@ -90,6 +90,10 @@ export function registerExtractorHandlers(): void {
log.info('Fetching ERP configuration from database...')
const erpConfig = await getErpConfig()
// Read headless setting from global config
const configManager = ConfigManager.getInstance()
const globalConfig = configManager.getConfig()
log.info('ERP config retrieved', {
url: erpConfig.url ? 'configured' : 'EMPTY',
username: erpConfig.username ? 'configured' : 'EMPTY'
@@ -188,7 +192,7 @@ export function registerExtractorHandlers(): void {
url: erpConfig.url,
username: erpConfig.username,
password: erpConfig.password,
headless: true
headless: globalConfig.extraction.headless
})
sendProgress(sender, '登录 ERP 系统...', 9.99, {

View File

@@ -78,7 +78,8 @@ const DEFAULT_CONFIG: FullConfig = {
verbose: true,
autoConvert: true,
mergeBatches: true,
enableDbPersistence: true
enableDbPersistence: true,
headless: true
},
validation: {
dataSource: 'database_full',

View File

@@ -83,7 +83,8 @@ export const extractionConfigSchema = z.object({
verbose: z.boolean().default(true),
autoConvert: z.boolean().default(true),
mergeBatches: z.boolean().default(true),
enableDbPersistence: z.boolean().default(true)
enableDbPersistence: z.boolean().default(true),
headless: z.boolean().default(true)
})
/**