Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
a0832af1
authored
Apr 03, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 数据集刷新导致页面抖动
parent
677e6141
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
+3
-7
src/hooks/usePagination.tsx
+3
-7
No files found.
src/hooks/usePagination.tsx
View file @
a0832af1
...
@@ -17,13 +17,10 @@ export const usePagination = <T = any,>({
...
@@ -17,13 +17,10 @@ export const usePagination = <T = any,>({
const
{
toast
}
=
useToast
();
const
{
toast
}
=
useToast
();
const
[
pageNum
,
setPageNum
]
=
useState
(
1
);
const
[
pageNum
,
setPageNum
]
=
useState
(
1
);
const
[
total
,
setTotal
]
=
useState
(
0
);
const
[
total
,
setTotal
]
=
useState
(
0
);
const
[
data
,
setData
]
=
useState
<
T
[]
>
([]);
const
maxPage
=
useMemo
(()
=>
Math
.
ceil
(
total
/
pageSize
),
[
pageSize
,
total
]);
const
maxPage
=
useMemo
(()
=>
Math
.
ceil
(
total
/
pageSize
),
[
pageSize
,
total
]);
const
{
const
{
mutate
,
isLoading
}
=
useMutation
({
mutate
,
data
=
[],
isLoading
}
=
useMutation
({
mutationFn
:
async
(
num
:
number
=
pageNum
)
=>
{
mutationFn
:
async
(
num
:
number
=
pageNum
)
=>
{
try
{
try
{
const
res
:
PagingData
<
T
>
=
await
api
({
const
res
:
PagingData
<
T
>
=
await
api
({
...
@@ -33,7 +30,7 @@ export const usePagination = <T = any,>({
...
@@ -33,7 +30,7 @@ export const usePagination = <T = any,>({
});
});
setPageNum
(
num
);
setPageNum
(
num
);
setTotal
(
res
.
total
);
setTotal
(
res
.
total
);
return
res
.
data
;
setData
(
res
.
data
)
;
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
toast
({
toast
({
title
:
error
?.
message
||
'获取数据异常'
,
title
:
error
?.
message
||
'获取数据异常'
,
...
@@ -43,7 +40,6 @@ export const usePagination = <T = any,>({
...
@@ -43,7 +40,6 @@ export const usePagination = <T = any,>({
}
}
}
}
});
});
useQuery
([
'init'
],
()
=>
{
useQuery
([
'init'
],
()
=>
{
mutate
(
1
);
mutate
(
1
);
return
null
;
return
null
;
...
...
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