admin模块接入数据库
This commit is contained in:
@@ -39,23 +39,43 @@ export function getCurrentPageUrlWithQuery(): string {
|
||||
|
||||
export function toLoginWithRedirect(redirectUrl?: string, opts?: AuthRedirectOptions) {
|
||||
const loginPath = opts?.loginPath ?? '/pages/user/login'
|
||||
const registerPath = opts?.registerPath ?? '/pages/user/register'
|
||||
const fallback = opts?.fallbackUrl ?? '/pages/mall/consumer/index'
|
||||
const target = (redirectUrl != null && redirectUrl.length > 0)
|
||||
|
||||
let target = (redirectUrl != null && redirectUrl.length > 0)
|
||||
? redirectUrl
|
||||
: (getCurrentPageUrlWithQuery() || fallback)
|
||||
|
||||
// 避免 redirect 无限嵌套:如果目标本身就是 login/register,则回落到 fallback
|
||||
const normalizedLogin = normalizePath(loginPath)
|
||||
const normalizedRegister = normalizePath(registerPath)
|
||||
const normalizedTarget = normalizePath(target.split('?')[0] ?? '')
|
||||
if (normalizedTarget === normalizedLogin || normalizedTarget === normalizedRegister) {
|
||||
target = fallback
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: `${loginPath}?redirect=${safeEncode(target)}`
|
||||
})
|
||||
}
|
||||
|
||||
export function toRegisterWithRedirect(redirectUrl?: string, opts?: AuthRedirectOptions) {
|
||||
const loginPath = opts?.loginPath ?? '/pages/user/login'
|
||||
const registerPath = opts?.registerPath ?? '/pages/user/register'
|
||||
const fallback = opts?.fallbackUrl ?? '/pages/mall/consumer/index'
|
||||
const target = (redirectUrl != null && redirectUrl.length > 0)
|
||||
|
||||
let target = (redirectUrl != null && redirectUrl.length > 0)
|
||||
? redirectUrl
|
||||
: (getCurrentPageUrlWithQuery() || fallback)
|
||||
|
||||
// 避免 redirect 无限嵌套:如果目标本身就是 login/register,则回落到 fallback
|
||||
const normalizedLogin = normalizePath(loginPath)
|
||||
const normalizedRegister = normalizePath(registerPath)
|
||||
const normalizedTarget = normalizePath(target.split('?')[0] ?? '')
|
||||
if (normalizedTarget === normalizedLogin || normalizedTarget === normalizedRegister) {
|
||||
target = fallback
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: `${registerPath}?redirect=${safeEncode(target)}`
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user