feat(projects): add table total items

This commit is contained in:
paynezhuang 2024-04-25 21:08:25 +08:00
parent e57bf0b076
commit b27cb3f36e
4 changed files with 14 additions and 1 deletions

View File

@ -13,6 +13,8 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
const scope = effectScope();
const appStore = useAppStore();
const isMobile = computed(() => appStore.isMobile);
const { apiFn, apiParams, immediate } = config;
const SELECTION_KEY = '__selection__';
@ -104,6 +106,7 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
pageSize: 10,
showSizePicker: true,
pageSizes: [10, 15, 20, 25, 30],
prefix: page => $t('datatable.itemCount', { total: page.itemCount }),
onUpdatePage: async (page: number) => {
pagination.page = page;
@ -131,7 +134,8 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
const mobilePagination = computed(() => {
const p: PaginationProps = {
...pagination,
pageSlot: appStore.isMobile ? 3 : 9
pageSlot: isMobile ? 3 : 9,
prefix: isMobile ? undefined : pagination.prefix
};
return p;

View File

@ -445,6 +445,9 @@ const local: App.I18n.Schema = {
expand: 'Expand Menu',
pin: 'Pin',
unpin: 'Unpin'
},
datatable: {
itemCount: 'Total {total} items'
}
};

View File

@ -445,6 +445,9 @@ const local: App.I18n.Schema = {
expand: '展开菜单',
pin: '固定',
unpin: '取消固定'
},
datatable: {
itemCount: '共 {total} 条'
}
};

View File

@ -602,6 +602,9 @@ declare namespace App {
pin: string;
unpin: string;
};
datatable: {
itemCount: string;
};
};
type GetI18nKey<T extends Record<string, unknown>, K extends keyof T = keyof T> = K extends string