From f1fed76273361a6d6ed7ed276a9cafd32677be79 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 4 Oct 2021 10:28:13 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E5=8D=87=E7=BA=A7element-ui=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC2.15.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 ++-- ruoyi-ui/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2e1d5e075..c1d9a291c 100644 --- a/pom.xml +++ b/pom.xml @@ -21,8 +21,8 @@ 1.2.6 1.21 3.0.0 - 2.3.2 - 2.1.4 + 2.3.2 + 2.1.4 1.3.1 1.2.78 5.8.0 diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index c7db2d8ed..034e0642d 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -41,7 +41,7 @@ "clipboard": "2.0.6", "core-js": "3.8.1", "echarts": "4.9.0", - "element-ui": "2.15.5", + "element-ui": "2.15.6", "file-saver": "2.0.5", "fuse.js": "6.4.3", "highlight.js": "9.18.5", From 0b14155a75f955e553f8730447f2cf17a584fe81 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 9 Oct 2021 11:42:29 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20sendGet=20=E6=97=A0?= =?UTF-8?q?=E5=8F=82=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/utils/http/HttpUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java index 200374328..c920f5b12 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java @@ -19,6 +19,7 @@ import javax.net.ssl.X509TrustManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.utils.StringUtils; /** * 通用http发送方法 @@ -55,7 +56,7 @@ public class HttpUtils BufferedReader in = null; try { - String urlNameString = url + "?" + param; + String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url; log.info("sendGet - {}", urlNameString); URL realUrl = new URL(urlNameString); URLConnection connection = realUrl.openConnection(); From 7ae47b50b850d6fd2eac4b76cfcd9c63100f5e92 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 9 Oct 2021 11:43:26 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index b9f9ac289..fa9529119 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -493,7 +493,7 @@ public class ExcelUtil */ public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException { - importTemplateExcel(response, sheetName); + importTemplateExcel(response, sheetName, StringUtils.EMPTY); } /** From f6e477b4f539715bbbc08bf7c0c9bbb8d4208fe7 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 9 Oct 2021 11:43:34 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E5=8D=87=E7=BA=A7druid=E5=88=B0=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=89=881.2.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c1d9a291c..69cd0efab 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ UTF-8 1.8 3.1.1 - 1.2.6 + 1.2.8 1.21 3.0.0 2.3.2 From c4207f640b798009d81fa0d9270e88341a4d5d24 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 10 Oct 2021 11:21:46 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E4=BD=BF=E7=94=A8JSONField=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/core/domain/model/LoginUser.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java index 7b1d8966a..993ca2268 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java @@ -4,7 +4,7 @@ import java.util.Collection; import java.util.Set; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.alibaba.fastjson.annotation.JSONField; import com.ruoyi.common.core.domain.entity.SysUser; /** @@ -119,7 +119,7 @@ public class LoginUser implements UserDetails this.permissions = permissions; } - @JsonIgnore + @JSONField(serialize = false) @Override public String getPassword() { @@ -135,7 +135,7 @@ public class LoginUser implements UserDetails /** * 账户是否未过期,过期无法验证 */ - @JsonIgnore + @JSONField(serialize = false) @Override public boolean isAccountNonExpired() { @@ -147,7 +147,7 @@ public class LoginUser implements UserDetails * * @return */ - @JsonIgnore + @JSONField(serialize = false) @Override public boolean isAccountNonLocked() { @@ -159,7 +159,7 @@ public class LoginUser implements UserDetails * * @return */ - @JsonIgnore + @JSONField(serialize = false) @Override public boolean isCredentialsNonExpired() { @@ -171,7 +171,7 @@ public class LoginUser implements UserDetails * * @return */ - @JsonIgnore + @JSONField(serialize = false) @Override public boolean isEnabled() { From 4fdb0f48ec1f7833d37db1b995ff1b05d0310e6e Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 10 Oct 2021 11:23:04 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E5=90=8C=E6=AD=A5element2.15.6=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/monitor/cache/index.vue | 48 ++++---- ruoyi-ui/src/views/monitor/server/index.vue | 118 ++++++++++---------- 2 files changed, 83 insertions(+), 83 deletions(-) diff --git a/ruoyi-ui/src/views/monitor/cache/index.vue b/ruoyi-ui/src/views/monitor/cache/index.vue index 36957edd2..22501dc34 100644 --- a/ruoyi-ui/src/views/monitor/cache/index.vue +++ b/ruoyi-ui/src/views/monitor/cache/index.vue @@ -8,34 +8,34 @@ - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + +
Redis版本
{{ cache.info.redis_version }}
运行模式
{{ cache.info.redis_mode == "standalone" ? "单机" : "集群" }}
端口
{{ cache.info.tcp_port }}
客户端数
{{ cache.info.connected_clients }}
Redis版本
{{ cache.info.redis_version }}
运行模式
{{ cache.info.redis_mode == "standalone" ? "单机" : "集群" }}
端口
{{ cache.info.tcp_port }}
客户端数
{{ cache.info.connected_clients }}
运行时间(天)
{{ cache.info.uptime_in_days }}
使用内存
{{ cache.info.used_memory_human }}
使用CPU
{{ parseFloat(cache.info.used_cpu_user_children).toFixed(2) }}
内存配置
{{ cache.info.maxmemory_human }}
运行时间(天)
{{ cache.info.uptime_in_days }}
使用内存
{{ cache.info.used_memory_human }}
使用CPU
{{ parseFloat(cache.info.used_cpu_user_children).toFixed(2) }}
内存配置
{{ cache.info.maxmemory_human }}
AOF是否开启
{{ cache.info.aof_enabled == "0" ? "否" : "是" }}
RDB是否成功
{{ cache.info.rdb_last_bgsave_status }}
Key数量
{{ cache.dbSize }}
网络入口/出口
{{ cache.info.instantaneous_input_kbps }}kps/{{cache.info.instantaneous_output_kbps}}kps
AOF是否开启
{{ cache.info.aof_enabled == "0" ? "否" : "是" }}
RDB是否成功
{{ cache.info.rdb_last_bgsave_status }}
Key数量
{{ cache.dbSize }}
网络入口/出口
{{ cache.info.instantaneous_input_kbps }}kps/{{cache.info.instantaneous_output_kbps}}kps
diff --git a/ruoyi-ui/src/views/monitor/server/index.vue b/ruoyi-ui/src/views/monitor/server/index.vue index 367001f4d..503bf9b61 100644 --- a/ruoyi-ui/src/views/monitor/server/index.vue +++ b/ruoyi-ui/src/views/monitor/server/index.vue @@ -8,26 +8,26 @@ - - + + - - + + - - + + - - + + - - + +
属性
属性
核心数
{{ server.cpu.cpuNum }}
核心数
{{ server.cpu.cpuNum }}
用户使用率
{{ server.cpu.used }}%
用户使用率
{{ server.cpu.used }}%
系统使用率
{{ server.cpu.sys }}%
系统使用率
{{ server.cpu.sys }}%
当前空闲率
{{ server.cpu.free }}%
当前空闲率
{{ server.cpu.free }}%
@@ -42,31 +42,31 @@ - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
属性
内存
JVM
属性
内存
JVM
总内存
{{ server.mem.total }}G
{{ server.jvm.total }}M
总内存
{{ server.mem.total }}G
{{ server.jvm.total }}M
已用内存
{{ server.mem.used}}G
{{ server.jvm.used}}M
已用内存
{{ server.mem.used}}G
{{ server.jvm.used}}M
剩余内存
{{ server.mem.free }}G
{{ server.jvm.free }}M
剩余内存
{{ server.mem.free }}G
{{ server.jvm.free }}M
使用率
{{ server.mem.usage }}%
{{ server.jvm.usage }}%
使用率
{{ server.mem.usage }}%
{{ server.jvm.usage }}%
@@ -83,16 +83,16 @@ - - - - + + + + - - - - + + + +
服务器名称
{{ server.sys.computerName }}
操作系统
{{ server.sys.osName }}
服务器名称
{{ server.sys.computerName }}
操作系统
{{ server.sys.osName }}
服务器IP
{{ server.sys.computerIp }}
系统架构
{{ server.sys.osArch }}
服务器IP
{{ server.sys.computerIp }}
系统架构
{{ server.sys.osArch }}
@@ -109,24 +109,24 @@ - - - - + + + + - - - - + + + + - - + + - - + +
Java名称
{{ server.jvm.name }}
Java版本
{{ server.jvm.version }}
Java名称
{{ server.jvm.name }}
Java版本
{{ server.jvm.version }}
启动时间
{{ server.jvm.startTime }}
运行时长
{{ server.jvm.runTime }}
启动时间
{{ server.jvm.startTime }}
运行时长
{{ server.jvm.runTime }}
安装路径
{{ server.jvm.home }}
安装路径
{{ server.jvm.home }}
项目路径
{{ server.sys.userDir }}
项目路径
{{ server.sys.userDir }}
@@ -143,24 +143,24 @@ - - - - - - - + + + + + + + - - - - - - - + + + + + + +
盘符路径
文件系统
盘符类型
总大小
可用大小
已用大小
已用百分比
盘符路径
文件系统
盘符类型
总大小
可用大小
已用大小
已用百分比
{{ sysFile.dirName }}
{{ sysFile.sysTypeName }}
{{ sysFile.typeName }}
{{ sysFile.total }}
{{ sysFile.free }}
{{ sysFile.used }}
{{ sysFile.usage }}%
{{ sysFile.dirName }}
{{ sysFile.sysTypeName }}
{{ sysFile.typeName }}
{{ sysFile.total }}
{{ sysFile.free }}
{{ sysFile.used }}
{{ sysFile.usage }}%
From ae5c68368be574a12952b64b1b91808307eed310 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 10 Oct 2021 11:24:16 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E5=8D=87=E7=BA=A7SpringBoot=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC2.5.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../controller/system/SysRegisterController.java | 2 +- .../ruoyi/framework/config/ResourcesConfig.java | 15 ++++++++++----- .../interceptor/RepeatSubmitInterceptor.java | 6 +++--- .../framework/web/service/SysRegisterService.java | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 69cd0efab..5e4ec7b13 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ org.springframework.boot spring-boot-dependencies - 2.2.13.RELEASE + 2.5.5 pom import diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java index e88a2ad6e..f1552e033 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java @@ -1,13 +1,13 @@ package com.ruoyi.web.controller.system; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.model.RegisterBody; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.service.SysRegisterService; import com.ruoyi.system.service.ISysConfigService; diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java index 9cd523e76..24ef0dec9 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java @@ -28,10 +28,12 @@ public class ResourcesConfig implements WebMvcConfigurer public void addResourceHandlers(ResourceHandlerRegistry registry) { /** 本地文件上传路径 */ - registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); + registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**") + .addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); /** swagger配置 */ - registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/"); + registry.addResourceHandler("/swagger-ui/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/"); } /** @@ -49,17 +51,20 @@ public class ResourcesConfig implements WebMvcConfigurer @Bean public CorsFilter corsFilter() { - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); // 设置访问源地址 - config.addAllowedOrigin("*"); + config.addAllowedOriginPattern("*"); // 设置访问源请求头 config.addAllowedHeader("*"); // 设置访问源请求方法 config.addAllowedMethod("*"); - // 对接口配置跨域设置 + // 有效期 1800秒 + config.setMaxAge(1800L); + // 添加映射路径,拦截一切请求 + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/**", config); + // 返回新的CorsFilter return new CorsFilter(source); } } \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java index 7b7f5a407..509e28731 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java @@ -5,7 +5,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Component; import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import org.springframework.web.servlet.HandlerInterceptor; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.annotation.RepeatSubmit; import com.ruoyi.common.core.domain.AjaxResult; @@ -17,7 +17,7 @@ import com.ruoyi.common.utils.ServletUtils; * @author ruoyi */ @Component -public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter +public abstract class RepeatSubmitInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception @@ -40,7 +40,7 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter } else { - return super.preHandle(request, response, handler); + return true; } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java index c7fbdc942..35a425c7d 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java @@ -2,7 +2,6 @@ package com.ruoyi.framework.web.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.entity.SysUser; @@ -12,6 +11,7 @@ import com.ruoyi.common.exception.user.CaptchaException; import com.ruoyi.common.exception.user.CaptchaExpireException; import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.manager.AsyncManager; import com.ruoyi.framework.manager.factory.AsyncFactory; import com.ruoyi.system.service.ISysConfigService; From 8bd6296721185bf5350ac975eb6caca7c9e7b75c Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 10 Oct 2021 11:25:37 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E5=8D=87=E7=BA=A7pagehelper=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=881.4.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5e4ec7b13..91da95425 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 3.0.0 2.3.2 2.1.4 - 1.3.1 + 1.4.0 1.2.78 5.8.0 5.8.0 From b1e5ebab8f2d522b876a46f6a60f37227a6de1e5 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 10 Oct 2021 11:26:50 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E5=8D=87=E7=BA=A7spring-boot-mybatis?= =?UTF-8?q?=E5=88=B0=E6=9C=80=E6=96=B0=E7=89=882.2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 91da95425..91ac13cee 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.21 3.0.0 2.3.2 - 2.1.4 + 2.2.0 1.4.0 1.2.78 5.8.0 From eb4376b649a0f8783e8f70406a438ad3c61b8f12 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 10 Oct 2021 14:30:08 +0800 Subject: [PATCH 10/19] =?UTF-8?q?Excel=E5=AF=BC=E5=85=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?@Excels=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/utils/poi/ExcelUtil.java | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index fa9529119..4169360a1 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -268,22 +268,15 @@ public class ExcelUtil } } // 有数据时才处理 得到类的所有field. - Field[] allFields = clazz.getDeclaredFields(); - // 定义一个map用于存放列的序号和field. - Map fieldsMap = new HashMap(); - for (int col = 0; col < allFields.length; col++) + List fields = this.getFields(); + Map fieldsMap = new HashMap(); + for (Object[] objects : fields) { - Field field = allFields[col]; - Excel attr = field.getAnnotation(Excel.class); - if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) + Excel attr = (Excel) objects[1]; + Integer column = cellMap.get(attr.name()); + if (column != null) { - // 设置类的私有字段属性可访问. - field.setAccessible(true); - Integer column = cellMap.get(attr.name()); - if (column != null) - { - fieldsMap.put(column, field); - } + fieldsMap.put(column, objects); } } for (int i = titleNum + 1; i <= rows; i++) @@ -296,14 +289,15 @@ public class ExcelUtil continue; } T entity = null; - for (Map.Entry entry : fieldsMap.entrySet()) + for (Map.Entry entry : fieldsMap.entrySet()) { Object val = this.getCellValue(row, entry.getKey()); // 如果不存在实例则新建. entity = (entity == null ? clazz.newInstance() : entity); // 从map中得到对应列的field. - Field field = fieldsMap.get(entry.getKey()); + Field field = (Field) entry.getValue()[0]; + Excel attr = (Excel) entry.getValue()[1]; // 取得类型,并根据对象类型设置值. Class fieldType = field.getType(); if (String.class == fieldType) @@ -363,7 +357,6 @@ public class ExcelUtil } if (StringUtils.isNotNull(fieldType)) { - Excel attr = field.getAnnotation(Excel.class); String propertyName = field.getName(); if (StringUtils.isNotEmpty(attr.targetAttr())) { @@ -610,8 +603,6 @@ public class ExcelUtil { Field field = (Field) os[0]; Excel excel = (Excel) os[1]; - // 设置实体类私有属性可访问 - field.setAccessible(true); this.addCell(excel, row, vo, field, column++); } } @@ -1164,7 +1155,17 @@ public class ExcelUtil */ private void createExcelField() { - this.fields = new ArrayList(); + this.fields = getFields(); + this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList()); + this.maxHeight = getRowHeight(); + } + + /** + * 获取字段注解信息 + */ + public List getFields() + { + List fields = new ArrayList(); List tempFields = new ArrayList<>(); tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); @@ -1173,7 +1174,12 @@ public class ExcelUtil // 单注解 if (field.isAnnotationPresent(Excel.class)) { - putToField(field, field.getAnnotation(Excel.class)); + Excel attr = field.getAnnotation(Excel.class); + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) + { + field.setAccessible(true); + fields.add(new Object[] { field, attr }); + } } // 多注解 @@ -1181,14 +1187,17 @@ public class ExcelUtil { Excels attrs = field.getAnnotation(Excels.class); Excel[] excels = attrs.value(); - for (Excel excel : excels) + for (Excel attr : excels) { - putToField(field, excel); + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) + { + field.setAccessible(true); + fields.add(new Object[] { field, attr }); + } } } } - this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList()); - this.maxHeight = getRowHeight(); + return fields; } /** @@ -1205,17 +1214,6 @@ public class ExcelUtil return (short) (maxHeight * 20); } - /** - * 放到字段集合中 - */ - private void putToField(Field field, Excel attr) - { - if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) - { - this.fields.add(new Object[] { field, attr }); - } - } - /** * 创建一个工作簿 */ From 6d6271d6c97a9077626e50f09c1b860c41a44d60 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 14 Oct 2021 16:19:46 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=94=E7=BA=A7?= =?UTF-8?q?=E4=BB=A5=E4=B8=8A=E8=8F=9C=E5=8D=95404=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/store/modules/permission.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/store/modules/permission.js b/ruoyi-ui/src/store/modules/permission.js index 340524abc..6143038ab 100644 --- a/ruoyi-ui/src/store/modules/permission.js +++ b/ruoyi-ui/src/store/modules/permission.js @@ -86,7 +86,7 @@ function filterChildren(childrenMap, lastRouter = false) { var children = [] childrenMap.forEach((el, index) => { if (el.children && el.children.length) { - if (el.component === 'ParentView') { + if (el.component === 'ParentView' && !lastRouter) { el.children.forEach(c => { c.path = el.path + '/' + c.path if (c.children && c.children.length) { From e7afea4cb744c4789babd71af2dc03fd0d459ad7 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 14 Oct 2021 16:20:18 +0800 Subject: [PATCH 12/19] =?UTF-8?q?=E5=8D=87=E7=BA=A7oshi=E5=88=B0=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=89=88=E6=9C=ACv5.8.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 91ac13cee..6feb0ee79 100644 --- a/pom.xml +++ b/pom.xml @@ -25,8 +25,8 @@ 2.2.0 1.4.0 1.2.78 - 5.8.0 - 5.8.0 + 5.8.2 + 5.9.0 2.11.0 1.4 3.2.2 @@ -242,7 +242,7 @@ public aliyun nexus - http://maven.aliyun.com/nexus/content/groups/public/ + https://maven.aliyun.com/repository/public true @@ -253,7 +253,7 @@ public aliyun nexus - http://maven.aliyun.com/nexus/content/groups/public/ + https://maven.aliyun.com/repository/public true From e66d0e4f7465e840cc73e3b2d7dc4eeb2dc804b8 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 15 Oct 2021 17:56:57 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E8=A7=92=E8=89=B2=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B=E4=BF=9D=E6=8C=81=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java | 2 +- .../src/main/java/com/ruoyi/system/service/ISysRoleService.java | 2 +- .../java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java | 2 +- ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java index e4379c97b..58ede18e0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java @@ -39,7 +39,7 @@ public interface SysRoleMapper * @param userId 用户ID * @return 选中角色ID列表 */ - public List selectRoleListByUserId(Long userId); + public List selectRoleListByUserId(Long userId); /** * 通过角色ID查询角色 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java index 1690ed53a..bf1f7b3d9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java @@ -49,7 +49,7 @@ public interface ISysRoleService * @param userId 用户ID * @return 选中角色ID列表 */ - public List selectRoleListByUserId(Long userId); + public List selectRoleListByUserId(Long userId); /** * 通过角色ID查询角色 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index cde75c873..f53f975fe 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -122,7 +122,7 @@ public class SysRoleServiceImpl implements ISysRoleService * @return 选中角色ID列表 */ @Override - public List selectRoleListByUserId(Long userId) + public List selectRoleListByUserId(Long userId) { return roleMapper.selectRoleListByUserId(userId); } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index c26cfe5a0..a8d3ede58 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -65,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select r.role_id from sys_role r left join sys_user_role ur on ur.role_id = r.role_id From 519ea854d57f83feb6d6e992ce85eaad0a9acaaa Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 15 Oct 2021 17:57:46 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E8=B7=AF=E7=94=B1=E6=87=92=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E9=A1=B5=E9=9D=A2=E5=93=8D=E5=BA=94=E9=80=9F?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/store/modules/permission.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ruoyi-ui/src/store/modules/permission.js b/ruoyi-ui/src/store/modules/permission.js index 6143038ab..4c8ed023b 100644 --- a/ruoyi-ui/src/store/modules/permission.js +++ b/ruoyi-ui/src/store/modules/permission.js @@ -106,8 +106,13 @@ function filterChildren(childrenMap, lastRouter = false) { return children } -export const loadView = (view) => { // 路由懒加载 - return (resolve) => require([`@/views/${view}`], resolve) +export const loadView = (view) => { + if (process.env.NODE_ENV === 'development') { + return (resolve) => require([`@/views/${view}`], resolve) + } else { + // 使用 import 实现生产环境的路由懒加载 + return () => import(`@/views/${view}`) + } } export default permission From c2a179e9dd0bcc0b7f0607b0220d1264dae46461 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 20 Oct 2021 11:18:20 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E7=AE=80=E5=8C=96=E6=9D=83=E9=99=90=E9=AA=8C?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/plugins/auth.js | 60 +++++++++++++++++++++++++++++++++++ ruoyi-ui/src/plugins/index.js | 3 ++ 2 files changed, 63 insertions(+) create mode 100644 ruoyi-ui/src/plugins/auth.js diff --git a/ruoyi-ui/src/plugins/auth.js b/ruoyi-ui/src/plugins/auth.js new file mode 100644 index 000000000..af740aaef --- /dev/null +++ b/ruoyi-ui/src/plugins/auth.js @@ -0,0 +1,60 @@ +import store from '@/store' + +function authPermission(permission) { + const all_permission = "*:*:*"; + const permissions = store.getters && store.getters.permissions + if (permission && permission.length > 0) { + return permissions.some(v => { + return all_permission === v || v === permission + }) + } else { + return false + } +} + +function authRole(role) { + const super_admin = "admin"; + const roles = store.getters && store.getters.roles + if (role && role.length > 0) { + return roles.some(v => { + return super_admin === v || v === role + }) + } else { + return false + } +} + +export default { + // 验证用户是否具备某权限 + hasPermi(permission) { + return authPermission(permission); + }, + // 验证用户是否含有指定权限,只需包含其中一个 + hasPermiOr(permissions) { + return permissions.some(item => { + return authPermission(item) + }) + }, + // 验证用户是否含有指定权限,必须全部拥有 + hasPermiAnd(permissions) { + return permissions.every(item => { + return authPermission(item) + }) + }, + // 验证用户是否具备某角色 + hasRole(role) { + return authRole(role); + }, + // 验证用户是否含有指定角色,只需包含其中一个 + hasRoleOr(roles) { + return roles.some(item => { + return authRole(item) + }) + }, + // 验证用户是否含有指定角色,必须全部拥有 + hasRoleAnd(roles) { + return roles.every(item => { + return authRole(item) + }) + } +} diff --git a/ruoyi-ui/src/plugins/index.js b/ruoyi-ui/src/plugins/index.js index a138e6d6f..7cc83a4c8 100644 --- a/ruoyi-ui/src/plugins/index.js +++ b/ruoyi-ui/src/plugins/index.js @@ -1,9 +1,12 @@ +import auth from './auth' import cache from './cache' import modal from './modal' import download from './download' export default { install(Vue) { + // 认证对象 + Vue.prototype.$auth = auth // 缓存对象 Vue.prototype.$cache = cache // 模态框对象 From 2d7d137abd0eb54a632ca2e18424348eab96cdd8 Mon Sep 17 00:00:00 2001 From: abbfun <819589789@qq.com> Date: Fri, 22 Oct 2021 03:09:54 +0000 Subject: [PATCH 16/19] =?UTF-8?q?update=20ruoyi-common/src/main/java/com/r?= =?UTF-8?q?uoyi/common/core/domain/AjaxResult.java.=20AjaxResult=E9=93=BE?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/core/domain/AjaxResult.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java index b26e066ab..472afc868 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java @@ -145,4 +145,16 @@ public class AjaxResult extends HashMap { return new AjaxResult(code, msg, null); } + + /** + * 链式调用 + * + * @param key 键 + * @param value 内容 + * @return 警告消息 + */ + public AjaxResult put(String key, Object value) { + super.put(key, value); + return this; + } } From 3dbbc6a22360fa65c66609285f10bffc3a32334d Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 22 Oct 2021 16:23:08 +0800 Subject: [PATCH 17/19] =?UTF-8?q?AjaxResult=E9=87=8D=E5=86=99put=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E4=BB=A5=E6=96=B9=E4=BE=BF=E9=93=BE=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/core/domain/AjaxResult.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java index 472afc868..8ca1b9b11 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java @@ -146,15 +146,17 @@ public class AjaxResult extends HashMap return new AjaxResult(code, msg, null); } - /** - * 链式调用 - * - * @param key 键 - * @param value 内容 - * @return 警告消息 - */ - public AjaxResult put(String key, Object value) { - super.put(key, value); - return this; - } + /** + * 方便链式调用 + * + * @param key 键 + * @param value 值 + * @return 数据对象 + */ + @Override + public AjaxResult put(String key, Object value) + { + super.put(key, value); + return this; + } } From ef4fef3d56f569d151ef71a9288e9973a19f4f6d Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 23 Oct 2021 10:21:02 +0800 Subject: [PATCH 18/19] update ry.sh. --- ry.bat | 26 +++++++++++++------------- ry.sh | 12 ++++-------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/ry.bat b/ry.bat index 5de3e1503..9f16232b2 100644 --- a/ry.bat +++ b/ry.bat @@ -4,36 +4,36 @@ rem jarƽ set AppName=ruoyi-admin.jar rem JVM -set JVM_OPTS="-Dname=%AppName% -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" +set JVM_OPTS="-Dname=%AppName% -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" -ECHO. +ECHO. ECHO. [1] %AppName% ECHO. [2] ر%AppName% ECHO. [3] %AppName% ECHO. [4] ״̬ %AppName% - ECHO. [5] -ECHO. + ECHO. [5] +ECHO. ECHO.ѡĿ: set /p ID= - IF "%id%"=="1" GOTO start - IF "%id%"=="2" GOTO stop - IF "%id%"=="3" GOTO restart + IF "%id%"=="1" GOTO start + IF "%id%"=="2" GOTO stop + IF "%id%"=="3" GOTO restart IF "%id%"=="4" GOTO status IF "%id%"=="5" EXIT -PAUSE +PAUSE :start for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do ( set pid=%%a set image_name=%%b ) if defined pid ( - echo %%is running - PAUSE - ) + echo %%is running + PAUSE + ) -start javaw -jar %JAVA_OPTS% ruoyi-admin.jar +start javaw %JAVA_OPTS% -jar %AppName% echo starting echo Start %AppName% success... @@ -64,4 +64,4 @@ goto:eof if not defined pid (echo process %AppName% is dead ) else ( echo %image_name% is running ) -goto:eof \ No newline at end of file +goto:eof diff --git a/ry.sh b/ry.sh index 7c4f50385..d6a9cf33a 100644 --- a/ry.sh +++ b/ry.sh @@ -1,13 +1,9 @@ #!/bin/sh -# author ruoyi -# ./ry.sh start 启动 -# ./ry.sh stop 停止 -# ./ry.sh restart 重启 -# ./ry.sh status 状态 +# ./ry.sh start 启动 stop 停止 restart 重启 status 状态 AppName=ruoyi-admin.jar # JVM参数 -JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" +JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" APP_HOME=`pwd` LOG_PATH=$APP_HOME/logs/$AppName.log @@ -30,7 +26,7 @@ function start() if [ x"$PID" != x"" ]; then echo "$AppName is running..." else - nohup java -jar $JVM_OPTS target/$AppName > /dev/null 2>&1 & + nohup java $JVM_OPTS -jar $AppName > /dev/null 2>&1 & echo "Start $AppName success..." fi } @@ -38,7 +34,7 @@ function start() function stop() { echo "Stop $AppName" - + PID="" query(){ PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'` From a4558c32b2b7630236f9f4323c79033879c1378b Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 23 Oct 2021 10:23:32 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E8=A7=A3=E6=9E=90blob=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E7=99=BB=E5=BD=95=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/plugins/download.js | 45 +++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/ruoyi-ui/src/plugins/download.js b/ruoyi-ui/src/plugins/download.js index cb10ab0e4..2aa81229a 100644 --- a/ruoyi-ui/src/plugins/download.js +++ b/ruoyi-ui/src/plugins/download.js @@ -1,6 +1,7 @@ import { saveAs } from 'file-saver' import axios from 'axios' import { getToken } from '@/utils/auth' +import { Message } from 'element-ui' const baseURL = process.env.VUE_APP_BASE_API @@ -12,9 +13,14 @@ export default { url: url, responseType: 'blob', headers: { 'Authorization': 'Bearer ' + getToken() } - }).then(res => { - const blob = new Blob([res.data]) - this.saveAs(blob, decodeURI(res.headers['download-filename'])) + }).then(async (res) => { + const isLogin = await this.blobValidate(res.data); + if (isLogin) { + const blob = new Blob([res.data]) + this.saveAs(blob, decodeURI(res.headers['download-filename'])) + } else { + Message.error('无效的会话,或者会话已过期,请重新登录。'); + } }) }, resource(resource) { @@ -24,9 +30,14 @@ export default { url: url, responseType: 'blob', headers: { 'Authorization': 'Bearer ' + getToken() } - }).then(res => { - const blob = new Blob([res.data]) - this.saveAs(blob, decodeURI(res.headers['download-filename'])) + }).then(async (res) => { + const isLogin = await this.blobValidate(res.data); + if (isLogin) { + const blob = new Blob([res.data]) + this.saveAs(blob, decodeURI(res.headers['download-filename'])) + } else { + Message.error('无效的会话,或者会话已过期,请重新登录。'); + } }) }, zip(url, name) { @@ -36,13 +47,27 @@ export default { url: url, responseType: 'blob', headers: { 'Authorization': 'Bearer ' + getToken() } - }).then(res => { - const blob = new Blob([res.data], { type: 'application/zip' }) - this.saveAs(blob, name) + }).then(async (res) => { + const isLogin = await this.blobValidate(res.data); + if (isLogin) { + const blob = new Blob([res.data], { type: 'application/zip' }) + this.saveAs(blob, name) + } else { + Message.error('无效的会话,或者会话已过期,请重新登录。'); + } }) }, saveAs(text, name, opts) { saveAs(text, name, opts); - } + }, + async blobValidate(data) { + try { + const text = await data.text(); + JSON.parse(text); + return false; + } catch (error) { + return true; + } + }, }