refactor(system): 重构request.js

-移除了多余的错误代码判断和冗余的错误提示
- 优化了请求成功和失败的处理流程
- 统一了错误信息的展示方式
- 调整了部分代码结构以提高可读性和维护性
This commit is contained in:
du.meimei
2025-04-25 16:59:50 +08:00
parent 2a11499334
commit 9f04419bd2
8 changed files with 100 additions and 233 deletions

View File

@@ -183,11 +183,7 @@ export default {
getRoleList({})
.then(response => {
if (response.code === '0') {
this.roleListData = response.content.content || []
} else {
this.$message.error(response.msg || '获取角色列表失败')
}
this.roleListData = response.content.content || []
})
.catch(error => {
this.$message.error('获取角色列表出错', error)
@@ -218,22 +214,12 @@ export default {
: addUser(submitData)
apiRequest
.then(response => {
if (response.code === '0') {
this.$message.success(this.isEdit ? '修改成功' : '添加成功')
this.$emit('submit', submitData)
this.handleClose()
} else {
this.$message.error(
response.msg || (this.isEdit ? '修改失败' : '添加失败')
)
}
.then(() => {
this.$message.success(this.isEdit ? '修改成功' : '添加成功')
this.$emit('submit', submitData)
this.handleClose()
})
.catch(error => {
console.error(
this.isEdit ? '修改用户出错:' : '添加用户出错:',
error
)
.catch(() => {
this.$message.error(this.isEdit ? '修改用户出错' : '添加用户出错')
})
.finally(() => {