修复跳转问题

This commit is contained in:
tianfeng 2025-09-05 12:11:47 +08:00
parent 0ed0b02473
commit ae808e9d4c
3 changed files with 60 additions and 14 deletions

View File

@ -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",

View File

@ -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);
}

View File

@ -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')
}