作者 RuoYi

优化代码

1 -如果使用的是RuoYi-Vue3前端,那么需要覆盖一下此目录的模板index.vue.vm、index-tree.vue.vm文件到上级vue目录。  
@@ -168,7 +168,7 @@ export default { @@ -168,7 +168,7 @@ export default {
168 // 删除图片 168 // 删除图片
169 handleDelete(file) { 169 handleDelete(file) {
170 const findex = this.fileList.map(f => f.name).indexOf(file.name); 170 const findex = this.fileList.map(f => f.name).indexOf(file.name);
171 - if(findex > -1) { 171 + if (findex > -1) {
172 this.fileList.splice(findex, 1); 172 this.fileList.splice(findex, 1);
173 this.$emit("input", this.listToString(this.fileList)); 173 this.$emit("input", this.listToString(this.fileList));
174 } 174 }
1 /** 1 /**
2 -* v-dialogDragWidth 可拖动弹窗高度(右下角)  
3 -* Copyright (c) 2019 ruoyi  
4 -*/ 2 + * v-dialogDragWidth 可拖动弹窗高度(右下角)
  3 + * Copyright (c) 2019 ruoyi
  4 + */
5 5
6 export default { 6 export default {
7 bind(el) { 7 bind(el) {
1 /** 1 /**
2 -* v-dialogDragWidth 可拖动弹窗宽度(右侧边)  
3 -* Copyright (c) 2019 ruoyi  
4 -*/ 2 + * v-dialogDragWidth 可拖动弹窗宽度(右侧边)
  3 + * Copyright (c) 2019 ruoyi
  4 + */
5 5
6 export default { 6 export default {
7 bind(el) { 7 bind(el) {
@@ -13,8 +13,8 @@ @@ -13,8 +13,8 @@
13 <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" /> 13 <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
14 </template> 14 </template>
15 <sidebar-item 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 :is-nest="true" 18 :is-nest="true"
19 :item="child" 19 :item="child"
20 :base-path="resolvePath(child.path)" 20 :base-path="resolvePath(child.path)"
@@ -60,7 +60,7 @@ export default { @@ -60,7 +60,7 @@ export default {
60 }, 60 },
61 // 添加tab页签 61 // 添加tab页签
62 openPage(title, url, params) { 62 openPage(title, url, params) {
63 - var obj = { path: url, meta: { title: title } } 63 + const obj = { path: url, meta: { title: title } }
64 store.dispatch('tagsView/addView', obj); 64 store.dispatch('tagsView/addView', obj);
65 return router.push({ path: url, query: params }); 65 return router.push({ path: url, query: params });
66 }, 66 },
@@ -15,10 +15,8 @@ export function checkPermi(value) { @@ -15,10 +15,8 @@ export function checkPermi(value) {
15 return all_permission === permission || permissionDatas.includes(permission) 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 } else { 20 } else {
23 console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`) 21 console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`)
24 return false 22 return false
@@ -40,10 +38,8 @@ export function checkRole(value) { @@ -40,10 +38,8 @@ export function checkRole(value) {
40 return super_admin === role || permissionRoles.includes(role) 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 } else { 43 } else {
48 console.error(`need roles! Like checkRole="['admin','editor']"`) 44 console.error(`need roles! Like checkRole="['admin','editor']"`)
49 return false 45 return false
@@ -65,10 +65,7 @@ export function validEmail(email) { @@ -65,10 +65,7 @@ export function validEmail(email) {
65 * @returns {Boolean} 65 * @returns {Boolean}
66 */ 66 */
67 export function isString(str) { 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 /**