/** * 强制 App 使用 webview 渲染,避免 renderer:auto 在部分设备上卡启动页。 */ import fs from 'fs' import path from 'path' import { fileURLToPath } from 'url' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const root = path.resolve(__dirname, '..') const targets = [ path.join(root, 'dist/build/app/app-config-service.js'), path.join(root, 'dist/build/app-plus/app-config-service.js') ] for (const file of targets) { if (!fs.existsSync(file)) continue let content = fs.readFileSync(file, 'utf8') const next = content .replace(/"renderer":"auto"/g, '"renderer":"webview"') .replace(/"waiting":true/g, '"waiting":false') if (next !== content) { fs.writeFileSync(file, next, 'utf8') console.log('[patch-app-config] patched', path.relative(root, file)) } }