yanzhu-saas/yanzhu-ui/yanzhu-ui-mall-uniapp/sheep/libs/mplive-manifest-plugin.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

2026-02-04 17:47:51 +08:00
const fs = require('fs');
const manifestPath = process.env.UNI_INPUT_DIR + '/manifest.json';
let Manifest = fs.readFileSync(manifestPath, {
encoding: 'utf-8'
});
function mpliveMainfestPlugin(isOpen) {
2026-02-06 14:32:50 +08:00
if (process.env.UNI_PLATFORM !== 'mp-weixin') return { name: 'mplive-mainfest-plugin' };
2026-02-04 17:47:51 +08:00
2026-02-06 14:32:50 +08:00
try {
const manifestData = JSON.parse(Manifest)
2026-02-04 17:47:51 +08:00
2026-02-06 14:32:50 +08:00
if (isOpen === '0') {
if (manifestData['mp-weixin'] && manifestData['mp-weixin'].plugins) {
delete manifestData['mp-weixin'].plugins['live-player-plugin'];
}
}
2026-02-04 17:47:51 +08:00
2026-02-06 14:32:50 +08:00
if (isOpen === '1') {
if (!manifestData['mp-weixin']) {
manifestData['mp-weixin'] = {};
}
if (!manifestData['mp-weixin'].plugins) {
manifestData['mp-weixin'].plugins = {};
}
manifestData['mp-weixin'].plugins['live-player-plugin'] = {
"version": "1.3.5",
"provider": "wx2b03c6e691cd7370"
}
2026-02-04 17:47:51 +08:00
}
2026-02-06 14:32:50 +08:00
Manifest = JSON.stringify(manifestData, null, 2)
fs.writeFileSync(manifestPath, Manifest, {
"flag": "w"
})
} catch (error) {
console.error('Error processing manifest.json:', error);
}
2026-02-04 17:47:51 +08:00
2026-02-06 14:32:50 +08:00
return { name: 'mplive-mainfest-plugin' };
2026-02-04 17:47:51 +08:00
}
export default mpliveMainfestPlugin