feat:完善前端友好提示功能
This commit is contained in:
@@ -183,6 +183,9 @@ RABC权限管理系统(正在更新)
|
|||||||
- 用户在线
|
- 用户在线
|
||||||
- 操作日志
|
- 操作日志
|
||||||
- 登录日志
|
- 登录日志
|
||||||
|
- 定时任务
|
||||||
|
- 缓存列表
|
||||||
|
- 服务监控
|
||||||
- 等等
|
- 等等
|
||||||
|
|
||||||
**演示截图:**
|
**演示截图:**
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace Yi.Furion.Application.Rbac.Job
|
|||||||
_db.DbMaintenance.TruncateTable<DictionaryEntity>();
|
_db.DbMaintenance.TruncateTable<DictionaryEntity>();
|
||||||
_db.DbMaintenance.TruncateTable<DictionaryTypeEntity>();
|
_db.DbMaintenance.TruncateTable<DictionaryTypeEntity>();
|
||||||
await _dataSeedExecuteHandler.Invoker();
|
await _dataSeedExecuteHandler.Invoker();
|
||||||
_logger.LogWarning("数据已经重置还原");
|
_logger.LogWarning("------->数据已经重置还原<-------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ namespace Yi.Furion.Core.Rbac.DataSeeds
|
|||||||
IsLink = false,
|
IsLink = false,
|
||||||
IsCache = true,
|
IsCache = true,
|
||||||
Component = "monitor/job/index",
|
Component = "monitor/job/index",
|
||||||
MenuIcon = "server",
|
MenuIcon = "job",
|
||||||
OrderNum = 97,
|
OrderNum = 97,
|
||||||
ParentId = monitoring.Id,
|
ParentId = monitoring.Id,
|
||||||
IsDeleted = false
|
IsDeleted = false
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class Startup : AppStartup
|
|||||||
services.AddSchedule(options =>
|
services.AddSchedule(options =>
|
||||||
{
|
{
|
||||||
// 注册作业,并配置作业触发器
|
// 注册作业,并配置作业触发器
|
||||||
options.AddJob<TestJob>(Triggers.Period(10000)); // 表示每秒执行
|
options.AddJob<TestJob>(Triggers.Period(10000));
|
||||||
options.AddJob<SystemDataJob>(Triggers.Cron("0 0 0,12 ? * ?",CronStringFormat.WithSeconds)); // 表示每天凌晨与12点
|
options.AddJob<SystemDataJob>(Triggers.Cron("0 0 0,12 ? * ?",CronStringFormat.WithSeconds)); // 表示每天凌晨与12点
|
||||||
});
|
});
|
||||||
services.AddFileLogging("application-{0:yyyy}-{0:MM}-{0:dd}.log", options =>
|
services.AddFileLogging("application-{0:yyyy}-{0:MM}-{0:dd}.log", options =>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { ElNotification , ElMessageBox, ElMessage, ElLoading } from 'element-plus'
|
import { ElNotification, ElMessageBox, ElMessage, ElLoading } from 'element-plus'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import errorCode from '@/utils/errorCode'
|
import errorCode from '@/utils/errorCode'
|
||||||
import { tansParams, blobValidate } from '@/utils/ruoyi'
|
import { tansParams, blobValidate } from '@/utils/ruoyi'
|
||||||
@@ -20,7 +20,7 @@ const service = axios.create({
|
|||||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||||
// 超时
|
// 超时
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
transformResponse: [ data => {
|
transformResponse: [data => {
|
||||||
const json = JsonBig({
|
const json = JsonBig({
|
||||||
storeAsString: true
|
storeAsString: true
|
||||||
})
|
})
|
||||||
@@ -76,120 +76,26 @@ service.interceptors.request.use(config => {
|
|||||||
|
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
service.interceptors.response.use(res => {
|
service.interceptors.response.use(res => {
|
||||||
|
// 二进制数据则直接返回
|
||||||
//业务错误
|
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
|
||||||
if(res.data.statusCode==403)
|
return res
|
||||||
{
|
|
||||||
ElMessage({
|
|
||||||
message: res.data.errors,
|
|
||||||
type: 'error'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 未设置状态码则默认成功状态
|
|
||||||
const code = res.status || 200;
|
|
||||||
|
|
||||||
// 获取错误信息
|
|
||||||
const msg = errorCode[code] || res.data.message || errorCode['default']
|
|
||||||
|
|
||||||
// 二进制数据则直接返回
|
|
||||||
if(res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer'){
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
if (code === 401) {
|
|
||||||
|
|
||||||
if (!isRelogin.show) {
|
|
||||||
|
|
||||||
isRelogin.show = true;
|
|
||||||
ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
|
||||||
confirmButtonText: '重新登录',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
}
|
|
||||||
).then(() => {
|
|
||||||
isRelogin.show = false;
|
|
||||||
useUserStore().logOut().then(() => {
|
|
||||||
location.href = '/index';
|
|
||||||
})
|
|
||||||
}).catch(() => {
|
|
||||||
isRelogin.show = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
|
|
||||||
}
|
|
||||||
else if (code === 500) {
|
|
||||||
|
|
||||||
ElMessage({
|
|
||||||
message: msg,
|
|
||||||
type: 'error'
|
|
||||||
})
|
|
||||||
return Promise.reject(new Error(msg))
|
|
||||||
} else if (code !== 200) {
|
|
||||||
ElNotification.error({
|
|
||||||
title: msg
|
|
||||||
})
|
|
||||||
return Promise.reject('error')
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return Promise.resolve(res.data)
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
error=>{
|
|
||||||
const response=error.response;
|
|
||||||
const code=response.status
|
|
||||||
const msg=response.data.message
|
|
||||||
if(code==403)
|
|
||||||
{
|
|
||||||
ElMessage({
|
|
||||||
message: msg,
|
|
||||||
type: 'error'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else if (code === 401) {
|
|
||||||
|
|
||||||
if (!isRelogin.show) {
|
|
||||||
|
|
||||||
isRelogin.show = true;
|
|
||||||
ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
|
||||||
confirmButtonText: '重新登录',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
}
|
|
||||||
).then(() => {
|
|
||||||
isRelogin.show = false;
|
|
||||||
useUserStore().logOut().then(() => {
|
|
||||||
location.href = '/index';
|
|
||||||
})
|
|
||||||
}).catch(() => {
|
|
||||||
isRelogin.show = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
const code = res.data.statusCode || 200;
|
||||||
|
// 获取错误信息
|
||||||
|
const msg = res.data.errors;
|
||||||
|
|
||||||
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
|
handler(code, msg);
|
||||||
}
|
return Promise.resolve(res.data);
|
||||||
else if (code === 500) {
|
},
|
||||||
|
error => {
|
||||||
ElMessage({
|
const code = error.response.status;
|
||||||
message: msg,
|
const msg = error.response.data.message;
|
||||||
type: 'error'
|
handler(code, msg);
|
||||||
})
|
|
||||||
return Promise.reject(new Error(msg))
|
|
||||||
} else if (code !== 200) {
|
|
||||||
ElNotification.error({
|
|
||||||
title: msg
|
|
||||||
})
|
|
||||||
return Promise.reject('error')
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return Promise.resolve(res)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -219,4 +125,48 @@ export function download(url, params, filename) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handler = (code, msg) => {
|
||||||
|
switch (code) {
|
||||||
|
//服务器异常
|
||||||
|
case 500:
|
||||||
|
ElMessage({
|
||||||
|
message: msg,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
//业务异常
|
||||||
|
case 403:
|
||||||
|
ElNotification.error({
|
||||||
|
title: msg
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
|
||||||
|
//未授权
|
||||||
|
case 401:
|
||||||
|
ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
||||||
|
confirmButtonText: '重新登录',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
isRelogin.show = false;
|
||||||
|
useUserStore().logOut().then(() => {
|
||||||
|
location.href = '/index';
|
||||||
|
})
|
||||||
|
}).catch(() => {
|
||||||
|
isRelogin.show = false;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 404:
|
||||||
|
ElMessage({
|
||||||
|
message: "404未找到资源",
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
//正常
|
||||||
|
case 200:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default service
|
export default service
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
<div class="el-login-footer">
|
<div class="el-login-footer">
|
||||||
<span>Copyright © 2018-2022 ruoyi.vip All Rights Reserved.</span>
|
<span>Copyright © 2018-2023 ruoyi.vip All Rights Reserved.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user