修复跳转问题
This commit is contained in:
parent
0ed0b02473
commit
ae808e9d4c
@ -6,7 +6,9 @@ const router = createRouter({
|
||||
routes: [
|
||||
{
|
||||
path: "/",
|
||||
redirect: "/loading", // 默认跳转到加载页面
|
||||
name: "root",
|
||||
component: () => import("../views/LoadingView.vue"),
|
||||
meta: { requiresAuth: false, isPublic: true },
|
||||
},
|
||||
{
|
||||
path: "/loading",
|
||||
|
||||
@ -396,17 +396,11 @@ class RouteGuard {
|
||||
*/
|
||||
isPublicPage(path) {
|
||||
const publicPages = [
|
||||
PAGES.APPLY, // 申请页面 - 重要:申请页面不需要权限检查
|
||||
PAGES.NOT_APP, // 错误页面 - APP连接失败时的页面
|
||||
"/404", // 404页面
|
||||
"/error", // 通用错误页面
|
||||
|
||||
// "/admin-center", //管理员中心(临时配置)
|
||||
"/item-distribution", //赠送页面(临时配置)
|
||||
"/recharge", //支付前页面(临时配置)
|
||||
"/recharge-standard", //标准支付页面(临时配置)
|
||||
"/recharge-freight-agent", //金币代理支付页面(临时配置)
|
||||
];
|
||||
PAGES.APPLY, // 申请页面 - 重要:申请页面不需要权限检查
|
||||
PAGES.NOT_APP, // 错误页面 - APP连接失败时的页面
|
||||
'/404', // 404页面
|
||||
'/error' // 通用错误页面
|
||||
]
|
||||
return publicPages.includes(path);
|
||||
}
|
||||
|
||||
|
||||
@ -53,6 +53,31 @@ import {getDefaultPage} from "@/utils/permissionManager.js";
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
// 检查是否应该执行重定向
|
||||
const checkShouldRedirect = () => {
|
||||
const currentRoute = router.currentRoute.value
|
||||
const currentPath = currentRoute.path
|
||||
const routeName = currentRoute.name
|
||||
|
||||
console.log('Checking redirect conditions:', {
|
||||
path: currentPath,
|
||||
name: routeName,
|
||||
url: window.location.href
|
||||
})
|
||||
|
||||
// 只有当访问根路径或loading页面时,才执行自动跳转
|
||||
const isRootAccess = currentPath === '/' || routeName === 'root'
|
||||
const isLoadingAccess = currentPath === '/loading' || routeName === 'loading'
|
||||
|
||||
console.log('Redirect decision:', {
|
||||
isRootAccess,
|
||||
isLoadingAccess,
|
||||
shouldRedirect: isRootAccess || isLoadingAccess
|
||||
})
|
||||
|
||||
return isRootAccess || isLoadingAccess
|
||||
}
|
||||
|
||||
// 响应式数据
|
||||
const loadingText = ref('Initializing...')
|
||||
const subText = ref('Setting up your experience')
|
||||
@ -73,6 +98,14 @@ let stepTimeout = null
|
||||
// 开始加载流程
|
||||
const startLoading = async () => {
|
||||
try {
|
||||
// 检查是否应该执行自动跳转
|
||||
const shouldRedirect = checkShouldRedirect()
|
||||
|
||||
if (!shouldRedirect) {
|
||||
console.log('User accessed specific path directly, not performing redirect')
|
||||
return
|
||||
}
|
||||
|
||||
// 如果在APP环境中,进行连接
|
||||
if (isInApp()) {
|
||||
await connectToApp()
|
||||
@ -160,9 +193,26 @@ const waitForLoadingComplete = () => {
|
||||
// 跳转到目标页面
|
||||
const navigateToTargetPage = async () => {
|
||||
try {
|
||||
router.replace(getDefaultPage())
|
||||
// 获取当前路由信息
|
||||
const currentRoute = router.currentRoute.value
|
||||
const currentPath = currentRoute.path
|
||||
const routeName = currentRoute.name
|
||||
|
||||
console.log('Current path:', currentPath)
|
||||
console.log('Route name:', routeName)
|
||||
|
||||
// 只有当访问根路径 ("/") 或者 loading 页面时,才跳转到默认页面
|
||||
// 其他所有具体路径都不应该被重定向
|
||||
if (currentPath === '/' || routeName === 'root' || currentPath === '/loading' || routeName === 'loading') {
|
||||
console.log('Navigating to default page from root or loading')
|
||||
router.replace(getDefaultPage())
|
||||
} else {
|
||||
console.log('User accessed specific path, not redirecting:', currentPath)
|
||||
// 如果用户直接访问了具体路径,不进行任何跳转
|
||||
return
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to get team entry:', error)
|
||||
console.error('Failed to get default page:', error)
|
||||
// 出错时跳转到申请页面
|
||||
router.replace('/apply')
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user