zhaobao 3 rokov pred
rodič
commit
43ba6428bd

+ 35 - 0
build/index.js

@@ -0,0 +1,35 @@
+const { run } = require('runjs')
+const chalk = require('chalk')
+const config = require('../vue.config.js')
+const rawArgv = process.argv.slice(2)
+const args = rawArgv.join(' ')
+
+if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
+  const report = rawArgv.includes('--report')
+
+  run(`vue-cli-service build ${args}`)
+
+  const port = 9526
+  const publicPath = config.publicPath
+
+  var connect = require('connect')
+  var serveStatic = require('serve-static')
+  const app = connect()
+
+  app.use(
+    publicPath,
+    serveStatic('./dist', {
+      index: ['index.html', '/']
+    })
+  )
+
+  app.listen(port, function () {
+    console.log(chalk.green(`> Preview at  http://localhost:${port}${publicPath}`))
+    if (report) {
+      console.log(chalk.green(`> Report at  http://localhost:${port}${publicPath}report.html`))
+    }
+
+  })
+} else {
+  run(`vue-cli-service build ${args}`)
+}

+ 27 - 15
src/layout/components/Navbar.vue

@@ -80,13 +80,13 @@ export default {
       logo: require('@/assets/images/logo/logo.png'),
       sideMenuTabIndex: 0,
       sideMenuTabList: [
-        { name: '数字全景', icon: 'el-icon-s-platform', path: '/' },
-        { name: '监测预警', icon: 'icon-common_saving', path: '/' },
-        { name: '安全流程化', icon: 'icon-common_safety', path: '/' },
-        { name: '双重预防', icon: 'icon-common_quality', path: '/' },
-        { name: '作业票', icon: 'icon-common_satisfaction', path: '/' },
-        { name: '安全培训', icon: 'icon-common_quality', path: '/' },
-        { name: '系统管理', icon: 'icon-common_saving', path: '/' }
+        { name: '数字全景', icon: 'el-icon-s-platform', path: '/', permit: 'system_platform' },
+        { name: '监测预警', icon: 'icon-common_saving', path: '/', permit: 'system_platform' },
+        { name: '安全流程化', icon: 'icon-common_safety', path: '/', permit: 'system_platform' },
+        { name: '双重预防', icon: 'icon-common_quality', path: '/', permit: 'system_platform' },
+        { name: '作业票', icon: 'icon-common_satisfaction', path: '/', permit: 'system_platform' },
+        { name: '安全培训', icon: 'icon-common_quality', path: '/', permit: 'system_platform' },
+        { name: '系统管理', icon: 'icon-common_saving', path: '/', permit: 'system_platform' }
       ]
     }
   },
@@ -97,7 +97,8 @@ export default {
       'avatar',
       'userData',
       'permission_routes',
-      'menuSiderTab'
+      'menuSiderTab',
+      'permits'
     ])
   },
   watch: {
@@ -108,13 +109,8 @@ export default {
   },
   mounted() {
     this.getUnReadMsg()
-    let index = 0
-    if (this.isNotNull(localStorage.getItem('tabIndex'))) {
-      index = parseFloat(localStorage.getItem('tabIndex'))
-    }
-    this.sideTabChange(index, {
-      path: this.$route.fullPath
-    })
+    this.initSideMenu()
+    this.initsideTab()
   },
   methods: {
     getUnReadMsg() {
@@ -122,6 +118,22 @@ export default {
         this.unReadCount = resp.data
       })
     },
+    initSideMenu() {
+      const permits = JSON.parse(JSON.stringify(this.permits))
+      let sideMenuTabList = JSON.parse(JSON.stringify(this.sideMenuTabList))
+      sideMenuTabList = sideMenuTabList.filter(item => permits.includes(item.permit))
+      this.sideMenuTabList = sideMenuTabList
+      console.log({ sideMenuTabList, permits })
+    },
+    initsideTab() {
+      let index = 0
+      if (this.isNotNull(localStorage.getItem('tabIndex'))) {
+        index = parseFloat(localStorage.getItem('tabIndex'))
+      }
+      this.sideTabChange(index, {
+        path: this.$route.fullPath
+      })
+    },
     toggleSideBar() {
       this.$store.dispatch('app/toggleSideBar')
     },

+ 2 - 1
src/store/getters.js

@@ -10,6 +10,7 @@ const getters = {
   userData: state => state.user.userData,
   permits: state => state.user.permits,
   permission_routes: state => state.permission.routes,
-  errorLogs: state => state.errorLog.logs
+  errorLogs: state => state.errorLog.logs,
+  menuSiderTab: state => state.app.sidebarTab
 }
 export default getters

+ 7 - 0
src/store/modules/app.js

@@ -7,6 +7,7 @@ const state = {
   },
   device: 'desktop',
   size: Cookies.get('size') || 'medium',
+  sidebarTab: 0,
   message: 0
 }
 
@@ -32,6 +33,9 @@ const mutations = {
     state.size = size
     Cookies.set('size', size)
   },
+  SET_MenuSiderTab: (state, sidebarTab) => {
+    state.sidebarTab = sidebarTab
+  },
   SET_Message: (state, message) => {
     state.message = message
   }
@@ -50,6 +54,9 @@ const actions = {
   setSize({ commit }, size) {
     commit('SET_SIZE', size)
   },
+  setMenuSiderTab({ commit }, sidebarTab) {
+    commit('SET_MenuSiderTab', sidebarTab)
+  },
   SET_Message({ commit }, message) {
     commit('SET_Message', message)
   }