提交 b3b2d134 编写于 作者: D DCloud_LXH

chore(App): isTabBarPage、getStatusbarHeight、uuid

上级 e261637c
......@@ -78,3 +78,32 @@ export function callApiSync<T extends (...args: any) => any>(
reject(errMsg)
})
}
export function isTabBarPage(path = '') {
if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) {
return false
}
try {
if (!path) {
const pages = getCurrentPages()
if (!pages.length) {
return false
}
const page = pages[pages.length - 1]
if (!page) {
return false
}
return page.$page.meta.isTabBar
}
if (!/^\//.test(path)) {
path = '/' + path
}
const route = __uniRoutes.find((route) => route.path === path)
return route && route.meta.isTabBar
} catch (e) {
if (process.env.NODE_ENV !== 'production') {
console.log('getCurrentPages is not ready')
}
}
return false
}
export function getStatusbarHeight() {
// 横屏时 iOS 获取的状态栏高度错误,进行纠正
return plus.navigator.isImmersedStatusbar()
? Math.round(
plus.os.name! === 'iOS'
? plus.navigator.getSafeAreaInsets().top!
: plus.navigator.getStatusbarHeight()
)
: 0
}
let deviceId: string
interface _PlusRuntime extends PlusRuntime {
getDCloudId: (...args: any[]) => string
}
export default function () {
deviceId = deviceId || (plus.runtime as _PlusRuntime).getDCloudId()
return deviceId
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册