fix:优化动态添加直播组件
parent
f806152116
commit
8aa295b02d
5
env
5
env
|
@ -13,4 +13,7 @@ SHOPRO_API_PATH = /shop/api/
|
||||||
# 客户端静态资源地址 空=默认使用服务端指定的CDN资源地址前缀 | local=本地 | http(s)://xxx.xxx=自定义静态资源地址前缀
|
# 客户端静态资源地址 空=默认使用服务端指定的CDN资源地址前缀 | local=本地 | http(s)://xxx.xxx=自定义静态资源地址前缀
|
||||||
SHOPRO_STATIC_URL = https://file.sheepjs.com
|
SHOPRO_STATIC_URL = https://file.sheepjs.com
|
||||||
|
|
||||||
SHOPRO_VERSION = v1.1.15
|
SHOPRO_VERSION = v1.8.1
|
||||||
|
|
||||||
|
# 是否开启直播 1 开启直播 | 0 关闭直播
|
||||||
|
SHOPRO_MPLIVE_ON = 0
|
|
@ -69,7 +69,10 @@
|
||||||
"schemes": "shopro"
|
"schemes": "shopro"
|
||||||
},
|
},
|
||||||
"ios": {
|
"ios": {
|
||||||
"urlschemewhitelist" : [ "baidumap", "iosamap" ],
|
"urlschemewhitelist": [
|
||||||
|
"baidumap",
|
||||||
|
"iosamap"
|
||||||
|
],
|
||||||
"dSYMs": false,
|
"dSYMs": false,
|
||||||
"privacyDescription": {
|
"privacyDescription": {
|
||||||
"NSPhotoLibraryUsageDescription": "需要同意访问您的相册选取图片才能完善该条目",
|
"NSPhotoLibraryUsageDescription": "需要同意访问您的相册选取图片才能完善该条目",
|
||||||
|
@ -80,7 +83,9 @@
|
||||||
"urltypes": "shopro",
|
"urltypes": "shopro",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
"com.apple.developer.associated-domains" : [ "applinks:shopro.sheepjs.com" ]
|
"com.apple.developer.associated-domains": [
|
||||||
|
"applinks:shopro.sheepjs.com"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"idfa": true
|
"idfa": true
|
||||||
|
@ -99,12 +104,18 @@
|
||||||
},
|
},
|
||||||
"payment": {
|
"payment": {
|
||||||
"weixin": {
|
"weixin": {
|
||||||
"__platform__" : [ "ios", "android" ],
|
"__platform__": [
|
||||||
|
"ios",
|
||||||
|
"android"
|
||||||
|
],
|
||||||
"appid": "wxae7a0c156da9383b",
|
"appid": "wxae7a0c156da9383b",
|
||||||
"UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
|
"UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
|
||||||
},
|
},
|
||||||
"alipay": {
|
"alipay": {
|
||||||
"__platform__" : [ "ios", "android" ]
|
"__platform__": [
|
||||||
|
"ios",
|
||||||
|
"android"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"share": {
|
"share": {
|
||||||
|
@ -114,7 +125,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orientation" : [ "portrait-primary" ],
|
"orientation": [
|
||||||
|
"portrait-primary"
|
||||||
|
],
|
||||||
"splashscreen": {
|
"splashscreen": {
|
||||||
"androidStyle": "common",
|
"androidStyle": "common",
|
||||||
"iosStyle": "common",
|
"iosStyle": "common",
|
||||||
|
@ -190,7 +203,9 @@
|
||||||
"lazyCodeLoading": "requiredComponents",
|
"lazyCodeLoading": "requiredComponents",
|
||||||
"usingComponents": {},
|
"usingComponents": {},
|
||||||
"permission": {},
|
"permission": {},
|
||||||
"requiredPrivateInfos" : [ "chooseAddress" ]
|
"requiredPrivateInfos": [
|
||||||
|
"chooseAddress"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"mp-alipay": {
|
"mp-alipay": {
|
||||||
"usingComponents": true
|
"usingComponents": true
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
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
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const manifestPath = process.env.UNI_INPUT_DIR + '/manifest.json';
|
||||||
|
|
||||||
|
let Manifest = fs.readFileSync(manifestPath, {
|
||||||
|
encoding: 'utf-8'
|
||||||
|
});
|
||||||
|
|
||||||
|
function mpliveMainfestPlugin(isOpen) {
|
||||||
|
if (process.env.UNI_PLATFORM !== 'mp-weixin') return;
|
||||||
|
|
||||||
|
const manifestData = JSON.parse(Manifest)
|
||||||
|
|
||||||
|
if (isOpen === '0') {
|
||||||
|
delete manifestData['mp-weixin'].plugins['live-player-plugin'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isOpen === '1') {
|
||||||
|
manifestData['mp-weixin'].plugins['live-player-plugin'] = {
|
||||||
|
"version": "1.3.5",
|
||||||
|
"provider": "wx2b03c6e691cd7370"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Manifest = JSON.stringify(manifestData, null, 2)
|
||||||
|
|
||||||
|
fs.writeFileSync(manifestPath, Manifest, {
|
||||||
|
"flag": "w"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default mpliveMainfestPlugin
|
|
@ -3,28 +3,12 @@ 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 mpliveMainfestPlugin from './sheep/libs/mpLive-manifest-plugin';
|
||||||
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: [
|
||||||
|
@ -36,6 +20,7 @@ export default (command, mode) => {
|
||||||
pagesJsonDir: path.resolve(__dirname, './pages.json'),
|
pagesJsonDir: path.resolve(__dirname, './pages.json'),
|
||||||
includes: ['path', 'aliasPath', 'name', 'meta'],
|
includes: ['path', 'aliasPath', 'name', 'meta'],
|
||||||
}),
|
}),
|
||||||
|
mpliveMainfestPlugin(env.SHOPRO_MPLIVE_ON)
|
||||||
],
|
],
|
||||||
server: {
|
server: {
|
||||||
host: true,
|
host: true,
|
||||||
|
|
Loading…
Reference in New Issue