usePaginationStore.ts 665 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * 存储分页信息
  3. */
  4. import { reactive } from 'vue';
  5. import { defineStore } from 'pinia';
  6. import { DEFAULT_PAGE_SIZE } from '@/constant/pagination';
  7. export const usePaginationStore = defineStore('pagination', () => {
  8. const pagination = reactive({
  9. page: 1,
  10. pageSize: DEFAULT_PAGE_SIZE,
  11. });
  12. const setPage = (page: number) => {
  13. pagination.page = page;
  14. };
  15. const setPageSize = (pageSize: number) => {
  16. pagination.pageSize = pageSize;
  17. };
  18. const resetPagination = () => {
  19. pagination.page = 1;
  20. pagination.pageSize = DEFAULT_PAGE_SIZE;
  21. };
  22. return {
  23. pagination,
  24. setPage,
  25. setPageSize,
  26. resetPagination,
  27. };
  28. });