diff --git a/pom.xml b/pom.xml
index 816775564..0461bc403 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
UTF-8
UTF-8
1.8
- 2.5.5
+ 2.5.6
2020.0.4
2021.1
2.0.3
diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/interceptor/HeaderInterceptor.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/interceptor/HeaderInterceptor.java
index caefceb28..3453e1d19 100644
--- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/interceptor/HeaderInterceptor.java
+++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/interceptor/HeaderInterceptor.java
@@ -14,6 +14,7 @@ import com.ruoyi.system.api.model.LoginUser;
/**
* 自定义请求头拦截器,将Header数据封装到线程变量中方便获取
+ * 注意:此拦截器会同时验证当前用户有效期自动刷新有效期
*
* @author ruoyi
*/
diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
index e996fffab..101de6386 100644
--- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
+++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
@@ -59,7 +59,7 @@ public class AuthFilter implements GlobalFilter, Ordered
Claims claims = JwtUtils.parseToken(token);
if (claims == null)
{
- return unauthorizedResponse(exchange, "token已过期或验证不正确!");
+ return unauthorizedResponse(exchange, "令牌已过期或验证不正确!");
}
String userkey = JwtUtils.getUserKey(claims);
boolean islogin = redisService.hasKey(getTokenKey(userkey));
diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/SentinelFallbackHandler.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/SentinelFallbackHandler.java
index c770a1547..1b496e29e 100644
--- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/SentinelFallbackHandler.java
+++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/SentinelFallbackHandler.java
@@ -17,7 +17,7 @@ public class SentinelFallbackHandler implements WebExceptionHandler
{
private Mono writeResponse(ServerResponse response, ServerWebExchange exchange)
{
- return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "请求超过最大数,请稍后再试");
+ return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "请求超过最大数,请稍候再试");
}
@Override
diff --git a/ruoyi-ui/src/layout/components/Settings/index.vue b/ruoyi-ui/src/layout/components/Settings/index.vue
index 4dff1d0c5..bd2f553cf 100644
--- a/ruoyi-ui/src/layout/components/Settings/index.vue
+++ b/ruoyi-ui/src/layout/components/Settings/index.vue
@@ -162,7 +162,7 @@ export default {
this.sideTheme = val;
},
saveSetting() {
- this.$modal.loading("正在保存到本地,请稍后...");
+ this.$modal.loading("正在保存到本地,请稍候...");
this.$cache.local.set(
"layout-setting",
`{
@@ -178,7 +178,7 @@ export default {
setTimeout(this.$modal.closeLoading(), 1000)
},
resetSetting() {
- this.$modal.loading("正在清除设置缓存并刷新,请稍后...");
+ this.$modal.loading("正在清除设置缓存并刷新,请稍候...");
this.$cache.local.remove("layout-setting")
setTimeout("window.location.reload()", 1000)
}
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/download.js b/ruoyi-ui/src/plugins/download.js
index bc838fd0f..e3983731f 100644
--- a/ruoyi-ui/src/plugins/download.js
+++ b/ruoyi-ui/src/plugins/download.js
@@ -1,6 +1,8 @@
-import { saveAs } from 'file-saver'
import axios from 'axios'
+import { Message } from 'element-ui'
+import { saveAs } from 'file-saver'
import { getToken } from '@/utils/auth'
+import { blobValidate } from "@/utils/ruoyi";
const baseURL = process.env.VUE_APP_BASE_API
@@ -12,9 +14,14 @@ 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 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) {
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
// 模态框对象
diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js
index 6db38ba15..f2eccb544 100644
--- a/ruoyi-ui/src/utils/request.js
+++ b/ruoyi-ui/src/utils/request.js
@@ -3,7 +3,7 @@ import { Notification, MessageBox, Message, Loading } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
-import { tansParams } from "@/utils/ruoyi";
+import { tansParams, blobValidate } from "@/utils/ruoyi";
import { saveAs } from 'file-saver'
let downloadLoadingInstance;
@@ -43,6 +43,10 @@ service.interceptors.response.use(res => {
const code = res.data.code || 200;
// 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default']
+ // 二进制数据则直接返回
+ if(res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer'){
+ return res.data
+ }
if (code === 401) {
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
confirmButtonText: '重新登录',
@@ -93,15 +97,19 @@ service.interceptors.response.use(res => {
// 通用下载方法
export function download(url, params, filename) {
- downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍后", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
+ downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
return service.post(url, params, {
transformRequest: [(params) => { return tansParams(params) }],
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob'
- }).then((data) => {
- const content = data
- const blob = new Blob([content])
- saveAs(blob, filename)
+ }).then(async (data) => {
+ const isLogin = await blobValidate(data);
+ if (isLogin) {
+ const blob = new Blob([data])
+ saveAs(blob, filename)
+ } else {
+ Message.error('无效的会话,或者会话已过期,请重新登录。');
+ }
downloadLoadingInstance.close();
}).catch((r) => {
console.error(r)
diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js
index 1d867d40b..8d5bfc6d7 100644
--- a/ruoyi-ui/src/utils/ruoyi.js
+++ b/ruoyi-ui/src/utils/ruoyi.js
@@ -214,3 +214,14 @@ export function tansParams(params) {
}
return result
}
+
+// 验证是否为blob格式
+export async function blobValidate(data) {
+ try {
+ const text = await data.text();
+ JSON.parse(text);
+ return false;
+ } catch (error) {
+ return true;
+ }
+}
diff --git a/ruoyi-ui/src/views/system/role/index.vue b/ruoyi-ui/src/views/system/role/index.vue
index f44b4a54b..b2cfd6bf8 100644
--- a/ruoyi-ui/src/views/system/role/index.vue
+++ b/ruoyi-ui/src/views/system/role/index.vue
@@ -199,7 +199,7 @@
ref="menu"
node-key="id"
:check-strictly="!form.menuCheckStrictly"
- empty-text="加载中,请稍后"
+ empty-text="加载中,请稍候"
:props="defaultProps"
>
@@ -244,7 +244,7 @@
ref="dept"
node-key="id"
:check-strictly="!form.deptCheckStrictly"
- empty-text="加载中,请稍后"
+ empty-text="加载中,请稍候"
:props="defaultProps"
>