Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
intelligent_qp_manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张伯涛
intelligent_qp_manager
Commits
b4a23b35
Commit
b4a23b35
authored
Oct 25, 2024
by
张伯涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
axios请求头修改,响应拦截器封装,用户管理模块修改
parent
b89678a4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
10 deletions
+39
-10
user.ts
src/api/system/user/user.ts
+2
-3
errorCode.ts
src/utils/errorCode.ts
+6
-0
index.ts
src/utils/http/axios/index.ts
+30
-5
account.data.ts
src/views/system/user/account.data.ts
+1
-1
index.vue
src/views/system/user/index.vue
+0
-1
No files found.
src/api/system/user/user.ts
View file @
b4a23b35
...
@@ -24,7 +24,7 @@ export const addUserApi = (params: any) =>
...
@@ -24,7 +24,7 @@ export const addUserApi = (params: any) =>
defHttp
.
post
({
defHttp
.
post
({
url
:
Api
.
addUser
,
url
:
Api
.
addUser
,
params
:
params
,
params
:
params
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
//
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
});
});
/** 获取用户详情信息*/
/** 获取用户详情信息*/
...
@@ -36,7 +36,6 @@ export const UserUpdataApi = (params: any) =>
...
@@ -36,7 +36,6 @@ export const UserUpdataApi = (params: any) =>
defHttp
.
put
<
any
>
({
defHttp
.
put
<
any
>
({
url
:
Api
.
updataApi
,
url
:
Api
.
updataApi
,
params
:
params
,
params
:
params
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
});
});
...
@@ -45,5 +44,5 @@ export const changeFlagApi = (params: any) =>
...
@@ -45,5 +44,5 @@ export const changeFlagApi = (params: any) =>
defHttp
.
put
<
any
>
({
defHttp
.
put
<
any
>
({
url
:
Api
.
changeFlag
,
url
:
Api
.
changeFlag
,
params
:
params
,
params
:
params
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
//
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
});
});
src/utils/errorCode.ts
0 → 100644
View file @
b4a23b35
export
default
{
'401'
:
'认证失败,无法访问系统资源'
,
'403'
:
'当前操作没有权限'
,
'404'
:
'访问资源不存在'
,
'default'
:
'系统未知错误,请反馈给管理员'
}
src/utils/http/axios/index.ts
View file @
b4a23b35
...
@@ -19,7 +19,7 @@ import { joinTimestamp, formatRequestDate } from './helper';
...
@@ -19,7 +19,7 @@ import { joinTimestamp, formatRequestDate } from './helper';
import
{
useUserStoreWithOut
}
from
'@/store/modules/user'
;
import
{
useUserStoreWithOut
}
from
'@/store/modules/user'
;
import
{
AxiosRetry
}
from
'@/utils/http/axios/axiosRetry'
;
import
{
AxiosRetry
}
from
'@/utils/http/axios/axiosRetry'
;
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
errorCode
from
'@/utils/errorCode'
const
globSetting
=
useGlobSetting
();
const
globSetting
=
useGlobSetting
();
const
urlPrefix
=
globSetting
.
urlPrefix
;
const
urlPrefix
=
globSetting
.
urlPrefix
;
const
{
createMessage
,
createErrorModal
,
createSuccessModal
}
=
useMessage
();
const
{
createMessage
,
createErrorModal
,
createSuccessModal
}
=
useMessage
();
...
@@ -166,9 +166,33 @@ const transform: AxiosTransform = {
...
@@ -166,9 +166,33 @@ const transform: AxiosTransform = {
/**
/**
* @description: 响应拦截器处理
* @description: 响应拦截器处理
*/
*/
responseInterceptors
:
(
res
:
AxiosResponse
<
any
>
)
=>
{
responseInterceptors
:
(
res
:
any
)
=>
{
// console.log('ree',res)
// 未设置状态码则默认成功状态
return
res
;
const
code
=
res
.
data
.
code
||
200
// 获取错误信息
const
message
=
errorCode
[
code
]
||
res
.
data
.
msg
||
res
.
data
.
message
||
errorCode
[
'default'
]
if
(
code
===
401
)
{
createMessage
.
error
(
'用户不存在或密码错误'
);
}
else
if
(
code
===
410
)
{
createMessage
.
error
(
'当前登录无权限,请重新登录'
);
userStore
.
logout
(
true
);
}
else
if
(
code
===
500
||
code
===
400
)
{
const
errMsg
=
res
.
data
.
message
||
res
.
data
.
msg
console
.
log
(
'errMsg'
,
errMsg
)
createMessage
.
error
(
errMsg
);
return
Promise
.
reject
(
new
Error
(
message
))
}
else
if
(
code
!==
200
&&
code
!==
'E004'
)
{
createMessage
.
error
(
message
);
return
Promise
.
reject
(
'error'
)
}
else
if
(
code
!==
'E004'
)
{
return
res
;
// if (res.config.url.indexOf('downLoadSignaturesSample') > -1 || res.config.url.indexOf('downLoadSignatures') > -1) {
// return res
// } else {
// return res.data
// }
}
},
},
/**
/**
...
@@ -234,7 +258,8 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
...
@@ -234,7 +258,8 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
// 基础接口地址
// 基础接口地址
// baseURL: globSetting.apiUrl,
// baseURL: globSetting.apiUrl,
headers
:
{
'Content-Type'
:
ContentTypeEnum
.
JSON
},
// headers: { 'Content-Type': ContentTypeEnum.JSON },
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
// 如果是form-data格式
// 如果是form-data格式
// headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED },
// headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED },
// 数据处理方式
// 数据处理方式
...
...
src/views/system/user/account.data.ts
View file @
b4a23b35
...
@@ -73,7 +73,7 @@ export const columns: BasicColumn[] = [
...
@@ -73,7 +73,7 @@ export const columns: BasicColumn[] = [
createMessage
.
success
(
text
+
`成功`
);
createMessage
.
success
(
text
+
`成功`
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
createMessage
.
error
(
'操作失败'
);
//
createMessage.error('操作失败');
})
})
.
finally
(()
=>
{
.
finally
(()
=>
{
record
.
pendingStatus
=
false
;
record
.
pendingStatus
=
false
;
...
...
src/views/system/user/index.vue
View file @
b4a23b35
...
@@ -109,7 +109,6 @@
...
@@ -109,7 +109,6 @@
console
.
log
(
result
);
console
.
log
(
result
);
reload
();
reload
();
}
else
{
}
else
{
createMessage
.
success
(
'新增成功'
);
reload
();
reload
();
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment