fix:优化动态添加直播组件

pull/8/head
kele 2023-03-20 14:35:31 +08:00
parent f806152116
commit 8aa295b02d
5 changed files with 275 additions and 268 deletions

5
env
View File

@ -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

View File

@ -1,230 +1,245 @@
{ {
"name" : "星品购", "name": "星品购",
"appid" : "__UNI__082C0BA", "appid": "__UNI__082C0BA",
"description" : "应用描述", "description": "应用描述",
"versionName" : "1.0.7", "versionName": "1.0.7",
"versionCode" : 107, "versionCode": 107,
"transformPx" : false, "transformPx": false,
"app-plus" : { "app-plus": {
"usingComponents" : true, "usingComponents": true,
"nvueCompiler" : "uni-app", "nvueCompiler": "uni-app",
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler": "uni-app",
"compilerVersion" : 3, "compilerVersion": 3,
"nvueLaunchMode" : "fast", "nvueLaunchMode": "fast",
"splashscreen" : { "splashscreen": {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender": true,
"waiting" : true, "waiting": true,
"autoclose" : true, "autoclose": true,
"delay" : 0 "delay": 0
},
"safearea": {
"bottom": {
"offset": "none"
}
},
"modules": {
"Payment": {},
"Share": {},
"VideoPlayer": {},
"OAuth": {}
},
"distribute": {
"android": {
"permissions": [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_MOCK_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.GET_TASKS\"/>",
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.READ_SMS\"/>",
"<uses-permission android:name=\"android.permission.RECEIVE_BOOT_COMPLETED\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.SEND_SMS\"/>",
"<uses-permission android:name=\"android.permission.SYSTEM_ALERT_WINDOW\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SMS\"/>",
"<uses-permission android:name=\"android.permission.RECEIVE_USER_PRESENT\"/>"
],
"minSdkVersion": 21,
"schemes": "shopro"
},
"ios": {
"urlschemewhitelist": [
"baidumap",
"iosamap"
],
"dSYMs": false,
"privacyDescription": {
"NSPhotoLibraryUsageDescription": "需要同意访问您的相册选取图片才能完善该条目",
"NSPhotoLibraryAddUsageDescription": "需要同意访问您的相册才能保存该图片",
"NSCameraUsageDescription": "需要同意访问您的摄像头拍摄照片才能完善该条目",
"NSUserTrackingUsageDescription": "开启追踪并不会获取您在其它站点的隐私信息,该行为仅用于标识设备,保障服务安全和提升浏览体验"
}, },
"safearea" : { "urltypes": "shopro",
"bottom" : { "capabilities": {
"offset" : "none" "entitlements": {
} "com.apple.developer.associated-domains": [
"applinks:shopro.sheepjs.com"
]
}
}, },
"modules" : { "idfa": true
"Payment" : {}, },
"Share" : {}, "sdkConfigs": {
"VideoPlayer" : {}, "speech": {
"OAuth" : {} "ifly": {}
}, },
"distribute" : { "ad": {},
"android" : { "oauth": {
"permissions" : [ "apple": {},
"<uses-feature android:name=\"android.hardware.camera\"/>", "weixin": {
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", "appid": "wxae7a0c156da9383b",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>", "UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", }
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>", },
"<uses-permission android:name=\"android.permission.ACCESS_MOCK_LOCATION\"/>", "payment": {
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", "weixin": {
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", "__platform__": [
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>", "ios",
"<uses-permission android:name=\"android.permission.CAMERA\"/>", "android"
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", ],
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>", "appid": "wxae7a0c156da9383b",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", "UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", },
"<uses-permission android:name=\"android.permission.GET_TASKS\"/>", "alipay": {
"<uses-permission android:name=\"android.permission.INTERNET\"/>", "__platform__": [
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>", "ios",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", "android"
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>", ]
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>", }
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", },
"<uses-permission android:name=\"android.permission.READ_SMS\"/>", "share": {
"<uses-permission android:name=\"android.permission.RECEIVE_BOOT_COMPLETED\"/>", "weixin": {
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>", "appid": "wxae7a0c156da9383b",
"<uses-permission android:name=\"android.permission.SEND_SMS\"/>", "UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
"<uses-permission android:name=\"android.permission.SYSTEM_ALERT_WINDOW\"/>", }
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SMS\"/>",
"<uses-permission android:name=\"android.permission.RECEIVE_USER_PRESENT\"/>"
],
"minSdkVersion" : 21,
"schemes" : "shopro"
},
"ios" : {
"urlschemewhitelist" : [ "baidumap", "iosamap" ],
"dSYMs" : false,
"privacyDescription" : {
"NSPhotoLibraryUsageDescription" : "需要同意访问您的相册选取图片才能完善该条目",
"NSPhotoLibraryAddUsageDescription" : "需要同意访问您的相册才能保存该图片",
"NSCameraUsageDescription" : "需要同意访问您的摄像头拍摄照片才能完善该条目",
"NSUserTrackingUsageDescription" : "开启追踪并不会获取您在其它站点的隐私信息,该行为仅用于标识设备,保障服务安全和提升浏览体验"
},
"urltypes" : "shopro",
"capabilities" : {
"entitlements" : {
"com.apple.developer.associated-domains" : [ "applinks:shopro.sheepjs.com" ]
}
},
"idfa" : true
},
"sdkConfigs" : {
"speech" : {
"ifly" : {}
},
"ad" : {},
"oauth" : {
"apple" : {},
"weixin" : {
"appid" : "wxae7a0c156da9383b",
"UniversalLinks" : "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
}
},
"payment" : {
"weixin" : {
"__platform__" : [ "ios", "android" ],
"appid" : "wxae7a0c156da9383b",
"UniversalLinks" : "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
},
"alipay" : {
"__platform__" : [ "ios", "android" ]
}
},
"share" : {
"weixin" : {
"appid" : "wxae7a0c156da9383b",
"UniversalLinks" : "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
}
}
},
"orientation" : [ "portrait-primary" ],
"splashscreen" : {
"androidStyle" : "common",
"iosStyle" : "common",
"useOriginalMsgbox" : true
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
}
} }
}, },
"quickapp" : {}, "orientation": [
"quickapp-native" : { "portrait-primary"
"icon" : "/static/logo.png", ],
"package" : "com.example.demo", "splashscreen": {
"features" : [ "androidStyle": "common",
{ "iosStyle": "common",
"name" : "system.clipboard" "useOriginalMsgbox": true
} },
] "icons": {
}, "android": {
"quickapp-webview" : { "hdpi": "unpackage/res/icons/72x72.png",
"icon" : "/static/logo.png", "xhdpi": "unpackage/res/icons/96x96.png",
"package" : "com.example.demo", "xxhdpi": "unpackage/res/icons/144x144.png",
"minPlatformVersion" : 1070, "xxxhdpi": "unpackage/res/icons/192x192.png"
"versionName" : "1.0.0",
"versionCode" : 100
},
"mp-weixin" : {
"appid" : "wx43051b2afa4ed3d0",
"setting" : {
"urlCheck" : false,
"minified" : true,
"postcss" : true
}, },
"optimization" : { "ios": {
"subPackages" : true "appstore": "unpackage/res/icons/1024x1024.png",
}, "ipad": {
"plugins" : { "app": "unpackage/res/icons/76x76.png",
"live-player-plugin" : { "app@2x": "unpackage/res/icons/152x152.png",
"version" : "1.3.5", "notification": "unpackage/res/icons/20x20.png",
"provider" : "wx2b03c6e691cd7370" "notification@2x": "unpackage/res/icons/40x40.png",
} "proapp@2x": "unpackage/res/icons/167x167.png",
}, "settings": "unpackage/res/icons/29x29.png",
"lazyCodeLoading" : "requiredComponents", "settings@2x": "unpackage/res/icons/58x58.png",
"usingComponents" : {}, "spotlight": "unpackage/res/icons/40x40.png",
"permission" : {}, "spotlight@2x": "unpackage/res/icons/80x80.png"
"requiredPrivateInfos" : [ "chooseAddress" ] },
}, "iphone": {
"mp-alipay" : { "app@2x": "unpackage/res/icons/120x120.png",
"usingComponents" : true "app@3x": "unpackage/res/icons/180x180.png",
}, "notification@2x": "unpackage/res/icons/40x40.png",
"mp-baidu" : { "notification@3x": "unpackage/res/icons/60x60.png",
"usingComponents" : true "settings@2x": "unpackage/res/icons/58x58.png",
}, "settings@3x": "unpackage/res/icons/87x87.png",
"mp-toutiao" : { "spotlight@2x": "unpackage/res/icons/80x80.png",
"usingComponents" : true "spotlight@3x": "unpackage/res/icons/120x120.png"
}, }
"mp-jd" : {
"usingComponents" : true
},
"h5" : {
"template" : "index.html",
"router" : {
"mode" : "hash",
"base" : "./"
},
"sdkConfigs" : {
"maps" : {}
},
"async" : {
"timeout" : 20000
},
"title" : "星品购",
"optimization" : {
"treeShaking" : {
"enable" : true
}
} }
}
}
},
"quickapp": {},
"quickapp-native": {
"icon": "/static/logo.png",
"package": "com.example.demo",
"features": [
{
"name": "system.clipboard"
}
]
},
"quickapp-webview": {
"icon": "/static/logo.png",
"package": "com.example.demo",
"minPlatformVersion": 1070,
"versionName": "1.0.0",
"versionCode": 100
},
"mp-weixin": {
"appid": "wx43051b2afa4ed3d0",
"setting": {
"urlCheck": false,
"minified": true,
"postcss": true
}, },
"vueVersion" : "3", "optimization": {
"_spaceID" : "192b4892-5452-4e1d-9f09-eee1ece40639", "subPackages": true
"locale" : "zh-Hans", },
"fallbackLocale" : "zh-Hans" "plugins": {
} "live-player-plugin": {
"version": "1.3.5",
"provider": "wx2b03c6e691cd7370"
}
},
"lazyCodeLoading": "requiredComponents",
"usingComponents": {},
"permission": {},
"requiredPrivateInfos": [
"chooseAddress"
]
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"mp-jd": {
"usingComponents": true
},
"h5": {
"template": "index.html",
"router": {
"mode": "hash",
"base": "./"
},
"sdkConfigs": {
"maps": {}
},
"async": {
"timeout": 20000
},
"title": "星品购",
"optimization": {
"treeShaking": {
"enable": true
}
}
},
"vueVersion": "3",
"_spaceID": "192b4892-5452-4e1d-9f09-eee1ece40639",
"locale": "zh-Hans",
"fallbackLocale": "zh-Hans"
}

View File

@ -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

View File

@ -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

View File

@ -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,