rename clientInfo in frontend to _clientInfo
This commit is contained in:
parent
4e45a4e642
commit
dce1e02085
@ -99,7 +99,7 @@ module.exports = {
|
||||
windowTitle =
|
||||
windowTitle || wo?.envar?.callnames?.[langNow] || wo?.pagesJson?.appInfo?.i18nText?.[langNow] || wo?.pagesJson?.globalStyle?.navigationBarTitleText || ''
|
||||
|
||||
if (wo.envar.clientInfo.deviceType === 'pc') {
|
||||
if (wo.envar._clientInfo.deviceType === 'pc') {
|
||||
uni.setNavigationBarTitle({ title: windowTitle + (navibarTitle ? ` - ${navibarTitle}` : '') })
|
||||
} else {
|
||||
uni.setNavigationBarTitle({ title: navibarTitle })
|
||||
@ -109,7 +109,7 @@ module.exports = {
|
||||
//// 设置窗口标题栏 document.title
|
||||
//// navibarTitle 也会被用于浏览器的标签标题,可用 document.title 去覆盖。必须放在 setNavigationBarTitle 之后。
|
||||
//// 但这个方案,在电脑上,还是会显示 navibarTitle 在浏览器窗口顶栏,不知为何。
|
||||
if (wo.envar.clientInfo.deviceType !== 'pc' && /MicroMessenger/i.test(globalThis.window?.navigator?.userAgent)) {
|
||||
if (wo.envar._clientInfo.deviceType !== 'pc' && /MicroMessenger/i.test(globalThis.window?.navigator?.userAgent)) {
|
||||
//// 微信浏览器里,本身就显示了标题栏,和自有的导航栏形成功能重叠和混淆。
|
||||
//// 设置标题栏为空或覆盖
|
||||
document.title = windowTitle
|
||||
@ -118,7 +118,7 @@ module.exports = {
|
||||
}
|
||||
//#endif
|
||||
|
||||
if (wo.envar.clientInfo.deviceType === 'pc') {
|
||||
if (wo.envar._clientInfo.deviceType === 'pc') {
|
||||
uni.hideTabBar()
|
||||
} else {
|
||||
// 必须要在有 tab 的页面里 setTabBarItem 才有效果
|
||||
@ -197,7 +197,7 @@ module.exports = {
|
||||
const startTime = new Date().toJSON()
|
||||
let apiurl = undefined
|
||||
apiWhat._clientInfo = {
|
||||
...globalThis.wo?.envar?.clientInfo,
|
||||
...globalThis.wo?.envar?._clientInfo,
|
||||
lang: globalThis.wo?.ss?.i18n?.mylang,
|
||||
// #ifdef WEB
|
||||
requrl: globalThis.location?.href,
|
||||
@ -482,7 +482,7 @@ module.exports = {
|
||||
fileSize = fileDragged.size
|
||||
filePath = fileDragged.filePath
|
||||
filePicked = fileDragged
|
||||
cloudPath = `WEB_${wo.envar.clientInfo.osName}_${random}_${path.extname(fileDragged.name || { image: '.jpg', video: '.mp4' }[mediaType] || '')}` // tempFile and name are H5 only
|
||||
cloudPath = `WEB_${wo.envar._clientInfo.osName}_${random}_${path.extname(fileDragged.name || { image: '.jpg', video: '.mp4' }[mediaType] || '')}` // tempFile and name are H5 only
|
||||
} else if (mediaType === 'image') {
|
||||
let [errorChoose, { tempFilePaths, tempFiles } = {}] = await uni.chooseImage({ count, sizeType, sourceType })
|
||||
if (errorChoose) {
|
||||
@ -497,10 +497,10 @@ module.exports = {
|
||||
// #ifndef WEB
|
||||
// let [errorGetImageInfo, { path, width, height, orientation, type }] = await uni.getImageInfo({ src: filePath })
|
||||
// cloudPath = path // 完整路径,包含后缀名。形如 file:///var/mobile/Containers/Data/Application/55A76332-44F5-4D5F-A9F6-3F857D584883/Documents/Pandora/apps/D064A425A8BEC13F9D8F741B98B37BC5/doc/uniapp_temp_1598593902955/compressed/1598593925815.png
|
||||
cloudPath = `APP_${wo.envar.clientInfo.osName}_${random}${path.extname(filePath || '.jpg')}`
|
||||
cloudPath = `APP_${wo.envar._clientInfo.osName}_${random}${path.extname(filePath || '.jpg')}`
|
||||
// #endif
|
||||
// #ifdef WEB
|
||||
cloudPath = `WEB_${wo.envar.clientInfo.osName}_${random}${path.extname(tempFiles?.[0]?.name || '.jpg')}` // name is available in H5 only. 只包含文件名和后缀名,不包含路径。
|
||||
cloudPath = `WEB_${wo.envar._clientInfo.osName}_${random}${path.extname(tempFiles?.[0]?.name || '.jpg')}` // name is available in H5 only. 只包含文件名和后缀名,不包含路径。
|
||||
// #endif
|
||||
} else if (mediaType === 'video') {
|
||||
let [errorChoose, { tempFilePath, tempFile, duration, size, width, height, name }] = await uni.chooseVideo({ sourceType, maxDuration })
|
||||
@ -514,10 +514,10 @@ module.exports = {
|
||||
filePicked = tempFile
|
||||
filePath = tempFilePath // 在 iOS 上形如 "file:///var/mobile/Containers/Data/Application/55A76332-44F5-4D5F-A9F6-3F857D584883/Documents/Pandora/apps/26B43CD2F587D37FC6799108434A6F84/doc/uniapp_temp_1598596171580/gallery/IMG_3082.MOV"
|
||||
// #ifndef WEB
|
||||
cloudPath = `APP_${wo.envar.clientInfo.osName}_${random}_dur${duration}${path.extname(filePath || '.mp4')}`
|
||||
cloudPath = `APP_${wo.envar._clientInfo.osName}_${random}_dur${duration}${path.extname(filePath || '.mp4')}`
|
||||
// #endif
|
||||
// #ifdef WEB
|
||||
cloudPath = `WEB_${wo.envar.clientInfo.osName}_${random}_dur${duration}${path.extname(name || '.mp4')}` // tempFile and name are H5 only
|
||||
cloudPath = `WEB_${wo.envar._clientInfo.osName}_${random}_dur${duration}${path.extname(name || '.mp4')}` // tempFile and name are H5 only
|
||||
// #endif
|
||||
// iOS 上测试,filePath 为 *.MOV,而阿里云只允许 *.mp4, 所以默认添加 .mp4 后缀。参见 https://uniapp.dcloud.net.cn/uniCloud/storage?id=clouduploadfile
|
||||
// 20200915测试,阿里云支持上传 *.mov 了。
|
||||
@ -541,7 +541,7 @@ module.exports = {
|
||||
fileSize = tempFiles?.[0]?.size
|
||||
filePicked = tempFiles?.[0]
|
||||
filePath = tempFilePaths?.[0]
|
||||
cloudPath = `WEB_${wo.envar.clientInfo.osName}_${random}${path.extname(tempFiles?.[0]?.name || '')}` // name is available in H5 only. 只包含文件名和后缀名,不包含路径。
|
||||
cloudPath = `WEB_${wo.envar._clientInfo.osName}_${random}${path.extname(tempFiles?.[0]?.name || '')}` // name is available in H5 only. 只包含文件名和后缀名,不包含路径。
|
||||
// #endif
|
||||
// #ifndef WEB
|
||||
return { _state: 'UNSUPPORTED_FILETYPE', _msg: { zhCN: '请切换到网页端上传文件!', enUS: 'Please switch to WebApp to upload files.' } }
|
||||
@ -668,20 +668,30 @@ module.exports = {
|
||||
|
||||
parse_ua_to_browser () {
|
||||
// #ifdef WEB
|
||||
let userAgent = globalThis.window?.navigator?.userAgent?.toLowerCase?.()
|
||||
return /msie/.test(userAgent) && !/opera/.test(userAgent)
|
||||
? 'msie'
|
||||
: /opera/.test(userAgent)
|
||||
? 'opera'
|
||||
: /version.*safari/.test(userAgent)
|
||||
? 'safari'
|
||||
: /chrome/.test(userAgent)
|
||||
? 'chrome'
|
||||
: /gecko/.test(userAgent) && !/webkit/.test(userAgent)
|
||||
? 'firefox'
|
||||
: /micromessenger/.test(userAgent)
|
||||
? 'wechat'
|
||||
: 'unknown' // 只要在 H5, 即使不认识也要返回一个名称。
|
||||
let ua = globalThis.window?.navigator?.userAgent?.toLowerCase?.()
|
||||
if (/msie/.test(ua) && !/opera/.test(ua)) {
|
||||
return 'msie'
|
||||
} else if (/opera/.test(ua)) {
|
||||
return 'opera'
|
||||
} else if (/version.*safari/.test(ua)) {
|
||||
return 'safari'
|
||||
} else if (/chrome/.test(ua)) {
|
||||
return 'chrome'
|
||||
} else if (/gecko/.test(ua) && !/webkit/.test(ua)) {
|
||||
return 'firefox'
|
||||
} else if (ua.match(/MicroMessenger/i) == 'micromessenger' && ua.match(/miniprogram/i) == 'miniprogram') {
|
||||
// 微信小程序
|
||||
return 'wechat_mp'
|
||||
} else if (/micromessenger/.test(ua)) {
|
||||
// 微信公众号或微信浏览器
|
||||
return 'wechat'
|
||||
} else if (ua.match(/alipay/i) == 'alipay' && ua.match(/miniprogram/i) == 'miniprogram') {
|
||||
return 'alipay_mp'
|
||||
} else if (ua.match(/alipay/i) == 'alipay') {
|
||||
return 'alipay'
|
||||
} else {
|
||||
return 'unknown' // 只要在 H5, 即使不认识也要返回一个名称。
|
||||
}
|
||||
// #endif
|
||||
return '' // 如果不在 H5。
|
||||
},
|
||||
@ -727,16 +737,17 @@ module.exports = {
|
||||
mytoast?.show?.({ type, title, duration, ...rest })
|
||||
} else {
|
||||
// #ifdef APP
|
||||
uni.showToast({ icon: 'none', title, duration, ...rest })
|
||||
uni.showToast({ icon: ['error', 'success'].includes(type) ? type : 'none', title, duration, ...rest })
|
||||
// plus.nativeUI.toast( title, { align: center/left/right, verticalAlign: bottom/center/top, duration:long/short, icon, iconWidth, iconHeight, style: block/inline, type:text/richtext })
|
||||
// #endif
|
||||
// #ifndef APP
|
||||
uni.showToast({ icon: 'none', image, title, duration, ...rest })
|
||||
uni.showToast({ icon: ['error', 'success'].includes(type) ? type : 'none', image, title, duration, ...rest })
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
|
||||
showModal (option = {}) {
|
||||
option = { ...option } // 避免在 option 里直接增删。
|
||||
option.title = this.localizeText(option.title)
|
||||
option.content =
|
||||
(uni.getSystemInfoSync().uniPlatform === 'app' ? '\n' : '') + this.localizeText(option.content)?.substring?.(0, option.contentLength || 300)
|
||||
|
Loading…
Reference in New Issue
Block a user