1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-09-12 16:40:40 +08:00

refactor: 架构升级

This commit is contained in:
小莫唐尼
2026-08-31 07:58:23 +08:00
commit ba5b77568b
693 changed files with 118430 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
import { getLastPage } from '@/utils'
import { debounce } from '@/utils/debounce'
interface ToLoginPageOptions {
/**
* 跳转模式, uni.navigateTo | uni.reLaunch
* @default 'navigateTo'
*/
mode?: 'navigateTo' | 'reLaunch'
/**
* 查询参数
* @example '?redirect=/pages/home/index'
*/
queryString?: string
}
// TODO: 自己增加登录页
const LOGIN_PAGE = '/pages/login/index'
/**
* 跳转到登录页, 带防抖处理
*
* 如果要立即跳转,不做延时,可以使用 `toLoginPage.flush()` 方法
*/
export const toLoginPage = debounce((options: ToLoginPageOptions = {}) => {
const { mode = 'navigateTo', queryString = '' } = options
const url = `${LOGIN_PAGE}${queryString}`
// 获取当前页面路径
const currentPage = getLastPage()
const currentPath = `/${currentPage.route}`
// 如果已经在登录页,则不跳转
if (currentPath === LOGIN_PAGE) {
return
}
if (mode === 'navigateTo') {
uni.navigateTo({ url })
}
else {
uni.reLaunch({ url })
}
}, 500)