/* * @Author: your name * @Date: 2021-10-08 09:26:42 * @LastEditTime: 2022-02-11 09:53:01 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: /data-show/src/permission.js */ import store from '@/store' import router from "@/router" import NProgress from "nprogress" import "nprogress/nprogress.css" const whitePath = ['/', '/login', '/industryDataExport','/index','/keyMediaHome'] router.beforeEach((to, from, next) => { NProgress.start() const token = store.getters.getToken; if(!token && !whitePath.includes(to.path)) { next('/login'); } else { checkMenu(to.path, next); } }) router.afterEach(() => { NProgress.done() }) // 检查菜单权限 function checkMenu(path, next) { let menuStr = store.getters.getMenu || []; let arr = ['/modelInsight', '/eventInsight', '/marketingAnalysis', '/saleRank', '/specialAnalize']; let n = menuStr.findIndex(ele => ele.link === path); if(arr.includes(path) && n === -1) next('/index') else next() } export default router