2024-08-07 10:31:42 +08:00
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const manifestPath = process.env.UNI_INPUT_DIR + '/manifest.json';
|
|
|
|
|
|
|
|
let Manifest = fs.readFileSync(manifestPath, {
|
2024-08-07 21:40:27 +08:00
|
|
|
encoding: 'utf-8',
|
2024-08-07 10:31:42 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
function mpliveMainfestPlugin(isOpen) {
|
2024-08-07 21:40:27 +08:00
|
|
|
if (process.env.UNI_PLATFORM !== 'mp-weixin') return;
|
2024-08-07 10:31:42 +08:00
|
|
|
|
2024-08-07 21:40:27 +08:00
|
|
|
const manifestData = JSON.parse(Manifest);
|
2024-08-07 10:31:42 +08:00
|
|
|
|
2024-08-07 21:40:27 +08:00
|
|
|
if (isOpen === '0') {
|
|
|
|
delete manifestData['mp-weixin'].plugins['live-player-plugin'];
|
|
|
|
}
|
2024-08-07 10:31:42 +08:00
|
|
|
|
2024-08-07 21:40:27 +08:00
|
|
|
if (isOpen === '1') {
|
|
|
|
manifestData['mp-weixin'].plugins['live-player-plugin'] = {
|
|
|
|
version: '1.3.5',
|
|
|
|
provider: 'wx2b03c6e691cd7370',
|
|
|
|
};
|
|
|
|
}
|
2024-08-07 10:31:42 +08:00
|
|
|
|
2024-08-07 21:40:27 +08:00
|
|
|
Manifest = JSON.stringify(manifestData, null, 2);
|
2024-08-07 10:31:42 +08:00
|
|
|
|
2024-08-07 21:40:27 +08:00
|
|
|
fs.writeFileSync(manifestPath, Manifest, {
|
|
|
|
flag: 'w',
|
|
|
|
});
|
2024-08-07 10:31:42 +08:00
|
|
|
}
|
|
|
|
|
2024-08-07 21:40:27 +08:00
|
|
|
export default mpliveMainfestPlugin;
|