forked from wangziqi/gongxue-base
fix: prefer H5 pathname for route guard
This commit is contained in:
@@ -24,14 +24,13 @@ function forbiddenUrl(reason: string, redirectPath: string) {
|
||||
}
|
||||
|
||||
export function currentPagePath() {
|
||||
const instance = Taro.getCurrentInstance();
|
||||
const path = instance.router?.path || '';
|
||||
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
||||
if (normalizedPath !== '/') return normalizedPath;
|
||||
if (isH5Runtime() && typeof window !== 'undefined') {
|
||||
const pathname = window.location.pathname || '';
|
||||
if (pathname.startsWith('/pages/')) return pathname;
|
||||
}
|
||||
const instance = Taro.getCurrentInstance();
|
||||
const path = instance.router?.path || '';
|
||||
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
||||
return normalizedPath;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user