这是一个剪刀的路由拦截
router分位两个文件,一个是路由统一配置,一个是具体的路由信息
1路由
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const Wrap = resolve => require(['@/views/wrap/index/index.vue'], resolve)
const Home = resolve => require(['@/views/wrap/home/home.vue'], resolve) //首页
const Company = resolve => require(['@/views/wrap/company/company.vue'], resolve) //首页
const Login = resolve => require(['@/views/login/login.vue'], resolve) //登录
const Register = resolve => require(['@/views/login/register.vue'], resolve) //注册
const EditPassword = resolve => require(['@/views/login/edit-password.vue'], resolve)
const Error = resolve => require(['@/views/error/error.vue'], resolve) //404页面
const Sucess = resolve => require(['@/views/error/sucess.vue'], resolve) //提交成功
//激活页面 忘记密码
const ActivationPage = resolve => require(['@/views/login/activation-page.vue'], resolve) //激活
const ForgetPassword = resolve => require(['@/views/login/forget-password.vue'], resolve) //忘记喵喵
const Apply = resolve => require(['@/views/wrap/apply/apply.vue'], resolve) //月度电量申报
const UserList = resolve => require(['@/views/wrap/user/user-list.vue'], resolve) //用户列表
const Audit = resolve => require(['@/views/wrap/audit/audit.vue'], resolve) //业务审核
const AuditDetail = resolve => require(['@/views/wrap/audit/audit-detail.vue'], resolve) //审核详情
const UserInvite = resolve => require(['@/views/wrap/user/user-invite.vue'], resolve) //用户邀请
const Report = resolve => require(['@/views/wrap/report/report.vue'], resolve) //事件上报
const ReportDetail = resolve => require(['@/views/wrap/report/report-detail.vue'], resolve) //事件上报
const UserManage = resolve => require(['@/views/wrap/user/user-manage.vue'], resolve) //
const userAgreement = resolve => require(['@/views/wrap/user/user-agreement.vue'], resolve) //用户协议
const Mine = resolve => require(['@/views/wrap/mine/mine.vue'], resolve) //我的
const PersonInfo = resolve => require(['@/views/wrap/mine/person-info.vue'], resolve) //我的信息
const ContactInformation = resolve => require(['@/views/wrap/contact-information/index.vue'], resolve) //联系方式
const SellingElectricity = resolve => require(['@/views/wrap/selling-electricity/index.vue'], resolve) //售电业务
export default [
{
path: '/',
redirect: '/wrap/home'
}, {
path: '/login',
component: Login,
meta: { title: '登录', requireAuth: false, requireRole: false, role: ['1', '2', '3','5'] }
},
{
path: '/sucess',
component: Sucess,
meta: { title: '提交成功', requireAuth: false, requireRole: false, role: ['1', '2', '3','5'] }
},
{
path: '/error',
component: Error,
meta: { title: '报错页面', requireAuth: false, requireRole: false, role: ['1', '2', '3','5'] }
},
{
path: '/register',
component: Register,
meta: { title: '注册页面', requireAuth: false, requireRole: false, role: ['1', '2', '3','5'] }
},
{
name: 'jurisd',
path: '/jurisd',
component: NoJurisdiction,
meta: { title: '能源e+', requireAuth: false, requireRole: false, role: ['1', '2', '3','5'] }
},
{
path: '/wrap',
component: Wrap,
meta: { title: '系统', requireAuth: true, requireRole: false, role: ['1', '2', '3'] },
children: [
{
path: '/',
redirect: 'home'
},
{
name: '企业列表',
path: 'company',
component: Company,
meta: { title: '企业列表', requireAuth: false, requireRole: false, role: ['3'] }
},
{
name: '修改密码',
path: 'editPaw',
component: EditPassword,
meta: { title: '修改密码', requireAuth: true, requireRole: false, role: ['1', '2', '3','5'] }
},
{
name: '首页',
path: 'home',
component: Home,
meta: { title: '首页', requireAuth: true, requireRole: true, role: ['1', '2', '3'] }
},
{
path: '**',
component: Login,
meta: { title: '登录', requireAuth: false, requireRole: false, role: ['1', '2', '3'] }
},
]
}
]