JeecgBoot低代码平台 3.0版本发布—新里程牌开始,迎接VUE3版本到来!!

This commit is contained in:
zhangdaiscott
2021-10-27 10:26:33 +08:00
parent ac0422788b
commit 41cd7823ea
31 changed files with 449 additions and 568 deletions

View File

@ -8,6 +8,7 @@ const FormTypes = {
select: 'select',
date: 'date',
datetime: 'datetime',
time: 'time',
upload: 'upload',
file: 'file',
image: 'image',

View File

@ -75,7 +75,7 @@ const err = (error) => {
Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时'})
break
case 401:
Vue.prototype.$Jnotification.error({ message: '系统提示', description:'未授权请重新登录',duration: 4})
Vue.prototype.$Jnotification.error({ message: '系统提示', description:'很抱歉登录已过期请重新登录',duration: 4})
if (token) {
store.dispatch('Logout').then(() => {
setTimeout(() => {

View File

@ -591,3 +591,39 @@ export function getReportPrintUrl(url, id, open) {
}
return url
}
/**
* JS实现AOP切面
*
* @param obj 包含函数的对象
* @param funcName 要切面的函数名
* @param callback 执行方法前的回调用于切面callback的返回值就是funcName最终的返回值
*/
export function aspectAroundFunction(obj, funcName, callback) {
if (typeof callback !== 'function' || !obj) {
console.warn('aspectAroundFunctionobj或callback格式不正确')
return
}
// 保存原来的函数
let func = obj[funcName]
if (typeof func !== 'function') {
console.warn('aspectAroundFunction' + funcName + '不是一个方法')
return
}
// 赋值新方法
// 实现当外部调用 funcName 时,首先调用我定义的新方法
// 然后调用传入的callback方法以决定是否执行 funcName以及更改参数、返回值
obj[funcName] = function (...args) {
return callback({
args,
// 只有执行 proceed 才会真正执行给定的 funcName 方法
proceed() {
try {
return func.apply(obj, args)
} catch (e) {
console.error(e)
}
},
})
}
}