Skip to content

Commit

Permalink
fix(packages): @sa/hooks: fix searchParams of useHookTable. fixed #552
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jul 19, 2024
1 parent a91335d commit 96c1044
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
},
"dependencies": {
"@sa/axios": "workspace:*"
"@sa/axios": "workspace:*",
"@sa/utils": "workspace:*"
}
}
5 changes: 3 additions & 2 deletions packages/hooks/src/use-table.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { computed, reactive, ref } from 'vue';
import type { Ref } from 'vue';
import { jsonClone } from '@sa/utils';
import useBoolean from './use-boolean';
import useLoading from './use-loading';

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

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

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

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

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

/** reset search params */
function resetSearchParams() {
Object.assign(searchParams, apiParams);
Object.assign(searchParams, jsonClone(apiParams));
}

if (immediate) {
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 96c1044

Please sign in to comment.