Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄庭坚
jinfa-platform
Commits
f6b36b67
Commit
f6b36b67
authored
Jul 22, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:新增一个hooks
parent
c2d4ec4e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
1 deletion
+43
-1
base.config.json
config/base.config.json
+0
-0
useHttpRequest.ts
src/hooks/useHttpRequest.ts
+40
-0
register.tsx
src/pages/user/register.tsx
+3
-1
No files found.
config/base.config.json
View file @
f6b36b67
This diff is collapsed.
Click to expand it.
src/hooks/useHttpRequest.ts
0 → 100644
View file @
f6b36b67
import
React
,
{
useState
}
from
'react'
;
import
{
IApiRequest
}
from
'@/utils/request'
;
export
interface
IHttpRequestReturn
<
T
>
{
data
:
T
|
null
,
loading
:
boolean
,
err
:
any
,
run
(
params
?:
any
)
}
/**
* 简易版本的useRequest hooks, 用于处理带有loading的业务场景
* @auth xjm
*/
export
function
useHttpRequest
<
T
>
(
api
:
(
params
?,
config
?)
=>
Promise
<
T
>
,
config
?:
IApiRequest
):
IHttpRequestReturn
<
T
>
{
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
[
data
,
setData
]
=
useState
<
T
|
null
>
(
null
)
const
[
err
,
setErr
]
=
useState
()
const
run
=
(
params
)
=>
{
setLoading
(
true
)
api
(
params
).
then
((
res
:
any
)
=>
{
setData
(
res
.
data
)
}).
catch
(
err
=>
{
setErr
(
err
)
}).
finally
(()
=>
{
setTimeout
(()
=>
{
setLoading
(
false
)
},
200
)
})
}
return
{
data
,
loading
,
err
,
run
}
}
\ No newline at end of file
src/pages/user/register.tsx
View file @
f6b36b67
...
...
@@ -49,6 +49,7 @@ const CustomCheckbox = props => {
const
CustomInput
=
props
=>
{
const
{
help
,
...
restProps
}
=
props
console
.
log
(
props
)
return
(
<
AntdInput
{
...
restProps
}
...
...
@@ -89,7 +90,7 @@ const actions = createFormActions()
const
UserRegistry
=
()
=>
{
const
[
identityForm1
]
=
Form
.
useForm
();
const
[
licenseForm
]
=
Form
.
useForm
();
const
[
current
,
setCurrent
]
=
useState
(
1
)
const
[
current
,
setCurrent
]
=
useState
(
0
)
const
[
identityFormData
,
setIdentityFormData
]
=
useState
<
IFormControllers
[]
>
([])
const
[
licenseFormData
,
setLicenseFormData
]
=
useState
<
IFormControllers
[]
>
([])
const
stepList
=
[
...
...
@@ -309,6 +310,7 @@ const UserRegistry = () => {
pattern
:
v
.
rulePattern
}
})
}
maxLength=
{
field
.
fieldLength
}
x
-
component
-
props=
{
{
help
:
field
.
fieldRemark
,
placeholder
:
`请输入${field.fieldCNName}`
,
size
:
'large'
}
}
x
-
component=
'CustomInput'
>
...
...
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