Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(projects): add table total items #404

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/hooks/common/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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__';
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/locales/langs/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ const local: App.I18n.Schema = {
expand: 'Expand Menu',
pin: 'Pin',
unpin: 'Unpin'
},
datatable: {
itemCount: 'Total {total} items'
}
};

Expand Down
3 changes: 3 additions & 0 deletions src/locales/langs/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ const local: App.I18n.Schema = {
expand: '展开菜单',
pin: '固定',
unpin: '取消固定'
},
datatable: {
itemCount: '共 {total} 条'
}
};

Expand Down
3 changes: 3 additions & 0 deletions src/typings/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading