Procházet zdrojové kódy

fix: permission exception

daigang před 3 roky
rodič
revize
cde71933ea

+ 1 - 1
src/layout/components/Navbar/Breadcrumb.vue

@@ -48,7 +48,7 @@ export default {
   },
   methods: {
     getBreadcrumb () {
-      this.levelList = this.$route.matched.filter(item => item?.meta.title && item?.meta.breadcrumb !== false)
+      this.levelList = this.$route.matched.filter(item => item.meta?.title && item.meta?.breadcrumb !== false)
     },
     pathCompile (path) {
       // To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561

+ 1 - 1
src/layout/components/Navbar/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="l-flex--row c-navbar">
     <breadcrumb class="l-flex__auto c-navbar__item" />
-    <UploadDashboard class="l-flex__none c-navbar__item" />
+    <upload-dashboard class="l-flex__none c-navbar__item" />
     <el-dropdown
       class="l-flex__none c-navbar__item c-navbar__user u-pointer"
       trigger="click"

+ 5 - 12
src/router/index.js

@@ -109,10 +109,7 @@ export const asyncRoutes = [
         name: 'review',
         path: 'review',
         component: () => import('@/views/review/index'),
-        meta: {
-          title: '审核管理',
-          roles: [Role.SUPERVISOR]
-        }
+        meta: { title: '审核管理', roles: [Role.SUPERVISOR] }
       },
       {
         name: 'schedule-deploy-history',
@@ -151,13 +148,13 @@ export const asyncRoutes = [
         name: 'category',
         path: 'category',
         component: () => import('@/views/device/category/index'),
-        meta: { title: '产品分类' }
+        meta: { title: '产品分类', roles: [Role.ADMIN] }
       },
       {
         name: 'product',
         path: 'product',
         component: () => import('@/views/device/product/index'),
-        meta: { title: '产品管理' }
+        meta: { title: '产品管理', roles: [Role.ADMIN] }
       },
       {
         name: 'device',
@@ -176,6 +173,7 @@ export const asyncRoutes = [
   {
     path: '/l',
     component: Layout,
+    meta: { roles: [Role.ADMIN] },
     children: [
       {
         path: '',
@@ -200,12 +198,7 @@ export const asyncRoutes = [
   {
     path: '/u',
     component: Layout,
-    meta: {
-      title: '升级管理',
-      icon: 'el-icon-upload',
-      placeholder: true,
-      roles: [Role.ADMIN]
-    },
+    meta: { title: '升级管理', icon: 'el-icon-upload', placeholder: true, roles: [Role.ADMIN] },
     children: [
       {
         path: 'apk',

+ 16 - 36
src/utils/index.js

@@ -79,42 +79,34 @@ export function formatTime (time, option) {
   }
 }
 
-export function debounce (fn, wait, immediate) {
-  let timeout, context, args, timestamp
+export function debounce (func, wait, immediate) {
+  let timeout, context, args
 
   const later = function () {
-    // 据上一次触发时间间隔
-    const last = Date.now() - timestamp
-
-    // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
-    if (last < wait) {
-      timeout = setTimeout(later, wait - last)
-    } else {
-      if (!immediate) {
-        fn.apply(context, args)
-      }
-      timeout = context = args = null
+    if (!immediate) {
+      func.apply(context, args)
     }
+    timeout = context = args = null
   }
 
   return function (...params) {
-    timestamp = Date.now()
     context = this
     args = params
-    // 如果延时不存在,重新设定延时
-    if (!timeout) {
-      timeout = setTimeout(later, wait)
-      if (immediate) {
-        fn.apply(context, args)
-        context = params = null
-      }
+    if (timeout) {
+      clearTimeout(timeout)
+    } else if (immediate) {
+      func.apply(context, args)
+      context = args = null
     }
+    timeout = setTimeout(later, wait)
   }
 }
 
+// leading-true,trailing-true:默认情况,间隔到了立即执行且保留尾调用
+// leading-true,trailing-false:去除尾调用
+// leading-false, trailing-true:在间隔结束时执行函数
 export function throttle (func, wait, options) {
   let timeout, context, args
-
   // 上一次执行回调的时间戳
   let previous = 0
 
@@ -128,10 +120,7 @@ export function throttle (func, wait, options) {
     // 每次触发回调函数后设置 previous 为 0
     // 不然为当前时间
     previous = options.leading === false ? 0 : Date.now()
-
-    // 执行函数
     func.apply(context, args)
-
     timeout = context = args = null
   }
 
@@ -154,16 +143,9 @@ export function throttle (func, wait, options) {
     context = this
     args = params
 
-    // 要么是到了间隔时间了,随即触发方法(remaining <= 0)
-    // 要么是没有传入 {leading: false},且第一次触发回调,即立即触发
-    // 此时 previous 为 0,wait - (now - previous) 也满足 <= 0
-    // 之后便会把 previous 值迅速置为 now
-    if (remaining <= 0 || remaining > wait) {
+    if (remaining <= 0) {
       if (timeout) {
         clearTimeout(timeout)
-
-        // clearTimeout(timeout) 并不会把 timeout 设为 null
-        // 手动设置,便于后续判断
         timeout = null
       }
 
@@ -172,9 +154,7 @@ export function throttle (func, wait, options) {
 
       // 执行 func 函数
       func.apply(context, args)
-      if (!timeout) {
-        context = args = null
-      }
+      context = args = null
     } else if (!timeout && options.trailing !== false) {
       // 最后一次需要触发的情况
       // 如果已经存在一个定时器,则不会进入该 if 分支

+ 7 - 0
src/views/device/group/index.vue

@@ -140,11 +140,13 @@
           prop="serialNumber"
           label="序列号"
           align="center"
+          show-overflow-tooltip
         />
         <el-table-column
           prop="mac"
           label="MAC"
           align="center"
+          show-overflow-tooltip
         />
         <el-table-column
           prop="resolutionRatio"
@@ -198,26 +200,31 @@
           prop="name"
           label="设备名称"
           align="center"
+          show-overflow-tooltip
         />
         <el-table-column
           prop="productName"
           label="产品"
           align="center"
+          show-overflow-tooltip
         />
         <el-table-column
           prop="serialNumber"
           label="序列号"
           align="center"
+          show-overflow-tooltip
         />
         <el-table-column
           prop="mac"
           label="MAC"
           align="center"
+          show-overflow-tooltip
         />
         <el-table-column
           prop="resolutionRatio"
           label="分辨率"
           align="center"
+          width="120"
         />
         <el-table-column
           prop="remark"

+ 8 - 1
src/views/device/index.vue

@@ -85,11 +85,13 @@
         prop="serialNumber"
         label="序列号"
         align="center"
+        show-overflow-tooltip
       />
       <el-table-column
         prop="mac"
         label="MAC"
         align="center"
+        show-overflow-tooltip
       />
       <el-table-column
         prop="resolutionRatio"
@@ -141,7 +143,7 @@
       <el-table-column
         label="操作"
         align="center"
-        width="300"
+        :width="operationColumnWidth"
       >
         <template v-slot="scope">
           <template v-if="!scope.row.empty">
@@ -274,6 +276,7 @@
 </template>
 
 <script>
+import { mapGetters } from 'vuex'
 import {
   getDevices,
   addDevice,
@@ -320,6 +323,10 @@ export default {
     }
   },
   computed: {
+    ...mapGetters(['isAdmin']),
+    operationColumnWidth () {
+      return this.isAdmin ? 300 : 200
+    },
     type () {
       return this.isSub ? '备份设备' : '设备'
     },