Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas3-fe
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas3-fe
Commits
2b8aece0
Commit
2b8aece0
authored
Dec 23, 2021
by
guxukai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: api迁移
parent
c1f40810
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
axios.ts
src/shared/http/axios.ts
+18
-10
License.ts
src/shared/models/license-service/License.ts
+2
-2
No files found.
src/shared/http/axios.ts
View file @
2b8aece0
import
Axios
,
{
AxiosInstance
,
AxiosRequestConfig
}
from
'axios'
import
{
resultType
,
PureHttpError
,
RequestMethods
,
PureHttpResponse
,
PureHttpRequestConfig
}
from
'./types'
import
{
merge
}
from
'lodash'
import
{
PureHttpError
,
RequestMethods
,
PureHttpResponse
,
PureHttpRequestConfig
}
from
'./types'
import
{
isPlainObject
,
merge
}
from
'lodash'
import
{
addPendingRequest
,
removePendingRequest
}
from
'@shared/http/utils'
import
{
MessageUtils
}
from
'@shared/utils/message-utils'
import
{
HttpResponse
}
from
'@shared/http/HttpResponse'
import
{
authStore
}
from
'@shared/store/modules/auth'
// 文件类型处理
const
formatFile
=
(
params
?:
AxiosRequestConfig
)
=>
{
if
(
params
?.
data
)
{
if
(
isPlainObject
(
params
.
data
))
{
if
(
Object
.
values
(
params
.
data
).
some
(
_
=>
_
instanceof
File
))
{
const
formatData
=
new
FormData
()
for
(
const
[
k
,
v
]
of
params
.
data
)
{
formatData
.
append
(
k
,
v
)
}
params
.
data
=
formatData
}
}
}
}
// 相关配置请参考:www.axios-js.com/zh-cn/docs/#axios-request-config-1
const
defaultConfig
:
AxiosRequestConfig
=
{
...
...
@@ -124,14 +138,7 @@ class PureHttp {
// 单独抽离的post工具函数
public
post
<
T
=
HttpResponse
>
(
url
:
string
,
params
?:
AxiosRequestConfig
,
config
?:
PureHttpRequestConfig
):
Promise
<
T
>
{
// 文件类型处理
if
(
params
?.
data
?.
file
instanceof
File
)
{
const
formatData
=
new
FormData
()
for
(
const
[
k
,
v
]
of
params
.
data
)
{
formatData
.
append
(
k
,
v
)
}
params
.
data
=
formatData
}
formatFile
(
params
)
return
this
.
request
<
T
>
(
'post'
,
url
,
params
,
config
)
}
...
...
@@ -141,6 +148,7 @@ class PureHttp {
}
// 单独抽离的put工具函数
public
put
<
T
=
HttpResponse
>
(
url
:
string
,
params
?:
AxiosRequestConfig
,
config
?:
PureHttpRequestConfig
):
Promise
<
T
>
{
formatFile
(
params
)
return
this
.
request
<
T
>
(
'put'
,
url
,
params
,
config
)
}
...
...
src/shared/models/license-service/License.ts
View file @
2b8aece0
...
...
@@ -27,7 +27,7 @@ export class License extends Model<License> {
/**
* 更新许可证
*/
static
async
put
(
payload
:
LicenseP
o
utReq
)
{
static
async
put
(
payload
:
LicensePutReq
)
{
return
await
api
.
put
<
HttpResponse
<
boolean
>>
(
'/services/license-service/license'
,
{
data
:
payload
,
})
...
...
@@ -46,7 +46,7 @@ export class LicensePostReq extends Model<LicensePostReq> {
@
JsonProperty
()
mappingFile
:
File
}
@
Serializable
()
export
class
LicenseP
outReq
extends
Model
<
LicensePo
utReq
>
{
export
class
LicenseP
utReq
extends
Model
<
LicenseP
utReq
>
{
@
JsonProperty
()
keyFile
:
File
@
JsonProperty
()
licFile
:
File
@
JsonProperty
()
mappingFile
:
File
...
...
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