Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhangbo1_wd
2024-05-29 14:40:53 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b6f11d29cefa4738b8d5e401b0c01a818b7f8dfd
b6f11d29
1 parent
44f1f8c1
刷新token修改。
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
sight_harmony/commons/wdNetwork/src/main/ets/http/AxiosRequest.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpBizUtil.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/AxiosRequest.ets
View file @
b6f11d2
...
...
@@ -40,6 +40,9 @@ instance.interceptors.request.use(
// 公共请求参数
// config.params.key = key
Logger.debug('HttpRequest', 'request: ' + config.url)
// TODO 临时打印token,测试token失效。待删除
Logger.debug('HttpRequest', 'request token: ' + config?.headers?.get('RMRB-X-TOKEN'))
Logger.debug('HttpRequest', 'request cookie: ' + config?.headers?.get('cookie'))
return config;
},
(error: AxiosError) => {
...
...
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpBizUtil.ets
View file @
b6f11d2
...
...
@@ -29,10 +29,11 @@ export class HttpBizUtil {
// 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
if (res.code == 403 || res.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
headers.replace('cookie', 'RMRB-X-TOKEN=' + token)
if (!headers) {
headers = new HashMap()
}
headers?.replace('RMRB-X-TOKEN', token)
headers?.replace('cookie', 'RMRB-X-TOKEN=' + token)
Logger.debug(TAG, 'get again send: ' + token)
// refreshToken为空场景不处理,直接请求接口。
WDHttp.get<T>(url, headers).then((againResDTO: T) => {
...
...
@@ -67,10 +68,11 @@ export class HttpBizUtil {
Logger.debug(TAG, 'post catch error: ' + JSON.stringify(res))
if (res.code == 403 || res.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
headers.replace('cookie', 'RMRB-X-TOKEN=' + token)
if (!headers) {
headers = new HashMap()
}
headers?.replace('RMRB-X-TOKEN', token)
headers?.replace('cookie', 'RMRB-X-TOKEN=' + token)
Logger.debug(TAG, 'post again send: ' + token)
// refreshToken为空场景不处理,直接请求接口。
WDHttp.post<T>(url, data, headers).then((againResDTO: T) => {
...
...
Please
register
or
login
to post a comment