Kaynağa Gözat

优化代码

RuoYi 2 yıl önce
ebeveyn
işleme
85ab6236e7

+ 7 - 7
ruoyi-ui/src/App.vue

@@ -11,14 +11,14 @@ import ThemePicker from "@/components/ThemePicker";
11 11
 export default {
12 12
   name: "App",
13 13
   components: { ThemePicker },
14
-    metaInfo() {
15
-        return {
16
-            title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
17
-            titleTemplate: title => {
18
-                return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
19
-            }
20
-        }
14
+  metaInfo() {
15
+    return {
16
+      title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
17
+      titleTemplate: title => {
18
+        return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
19
+      }
21 20
     }
21
+  }
22 22
 };
23 23
 </script>
24 24
 <style scoped>

+ 2 - 2
ruoyi-ui/src/components/TopNav/index.vue

@@ -57,9 +57,9 @@ export default {
57 57
         if (menu.hidden !== true) {
58 58
           // 兼容顶部栏一级菜单内部跳转
59 59
           if (menu.path === "/") {
60
-              topMenus.push(menu.children[0]);
60
+            topMenus.push(menu.children[0]);
61 61
           } else {
62
-              topMenus.push(menu);
62
+            topMenus.push(menu);
63 63
           }
64 64
         }
65 65
       });

+ 31 - 31
ruoyi-ui/src/directive/dialog/dragHeight.js

@@ -1,34 +1,34 @@
1 1
 /**
2
-* v-dialogDragWidth 可拖动弹窗高度(右下角)
3
-* Copyright (c) 2019 ruoyi
4
-*/
2
+ * v-dialogDragWidth 可拖动弹窗高度(右下角)
3
+ * Copyright (c) 2019 ruoyi
4
+ */
5 5
 
6 6
 export default {
7
-    bind(el) {
8
-        const dragDom = el.querySelector('.el-dialog');
9
-        const lineEl = document.createElement('div');
10
-        lineEl.style = 'width: 6px; background: inherit; height: 10px; position: absolute; right: 0; bottom: 0; margin: auto; z-index: 1; cursor: nwse-resize;';
11
-        lineEl.addEventListener('mousedown',
12
-            function(e) {
13
-                // 鼠标按下,计算当前元素距离可视区的距离
14
-                const disX = e.clientX - el.offsetLeft;
15
-                const disY = e.clientY - el.offsetTop;
16
-                // 当前宽度 高度
17
-                const curWidth = dragDom.offsetWidth;
18
-                const curHeight = dragDom.offsetHeight;
19
-                document.onmousemove = function(e) {
20
-                    e.preventDefault(); // 移动时禁用默认事件
21
-                    // 通过事件委托,计算移动的距离
22
-                    const xl = e.clientX - disX;
23
-                    const yl = e.clientY - disY
24
-                    dragDom.style.width = `${curWidth + xl}px`;
25
-                    dragDom.style.height = `${curHeight + yl}px`;
26
-                };
27
-                document.onmouseup = function(e) {
28
-                    document.onmousemove = null;
29
-                    document.onmouseup = null;
30
-                };
31
-            }, false);
32
-        dragDom.appendChild(lineEl);
33
-    }
34
-}
7
+  bind(el) {
8
+    const dragDom = el.querySelector('.el-dialog');
9
+    const lineEl = document.createElement('div');
10
+    lineEl.style = 'width: 6px; background: inherit; height: 10px; position: absolute; right: 0; bottom: 0; margin: auto; z-index: 1; cursor: nwse-resize;';
11
+    lineEl.addEventListener('mousedown',
12
+      function(e) {
13
+        // 鼠标按下,计算当前元素距离可视区的距离
14
+        const disX = e.clientX - el.offsetLeft;
15
+        const disY = e.clientY - el.offsetTop;
16
+        // 当前宽度 高度
17
+        const curWidth = dragDom.offsetWidth;
18
+        const curHeight = dragDom.offsetHeight;
19
+        document.onmousemove = function(e) {
20
+          e.preventDefault(); // 移动时禁用默认事件
21
+          // 通过事件委托,计算移动的距离
22
+          const xl = e.clientX - disX;
23
+          const yl = e.clientY - disY
24
+          dragDom.style.width = `${curWidth + xl}px`;
25
+          dragDom.style.height = `${curHeight + yl}px`;
26
+        };
27
+        document.onmouseup = function(e) {
28
+          document.onmousemove = null;
29
+          document.onmouseup = null;
30
+        };
31
+      }, false);
32
+    dragDom.appendChild(lineEl);
33
+  }
34
+}

+ 27 - 27
ruoyi-ui/src/directive/dialog/dragWidth.js

