From d6ba9b13e97417dc856c55160a649f3162349975 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 10 Feb 2022 16:53:48 +0800 Subject: [PATCH 01/11] fix: `debounce` or `throttle` not resetting retries --- src/__tests__/index.test.tsx | 54 ++++++++++++++++++++++++++++++++++++ src/core/createQuery.ts | 4 ++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/__tests__/index.test.tsx b/src/__tests__/index.test.tsx index 8aad66b..d7d042e 100644 --- a/src/__tests__/index.test.tsx +++ b/src/__tests__/index.test.tsx @@ -1759,6 +1759,60 @@ describe('useRequest', () => { expect(mockFn).toHaveBeenCalledTimes(11); }); + test('errorRetry should work with debounce', async () => { + const wrapper = shallowMount( + defineComponent({ + setup() { + const { run, loading, error } = useRequest(failedRequest, { + manual: true, + debounceInterval: 1000, + errorRetryCount: 4, + errorRetryInterval: 1000, + }); + const handleClick = () => run(); + return () => ( + + ); + }, + }), + ); + + // request + await wrapper.find('button').trigger('click'); + await waitForTime(2001); + expect(wrapper.text()).toBe('fail'); + + // retrying 1 + await waitForTime(1000); + expect(wrapper.text()).toBe('true'); + await waitForTime(1000); + expect(wrapper.text()).toBe('fail'); + + // retrying 2 + await waitForTime(1000); + expect(wrapper.text()).toBe('true'); + await waitForTime(1000); + expect(wrapper.text()).toBe('fail'); + + // trigger button to reset retry count + await wrapper.find('button').trigger('click'); + await waitForTime(2001); + expect(wrapper.text()).toBe('fail'); + + for (let index = 0; index < 4; index++) { + await waitForTime(1000); + expect(wrapper.text()).toBe('true'); + await waitForTime(1000); + expect(wrapper.text()).toBe('fail'); + } + await waitForTime(1000); + expect(wrapper.text()).toBe('fail'); + await waitForTime(1000); + expect(wrapper.text()).toBe('fail'); + }); + test('errorRetry should work with pollingInterval', async () => { let flag = true; const mixinRequest = () => { diff --git a/src/core/createQuery.ts b/src/core/createQuery.ts index eadf7e9..05c382e 100644 --- a/src/core/createQuery.ts +++ b/src/core/createQuery.ts @@ -232,6 +232,9 @@ const createQuery = ( const run = (...args: P) => { clearAllTimer(); + + resetRetriedCount(); + // initial auto run should not debounce if (!initialAutoRunFlag.value && debouncedRun) { debouncedRun(...args); @@ -242,7 +245,6 @@ const createQuery = ( throttledRun(...args); return resolvedPromise; } - resetRetriedCount(); return _run(...args); }; -- Gitee From b0535a13af60f233ab70bc0d9c8c238afa0a0d53 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Feb 2022 09:42:28 +0800 Subject: [PATCH 02/11] build(deps): bump follow-redirects from 1.14.7 to 1.14.8 (#100) Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 0866ea0..1ed5551 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3803,9 +3803,9 @@ flatted@^3.1.0: integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== follow-redirects@^1.14.0: - version "1.14.7" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685" - integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ== + version "1.14.8" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc" + integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA== for-in@^1.0.2: version "1.0.2" -- Gitee From 18f4c5814630346227ba51cc864f9cd33678b169 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Mar 2022 09:23:00 +0800 Subject: [PATCH 03/11] build(deps-dev): bump simple-git from 2.38.0 to 3.3.0 (#114) Bumps [simple-git](https://github.com/steveukx/git-js/tree/HEAD/simple-git) from 2.38.0 to 3.3.0. - [Release notes](https://github.com/steveukx/git-js/releases) - [Changelog](https://github.com/steveukx/git-js/blob/main/simple-git/CHANGELOG.md) - [Commits](https://github.com/steveukx/git-js/commits/simple-git@3.3.0/simple-git) --- updated-dependencies: - dependency-name: simple-git dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 4552bb1..de0b5c1 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "rollup": "^2.33.1", "rollup-plugin-terser": "^7.0.2", "rollup-plugin-typescript2": "^0.29.0", - "simple-git": "^2.21.0", + "simple-git": "^3.3.0", "sort-package-json": "^1.50.0", "standard-version": "^9.1.1", "ts-jest": "^26.4.1", diff --git a/yarn.lock b/yarn.lock index 1ed5551..776a2aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3043,10 +3043,10 @@ debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee" - integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== +debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.3: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" @@ -7258,14 +7258,14 @@ signal-exit@^3.0.2, signal-exit@^3.0.3: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== -simple-git@^2.21.0: - version "2.38.0" - resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-2.38.0.tgz#5bc66bec40bce4f8ef950f4966f427799b4dd758" - integrity sha512-CORjrfirWMEGbJAxaXDH/PjZVOeATeG2bkafM9DsLVcFkbF9sXQGIIpEI6FeyXpvUsFK69T/pa4+4FKY9TUJMQ== +simple-git@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.3.0.tgz#91692d576f851be691124781b79872b246d2f92c" + integrity sha512-K9qcbbZwPHhk7MLi0k0ekvSFXJIrRoXgHhqMXAFM75qS68vdHTcuzmul1ilKI02F/4lXshVgBoDll2t++JK0PQ== dependencies: "@kwsites/file-exists" "^1.1.1" "@kwsites/promise-deferred" "^1.1.1" - debug "^4.3.1" + debug "^4.3.3" sisteransi@^1.0.5: version "1.0.5" -- Gitee From 0df0977c74c83301ad092554642dccb07420f011 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 1 Apr 2022 15:05:31 +0800 Subject: [PATCH 04/11] docs: update readme[skip ci] --- README-zh_CN.md | 6 +++++- README.md | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index 6d0fe67..efb8fc1 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -38,6 +38,10 @@ +## 项目状态 + +v2 版本正在测试阶段,详情可以查看 [next](https://github.com/AttoJS/vue-request/tree/next) 分支。 + ## 为什么选择 VueRequest 在以往的业务项目中,常常被 loading 状态的管理、请求的节流防抖、接口数据的缓存、分页等这些重复的实现所困惑。每当开启一个新项目时,我们都得手动去处理以上这些问题,这将是一个重复性的工作,而且还得确保团队的一致。 @@ -149,7 +153,7 @@ const { data, error, run } = useRequest(getUserInfo, { 如果你有很酷的想法,欢迎提交 issue 以便我们讨论 -- [ ] 支持 Vue 2 +- [x] 支持 Vue 2。详情请参阅 [next](https://github.com/AttoJS/vue-request/tree/next) 分支 - [x] 文档 - [x] 分页 - [x] 加载更多 diff --git a/README.md b/README.md index 48fb4ea..fef37c0 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,10 @@ English | [简体中文](README-zh_CN.md) +## Status + +v2 version is in the Alpha version, please check the [next](https://github.com/AttoJS/vue-request/tree/next) branch for details. + ## Why VueRequest In the past projects, they were often confused by repeated implementations such as the management of the loading state, the requested throttling and debounce, the caching of request data, and pagination. Whenever we start a new project, we have to manually deal with the above problems, which will be a repetitive work, but also to ensure that the team is consistent. @@ -148,7 +152,7 @@ const { data, error, run } = useRequest(getUserInfo, { If you have any cool features, please submit an issue for discussion -- [ ] Support Vue 2 +- [x] Support Vue 2. see [next](https://github.com/AttoJS/vue-request/tree/next) branch - [x] Documentation - [x] Pagination - [x] Load More -- Gitee From 8c939cd45d868efbe3f96966df5815b0fff709fe Mon Sep 17 00:00:00 2001 From: John Date: Fri, 17 Jun 2022 16:58:11 +0800 Subject: [PATCH 05/11] docs: update readme[skip ci] --- README-zh_CN.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index efb8fc1..611e91b 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -40,7 +40,7 @@ ## 项目状态 -v2 版本正在测试阶段,详情可以查看 [next](https://github.com/AttoJS/vue-request/tree/next) 分支。 +**v1 版本后续不会添加新的功能,只会对出现的 BUG 进行维护。想体验最新的功能,请切换到 v2 版本。v2 版本正在 RC 阶段,详情可以查看 [next](https://github.com/AttoJS/vue-request/blob/next/README-zh_CN.md) 分支。文档将随着正式版本发布。** ## 为什么选择 VueRequest diff --git a/README.md b/README.md index fef37c0..0593519 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ English | [简体中文](README-zh_CN.md) ## Status -v2 version is in the Alpha version, please check the [next](https://github.com/AttoJS/vue-request/tree/next) branch for details. +**The v1 version will not add new functions in the future, and will only maintain the bugs that appear. To experience the latest features, please switch to the v2 version. The v2 version is in the RC stage. For details, you can check the [next](https://github.com/AttoJS/vue-request/blob/next/README.md) branch. Documentation will be released with the official release.** ## Why VueRequest -- Gitee From 10460a9a603cd4207cf41811d8db0ed3dc5da434 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 29 Jun 2022 15:43:37 +0800 Subject: [PATCH 06/11] add FUNDING.yml --- .github/FUNDING.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..3d1f0e5 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: https://next.attojs.com/sponsor -- Gitee From 97f922e8785ceab12d5214ddfd8dec8cf5282920 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 09:40:28 +0800 Subject: [PATCH 07/11] build(deps): bump semver-regex from 3.1.3 to 3.1.4 (#132) Bumps [semver-regex](https://github.com/sindresorhus/semver-regex) from 3.1.3 to 3.1.4. - [Release notes](https://github.com/sindresorhus/semver-regex/releases) - [Commits](https://github.com/sindresorhus/semver-regex/commits/v3.1.4) --- updated-dependencies: - dependency-name: semver-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 776a2aa..4cac5e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7166,9 +7166,9 @@ semver-diff@^3.1.1: semver "^6.3.0" semver-regex@^3.1.2: - version "3.1.3" - resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-3.1.3.tgz#b2bcc6f97f63269f286994e297e229b6245d0dc3" - integrity sha512-Aqi54Mk9uYTjVexLnR67rTyBusmwd04cLkHy9hNvk3+G3nT2Oyg7E0l4XVbOaNwIvQ3hHeYxGcyEy+mKreyBFQ== + version "3.1.4" + resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-3.1.4.tgz#13053c0d4aa11d070a2f2872b6b1e3ae1e1971b4" + integrity sha512-6IiqeZNgq01qGf0TId0t3NvKzSvUsjcpdEO3AQNeIjR6A2+ckTnQlDpl4qu1bjRv0RzN3FP9hzFmws3lKqRWkA== "semver@2 || 3 || 4 || 5", semver@^5.5.0: version "5.7.1" -- Gitee From 80e15dbfc0a3e56faf75fcd374c22569040c0a5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 09:40:40 +0800 Subject: [PATCH 08/11] build(deps-dev): bump simple-git from 3.3.0 to 3.5.0 (#125) Bumps [simple-git](https://github.com/steveukx/git-js/tree/HEAD/simple-git) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/steveukx/git-js/releases) - [Changelog](https://github.com/steveukx/git-js/blob/main/simple-git/CHANGELOG.md) - [Commits](https://github.com/steveukx/git-js/commits/simple-git@3.5.0/simple-git) --- updated-dependencies: - dependency-name: simple-git dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4cac5e0..c055dd2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7259,9 +7259,9 @@ signal-exit@^3.0.2, signal-exit@^3.0.3: integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== simple-git@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.3.0.tgz#91692d576f851be691124781b79872b246d2f92c" - integrity sha512-K9qcbbZwPHhk7MLi0k0ekvSFXJIrRoXgHhqMXAFM75qS68vdHTcuzmul1ilKI02F/4lXshVgBoDll2t++JK0PQ== + version "3.5.0" + resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.5.0.tgz#3c3538f4d7a1b3c8f3904412b12740bdcad9c8b1" + integrity sha512-fZsaq5nzdxQRhMNs6ESGLpMUHoL5GRP+boWPhq9pMYMKwOGZV2jHOxi8AbFFA2Y/6u4kR99HoULizSbpzaODkA== dependencies: "@kwsites/file-exists" "^1.1.1" "@kwsites/promise-deferred" "^1.1.1" -- Gitee From bd5e556f5a46eab3fe38af9dbbf23ff72c07b0eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 09:40:54 +0800 Subject: [PATCH 09/11] build(deps): bump minimist from 1.2.5 to 1.2.6 (#123) Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c055dd2..e234486 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5894,9 +5894,9 @@ minimist-options@4.1.0: kind-of "^6.0.3" minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + version "1.2.6" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" + integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== mixin-deep@^1.2.0: version "1.3.2" -- Gitee From e5b588ad45a719046fe15591b7461ef88ed07703 Mon Sep 17 00:00:00 2001 From: zlm <1543057945@qq.com> Date: Tue, 6 Sep 2022 17:13:25 +0800 Subject: [PATCH 10/11] =?UTF-8?q?fix:=E5=88=86=E9=A1=B5=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BC=98=E5=85=88=E5=8F=96data=E9=87=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E5=8F=AF=E4=BF=9D=E8=AF=81=E6=9C=8D=E5=8A=A1=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=A4=B1=E8=B4=A5=E5=90=8E=EF=BC=8C=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E4=B8=8D=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/usePagination.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usePagination.ts b/src/usePagination.ts index 91378cd..6c8cee9 100644 --- a/src/usePagination.ts +++ b/src/usePagination.ts @@ -151,7 +151,7 @@ function usePagination( const total = computed(() => get(data.value!, totalKey, 0)); const current = computed({ get: () => - (params.value[0] as Record)?.[currentKey] ?? + data.value?.[currentKey]??(params.value[0] as Record)?.[currentKey] ?? finallyOptions.defaultParams[0][currentKey], set: (val: number) => { changeCurrent(val); @@ -159,7 +159,7 @@ function usePagination( }); const pageSize = computed({ get: () => - (params.value[0] as Record)?.[pageSizeKey] ?? + data.value?.[pageSize]??(params.value[0] as Record)?.[pageSizeKey] ?? finallyOptions.defaultParams[0][pageSizeKey], set: (val: number) => { changePageSize(val); -- Gitee From 617fbe95545ef78c305ac0a08b044e88a32614b1 Mon Sep 17 00:00:00 2001 From: zlm <1543057945@qq.com> Date: Tue, 6 Sep 2022 17:22:58 +0800 Subject: [PATCH 11/11] =?UTF-8?q?chore[usePagination]:=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=BC=98=E5=85=88=E5=8F=96data=E9=87=8C?= =?UTF-8?q?=E9=9D=A2=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/usePagination.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usePagination.ts b/src/usePagination.ts index 91378cd..366de8c 100644 --- a/src/usePagination.ts +++ b/src/usePagination.ts @@ -151,7 +151,7 @@ function usePagination( const total = computed(() => get(data.value!, totalKey, 0)); const current = computed({ get: () => - (params.value[0] as Record)?.[currentKey] ?? + data.value?.[currentKey]??(params.value[0] as Record)?.[currentKey] ?? finallyOptions.defaultParams[0][currentKey], set: (val: number) => { changeCurrent(val); @@ -159,7 +159,7 @@ function usePagination( }); const pageSize = computed({ get: () => - (params.value[0] as Record)?.[pageSizeKey] ?? + data.value?.[pageSizeKey]??(params.value[0] as Record)?.[pageSizeKey] ?? finallyOptions.defaultParams[0][pageSizeKey], set: (val: number) => { changePageSize(val); -- Gitee