feat:动态加载直播插件

This commit is contained in:
kele
2023-03-18 09:26:37 +08:00
parent e63fdf3dfc
commit 40d8dbf7f1
3 changed files with 47 additions and 3 deletions
+28
View File
@@ -0,0 +1,28 @@
const fs = require('fs');
const manifestPath = process.env.UNI_INPUT_DIR + '/manifest.json';
let Manifest = fs.readFileSync(manifestPath, { encoding: 'utf-8' });
function replaceManifest(value, remove) {
let data = JSON.parse(Manifest)
let newValue = JSON.parse(value)
if (remove === 'delete') {
delete data['mp-weixin'].plugins['live-player-plugin'];
} else {
if (data['mp-weixin'].plugins['live-player-plugin']) return;
data['mp-weixin'].plugins = {
...data['mp-weixin'].plugins,
...newValue
}
}
Manifest = JSON.stringify(data)
fs.writeFileSync(manifestPath, Manifest, {
"flag": "w"
})
}
export default replaceManifest