@@ -1,30 +1,30 @@
1 1
 /**
2
-* v-dialogDragWidth 可拖动弹窗宽度(右侧边)
3
-* Copyright (c) 2019 ruoyi
4
-*/
2
+ * v-dialogDragWidth 可拖动弹窗宽度(右侧边)
3
+ * Copyright (c) 2019 ruoyi
4
+ */
5 5
 
6 6
 export default {
7
-    bind(el) {
8
-        const dragDom = el.querySelector('.el-dialog');
9
-        const lineEl = document.createElement('div');
10
-        lineEl.style = 'width: 5px; background: inherit; height: 80%; position: absolute; right: 0; top: 0; bottom: 0; margin: auto; z-index: 1; cursor: w-resize;';
11
-        lineEl.addEventListener('mousedown',
12
-            function (e) {
13
-                // 鼠标按下,计算当前元素距离可视区的距离
14
-                const disX = e.clientX - el.offsetLeft;
15
-                // 当前宽度
16
-                const curWidth = dragDom.offsetWidth;
17
-                document.onmousemove = function (e) {
18
-                    e.preventDefault(); // 移动时禁用默认事件
19
-                    // 通过事件委托,计算移动的距离
20
-                    const l = e.clientX - disX;
21
-                    dragDom.style.width = `${curWidth + l}px`;
22
-                };
23
-                document.onmouseup = function (e) {
24
-                    document.onmousemove = null;
25
-                    document.onmouseup = null;
26
-                };
27
-            }, false);
28
-        dragDom.appendChild(lineEl);
29
-    }
30
-}
7
+  bind(el) {
8
+    const dragDom = el.querySelector('.el-dialog');
9
+    const lineEl = document.createElement('div');
10
+    lineEl.style = 'width: 5px; background: inherit; height: 80%; position: absolute; right: 0; top: 0; bottom: 0; margin: auto; z-index: 1; cursor: w-resize;';
11
+    lineEl.addEventListener('mousedown',
12
+      function (e) {
13
+        // 鼠标按下,计算当前元素距离可视区的距离
14
+        const disX = e.clientX - el.offsetLeft;
15
+        // 当前宽度
16
+        const curWidth = dragDom.offsetWidth;
17
+        document.onmousemove = function (e) {
18
+          e.preventDefault(); // 移动时禁用默认事件
19
+          // 通过事件委托,计算移动的距离
20
+          const l = e.clientX - disX;
21
+          dragDom.style.width = `${curWidth + l}px`;
22
+        };
23
+        document.onmouseup = function (e) {
24
+          document.onmousemove = null;
25
+          document.onmouseup = null;
26
+        };
27
+      }, false);
28
+    dragDom.appendChild(lineEl);
29
+  }
30
+}

+ 2 - 2
ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue

@@ -13,8 +13,8 @@
13 13
         <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
14 14
       </template>
15 15
       <sidebar-item
16
-        v-for="child in item.children"
17
-        :key="child.path"
16
+        v-for="(child, index) in item.children"
17
+        :key="child.path + index"
18 18
         :is-nest="true"
19 19
         :item="child"
20 20
         :base-path="resolvePath(child.path)"

+ 1 - 1
ruoyi-ui/src/plugins/tab.js

@@ -60,7 +60,7 @@ export default {
60 60
   },
61 61
   // 添加tab页签
62 62
   openPage(title, url, params) {
63
-    var obj = { path: url, meta: { title: title } }
63
+    const obj = { path: url, meta: { title: title } }
64 64
     store.dispatch('tagsView/addView', obj);
65 65
     return router.push({ path: url, query: params });
66 66
   },

+ 4 - 8
ruoyi-ui/src/utils/permission.js

@@ -15,10 +15,8 @@ export function checkPermi(value) {
15 15
       return all_permission === permission || permissionDatas.includes(permission)
16 16
     })
17 17
 
18
-    if (!hasPermission) {
19
-      return false
20
-    }
21
-    return true
18
+    return hasPermission;
19
+
22 20
   } else {
23 21
     console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`)
24 22
     return false
@@ -40,10 +38,8 @@ export function checkRole(value) {
40 38
       return super_admin === role || permissionRoles.includes(role)
41 39
     })
42 40
 
43
-    if (!hasRole) {
44
-      return false
45
-    }
46
-    return true
41
+    return hasRole;
42
+
47 43
   } else {
48 44
     console.error(`need roles! Like checkRole="['admin','editor']"`)
49 45
     return false

+ 1 - 4
ruoyi-ui/src/utils/validate.js

@@ -65,10 +65,7 @@ export function validEmail(email) {
65 65
  * @returns {Boolean}
66 66
  */
67 67
 export function isString(str) {
68
-  if (typeof str === 'string' || str instanceof String) {
69
-    return true
70
-  }
71
-  return false
68
+  return typeof str === 'string' || str instanceof String;
72 69
 }
73 70
 
74 71
 /**