You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
5.5 KiB
174 lines
5.5 KiB
import { createRouter, createWebHistory } from 'vue-router'
|
|
import Layout from '../layout/Layout.vue'
|
|
|
|
const routes = [
|
|
{
|
|
path: '/',
|
|
redirect: '/userPermissions/market'
|
|
},
|
|
{
|
|
path: '/login',
|
|
name: 'login',
|
|
component: () => import('../views/Login.vue'),
|
|
meta: {
|
|
title: '登录',
|
|
hiddenSidebar: true,
|
|
requireAuth: false // 登录页不需要登录
|
|
}
|
|
},
|
|
{
|
|
path: '',
|
|
component: Layout,
|
|
meta: {
|
|
requireAuth: true // Layout下所有子路由都需要登录
|
|
},
|
|
children: [
|
|
{
|
|
path: 'userPermissions',
|
|
name: 'userPermissions',
|
|
meta: { title: '用户权限管理', icon: "UserFilled", showSidebar: true, isParentNav: true },
|
|
children: [
|
|
{
|
|
path: 'market',
|
|
name: 'market',
|
|
component: () => import('../views/UserPermissions/Market.vue'),
|
|
meta: { title: '行情期限', showSidebar: true }
|
|
},
|
|
{
|
|
path: 'module',
|
|
name: 'module',
|
|
component: () => import('../views/UserPermissions/Module.vue'),
|
|
meta: { title: '模块期限', showSidebar: true }
|
|
},
|
|
{
|
|
path: 'invitedLook',
|
|
name: 'invitedLook',
|
|
component: () => import('../views/UserPermissions/invitedLook.vue'),
|
|
meta: { title: '查看被邀请用户', showSidebar: true }
|
|
},
|
|
// 深度探索--操作日志
|
|
{
|
|
path: 'logDeepexplore',
|
|
name: 'logDeepexplore',
|
|
component: () => import('../views/UserPermissions/LogDeepExplore.vue'),
|
|
meta: { hidden: true }
|
|
},
|
|
// DeepMate--操作日志
|
|
{
|
|
path: 'logDeepMate',
|
|
name: 'logDeepMate',
|
|
component: () => import('../views/UserPermissions/LogDeepMate.vue'),
|
|
meta: { hidden: true }
|
|
},
|
|
// 行情期限--操作日志
|
|
{
|
|
path: 'logMarket',
|
|
name: 'logMarket',
|
|
component: () => import('../views/UserPermissions/LogMarket.vue'),
|
|
meta: { hidden: true }
|
|
},
|
|
// 导出列表页面
|
|
{
|
|
path: 'export',
|
|
name: 'export',
|
|
component: () => import('../views/UserPermissions/Export.vue'),
|
|
meta: { hidden: true }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: 'platformData',
|
|
name: 'platformData',
|
|
meta: { title: '平台数据管理', icon: "TrendCharts", showSidebar: true, isParentNav: true },
|
|
children: [
|
|
{
|
|
path: 'overview',
|
|
name: 'overview',
|
|
component: () => import('../views/PlatformData/UserOverview.vue'),
|
|
meta: { title: '用户数据概览', showSidebar: true }
|
|
},
|
|
{
|
|
path: 'loginStats',
|
|
name: 'loginStats',
|
|
component: () => import('../views/PlatformData/UserLoginStats.vue'),
|
|
meta: { title: '用户登录统计', showSidebar: true }
|
|
},
|
|
{
|
|
path: 'activityStats',
|
|
name: 'activityStats',
|
|
component: () => import('../views/PlatformData/UserActivityStats.vue'),
|
|
meta: { title: '用户活跃度统计', showSidebar: true }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: 'EventManagement',
|
|
name: 'EventManagement',
|
|
meta: { title: '活动管理', icon: "Management", showSidebar: true, isParentNav: true },
|
|
children: [
|
|
{
|
|
path: 'NewYearAct',
|
|
name: 'NewYearAct',
|
|
meta: { title: '新年幸运签', showSidebar: true },
|
|
children: [
|
|
{
|
|
path: 'winningRecords',
|
|
name: 'winningRecords',
|
|
component: () => import('../views/EventManagement/WinningRecords.vue'),
|
|
meta: { title: '历史记录', showSidebar: true }
|
|
},
|
|
{
|
|
path: 'contentConfiguration',
|
|
name: 'contentConfiguration',
|
|
component: () => import('../views/EventManagement/ContentConfiguration.vue'),
|
|
meta: { title: '内容配置', showSidebar: true }
|
|
},
|
|
{
|
|
path: 'exchangeRecords',
|
|
name: 'exchangeRecords',
|
|
component: () => import('../views/EventManagement/ExchangeRecords.vue'),
|
|
meta: { title: 'Token兑换记录', showSidebar: true }
|
|
},
|
|
{
|
|
path: 'learningPageConfig',
|
|
name: 'learningPageConfig',
|
|
component: () => import('../views/EventManagement/LearningPageConfig.vue'),
|
|
meta: { title: '学习页配置', showSidebar: true }
|
|
},
|
|
]
|
|
},
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes
|
|
})
|
|
|
|
// 全局前置守卫
|
|
router.beforeEach((to, from, next) => {
|
|
// 登录状态判断
|
|
const token = localStorage.getItem('token')
|
|
|
|
// 权限拦截逻辑
|
|
if (to.meta.requireAuth) {
|
|
// 目标页面需要登录:已登录→放行,未登录→跳登录页
|
|
if (token) {
|
|
next() // 已登录,放行
|
|
} else {
|
|
next({ path: '/login' }) // 跳登录页
|
|
}
|
|
} else {
|
|
// 目标页面不需要登录:已登录→跳首页,未登录→放行
|
|
if (token && to.path === '/login') {
|
|
next('/') // 自动跳首页
|
|
} else {
|
|
next() // 未登录,放行到登录页
|
|
}
|
|
}
|
|
})
|
|
|
|
export default router
|