1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17- import React , { useEffect , useRef , useState } from 'react' ;
17+ import React , { useRef , useState } from 'react' ;
1818import { PageContainer } from '@ant-design/pro-layout' ;
1919import ProTable from '@ant-design/pro-table' ;
2020import type { ProColumns , ActionType } from '@ant-design/pro-table' ;
2121import { Popconfirm , Button , notification , Space } from 'antd' ;
2222import { history , useIntl } from 'umi' ;
23+
2324import { PlusOutlined } from '@ant-design/icons' ;
24- import querystring from 'query-string' ;
2525import { omit } from 'lodash' ;
26-
26+ import usePagination from '@/hooks/usePagination' ;
2727import { DELETE_FIELDS } from '@/constants' ;
2828
2929import { RawDataEditor } from '@/components/RawDataEditor' ;
@@ -37,19 +37,9 @@ const Page: React.FC = () => {
3737 const [ rawData , setRawData ] = useState < Record < string , any > > ( { } ) ;
3838 const [ id , setId ] = useState ( '' ) ;
3939 const [ editorMode , setEditorMode ] = useState < 'create' | 'update' > ( 'create' ) ;
40- const [ paginationConfig , setPaginationConfig ] = useState ( { pageSize : 10 , current : 1 } ) ;
41-
40+ const { paginationConfig, savePageList } = usePagination ( ) ;
4241 const { formatMessage } = useIntl ( ) ;
4342
44- const savePageList = ( page = 1 , pageSize = 10 ) => {
45- history . replace ( `/upstream/list?page=${ page } &pageSize=${ pageSize } ` ) ;
46- } ;
47-
48- useEffect ( ( ) => {
49- const { page = 1 , pageSize = 10 } = querystring . parse ( window . location . search ) ;
50- setPaginationConfig ( { pageSize : Number ( pageSize ) , current : Number ( page ) } ) ;
51- } , [ window . location . search ] ) ;
52-
5343 const columns : ProColumns < UpstreamModule . ResponseBody > [ ] = [
5444 {
5545 title : formatMessage ( { id : 'page.upstream.list.id' } ) ,
0 commit comments