把 getSystemInfoSync().model 等已经废弃的名称改成 deviceType 等新名称。
This commit is contained in:
parent
0dc6e13e67
commit
fae7f22baa
43
unitool.js
43
unitool.js
@ -116,7 +116,7 @@ export default {
|
|||||||
// 响应式方案:仅仅根据当前设备类型,如果是 PC 大屏幕,则始终显示 topWindow 并且隐藏顶部 navibar 和底部 tabBar。
|
// 响应式方案:仅仅根据当前设备类型,如果是 PC 大屏幕,则始终显示 topWindow 并且隐藏顶部 navibar 和底部 tabBar。
|
||||||
if (pagesJson?.topWindow || !envar?.showBarsOnPC) {
|
if (pagesJson?.topWindow || !envar?.showBarsOnPC) {
|
||||||
// 如果页头不是通过 pagesJson.topWindow 而是作为组件来引入个别页面,那么定义配置参数 showBarsOnPC 来控制。
|
// 如果页头不是通过 pagesJson.topWindow 而是作为组件来引入个别页面,那么定义配置参数 showBarsOnPC 来控制。
|
||||||
if (uni.getSystemInfoSync().model === 'PC') {
|
if (uni.getSystemInfoSync().deviceType === 'pc') {
|
||||||
if (window.innerWidth > (pagesJson?.topWindow?.matchMedia?.minWidth || 0)) {
|
if (window.innerWidth > (pagesJson?.topWindow?.matchMedia?.minWidth || 0)) {
|
||||||
uni.hideTabBar()
|
uni.hideTabBar()
|
||||||
// 不知为何,同一个二级页面,如果第二次进入,就仍然会显示 navibar, 必须通过 setTimeout 执行才能彻底隐藏。
|
// 不知为何,同一个二级页面,如果第二次进入,就仍然会显示 navibar, 必须通过 setTimeout 执行才能彻底隐藏。
|
||||||
@ -331,7 +331,10 @@ export default {
|
|||||||
|
|
||||||
let filePath,
|
let filePath,
|
||||||
cloudPath,
|
cloudPath,
|
||||||
systemInfo = this.getSystemInfo()
|
systemInfo = uni
|
||||||
|
.getSystemInfoSync()
|
||||||
|
.system.toLowerCase()
|
||||||
|
.replace(/\s+/g, '')
|
||||||
if (mediaType === 'image') {
|
if (mediaType === 'image') {
|
||||||
let [errorChoose, { tempFilePaths, tempFiles } = {}] = await uni.chooseImage({ count, sizeType, sourceType })
|
let [errorChoose, { tempFilePaths, tempFiles } = {}] = await uni.chooseImage({ count, sizeType, sourceType })
|
||||||
// uni.showModal({ title: 'tempFilePaths[0]=' + tempFilePaths[0] })
|
// uni.showModal({ title: 'tempFilePaths[0]=' + tempFilePaths[0] })
|
||||||
@ -339,20 +342,20 @@ export default {
|
|||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
// let [errorGetImageInfo, { path, width, height, orientation, type }] = await uni.getImageInfo({ src: filePath })
|
// 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 = 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_${systemInfo.platform}__${filePath}` // 在 iOS 上是 "_doc/uniapp_temp_1598593902955/compressed/1598593925815.png", 有时还包含从 file:/// 开始的完整路径名
|
cloudPath = `APP_${systemInfo}__${filePath}` // 在 iOS 上是 "_doc/uniapp_temp_1598593902955/compressed/1598593925815.png", 有时还包含从 file:/// 开始的完整路径名
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
cloudPath = `H5_${systemInfo.platform}_${systemInfo.browser}__${tempFiles[0].name}` // name is available in H5 only. 只包含文件名和后缀名,不包含路径。
|
cloudPath = `H5_${systemInfo}_${this.parse_ua_to_browser()}__${tempFiles[0].name}` // name is available in H5 only. 只包含文件名和后缀名,不包含路径。
|
||||||
// #endif
|
// #endif
|
||||||
} else if (mediaType === 'video') {
|
} else if (mediaType === 'video') {
|
||||||
let [errorChoose, { tempFilePath, tempFile, duration, size, width, height, name }] = await uni.chooseVideo({ sourceType, maxDuration })
|
let [errorChoose, { tempFilePath, tempFile, duration, size, width, height, name }] = await uni.chooseVideo({ sourceType, maxDuration })
|
||||||
// uni.showModal({ title: 'tempFilePath=' + tempFilePath })
|
// uni.showModal({ title: 'tempFilePath=' + tempFilePath })
|
||||||
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"
|
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 H5
|
// #ifndef H5
|
||||||
cloudPath = `APP_${systemInfo.platform}_dur${duration}__${filePath}`
|
cloudPath = `APP_${systemInfo}_dur${duration}__${filePath}`
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
cloudPath = `H5_${systemInfo.platform}_${systemInfo.browser}_dur${duration}__${name}` // tempFile and name are H5 only
|
cloudPath = `H5_${systemInfo}_${this.parse_ua_to_browser()}_dur${duration}__${name}` // tempFile and name are H5 only
|
||||||
// #endif
|
// #endif
|
||||||
// iOS 上测试,filePath 为 *.MOV,而阿里云只允许 *.mp4, 所以添加 .mp4 后缀。参见 https://uniapp.dcloud.net.cn/uniCloud/storage?id=clouduploadfile
|
// iOS 上测试,filePath 为 *.MOV,而阿里云只允许 *.mp4, 所以添加 .mp4 后缀。参见 https://uniapp.dcloud.net.cn/uniCloud/storage?id=clouduploadfile
|
||||||
// 20200915测试,阿里云支持上传 *.mov 了。
|
// 20200915测试,阿里云支持上传 *.mov 了。
|
||||||
@ -416,17 +419,11 @@ export default {
|
|||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
|
|
||||||
getSystemInfo () {
|
parse_ua_to_browser () {
|
||||||
let systemInfo = uni.getSystemInfoSync()
|
let userAgent = ''
|
||||||
// model=PC|iPhone|iPad|Nexus 6|...,
|
|
||||||
// platform=ios|android|mac|windows|linux|other,
|
|
||||||
// system=iOS 11.0|Android 4.0|Other 0|... 等等
|
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
systemInfo.environment = 'h5'
|
userAgent = window.navigator.userAgent.toLowerCase()
|
||||||
let userAgent = window.navigator.userAgent.toLowerCase()
|
return /msie/.test(userAgent) && !/opera/.test(userAgent)
|
||||||
systemInfo.browser =
|
|
||||||
/msie/.test(userAgent) && !/opera/.test(userAgent)
|
|
||||||
? 'msie'
|
? 'msie'
|
||||||
: /opera/.test(userAgent)
|
: /opera/.test(userAgent)
|
||||||
? 'opera'
|
? 'opera'
|
||||||
@ -438,19 +435,9 @@ export default {
|
|||||||
? 'firefox'
|
? 'firefox'
|
||||||
: /micromessenger/.test(userAgent)
|
: /micromessenger/.test(userAgent)
|
||||||
? 'wechat'
|
? 'wechat'
|
||||||
: 'unknown'
|
: 'unknown' // 只要在 H5, 即使不认识也要返回一个名称。
|
||||||
// #endif
|
// #endif
|
||||||
|
return '' // 如果不在 H5。
|
||||||
// #ifdef APP-PLUS || APP-PLUS-NVUE
|
|
||||||
systemInfo.environment = 'app'
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// #ifdef MP
|
|
||||||
systemInfo.environment = 'mp'
|
|
||||||
// 细分成 WEIXIN, ...
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
return systemInfo
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user