u
This commit is contained in:
parent
53e3aff7b0
commit
2cc8f66651
41
unitool.js
41
unitool.js
@ -37,7 +37,7 @@ export default {
|
||||
thisPage () {
|
||||
return this.__page__
|
||||
? this // constructor.name==='VueComponent' 只在 development 环境有用,在 production 环境会被简化成 'o'。
|
||||
: getCurrentPages().pop() || {} // [20220401] 发现在 topWindow 里,或者在 App.vue 里, getCurrentPages() 是 undefined 和 空数组 [],因此在这里默认 {} 做保护。
|
||||
: getCurrentPages()?.pop?.() || {} // [20220401] 发现在 topWindow 里,或者在 App.vue 里, getCurrentPages() 是 undefined 和 空数组 [],因此在这里默认 {} 做保护。
|
||||
},
|
||||
|
||||
localizeText (i18nText) {
|
||||
@ -167,7 +167,9 @@ export default {
|
||||
const thisRoute = getCurrentPages()?.pop?.()?.route || 'VueApp' // 立刻保存 route,因为在调用后台后,可能已切换到了其他页面。
|
||||
const startTime = new Date().toJSON()
|
||||
let url = undefined
|
||||
apiWhat._clientInfo = globalThis.wo?.envar?.clientInfo
|
||||
// #ifdef H5
|
||||
apiWhat._clientInfo = Object.assign(globalThis.wo?.envar?.clientInfo, { url: globalThis.location?.href, lang: globalThis.wo?.ss?.i18n?.mylang })
|
||||
// #endif
|
||||
apiWhat._passtoken = uni.getStorageSync('_passtoken')
|
||||
let result = {}
|
||||
if (baseType === 'UNICLOUD_OBJECT') {
|
||||
@ -451,22 +453,8 @@ export default {
|
||||
})
|
||||
*/
|
||||
showToast ({ tool, type = 'success', image, title, duration = 2000, wo = globalThis.wo, ...rest } = {}) {
|
||||
// rename to popToast?
|
||||
if (tool !== 'uni') {
|
||||
// 来自 <ucToast> 或 <u-toast> 或 <u-top-tips>
|
||||
const toast = getCurrentPages()?.pop()?.$refs?.toast || getApp().globalData?.toast || wo?.toast
|
||||
const popup = getCurrentPages()?.pop()?.$refs?.popup || getApp().globalData?.popup || wo?.popup
|
||||
if (toast) {
|
||||
toast.show({ type, title, duration, ...rest })
|
||||
return
|
||||
} else if (popup && wo?.ss) {
|
||||
wo.ss.popMessage = title
|
||||
wo.ss.popType = type // success/error/warning/info
|
||||
wo.ss.popDuration = duration
|
||||
popup.open()
|
||||
return
|
||||
}
|
||||
}
|
||||
title = this.localizeText(title)
|
||||
if (tool === 'uni') {
|
||||
// #ifdef APP-PLUS
|
||||
uni.showToast({ icon: '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 })
|
||||
@ -474,6 +462,19 @@ export default {
|
||||
// #ifndef APP-PLUS
|
||||
uni.showToast({ icon: 'none', image, title, duration, ...rest })
|
||||
// #endif
|
||||
return
|
||||
}
|
||||
// 来自 <ucToast> 或 <u-toast> 或 <u-top-tips> // rename to popToast?
|
||||
const popup = getCurrentPages()?.pop()?.$refs?.popup || getApp().globalData?.popup || wo?.popup
|
||||
if (popup) {
|
||||
wo.ss.popMessage = title
|
||||
wo.ss.popType = type // success/error/warning/info
|
||||
wo.ss.popDuration = duration
|
||||
popup.open()
|
||||
} else {
|
||||
const toast = getCurrentPages()?.pop()?.$refs?.toast || getApp().globalData?.toast || wo?.toast
|
||||
toast?.show?.({ type, title, duration, ...rest })
|
||||
}
|
||||
},
|
||||
|
||||
showLoading ({ title = { zhCN: '加载中...', enUS: 'Loading...' }, mask } = {}) {
|
||||
@ -605,11 +606,11 @@ export default {
|
||||
next_focus (currentFocus, focusList) {
|
||||
focusList = focusList || getCurrentPages()?.pop()?.focusList
|
||||
if (focusList) {
|
||||
for (let n in focusList) {
|
||||
for (let n in focusList) { // 不论对数组或对象都有效,n 是数组的index 或对象的key
|
||||
focusList[n] = false
|
||||
}
|
||||
setTimeout(() => {
|
||||
focusList[(parseInt(currentFocus) + 1) % Object.keys(focusList).length] = true
|
||||
focusList[(currentFocus + 1) % Object.keys(focusList).length] = true
|
||||
}, 200) // 如果没有 setTimeout 至少 200ms, 焦点短暂跳到下一个后,又会消失
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user