| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- import Vue from 'vue'
- import VueRouter from 'vue-router'
- // 加载条
- import NProgress from 'nprogress'
- import 'nprogress/nprogress.css'
- import VueAMap from 'vue-amap';
- Vue.use(VueRouter);
- // Vue.use(VueAMap);
- // VueAMap.initAMapApiLoader({
- // key: 'your amap key',
- // plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
- // // 默认高德 sdk 版本为 1.4.4
- // v: '1.4.4'
- // });
- const routes = [
- {
- path: '/',
- component: () => import( '../views/Index.vue'),
- children: [
- {
- path: '/',
- name: 'Main',
- component: () => import('@/views/Main.vue'),
- meta: {
- title: "首页",
- }
- },{
- path: '/member',
- name: 'Member',
- component: () => import('@/views/Member.vue'),
- meta: {
- title: "会员管理",
- }
- },{
- path: '/lesson',
- name: 'Lesson',
- component: () => import('@/views/Lesson.vue'),
- meta: {
- title: "课程模板",
- }
- },{
- path: '/lessonTable',
- name: 'lessonTable',
- component: () => import('@/views/LessonTable.vue'),
- meta: {
- title: "课程表模板",
- }
- },{
- path: '/editLessonTable',
- name: 'EditLessonTable.vue',
- component: () => import('@/views/EditLessonTable.vue'),
- meta: {
- title: "编辑课程表模板",
- }
- },{
- path: '/adminManage',
- name: 'AdminManage',
- component: () => import('@/views/AdminManage.vue'),
- meta: {
- title: "用户管理",
- }
- },{
- path: '/log',
- name: 'Log',
- component: () => import('@/views/Log.vue'),
- meta: {
- title: "操作日志",
- }
- },{
- path: '/shopManage',
- name: 'ShopManage',
- component: () => import('@/views/ShopManage.vue'),
- meta: {
- title: "店面管理",
- }
- },{
- path: '/adminSetting',
- name: 'AdminSetting',
- component: () => import('@/views/AdminSetting.vue'),
- meta: {
- title: "系统设置",
- }
- },{
- path: '/lessonManage',
- name: 'lessonManage',
- component: () => import('@/views/lessonManage.vue'),
- meta: {
- title: "课程表管理",
- }
- },{
- path: '/coach',
- name: 'coach',
- component: () => import('@/views/coach.vue'),
- meta: {
- title: "教练管理",
- }
- },{
- path: '/yhgl',
- name: 'Yhgl',
- component: () => import('@/views/Yhgl.vue'),
- meta: {
- title: "用户管理",
- }
- },{
- path: '/mockPage',
- name: 'MockPage',
- component: () => import('@/views/MockPage.vue'),
- meta: {
- title: "用户管理",
- }
- },{
- path: '/chart',
- name: 'Chart',
- component: () => import('@/views/Chart.vue'),
- meta: {
- title: "图表效果",
- }
- },{
- path: '/test',
- name: 'Test',
- component: () => import('@/views/Test.vue'),
- meta: {
- title: "Test",
- }
- },{
- path: '/aboutUs',
- name: 'AboutUs',
- component: () => import('@/views/AboutUs.vue'),
- meta: {
- title: "关于我们",
- }
- },{
- path: '/pwd',
- name: 'Pwd',
- component: () => import('@/views/Pwd.vue'),
- meta: {
- title: "密码修改",
- }
- },{
- path: '/basic',
- name: 'Basic',
- component: () => import('@/views/Basic.vue'),
- meta: {
- title: "基本设置",
- }
- },{
- path: '/upload',
- name: 'Upload',
- component: () => import('@/views/Upload.vue'),
- meta: {
- title: "上传文件",
- }
- },
- ]
- }, {
- path: '/login',
- name: 'Login',
- component: () => import( '../views/Login.vue')
- },, {
- path: '*',
- name: '404',
- component: () => import( '../views/404.vue')
- },
- ]
- const originalPush = VueRouter.prototype.push;
- VueRouter.prototype.push = function push(location) {
- return originalPush.call(this, location).catch(err => err)
- };
- const router = new VueRouter({
- mode: 'history',
- base: process.env.BASE_URL,
- routes
- });
- // 路由守卫
- router.beforeEach((to,from,next)=>{
- NProgress.start()
- const isLogin = localStorage.token? true : false;
- if(to.path == '/login' || to.path == '/register'){//'login'和'register'相当于是路由白名单
- next();
- }else{
- //如果token存在,就正常跳转,如果不存在,则说明未登陆,则跳转到'login'
- isLogin? next() : next("/login");
- }
- });
- router.afterEach(() => {
- NProgress.done()
- })
- export default router
|