diff --git a/src/utils/routeGuard.js b/src/utils/routeGuard.js index fddcb6c..9ea7319 100644 --- a/src/utils/routeGuard.js +++ b/src/utils/routeGuard.js @@ -19,7 +19,7 @@ import { appConnectionManager, isAppConnected } from './appConnectionManager.js' * APP连接检查器 */ class AppConnectionChecker { - constructor() { + constructor () { this.isConnecting = false } @@ -27,7 +27,7 @@ class AppConnectionChecker { * 确保APP连接 * @returns {Promise} 连接是否成功 */ - async ensureConnection() { + async ensureConnection () { console.debug('🔗 Checking APP connection...') // 如果不在APP环境中,直接返回成功 @@ -66,7 +66,7 @@ class AppConnectionChecker { * 执行APP连接 * @returns {Promise} */ - async _performConnection() { + async _performConnection () { try { console.debug('📱 Starting new APP connection...') @@ -120,7 +120,7 @@ class AppConnectionChecker { * APP连接成功后获取用户信息 * @private */ - async _fetchUserInfoAfterConnection() { + async _fetchUserInfoAfterConnection () { try { console.debug('👤 Fetching user info after connection...') @@ -143,7 +143,7 @@ class AppConnectionChecker { /** * 重置连接状态 */ - reset() { + reset () { appConnectionManager.reset() } } @@ -152,7 +152,7 @@ class AppConnectionChecker { * 身份检查器 */ class IdentityChecker { - constructor() { + constructor () { this.isChecking = false this.checkPromise = null } @@ -162,7 +162,7 @@ class IdentityChecker { * @param {string} userId - 用户ID * @returns {Promise} 返回主要身份 */ - async checkUserIdentity(userId) { + async checkUserIdentity (userId) { if (!userId) { console.warn('⚠️ No user ID provided') permissionManager.setUserIdentity(null) @@ -192,7 +192,7 @@ class IdentityChecker { * @param {string} userId - 用户ID * @returns {Promise} 主要身份 */ - async _performIdentityCheck(userId) { + async _performIdentityCheck (userId) { try { console.debug('🔍 Checking user identity for:', userId) @@ -221,7 +221,7 @@ class IdentityChecker { /** * 重置检查状态 */ - reset() { + reset () { this.isChecking = false this.checkPromise = null } @@ -238,7 +238,7 @@ class PageRedirector { * @param {string} currentPath - 当前页面路径 * @returns {Promise} 是否进行了重定向 */ - async redirectToCorrectPage(router, targetPath, currentPath) { + async redirectToCorrectPage (router, targetPath, currentPath) { const primaryRole = permissionManager.getPrimaryRole() // 检查目标页面权限 @@ -277,7 +277,7 @@ class PageRedirector { * @param {Object} router - Vue Router 实例 * @param {string} attemptedPage - 尝试访问的页面 */ - async handleUnauthorizedAccess(router, attemptedPage) { + async handleUnauthorizedAccess (router, attemptedPage) { const primaryRole = permissionManager.getPrimaryRole() const defaultPage = permissionManager.getDefaultPage() @@ -296,7 +296,7 @@ class PageRedirector { * 路由守卫类 */ class RouteGuard { - constructor() { + constructor () { this.appConnectionChecker = new AppConnectionChecker() this.identityChecker = new IdentityChecker() this.pageRedirector = new PageRedirector() @@ -307,7 +307,7 @@ class RouteGuard { * 安装路由守卫 * @param {Object} router - Vue Router 实例 */ - install(router) { + install (router) { router.beforeEach(async (to, from, next) => { await this.handleRouteChange(to, from, next) }) @@ -322,7 +322,7 @@ class RouteGuard { * @param {Object} from - 来源路由 * @param {Function} next - 路由继续函数 */ - async handleRouteChange(to, from, next) { + async handleRouteChange (to, from, next) { console.group('🛡️ Route Guard Check') console.debug('📍 Route change:', from.path, '→', to.path) @@ -394,7 +394,7 @@ class RouteGuard { * @param {string} path - 页面路径 * @returns {boolean} */ - isPublicPage(path) { + isPublicPage (path) { const publicPages = [ PAGES.APPLY, // 申请页面 - 重要:申请页面不需要权限检查 PAGES.NOT_APP, // 错误页面 - APP连接失败时的页面 @@ -404,6 +404,8 @@ class RouteGuard { '/recharge', '/recharge-freight-agent', '/pay-result', + '/top-list', //排行榜 + '/weekly-star', //每周明星 ] return publicPages.includes(path) } @@ -413,7 +415,7 @@ class RouteGuard { * @param {Object} router - Vue Router 实例 * @param {string} userId - 用户ID */ - async checkAndRedirect(router, userId) { + async checkAndRedirect (router, userId) { try { console.debug('🔄 Manual identity check and redirect') @@ -441,7 +443,7 @@ class RouteGuard { /** * 重置守卫状态 */ - reset() { + reset () { this.appConnectionChecker.reset() this.identityChecker.reset() permissionManager.reset()