Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
csbr-daop
/
fe-data-trusted-space
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
ddeaf1c0
authored
2025-12-10 11:26:04 +0800
by
lihua
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
封装通用的接口定义函数
1 parent
fa334d63
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
src/api/modules/common.ts
src/api/modules/common.ts
View file @
ddeaf1c
...
...
@@ -2,6 +2,7 @@ import { ElMessage } from 'element-plus'
import
{
getDownloadUrl
,
download
}
from
"@/utils/common"
;
import
{
getImageContent
}
from
"@/api/modules/queryService"
;
import
{
getDownFileSignByUrl
,
obsDownloadRequest
,
parseAndDecodeUrl
}
from
'./obsService'
;
import
request
from
'@/utils/request'
;
// export const onUploadFilePreview = (file) => {
// let url = file.url;
...
...
@@ -133,3 +134,25 @@ export const chunk = (array, size) => {
//输出新数组
return
result
;
}
/** 封装查询API接口,公共处理错误提示。 */
export
const
requestAPI
=
(
urlParams
,
loadingCallback
?:
(
loading
:
boolean
)
=>
void
)
=>
{
loadingCallback
?.(
true
);
return
new
Promise
((
resolve
,
reject
)
=>
{
request
(
urlParams
)
.
then
((
res
:
any
)
=>
{
loadingCallback
?.(
false
);
if
(
res
?.
code
==
'00000'
)
{
resolve
(
res
)
}
else
{
res
?.
msg
&&
ElMessage
.
error
(
res
?.
msg
)
reject
(
res
)
}
})
.
catch
((
error
:
Error
)
=>
{
loadingCallback
?.(
false
);
reject
(
error
)
})
})
}
\ No newline at end of file
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment