From 0e771a6c1b732772eaf0ebcea7a26f9098755d7d Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 27 Dec 2021 12:38:59 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E5=8D=87=E7=BA=A7spring-boot=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC2.5.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 16 +--------------- .../com/ruoyi/quartz/config/ScheduleConfig.java | 2 +- ruoyi-ui/src/views/monitor/job/index.vue | 2 +- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index 58658dbc5..4974a225d 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,6 @@ 4.1.2 2.3 0.9.1 - 2.17.0 @@ -44,7 +43,7 @@ org.springframework.boot spring-boot-dependencies - 2.5.6 + 2.5.8 pom import @@ -151,19 +150,6 @@ ${fastjson.version} - - - org.apache.logging.log4j - log4j-api - ${log4j2.version} - - - - org.apache.logging.log4j - log4j-to-slf4j - ${log4j2.version} - - io.jsonwebtoken diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java index e35eb26e4..04db2c9db 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java @@ -29,7 +29,7 @@ public class ScheduleConfig prop.put("org.quartz.threadPool.threadCount", "20"); prop.put("org.quartz.threadPool.threadPriority", "5"); // JobStore配置 - prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); + prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore"); // 集群配置 prop.put("org.quartz.jobStore.isClustered", "true"); prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); diff --git a/ruoyi-ui/src/views/monitor/job/index.vue b/ruoyi-ui/src/views/monitor/job/index.vue index b8284ab91..84ea6af69 100644 --- a/ruoyi-ui/src/views/monitor/job/index.vue +++ b/ruoyi-ui/src/views/monitor/job/index.vue @@ -204,7 +204,7 @@ - + 立即执行 执行一次 From 1294f682659c45169d966e40e5cac5597cec84aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=B0=8F=E6=B3=95?= Date: Mon, 27 Dec 2021 15:33:22 +0800 Subject: [PATCH 02/14] fix https://gitee.com/y_project/RuoYi-Vue/issues/I4O5WD --- ruoyi-ui/src/components/Crontab/hour.vue | 228 +++++++++++------------ 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/ruoyi-ui/src/components/Crontab/hour.vue b/ruoyi-ui/src/components/Crontab/hour.vue index 29b88919f..4b1f1fcdb 100644 --- a/ruoyi-ui/src/components/Crontab/hour.vue +++ b/ruoyi-ui/src/components/Crontab/hour.vue @@ -1,114 +1,114 @@ - - - \ No newline at end of file + + + From d51e7cbb51a4871b78b2a680cb1670c0131da287 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 29 Dec 2021 11:04:09 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E6=9F=A5=E8=AF=A2=E9=80=89=E6=8B=A9=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=90=8E=E5=88=86=E9=A1=B5=E5=8F=82=E6=95=B0=E5=88=9D?= =?UTF-8?q?=E5=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/system/user/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index 81a216179..4b00e0322 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -495,7 +495,7 @@ export default { // 节点单击事件 handleNodeClick(data) { this.queryParams.deptId = data.id; - this.getList(); + this.handleQuery(); }, // 用户状态修改 handleStatusChange(row) { From 530b2a51d5b15d5c2ffd9df3f75e918d636f4ba0 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 30 Dec 2021 14:13:38 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=95=E8=AF=8D?= =?UTF-8?q?=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/api/system/user.js | 4 ++-- ruoyi-ui/src/utils/ruoyi.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ruoyi-ui/src/api/system/user.js b/ruoyi-ui/src/api/system/user.js index 577bea24c..ad227f97b 100644 --- a/ruoyi-ui/src/api/system/user.js +++ b/ruoyi-ui/src/api/system/user.js @@ -1,5 +1,5 @@ import request from '@/utils/request' -import { praseStrEmpty } from "@/utils/ruoyi"; +import { parseStrEmpty } from "@/utils/ruoyi"; // 查询用户列表 export function listUser(query) { @@ -13,7 +13,7 @@ export function listUser(query) { // 查询用户详细 export function getUser(userId) { return request({ - url: '/system/user/' + praseStrEmpty(userId), + url: '/system/user/' + parseStrEmpty(userId), method: 'get' }) } diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 4cc5e24ea..0c4c77bbe 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -108,7 +108,7 @@ export function sprintf(str) { } // 转换字符串,undefined,null等转化为"" -export function praseStrEmpty(str) { +export function parseStrEmpty(str) { if (!str || str == "undefined" || str == "null") { return ""; } From f65cd6245de4757ecea7b6c127fa54f0786b514f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 30 Dec 2021 14:14:40 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E9=98=B2=E9=87=8D=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=A0=87=E8=AF=86=E7=BB=84=E5=90=88=EF=BC=88key=20+?= =?UTF-8?q?=20url=20+=20header=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interceptor/impl/SameUrlDataInterceptor.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java index 33c9c876b..b956b3f25 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java @@ -60,14 +60,10 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor String url = request.getRequestURI(); // 唯一值(没有消息头则使用请求地址) - String submitKey = request.getHeader(header); - if (StringUtils.isEmpty(submitKey)) - { - submitKey = url; - } + String submitKey = StringUtils.trimToEmpty(request.getHeader(header)); - // 唯一标识(指定key + 消息头) - String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey; + // 唯一标识(指定key + url + 消息头) + String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey; Object sessionObj = redisCache.getCacheObject(cacheRepeatKey); if (sessionObj != null) From bb1af390a7025247fdef1e63ce871b47e8e369e6 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 30 Dec 2021 14:41:25 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E5=8D=87=E7=BA=A7log4j2=E5=88=B02.17.1?= =?UTF-8?q?=EF=BC=8C=E9=98=B2=E6=AD=A2=E6=BC=8F=E6=B4=9E=E9=A3=8E=E9=99=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pom.xml b/pom.xml index 4974a225d..ecbce07ce 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,7 @@ 3.2.2 4.1.2 2.3 + 2.17.1 0.9.1 @@ -150,6 +151,19 @@ ${fastjson.version} + + + org.apache.logging.log4j + log4j-api + ${log4j2.version} + + + + org.apache.logging.log4j + log4j-to-slf4j + ${log4j2.version} + + io.jsonwebtoken From 6353f4ff094905021568ac5c7486cd3f6ad71632 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 31 Dec 2021 00:00:06 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E8=8B=A5=E4=BE=9D=203.8.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 +-- ruoyi-admin/pom.xml | 2 +- .../src/main/resources/application.yml | 2 +- ruoyi-common/pom.xml | 2 +- ruoyi-framework/pom.xml | 2 +- ruoyi-generator/pom.xml | 2 +- ruoyi-quartz/pom.xml | 2 +- ruoyi-system/pom.xml | 2 +- ruoyi-ui/package.json | 2 +- ruoyi-ui/src/views/index.vue | 35 ++++++++++++++++++- 10 files changed, 44 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index ecbce07ce..c024d33d7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,14 +6,14 @@ com.ruoyi ruoyi - 3.8.0 + 3.8.1 ruoyi http://www.ruoyi.vip 若依管理系统 - 3.8.0 + 3.8.1 UTF-8 UTF-8 1.8 diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index ca0631980..14769e515 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.8.0 + 3.8.1 4.0.0 jar diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 557179b40..286b1aeaa 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -3,7 +3,7 @@ ruoyi: # 名称 name: RuoYi # 版本 - version: 3.8.0 + version: 3.8.1 # 版权年份 copyrightYear: 2021 # 实例演示开关 diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index cbf4893a5..e18104ca1 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.8.0 + 3.8.1 4.0.0 diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml index 2e8817bfa..f1b68c7c5 100644 --- a/ruoyi-framework/pom.xml +++ b/ruoyi-framework/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.8.0 + 3.8.1 4.0.0 diff --git a/ruoyi-generator/pom.xml b/ruoyi-generator/pom.xml index 8ec90ea0d..b80b938cf 100644 --- a/ruoyi-generator/pom.xml +++ b/ruoyi-generator/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.8.0 + 3.8.1 4.0.0 diff --git a/ruoyi-quartz/pom.xml b/ruoyi-quartz/pom.xml index 7d7a72631..c70da0dad 100644 --- a/ruoyi-quartz/pom.xml +++ b/ruoyi-quartz/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.8.0 + 3.8.1 4.0.0 diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index a62fb550d..611cc8289 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -5,7 +5,7 @@ ruoyi com.ruoyi - 3.8.0 + 3.8.1 4.0.0 diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 62f4bcee1..fc15b2e15 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,6 +1,6 @@ { "name": "ruoyi", - "version": "3.8.0", + "version": "3.8.1", "description": "若依管理系统", "author": "若依", "license": "MIT", diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 75761cb75..f136d1aa9 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -147,6 +147,39 @@ 更新日志 + +
    +
  1. 新增Vue3前端代码生成模板
  2. +
  3. 新增图片预览组件
  4. +
  5. 新增压缩插件实现打包Gzip
  6. +
  7. 自定义xss校验注解实现
  8. +
  9. 自定义文字复制剪贴指令
  10. +
  11. 代码生成预览支持复制内容
  12. +
  13. 路由支持单独配置菜单或角色权限
  14. +
  15. 用户管理部门查询选择节点后分页参数初始
  16. +
  17. 修复用户分配角色属性错误
  18. +
  19. 修复打包后字体图标偶现的乱码问题
  20. +
  21. 修复菜单管理重置表单出现的错误
  22. +
  23. 修复版本差异导致的懒加载报错问题
  24. +
  25. 修复Cron组件中周回显问题
  26. +
  27. 修复定时任务多参数逗号分隔的问题
  28. +
  29. 修复根据ID查询列表可能出现的主键溢出问题
  30. +
  31. 修复tomcat配置参数已过期问题
  32. +
  33. 升级clipboard到最新版本2.0.8
  34. +
  35. 升级oshi到最新版本v5.8.6
  36. +
  37. 升级fastjson到最新版1.2.79
  38. +
  39. 升级spring-boot到最新版本2.5.8
  40. +
  41. 升级log4j2到2.17.1,防止漏洞风险
  42. +
  43. 优化下载解析blob异常提示
  44. +
  45. 优化代码生成字典组重复问题
  46. +
  47. 优化查询用户的角色组&岗位组代码
  48. +
  49. 优化定时任务cron表达式小时设置24
  50. +
  51. 优化用户导入提示溢出则显示滚动条
  52. +
  53. 优化防重复提交标识组合为(key+url+header)
  54. +
  55. 优化分页方法设置成通用方便灵活调用
  56. +
  57. 其他细节优化
  58. +
