Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev

 Conflicts:
	pom.xml
	ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java
	ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java
	ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
	ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
	ruoyi-ui/src/layout/components/Settings/index.vue
	ruoyi-ui/src/plugins/download.js
	ruoyi-ui/src/store/modules/permission.js
	ruoyi-ui/src/views/index.vue
	ruoyi-ui/src/views/monitor/server/index.vue
	ruoyi-ui/src/views/system/role/index.vue
	ry.bat
This commit is contained in:
疯狂的狮子Li
2021-10-25 18:24:55 +08:00
16 changed files with 144 additions and 57 deletions

View File

@ -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)
}

View File

@ -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)
})
}
}

View File

@ -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
@ -35,9 +36,14 @@ export default {
url: url,
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
}).then(res => {
const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
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], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
this.saveAs(blob, decodeURI(res.headers['download-filename']))
} else {
Message.error('无效的会话,或者会话已过期,请重新登录。');
}
})
},
oss(ossId) {
@ -47,9 +53,14 @@ export default {
url: url,
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
}).then(res => {
const blob = new Blob([res.data], { type: 'application/octet-stream' })
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], { type: 'application/octet-stream' })
this.saveAs(blob, decodeURI(res.headers['download-filename']))
} else {
Message.error('无效的会话,或者会话已过期,请重新登录。');
}
})
},
zip(url, name) {
@ -59,13 +70,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;
}
},
}

View File

@ -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
// 模态框对象

View File

@ -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) {
@ -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

View File

@ -478,7 +478,6 @@
</template>
<script>
export default {
name: "Index",
data() {

View File

@ -139,7 +139,7 @@ export default {
},
// 打开加载层
openLoading() {
this.$modal.loading("正在加载缓存监控数据,请稍");
this.$modal.loading("正在加载缓存监控数据,请稍");
},
},
};

View File

@ -200,7 +200,7 @@
ref="menu"
node-key="id"
:check-strictly="!form.menuCheckStrictly"
empty-text="加载中请稍"
empty-text="加载中请稍"
:props="defaultProps"
></el-tree>
</el-form-item>
@ -245,7 +245,7 @@
ref="dept"
node-key="id"
:check-strictly="!form.deptCheckStrictly"
empty-text="加载中请稍"
empty-text="加载中请稍"
:props="defaultProps"
></el-tree>
</el-form-item>