Skip to content

Commit 96c1044

Browse files
committed
fix(packages): @sa/hooks: fix searchParams of useHookTable. fixed #552
1 parent a91335d commit 96c1044

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

packages/hooks/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
}
1111
},
1212
"dependencies": {
13-
"@sa/axios": "workspace:*"
13+
"@sa/axios": "workspace:*",
14+
"@sa/utils": "workspace:*"
1415
}
1516
}

packages/hooks/src/use-table.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { computed, reactive, ref } from 'vue';
22
import type { Ref } from 'vue';
3+
import { jsonClone } from '@sa/utils';
34
import useBoolean from './use-boolean';
45
import useLoading from './use-loading';
56

@@ -65,7 +66,7 @@ export default function useHookTable<A extends ApiFn, T, C>(config: TableConfig<
6566

6667
const { apiFn, apiParams, transformer, immediate = true, getColumnChecks, getColumns } = config;
6768

68-
const searchParams: NonNullable<Parameters<A>[0]> = reactive({ ...apiParams });
69+
const searchParams: NonNullable<Parameters<A>[0]> = reactive(jsonClone({ ...apiParams }));
6970

7071
const allColumns = ref(config.columns()) as Ref<C[]>;
7172

@@ -129,7 +130,7 @@ export default function useHookTable<A extends ApiFn, T, C>(config: TableConfig<
129130

130131
/** reset search params */
131132
function resetSearchParams() {
132-
Object.assign(searchParams, apiParams);
133+
Object.assign(searchParams, jsonClone(apiParams));
133134
}
134135

135136
if (immediate) {

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)