feat:动态加载直播插件
parent
e63fdf3dfc
commit
40d8dbf7f1
|
|
@ -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
|
||||||
|
|
@ -138,8 +138,7 @@
|
||||||
top: 10rpx;
|
top: 10rpx;
|
||||||
width: 136rpx;
|
width: 136rpx;
|
||||||
height: 40rpx;
|
height: 40rpx;
|
||||||
background: #000000;
|
background: rgba(#000000, 0.5);
|
||||||
opacity: 0.5;
|
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
.icon {
|
.icon {
|
||||||
width: 40rpx;
|
width: 40rpx;
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,28 @@ import uni from '@dcloudio/vite-plugin-uni';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
// import viteCompression from 'vite-plugin-compression';
|
// import viteCompression from 'vite-plugin-compression';
|
||||||
import uniReadPagesV3Plugin from './sheep/router/utils/uni-read-pages-v3';
|
import uniReadPagesV3Plugin from './sheep/router/utils/uni-read-pages-v3';
|
||||||
|
// 引入直播组件
|
||||||
|
import replaceManifest from './modifyManifest'
|
||||||
|
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default (command, mode) => {
|
export default (command, mode) => {
|
||||||
const env = loadEnv(mode, __dirname, 'SHOPRO_');
|
const env = loadEnv(mode, __dirname, 'SHOPRO_');
|
||||||
|
if (env.SHOPRO_MPLIVE_ON === 'true') {
|
||||||
|
replaceManifest(`{
|
||||||
|
"live-player-plugin": {
|
||||||
|
"version": "1.3.5",
|
||||||
|
"provider": "wx2b03c6e691cd7370"
|
||||||
|
}
|
||||||
|
}`, 'push')
|
||||||
|
} else {
|
||||||
|
replaceManifest(`{
|
||||||
|
"live-player-plugin": {
|
||||||
|
"version": "1.3.5",
|
||||||
|
"provider": "wx2b03c6e691cd7370"
|
||||||
|
}
|
||||||
|
}`, 'delete')
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
envPrefix: "SHOPRO_",
|
envPrefix: "SHOPRO_",
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue