@@ -39,19 +39,19 @@ module.exports = {
is _text _file ( fileName = '' ) {
is _text _file ( fileName = '' ) {
const ext = /\./ . test ( fileName ) ? fileName . split ( '.' ) . pop ( ) . toLowerCase ( ) : ''
const ext = /\./ . test ( fileName ) ? fileName . split ( '.' ) . pop ( ) . toLowerCase ( ) : ''
return wo . envar . textExtensionList ? . includes ? . ( ext )
return wo . ss . textExtensionList ? . includes ? . ( ext )
} ,
} ,
is _image _file ( fileName = '' ) {
is _image _file ( fileName = '' ) {
const ext = /\./ . test ( fileName ) ? fileName . split ( '.' ) . pop ( ) . toLowerCase ( ) : ''
const ext = /\./ . test ( fileName ) ? fileName . split ( '.' ) . pop ( ) . toLowerCase ( ) : ''
return wo . envar . imageExtensionList ? . includes ? . ( ext )
return wo . ss . imageExtensionList ? . includes ? . ( ext )
} ,
} ,
is _video _file ( fileName = '' ) {
is _video _file ( fileName = '' ) {
const ext = /\./ . test ( fileName ) ? fileName . split ( '.' ) . pop ( ) . toLowerCase ( ) : ''
const ext = /\./ . test ( fileName ) ? fileName . split ( '.' ) . pop ( ) . toLowerCase ( ) : ''
return wo . envar . videoExtensionList ? . includes ? . ( ext )
return wo . ss . videoExtensionList ? . includes ? . ( ext )
} ,
} ,
is _audio _file ( fileName = '' ) {
is _audio _file ( fileName = '' ) {
const ext = /\./ . test ( fileName ) ? fileName . split ( '.' ) . pop ( ) . toLowerCase ( ) : ''
const ext = /\./ . test ( fileName ) ? fileName . split ( '.' ) . pop ( ) . toLowerCase ( ) : ''
return wo . envar . audioExtensionList ? . includes ? . ( ext )
return wo . ss . audioExtensionList ? . includes ? . ( ext )
} ,
} ,
thisPage ( ) {
thisPage ( ) {
@@ -101,12 +101,12 @@ module.exports = {
windowTitle =
windowTitle =
windowTitle ||
windowTitle ||
this . localizeText ( wo ? . envar ? . callnames , { langCode : langNow } ) ||
this . localizeText ( wo ? . ss ? . callnames , { langCode : langNow } ) ||
this . localizeText ( wo ? . pagesJson ? . appInfo ? . i18nText , { langCode : langNow } ) ||
this . localizeText ( wo ? . pagesJson ? . appInfo ? . i18nText , { langCode : langNow } ) ||
wo ? . pagesJson ? . globalStyle ? . navigationBarTitleText ||
wo ? . pagesJson ? . globalStyle ? . navigationBarTitleText ||
''
''
if ( wo . envar . _clientInfo . deviceType === 'pc' ) {
if ( wo . ss . _clientInfo . deviceType === 'pc' ) {
uni . setNavigationBarTitle ( { title : windowTitle + ( navibarTitle ? ` - ${ navibarTitle } ` : '' ) } )
uni . setNavigationBarTitle ( { title : windowTitle + ( navibarTitle ? ` - ${ navibarTitle } ` : '' ) } )
} else {
} else {
uni . setNavigationBarTitle ( { title : navibarTitle } )
uni . setNavigationBarTitle ( { title : navibarTitle } )
@@ -116,7 +116,7 @@ module.exports = {
//// 设置窗口标题栏 document.title
//// 设置窗口标题栏 document.title
//// navibarTitle 也会被用于浏览器的标签标题,可用 document.title 去覆盖。必须放在 setNavigationBarTitle 之后。
//// navibarTitle 也会被用于浏览器的标签标题,可用 document.title 去覆盖。必须放在 setNavigationBarTitle 之后。
//// 但这个方案,在电脑上,还是会显示 navibarTitle 在浏览器窗口顶栏,不知为何。
//// 但这个方案,在电脑上,还是会显示 navibarTitle 在浏览器窗口顶栏,不知为何。
if ( wo . envar . _clientInfo . deviceType !== 'pc' && /MicroMessenger/i . test ( globalThis . window ? . navigator ? . userAgent ) ) {
if ( wo . ss . _clientInfo . deviceType !== 'pc' && /MicroMessenger/i . test ( globalThis . window ? . navigator ? . userAgent ) ) {
//// 微信浏览器里,本身就显示了标题栏,和自有的导航栏形成功能重叠和混淆。
//// 微信浏览器里,本身就显示了标题栏,和自有的导航栏形成功能重叠和混淆。
//// 设置标题栏为空或覆盖
//// 设置标题栏为空或覆盖
document . title = windowTitle
document . title = windowTitle
@@ -125,7 +125,7 @@ module.exports = {
}
}
//#endif
//#endif
if ( wo . envar . _clientInfo . deviceType === 'pc' ) {
if ( wo . ss . _clientInfo . deviceType === 'pc' ) {
uni . hideTabBar ( )
uni . hideTabBar ( )
} else {
} else {
// 必须要在有 tab 的页面里 setTabBarItem 才有效果
// 必须要在有 tab 的页面里 setTabBarItem 才有效果
@@ -146,7 +146,7 @@ module.exports = {
}
}
} ,
} ,
make _server _url ( route , { envar = globalThis . wo ? . envar , fullUrl = false } = { } ) {
make _server _url ( route , { envar = globalThis . wo ? . ss , fullUrl = false } = { } ) {
if ( typeof route === 'string' ) route = route . replace ( '\\' , '/' )
if ( typeof route === 'string' ) route = route . replace ( '\\' , '/' )
else if ( route ? . apiWho && route ? . apiTodo ) {
else if ( route ? . apiWho && route ? . apiTodo ) {
const { apiVersion = 'api' , apiWho , apiTodo } = route
const { apiVersion = 'api' , apiWho , apiTodo } = route
@@ -196,7 +196,7 @@ module.exports = {
* - CLINET_WOBASE_EXCEPTION: 前端发现后台异常
* - CLINET_WOBASE_EXCEPTION: 前端发现后台异常
**/
**/
async callBase ( {
async callBase ( {
baseType = globalThis . wo ? . envar ? . baseTypeDefault || this . BASE _TYPE _DEFAULT ,
baseType = globalThis . wo ? . ss ? . baseTypeDefault || this . BASE _TYPE _DEFAULT ,
httpMethod = 'POST' ,
httpMethod = 'POST' ,
apiVersion = 'api' ,
apiVersion = 'api' ,
apiWho ,
apiWho ,
@@ -208,7 +208,7 @@ module.exports = {
const startTime = new Date ( ) . toJSON ( )
const startTime = new Date ( ) . toJSON ( )
let apiurl = undefined
let apiurl = undefined
apiWhat . _clientInfo = {
apiWhat . _clientInfo = {
... globalThis . wo ? . envar ? . _clientInfo ,
... globalThis . wo ? . ss ? . _clientInfo ,
lang : globalThis . wo ? . ss ? . i18n ? . mylang ,
lang : globalThis . wo ? . ss ? . i18n ? . mylang ,
// #ifdef WEB
// #ifdef WEB
requrl : globalThis . location ? . href ,
requrl : globalThis . location ? . href ,
@@ -386,7 +386,7 @@ module.exports = {
// https://uniapp.dcloud.net.cn/api/media/file.html
// https://uniapp.dcloud.net.cn/api/media/file.html
let [ errorChoose , { tempFilePaths , tempFiles } = { } ] = await uni . chooseFile ( {
let [ errorChoose , { tempFilePaths , tempFiles } = { } ] = await uni . chooseFile ( {
count ,
count ,
extension : wo . envar . audioExtensionList ,
extension : wo . ss . audioExtensionList ,
type : undefined ,
type : undefined ,
} ) // 20240429 但是测试下来 extension 参数无效
} ) // 20240429 但是测试下来 extension 参数无效
if ( errorChoose ) {
if ( errorChoose ) {
@@ -431,8 +431,8 @@ module.exports = {
_state : 'CER_EMPTY_FILE' ,
_state : 'CER_EMPTY_FILE' ,
_msg : { zhCN : '文件为空,无法上传:\n' + fileName , enUS : 'Empty files cannot be uploaded:\n' + fileName } ,
_msg : { zhCN : '文件为空,无法上传:\n' + fileName , enUS : 'Empty files cannot be uploaded:\n' + fileName } ,
}
}
} else if ( fileSize > ( globalThis . wo ? . envar ? . fileSizeLimit || 10485760 ) ) {
} else if ( fileSize > ( globalThis . wo ? . ss ? . fileSizeLimit || 10485760 ) ) {
let sizeLimitMB = parseInt ( ( globalThis . wo ? . envar ? . fileSizeLimit || 10485760 ) / 1048576 ) + 'MB'
let sizeLimitMB = parseInt ( ( globalThis . wo ? . ss ? . fileSizeLimit || 10485760 ) / 1048576 ) + 'MB'
return {
return {
_state : 'CER_FILE_TOO_LARGE' ,
_state : 'CER_FILE_TOO_LARGE' ,
_msg : { zhCN : ` 文件大于 ${ sizeLimitMB } ,无法上传 ` , enUS : ` The file exceeds ${ sizeLimitMB } and cannot be uploaded ` } ,
_msg : { zhCN : ` 文件大于 ${ sizeLimitMB } ,无法上传 ` , enUS : ` The file exceeds ${ sizeLimitMB } and cannot be uploaded ` } ,
@@ -520,7 +520,7 @@ module.exports = {
fileSize = fileDragged . size
fileSize = fileDragged . size
filePath = fileDragged . filePath
filePath = fileDragged . filePath
filePicked = fileDragged
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 . ss . _clientInfo . osName } _ ${ random } _ ${ path . extname ( fileDragged . name || { image : '.jpg' , video : '.mp4' } [mediaType] || '')} ` // tempFile and name are H5 only
} else if ( mediaType === 'image' ) {
} else if ( mediaType === 'image' ) {
let [ errorChoose , { tempFilePaths , tempFiles } = { } ] = await uni . chooseImage ( { count , sizeType , sourceType } )
let [ errorChoose , { tempFilePaths , tempFiles } = { } ] = await uni . chooseImage ( { count , sizeType , sourceType } )
if ( errorChoose ) {
if ( errorChoose ) {
@@ -535,10 +535,10 @@ module.exports = {
// #ifndef WEB
// #ifndef WEB
// 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_ ${ wo . envar . _clientInfo . osName } _ ${ random } ${ path . extname ( filePath || '.jpg' ) } `
cloudPath = ` APP_ ${ wo . ss . _clientInfo . osName } _ ${ random } ${ path . extname ( filePath || '.jpg' ) } `
// #endif
// #endif
// #ifdef WEB
// #ifdef WEB
cloudPath = ` WEB_ ${ wo . envar . _clientInfo . osName } _ ${ random } ${ path . extname ( tempFiles ? . [ 0 ] ? . name || '.jpg' ) } ` // name is available in H5 only. 只包含文件名和后缀名,不包含路径。
cloudPath = ` WEB_ ${ wo . ss . _clientInfo . osName } _ ${ random } ${ path . extname ( tempFiles ? . [ 0 ] ? . name || '.jpg' ) } ` // 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 } )
@@ -552,10 +552,10 @@ module.exports = {
filePicked = tempFile
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"
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
// #ifndef WEB
cloudPath = ` APP_ ${ wo . envar . _clientInfo . osName } _ ${ random } _dur ${ duration } ${ path . extname ( filePath || '.mp4' ) } `
cloudPath = ` APP_ ${ wo . ss . _clientInfo . osName } _ ${ random } _dur ${ duration } ${ path . extname ( filePath || '.mp4' ) } `
// #endif
// #endif
// #ifdef WEB
// #ifdef WEB
cloudPath = ` WEB_ ${ wo . envar . _clientInfo . osName } _ ${ random } _dur ${ duration } ${ path . extname ( name || '.mp4' ) } ` // tempFile and name are H5 only
cloudPath = ` WEB_ ${ wo . ss . _clientInfo . osName } _ ${ random } _dur ${ duration } ${ path . extname ( name || '.mp4' ) } ` // 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 了。
@@ -579,7 +579,7 @@ module.exports = {
fileSize = tempFiles ? . [ 0 ] ? . size
fileSize = tempFiles ? . [ 0 ] ? . size
filePicked = tempFiles ? . [ 0 ]
filePicked = tempFiles ? . [ 0 ]
filePath = tempFilePaths ? . [ 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 . ss . _clientInfo . osName } _ ${ random } ${ path . extname ( tempFiles ? . [ 0 ] ? . name || '' ) } ` // name is available in H5 only. 只包含文件名和后缀名,不包含路径。
// #endif
// #endif
// #ifndef WEB
// #ifndef WEB
return { _state : 'UNSUPPORTED_FILETYPE' , _msg : { zhCN : '请切换到网页端上传文件!' , enUS : 'Please switch to Web App to upload files.' } }
return { _state : 'UNSUPPORTED_FILETYPE' , _msg : { zhCN : '请切换到网页端上传文件!' , enUS : 'Please switch to Web App to upload files.' } }
@@ -590,8 +590,8 @@ module.exports = {
if ( ! fileSize ) {
if ( ! fileSize ) {
return { _state : 'CER_EMPTY_FILE' , _msg : { zhCN : '文件为空,无法上传:\n' + fileName , enUS : 'Empty files cannot be uploaded:\n' + fileName } }
return { _state : 'CER_EMPTY_FILE' , _msg : { zhCN : '文件为空,无法上传:\n' + fileName , enUS : 'Empty files cannot be uploaded:\n' + fileName } }
} else if ( fileSize > ( globalThis . wo ? . envar ? . fileSizeLimit || 10485760 ) ) {
} else if ( fileSize > ( globalThis . wo ? . ss ? . fileSizeLimit || 10485760 ) ) {
let sizeLimitMB = parseInt ( ( globalThis . wo ? . envar ? . fileSizeLimit || 10485760 ) / 1048576 ) + 'MB'
let sizeLimitMB = parseInt ( ( globalThis . wo ? . ss ? . fileSizeLimit || 10485760 ) / 1048576 ) + 'MB'
return {
return {
_state : 'CER_FILE_TOO_LARGE' ,
_state : 'CER_FILE_TOO_LARGE' ,
_msg : { zhCN : ` 文件大于 ${ sizeLimitMB } ,无法上传 ` , enUS : ` The file exceeds ${ sizeLimitMB } and cannot be uploaded ` } ,
_msg : { zhCN : ` 文件大于 ${ sizeLimitMB } ,无法上传 ` , enUS : ` The file exceeds ${ sizeLimitMB } and cannot be uploaded ` } ,
@@ -643,7 +643,7 @@ module.exports = {
} ,
} ,
async pickupFile ( {
async pickupFile ( {
baseType = globalThis . wo ? . envar ? . baseTypeDefault || this . BASE _TYPE _DEFAULT ,
baseType = globalThis . wo ? . ss ? . baseTypeDefault || this . BASE _TYPE _DEFAULT ,
fileDragged ,
fileDragged ,
mediaType = 'image' , // could be image, video, array of supported extensions, anything else // 20240502 todo: rename to pickupFileType
mediaType = 'image' , // could be image, video, array of supported extensions, anything else // 20240502 todo: rename to pickupFileType
count = 1 ,
count = 1 ,
@@ -669,7 +669,7 @@ module.exports = {
if ( ! url ) {
if ( ! url ) {
return
return
}
}
if ( wo . envar . inPc ) {
if ( wo . ss . inPc ) {
window . open ( url , '_blank' )
window . open ( url , '_blank' )
} else if ( inWebview ) {
} else if ( inWebview ) {
wo . ss . webviewUrl = url
wo . ss . webviewUrl = url
@@ -695,7 +695,7 @@ module.exports = {
} ,
} ,
open _url _in _webview ( { url , title } ) {
open _url _in _webview ( { url , title } ) {
url = this . localizeText ? . ( url ) || url
url = this . localizeText ? . ( url ) || url
if ( wo . envar . inPc ) {
if ( wo . ss . inPc ) {
window . open ( url , '_blank' )
window . open ( url , '_blank' )
} else {
} else {
wo . ss . webviewUrl = url
wo . ss . webviewUrl = url