Files
OpticalSystem/uniapp/scripts/patch-app-manifest.js
一休哥哥6666 721543f423 feat:uniapp模块
2026-07-14 14:53:45 +08:00

41 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* CLI 构建 app manifest 中 splashscreen.autoclose 恒为 false打包后补丁修正。
* HBuilderX 云打包会读取 dist/build/app 或 app-plus 下的 manifest.json。
*/
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/manifest.json'),
path.join(root, 'dist/build/app-plus/manifest.json')
]
for (const file of targets) {
if (!fs.existsSync(file)) continue
const manifest = JSON.parse(fs.readFileSync(file, 'utf8'))
if (manifest.plus) {
manifest.plus.splashscreen = {
...(manifest.plus.splashscreen || {}),
autoclose: true,
waiting: false,
delay: 0
}
manifest.plus.renderer = 'webview'
manifest.plus.compatible = { ignoreVersion: true }
manifest.plus.distribute = manifest.plus.distribute || {}
manifest.plus.distribute.google = {
...(manifest.plus.distribute.google || {}),
packagename: 'com.jyuan.optical'
}
if (manifest.plus['uni-app']) {
manifest.plus['uni-app'].renderer = 'webview'
}
}
fs.writeFileSync(file, JSON.stringify(manifest, null, 2), 'utf8')
console.log('[patch-app-manifest] patched', path.relative(root, file))
}