Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
schbrain-archetype-initializer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tools
schbrain-archetype-initializer
Commits
0c0b7062
Commit
0c0b7062
authored
Apr 08, 2022
by
liaozan
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: axios loading
parent
96a035a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
18 deletions
+11
-18
initializer-ui/src/App.vue
initializer-ui/src/App.vue
+1
-1
initializer-ui/src/components/starter.vue
initializer-ui/src/components/starter.vue
+6
-13
initializer-ui/src/utils/request.ts
initializer-ui/src/utils/request.ts
+4
-4
No files found.
initializer-ui/src/App.vue
View file @
0c0b7062
...
...
@@ -3,4 +3,4 @@
</
template
>
<
script
lang=
"ts"
setup
>
import
Starter
from
"
./components/starter.vue
"
;
</
script
>
\ No newline at end of file
import
Starter
from
"
./components/starter.vue
"
</
script
>
\ No newline at end of file
initializer-ui/src/components/starter.vue
View file @
0c0b7062
...
...
@@ -30,7 +30,7 @@
</
template
>
<
script
lang=
"ts"
setup
>
import
{
reactive
,
ref
,
computed
}
from
'
vue
'
import
{
computed
,
reactive
,
ref
}
from
'
vue
'
import
type
{
TreeProps
}
from
'
ant-design-vue
'
;
import
{
FormInstance
,
message
}
from
"
ant-design-vue
"
;
import
request
,
{
isLoading
}
from
"
../utils/request
"
;
...
...
@@ -91,16 +91,10 @@ const onPreview = async () => {
}
const
onDownload
=
async
(
id
:
number
)
=>
{
try
{
loading
.
value
=
true
let
res
=
await
request
.
get
(
`/archetype/download/
${
id
}
`
,
{
responseType
:
'
blob
'
})
const
{
headers
,
data
}
=
res
const
fileName
=
headers
[
'
content-disposition
'
].
replace
(
/
\w
+;
\s
filename="
(
.*
)
"/
,
'
$1
'
)
downloadGeneratedProject
(
data
,
fileName
)
}
catch
(
e
)
{
console
.
log
(
'
err:
'
,
e
)
loading
.
value
=
false
}
let
res
=
await
request
.
get
(
`/archetype/download/
${
id
}
`
,
{
responseType
:
'
blob
'
})
const
{
headers
,
data
}
=
res
const
fileName
=
headers
[
'
content-disposition
'
].
replace
(
/
\w
+;
\s
filename="
(
.*
)
"/
,
'
$1
'
)
downloadGeneratedProject
(
data
,
fileName
)
}
const
downloadGeneratedProject
=
(
data
:
BlobPart
,
fileName
:
string
)
=>
{
...
...
@@ -113,7 +107,6 @@ const downloadGeneratedProject = (data: BlobPart, fileName: string) => {
link
.
click
()
URL
.
revokeObjectURL
(
link
.
href
)
document
.
body
.
removeChild
(
link
)
loading
.
value
=
false
}
const
fetchFileList
=
async
(
id
:
number
)
=>
{
...
...
@@ -174,4 +167,4 @@ const createTreeData = (fileNodeList: FileNode[]): any => {
border-radius
:
6px
;
}
}
</
style
>
</
style
>
\ No newline at end of file
initializer-ui/src/utils/request.ts
View file @
0c0b7062
import
type
{
AxiosRequestConfig
,
AxiosResponse
}
from
"
axios
"
;
import
type
{
AxiosRequestConfig
,
AxiosResponse
}
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
{
message
}
from
"
ant-design-vue
"
;
import
{
ref
}
from
'
vue
'
import
{
ref
}
from
'
vue
'
export
const
isLoading
=
ref
(
false
)
...
...
@@ -20,7 +20,7 @@ axios.interceptors.response.use((config: AxiosResponse) => {
case
0
:
return
Promise
.
resolve
(
data
)
default
:
message
.
error
(
data
.
message
)
message
.
error
(
data
.
message
)
.
then
()
return
Promise
.
reject
(
data
)
}
}
else
{
...
...
@@ -28,4 +28,4 @@ axios.interceptors.response.use((config: AxiosResponse) => {
}
})
export
default
axios
export
default
axios
\ No newline at end of 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