1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import Vue from 'vue'
- import App from './App'
- import VueRouter from 'vue-router'
- import ElementUI from 'element-ui'
- import 'element-ui/lib/theme-chalk/index.css'
- //import 'element-ui/lib/theme-default/index.css'
- //import './assets/theme/theme-green/index.css'
- import store from './vuex/store'
- import Vuex from 'vuex'
- //import NProgress from 'nprogress'
- //import 'nprogress/nprogress.css'
- import routes from './routes'
- // import Mock from './mock'
- // Mock.bootstrap();
- import $ from 'jquery'
- import http from './http'
- Vue.prototype.http = http
- import port from './port'
- Vue.prototype.port = port
- import 'font-awesome/css/font-awesome.min.css'
- import './assets/iconfont/iconfont.css'
- Vue.use(ElementUI)
- Vue.use(VueRouter)
- Vue.use(Vuex)
- const router = new VueRouter({
- routes
- })
- router.beforeEach((to, from, next) => {
- if (to.path == '/login') {
- sessionStorage.removeItem('user');
- }
- let user = JSON.parse(sessionStorage.getItem('user'));
- if (!user && to.path != '/login') {
- next({ path: '/login' })
- } else {
- if(user){
- for(var i in routes){
- if(routes[i].name == "基础管理" && user.parentId != 0){
- routes[i].hidden = true
- } else if(routes[i].name == "基础管理"){
- routes[i].hidden = false
- }
-
- if(routes[i].name == "项目管理" && user.parentId > 1){
- var children = routes[i].children;
- for(var j in children){
- if(children[j].name == "人员管理" && user.isManager == 0){
- children[j].hidden = true
- }
- if(children[j].name == "权限管理" && user.isManager == 0){
- children[j].hidden = true
- }
- }
- } else if(routes[i].name == "项目管理") {
- var children = routes[i].children;
- for(var j in children){
- if(children[j].name != "项目详情"){
- children[j].hidden = false
- }
- }
- }
- }
- }
- next()
- }
- })
- // router.afterEach(transition => {
- // NProgress.done();
- // });
- new Vue({
- //el: '#app',
- //template: '<App/>',
- router,
- store,
- //components: { App }
- render: h => h(App)
- }).$mount('#app')
|