chore: initial commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
const HOME_URL = '/pages/home/home'
|
||||
|
||||
export function getCurrentRoute() {
|
||||
if (typeof getCurrentPages !== 'function') return ''
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
return currentPage ? currentPage.route || '' : ''
|
||||
}
|
||||
|
||||
export function navigateBackOr(fallbackUrl = HOME_URL) {
|
||||
const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : []
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack({ fail: () => uni.reLaunch({ url: fallbackUrl }) })
|
||||
return
|
||||
}
|
||||
uni.reLaunch({ url: fallbackUrl })
|
||||
}
|
||||
|
||||
export function navigateToUnique(url) {
|
||||
const route = url.split('?')[0].replace(/^\//, '')
|
||||
if (getCurrentRoute() === route) return
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
Reference in New Issue
Block a user