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
96a035a6
Commit
96a035a6
authored
Apr 08, 2022
by
cenlijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: axios loading
parent
de1573a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
17 deletions
+21
-17
initializer-ui/src/components/starter.vue
initializer-ui/src/components/starter.vue
+10
-15
initializer-ui/src/utils/request.ts
initializer-ui/src/utils/request.ts
+11
-2
No files found.
initializer-ui/src/components/starter.vue
View file @
96a035a6
<
template
>
<div
class=
"start-wrapper"
>
<a-spin
:
delay=
"500"
:
spinning=
"loading"
>
<a-spin
:spinning=
"loading"
>
<h3
style=
"margin-bottom: 20px"
>
项目初始代码生成
</h3>
<a-form
ref=
"downloadForm"
:labelCol=
"
{span: 6}" :model="formState" :rules="formRules" :wrapperCol="{span: 18}" class="form-wrapper">
<a-form-item
has-feedback
label=
"GroupId"
name=
"groupId"
>
...
...
@@ -30,10 +30,10 @@
</
template
>
<
script
lang=
"ts"
setup
>
import
{
reactive
,
ref
}
from
'
vue
'
import
{
reactive
,
ref
,
computed
}
from
'
vue
'
import
type
{
TreeProps
}
from
'
ant-design-vue
'
;
import
{
FormInstance
,
message
}
from
"
ant-design-vue
"
;
import
request
from
"
../utils/request
"
;
import
request
,
{
isLoading
}
from
"
../utils/request
"
;
import
BaseResponse
from
"
../models/BaseResponse
"
;
interface
FormState
{
...
...
@@ -54,7 +54,7 @@ const fileNodeList = ref<FileNode[]>([])
const
treeData
=
ref
<
TreeProps
[
'
treeData
'
]
>
([])
const
id
=
ref
(
-
1
)
const
visible
=
ref
(
false
)
const
loading
=
ref
(
fals
e
)
const
loading
=
computed
(()
=>
isLoading
.
valu
e
)
const
downloadForm
=
ref
<
FormInstance
>
();
const
formState
=
reactive
<
FormState
>
({
...
...
@@ -75,16 +75,11 @@ const onGenerate = async () => {
if
(
!
result
.
packageNama
)
{
result
.
packageNama
=
result
.
groupId
}
loading
.
value
=
true
try
{
let
data
:
BaseResponse
=
await
request
.
post
(
'
/archetype/generate
'
,
result
)
if
(
data
.
code
===
0
)
{
id
.
value
=
data
.
result
message
.
success
(
'
生成成功!
'
)
loading
.
value
=
false
}
}
catch
(
e
)
{
loading
.
value
=
false
let
data
:
BaseResponse
=
await
request
.
post
(
'
/archetype/generate
'
,
result
)
if
(
data
.
code
===
0
)
{
id
.
value
=
data
.
result
message
.
success
(
'
生成成功!
'
)
}
}
}
...
...
@@ -179,4 +174,4 @@ const createTreeData = (fileNodeList: FileNode[]): any => {
border-radius
:
6px
;
}
}
</
style
>
\ No newline at end of file
</
style
>
initializer-ui/src/utils/request.ts
View file @
96a035a6
import
type
{
AxiosResponse
}
from
"
axios
"
;
import
type
{
AxiosRequestConfig
,
AxiosResponse
}
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
{
message
}
from
"
ant-design-vue
"
;
import
{
ref
}
from
'
vue
'
export
const
isLoading
=
ref
(
false
)
// @ts-ignore
axios
.
defaults
.
baseURL
=
import
.
meta
.
env
.
VITE_APP_BASE_URL
axios
.
interceptors
.
request
.
use
((
config
:
AxiosRequestConfig
)
=>
{
isLoading
.
value
=
true
return
config
})
axios
.
interceptors
.
response
.
use
((
config
:
AxiosResponse
)
=>
{
isLoading
.
value
=
false
const
{
data
}
=
config
if
(
config
.
headers
[
'
content-type
'
]
===
'
application/json
'
)
{
switch
(
data
.
code
)
{
...
...
@@ -19,4 +28,4 @@ axios.interceptors.response.use((config: AxiosResponse) => {
}
})
export
default
axios
\ No newline at end of file
export
default
axios
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