refactor(hooks): streamline column visibility handling in useTable and table components

This commit is contained in:
Soybean
2025-07-20 00:29:47 +08:00
parent 8a7cd5934b
commit ee4341457a
3 changed files with 10 additions and 11 deletions

View File

@ -72,18 +72,14 @@ export default function useTable<ResponseData, ApiData, Column, Pagination exten
const data = ref([]) as Ref<ApiData[]>;
const allColumns = ref(columns()) as Ref<Column[]>;
const columnChecks = ref(getColumnChecks(columns())) as Ref<TableColumnCheck[]>;
const $columns = computed(() => getColumns(columns(), columnChecks.value));
function reloadColumns() {
allColumns.value = columns();
const checkMap = new Map(columnChecks.value.map(col => [col.key, col.checked]));
const defaultChecks = getColumnChecks(allColumns.value);
const defaultChecks = getColumnChecks(columns());
columnChecks.value = defaultChecks.map(col => ({
...col,