+
  1. 新增配套并同步的Vue3前端版本
  2. @@ -717,7 +750,7 @@ export default { data() { return { // 版本号 - version: "3.8.0", + version: "3.8.1", }; }, methods: { From 6ef899d0006034a031277bd439e67432d9b4f7d8 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 31 Dec 2021 10:03:54 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E5=90=8E=E5=A4=9A=E6=AC=A1=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=A4=9A=E6=AC=A1=E5=BC=B9=E7=AA=97=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/request.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index 8ee43ccb4..12e535a64 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -7,6 +7,8 @@ import { tansParams, blobValidate } from "@/utils/ruoyi"; import { saveAs } from 'file-saver' let downloadLoadingInstance; +// 是否显示重新登录 +let isReloginShow; axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' // 创建axios实例 @@ -48,16 +50,25 @@ service.interceptors.response.use(res => { return res.data } if (code === 401) { - MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { + if (!isReloginShow) { + isReloginShow = true; + MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' } ).then(() => { + isReloginShow = false; store.dispatch('LogOut').then(() => { - location.href = '/index'; + // 如果是登录页面不需要重新加载 + if (window.location.hash.indexOf("#/login") != 0) { + location.href = '/index'; + } }) - }).catch(() => {}); + }).catch(() => { + isReloginShow = false; + }); + } return Promise.reject('无效的会话,或者会话已过期,请重新登录。') } else if (code === 500) { Message({ From cb6228800b36a69744a2815035be6a7d9cffd96f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 1 Jan 2022 09:28:52 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=B0=E5=A2=9EJava=E7=B1=BB=E5=9E=8BBoolean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/tool/gen/editTable.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/ruoyi-ui/src/views/tool/gen/editTable.vue b/ruoyi-ui/src/views/tool/gen/editTable.vue index 5be5c5054..26571d935 100644 --- a/ruoyi-ui/src/views/tool/gen/editTable.vue +++ b/ruoyi-ui/src/views/tool/gen/editTable.vue @@ -33,6 +33,7 @@ + From 7bc15245aa48e743ad42fbe5d53582a90cd450cf Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 1 Jan 2022 09:46:18 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E9=A2=84=E8=A7=88=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E5=9B=BE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ImagePreview/index.vue | 121 ++++++++++-------- 1 file changed, 69 insertions(+), 52 deletions(-) diff --git a/ruoyi-ui/src/components/ImagePreview/index.vue b/ruoyi-ui/src/components/ImagePreview/index.vue index 44e27aac2..743d8d51d 100644 --- a/ruoyi-ui/src/components/ImagePreview/index.vue +++ b/ruoyi-ui/src/components/ImagePreview/index.vue @@ -1,67 +1,84 @@ From 10ae0bce65e6b33dbaec80d702372a39233775df Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 1 Jan 2022 09:50:35 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=B8=80=E6=AC=A1=E8=A7=92=E8=89=B2=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=85=B3=E8=81=94=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/web/controller/system/SysUserController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 9aacc3be0..77fcff913 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -104,9 +104,10 @@ public class SysUserController extends BaseController ajax.put("posts", postService.selectPostAll()); if (StringUtils.isNotNull(userId)) { + SysUser sysUser = userService.selectUserById(userId); ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId)); ajax.put("postIds", postService.selectPostListByUserId(userId)); - ajax.put("roleIds", roleService.selectRoleListByUserId(userId)); + ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); } return ajax; } From c9d19cbe56c73efd5ac64eddefedc5c657af996b Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 2 Jan 2022 10:29:15 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E7=A9=BA=E5=80=BC=E4=B8=8D=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E5=9B=9E=E6=98=BE=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/ruoyi.js | 323 ++++++++++++++++++------------------ 1 file changed, 164 insertions(+), 159 deletions(-) diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index 0c4c77bbe..8e3cb0cea 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -1,3 +1,5 @@ + + /** * 通用js方法封装处理 * Copyright (c) 2019 ruoyi @@ -5,130 +7,133 @@ // 日期格式化 export function parseTime(time, pattern) { - if (arguments.length === 0 || !time) { - return null - } - const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' - let date - if (typeof time === 'object') { - date = time - } else { - if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { - time = parseInt(time) - } else if (typeof time === 'string') { - time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm),''); - } - if ((typeof time === 'number') && (time.toString().length === 10)) { - time = time * 1000 - } - date = new Date(time) - } - const formatObj = { - y: date.getFullYear(), - m: date.getMonth() + 1, - d: date.getDate(), - h: date.getHours(), - i: date.getMinutes(), - s: date.getSeconds(), - a: date.getDay() - } - const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { - let value = formatObj[key] - // Note: getDay() returns 0 on Sunday - if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] } - if (result.length > 0 && value < 10) { - value = '0' + value - } - return value || 0 - }) - return time_str + if (arguments.length === 0 || !time) { + return null + } + const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' + let date + if (typeof time === 'object') { + date = time + } else { + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + time = parseInt(time) + } else if (typeof time === 'string') { + time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm), ''); + } + if ((typeof time === 'number') && (time.toString().length === 10)) { + time = time * 1000 + } + date = new Date(time) + } + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay() + } + const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { + let value = formatObj[key] + // Note: getDay() returns 0 on Sunday + if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] } + if (result.length > 0 && value < 10) { + value = '0' + value + } + return value || 0 + }) + return time_str } // 表单重置 export function resetForm(refName) { - if (this.$refs[refName]) { - this.$refs[refName].resetFields(); - } + if (this.$refs[refName]) { + this.$refs[refName].resetFields(); + } } // 添加日期范围 export function addDateRange(params, dateRange, propName) { - let search = params; - search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}; - dateRange = Array.isArray(dateRange) ? dateRange : []; - if (typeof (propName) === 'undefined') { - search.params['beginTime'] = dateRange[0]; - search.params['endTime'] = dateRange[1]; - } else { - search.params['begin' + propName] = dateRange[0]; - search.params['end' + propName] = dateRange[1]; - } - return search; + let search = params; + search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}; + dateRange = Array.isArray(dateRange) ? dateRange : []; + if (typeof (propName) === 'undefined') { + search.params['beginTime'] = dateRange[0]; + search.params['endTime'] = dateRange[1]; + } else { + search.params['begin' + propName] = dateRange[0]; + search.params['end' + propName] = dateRange[1]; + } + return search; } -// 回显数据字典 +// 回显数据字典 export function selectDictLabel(datas, value) { - var actions = []; - Object.keys(datas).some((key) => { - if (datas[key].value == ('' + value)) { - actions.push(datas[key].label); - return true; - } - }) - return actions.join(''); + var actions = []; + Object.keys(datas).some((key) => { + if (datas[key].value == ('' + value)) { + actions.push(datas[key].label); + return true; + } + }) + return actions.join(''); } // 回显数据字典(字符串数组) export function selectDictLabels(datas, value, separator) { - var actions = []; - var currentSeparator = undefined === separator ? "," : separator; - var temp = value.split(currentSeparator); - Object.keys(value.split(currentSeparator)).some((val) => { - Object.keys(datas).some((key) => { - if (datas[key].value == ('' + temp[val])) { - actions.push(datas[key].label + currentSeparator); - } - }) - }) - return actions.join('').substring(0, actions.join('').length - 1); + if(value === undefined) { + return ""; + } + var actions = []; + var currentSeparator = undefined === separator ? "," : separator; + var temp = value.split(currentSeparator); + Object.keys(value.split(currentSeparator)).some((val) => { + Object.keys(datas).some((key) => { + if (datas[key].value == ('' + temp[val])) { + actions.push(datas[key].label + currentSeparator); + } + }) + }) + return actions.join('').substring(0, actions.join('').length - 1); } // 字符串格式化(%s ) export function sprintf(str) { - var args = arguments, flag = true, i = 1; - str = str.replace(/%s/g, function () { - var arg = args[i++]; - if (typeof arg === 'undefined') { - flag = false; - return ''; - } - return arg; - }); - return flag ? str : ''; + var args = arguments, flag = true, i = 1; + str = str.replace(/%s/g, function () { + var arg = args[i++]; + if (typeof arg === 'undefined') { + flag = false; + return ''; + } + return arg; + }); + return flag ? str : ''; } // 转换字符串,undefined,null等转化为"" export function parseStrEmpty(str) { - if (!str || str == "undefined" || str == "null") { - return ""; - } - return str; + if (!str || str == "undefined" || str == "null") { + return ""; + } + return str; } // 数据合并 export function mergeRecursive(source, target) { - for (var p in target) { - try { - if (target[p].constructor == Object) { - source[p] = mergeRecursive(source[p], target[p]); - } else { - source[p] = target[p]; - } - } catch(e) { - source[p] = target[p]; - } + for (var p in target) { + try { + if (target[p].constructor == Object) { + source[p] = mergeRecursive(source[p], target[p]); + } else { + source[p] = target[p]; + } + } catch (e) { + source[p] = target[p]; } - return source; + } + return source; }; /** @@ -139,47 +144,47 @@ export function mergeRecursive(source, target) { * @param {*} children 孩子节点字段 默认 'children' */ export function handleTree(data, id, parentId, children) { - let config = { - id: id || 'id', - parentId: parentId || 'parentId', - childrenList: children || 'children' - }; + let config = { + id: id || 'id', + parentId: parentId || 'parentId', + childrenList: children || 'children' + }; - var childrenListMap = {}; - var nodeIds = {}; - var tree = []; + var childrenListMap = {}; + var nodeIds = {}; + var tree = []; - for (let d of data) { - let parentId = d[config.parentId]; - if (childrenListMap[parentId] == null) { - childrenListMap[parentId] = []; - } - nodeIds[d[config.id]] = d; - childrenListMap[parentId].push(d); - } + for (let d of data) { + let parentId = d[config.parentId]; + if (childrenListMap[parentId] == null) { + childrenListMap[parentId] = []; + } + nodeIds[d[config.id]] = d; + childrenListMap[parentId].push(d); + } - for (let d of data) { - let parentId = d[config.parentId]; - if (nodeIds[parentId] == null) { - tree.push(d); - } - } + for (let d of data) { + let parentId = d[config.parentId]; + if (nodeIds[parentId] == null) { + tree.push(d); + } + } - for (let t of tree) { - adaptToChildrenList(t); - } + for (let t of tree) { + adaptToChildrenList(t); + } - function adaptToChildrenList(o) { - if (childrenListMap[o[config.id]] !== null) { - o[config.childrenList] = childrenListMap[o[config.id]]; - } - if (o[config.childrenList]) { - for (let c of o[config.childrenList]) { - adaptToChildrenList(c); - } - } - } - return tree; + function adaptToChildrenList(o) { + if (childrenListMap[o[config.id]] !== null) { + o[config.childrenList] = childrenListMap[o[config.id]]; + } + if (o[config.childrenList]) { + for (let c of o[config.childrenList]) { + adaptToChildrenList(c); + } + } + } + return tree; } /** @@ -187,34 +192,34 @@ export function handleTree(data, id, parentId, children) { * @param {*} params 参数 */ export function tansParams(params) { - let result = '' - for (const propName of Object.keys(params)) { - const value = params[propName]; - var part = encodeURIComponent(propName) + "="; - if (value !== null && typeof (value) !== "undefined") { - if (typeof value === 'object') { - for (const key of Object.keys(value)) { - if (value[key] !== null && typeof (value[key]) !== 'undefined') { - let params = propName + '[' + key + ']'; - var subPart = encodeURIComponent(params) + "="; - result += subPart + encodeURIComponent(value[key]) + "&"; - } - } - } else { - result += part + encodeURIComponent(value) + "&"; - } - } - } - return result + let result = '' + for (const propName of Object.keys(params)) { + const value = params[propName]; + var part = encodeURIComponent(propName) + "="; + if (value !== null && typeof (value) !== "undefined") { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + if (value[key] !== null && typeof (value[key]) !== 'undefined') { + let params = propName + '[' + key + ']'; + var subPart = encodeURIComponent(params) + "="; + result += subPart + encodeURIComponent(value[key]) + "&"; + } + } + } else { + result += part + encodeURIComponent(value) + "&"; + } + } + } + return result } // 验证是否为blob格式 export async function blobValidate(data) { - try { - const text = await data.text(); - JSON.parse(text); - return false; - } catch (error) { - return true; - } -} + try { + const text = await data.text(); + JSON.parse(text); + return false; + } catch (error) { + return true; + } +} \ No newline at end of file From c8d9b3f8fc369b70bd6e81a697488d595748a1a5 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 2 Jan 2022 10:37:09 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=98=AF=E5=90=A6=E9=9C=80=E8=A6=81=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E6=95=B0=E6=8D=AE=E9=87=8D=E5=A4=8D=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/request.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index 12e535a64..107a28d67 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -4,6 +4,7 @@ import store from '@/store' import { getToken } from '@/utils/auth' import errorCode from '@/utils/errorCode' import { tansParams, blobValidate } from "@/utils/ruoyi"; +import cache from '@/plugins/cache' import { saveAs } from 'file-saver' let downloadLoadingInstance; @@ -23,6 +24,8 @@ const service = axios.create({ service.interceptors.request.use(config => { // 是否需要设置 token const isToken = (config.headers || {}).isToken === false + // 是否需要防止数据重复提交 + const isRepeatSubmit = (config.headers || {}).repeatSubmit === false if (getToken() && !isToken) { config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 } @@ -33,6 +36,29 @@ service.interceptors.request.use(config => { config.params = {}; config.url = url; } + if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) { + const requestObj = { + url: config.url, + data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data, + time: new Date().getTime() + } + const sessionObj = cache.session.getJSON('sessionObj') + if (sessionObj === undefined || sessionObj === null || sessionObj === '') { + cache.session.setJSON('sessionObj', requestObj) + } else { + const s_url = sessionObj.url; // 请求地址 + const s_data = sessionObj.data; // 请求数据 + const s_time = sessionObj.time; // 请求时间 + const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交 + if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) { + const message = '数据正在处理,请勿重复提交'; + console.warn(`[${s_url}]: ` + message) + return Promise.reject(new Error(message)) + } else { + cache.session.setJSON('sessionObj', requestObj) + } + } + } return config }, error => { console.log(error) From 8ba91fc9ddced1cfabed07edc0abff98feb17739 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 4 Jan 2022 09:10:49 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/web/controller/system/SysUserController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 77fcff913..e9be25e04 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -105,7 +105,7 @@ public class SysUserController extends BaseController if (StringUtils.isNotNull(userId)) { SysUser sysUser = userService.selectUserById(userId); - ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId)); + ajax.put(AjaxResult.DATA_TAG, sysUser); ajax.put("postIds", postService.selectPostListByUserId(userId)); ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); }