en.js 12.1 KB
import {
  createWebHistory,
  createWebHashHistory,
  createRouter
} from 'vue-router'
/* Layout */
import Layout from '@/layoutPc'
import Empty from '@/layoutPc/empty'
// import useUserStore from '@/store/modules/user'

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * roles: ['admin', 'common']       // 访问路由的角色权限
 * permissions: ['a:a:a', 'b:b:b']  // 访问路由的菜单权限
 * meta : {
    noCache: true                   // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标,对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false,则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性,则会高亮相对应的侧边栏。
  }
 */


// 公共路由
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/views/error/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error/401'),
    hidden: true
  },
  {
    path: '/index',
    redirect: '/'
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/viewsPc/index_en'),
        name: 'home'
      },
      {
        path: 'authQuery',
        component: () => import('@/viewsPc/auth/index'),
        name: 'authQuery'
      },
      {
        path: 'authAccurate',
        component: () => import('@/viewsPc/auth/accurate'),
        name: 'authAccurate'
      },
      {
        path: 'about',
        component: Empty,
        redirect: '/about/index',
        children: [
          {
            path: 'wudao',
            component: () => import('@/viewsPc/about/wudao_en'),
            name: 'dangNews',
            meta: { title: 'about us' }
          },
          {
            path: 'culture',
            component: () => import('@/viewsPc/about/culture_en'),
            name: 'culture',
            meta: { title: 'culture' }
          },
          {
            path: 'regulations',
            component: () => import('@/viewsPc/about/fileList'),
            name: 'regulations',
            meta: { title: 'rules and regulations' }
          }
        ]
      },
      {
        path: 'notice',
        component: Empty,
        redirect: '/notice/index',
        children: [
          {
            path: 'index',
            component: () => import('@/viewsPc/notice/index_en'),
            name: 'notice',
            meta: { title: 'NOTICEBOARD' }
          },
          {
            path: 'index/list',
            component: () => import('@/viewsPc/notice/list'),
            name: 'noticeList',
            meta: { title: '资讯列表' }
          },
          {
            path: 'index/coverlist',
            component: () => import('@/viewsPc/notice/coverlist'),
            name: 'coverList',
            meta: { title: '图文列表' }
          },
          {
            path: 'index/fileList',
            component: () => import('@/viewsPc/notice/fileList'),
            name: 'fileList',
            meta: { title: '文件列表' }
          },
          {
            path: 'index/personList',
            component: () => import('@/viewsPc/notice/personList'),
            name: 'personList',
            meta: { title: '人员列表' }
          }
        ]
      },
      {
        path: 'news',
        component: Empty,
        redirect: '/news/index',
        children: [
          {
            path: 'index',
            component: () => import('@/viewsPc/news/index_en'),
            name: 'news',
            meta: { title: 'NEWS' }
          },
          {
            path: 'list/:id',
            component: () => import('@/viewsPc/news/list_en'),
            name: 'newsList',
            meta: { title: '新闻列表' }
          },
          {
            path: 'detail/:id',
            component: () => import('@/viewsPc/news/detail'),
            name: 'newsDetail',
            meta: { title: '新闻详情' }
          }
        ]
      },
      {
        path: 'nationalTeam',
        component: Empty,
        redirect: '/nationalTeam/index',
        children: [
          {
            path: 'index',
            component: () => import('@/viewsPc/nationalTeam/index'),
            name: 'nationalTeam',
            meta: { title: '新闻' }
          },
          {
            path: 'index/personList',
            component: () => import('@/viewsPc/nationalTeam/components/member'),
            name: 'personListHasKind',
            meta: { title: '人员列表' }
          }

        ]
      },
      {
        path: 'meta',
        component: Empty,
        redirect: '/meta/index',
        children: [
          {
            path: 'index',
            component: () => import('@/viewsPc/meta/index_en'),
            name: 'meta',
            meta: { title: 'MEDIA' }
          }
        ]
      },
      {
        path: 'saiC',
        component: Empty,
        redirect: '/saiC/index',
        children: [
          {
            path: 'index',
            component: () => import('@/viewsPc/saiC/index_en'),
            name: 'saiC',
            meta: { title: 'COMPETITIONS' }
          }
        ]
      },
      {
        path: 'guide',
        component: Empty,
        redirect: '/guide/index',
        children: [
          {
            path: 'index',
            component: () => import('@/viewsPc/guide/index_en'),
            name: 'guide',
            meta: { title: 'GUIDELINE' }
          }
        ]
      },
      {
        path: 'search',
        component: Empty,
        redirect: '/search',
        children: [
          {
            path: '',
            component: () => import('@/viewsPc/searchList'),
            name: 'searchList',
            meta: { title: '搜索结果' }
          }
        ]
      },
      {
        path: 'competition',
        component: Empty,
        redirect: '/competition/index',
        children: [
          {
            path: 'index',
            component: () => import('@/viewsPc/competition/index'),
            name: 'competition',
            meta: { title: '竞赛服务' }
          },
          {
            path: 'coach/:kind',
            component: () => import('@/viewsPc/competition/coach'),
            name: 'competitionCoach',
            meta: { title: '竞赛服务' }
          },
          {
            path: 'calendar',
            component: () => import('@/viewsPc/competition/calendar'),
            name: 'calendar',
            meta: { title: '竞赛日程' }
          },
          {
            path: 'domesticRanking',
            component: () => import('@/viewsPc/competition/domesticRanking'),
            name: 'domesticRanking',
            meta: { title: '国内排名' }
          }
        ]
      },
      {
        path: 'match',
        component: Empty,
        redirect: '/match/list',
        children: [
          {
            path: 'list',
            component: () => import('@/viewsPc/match/index'),
            name: 'matchList',
            meta: { title: '赛事' }
          },
          {
            path: 'list/:id',
            component: () => import('@/viewsPc/match/detail_en'),
            name: 'matchDetail',
            meta: { title: '赛事详情' }
          },
          {
            path: 'list/:id/singleSign',
            component: () => import('@/viewsPc/match/singleSign'),
            name: 'singleSign',
            meta: { title: '个人报名' }
          },
          {
            path: 'list/:id/teamSign',
            component: () => import('@/viewsPc/match/teamSign'),
            name: 'teamSign',
            meta: { title: '团队报名' }
          },
          {
            path: 'list/:id/chooseCoach',
            component: () => import('@/viewsPc/match/chooseCoach'),
            name: 'chooseCoach',
            meta: { title: '选择教练/领队/其他' }
          },
          {
            path: 'list/:id/chooseSportsman',
            component: () => import('@/viewsPc/match/chooseSportsman'),
            name: 'chooseSportsman',
            meta: { title: '选择运动员' }
          },
          {
            path: 'list/:id/chooseProject',
            component: () => import('@/viewsPc/match/chooseProject'),
            name: 'chooseProject',
            meta: { title: '选择参赛项目' }
          },
          {
            path: 'list/:id/expenseDetails',
            component: () => import('@/viewsPc/match/expenseDetails'),
            name: 'expenseDetails',
            meta: { title: '费用明细' }
          }
        ]
      },
      {
        path: 'train',
        component: Empty,
        redirect: '/train/list',
        children: [
          {
            path: 'list',
            component: () => import('@/viewsPc/train/index'),
            name: 'trainList',
            meta: { title: '培训' }
          },
          {
            path: 'detail/:id',
            component: () => import('@/viewsPc/train/detail'),
            name: 'trainDetail',
            meta: { title: '培训详情' }
          },
          {
            path: 'signUp/:id',
            component: () => import('@/viewsPc/train/signUp'),
            name: 'trainSignUp',
            meta: { title: '培训报名' }
          }
        ]
      },
      {
        path: 'center',
        component: () => import('@/viewsPc/center/index'),
        children: [
          {
            path: 'myInfo',
            component: () => import('@/viewsPc/center/myInfo'),
            name: 'myInfo',
            meta: { title: '个人中心' }
          },
          {
            path: 'myTeam',
            component: () => import('@/viewsPc/center/teamInfo'),
            name: 'myTeam',
            meta: { title: '我的团队' }
          },
          {
            path: 'myMatch',
            component: () => import('@/viewsPc/center/myMatch'),
            name: 'myMatch',
            meta: { title: '我的赛事' }
          },
          {
            path: 'myTrain',
            component: () => import('@/viewsPc/center/myTrain'),
            name: 'myTrain',
            meta: { title: '我的培训' }
          }
        ]
      }
    ]
  }
]

const router = createRouter({
  // history: createWebHistory(import.meta.env.VITE_APP_CONTEXT_PATH),
  history: createWebHashHistory(import.meta.env.VITE_APP_CONTEXT_PATH),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  }
})

export default router