diff --git a/packages/ui/src/components/pagination/Pagination.vue b/packages/ui/src/components/pagination/Pagination.vue new file mode 100644 index 00000000..2f66673a --- /dev/null +++ b/packages/ui/src/components/pagination/Pagination.vue @@ -0,0 +1,26 @@ + + + diff --git a/packages/ui/src/components/pagination/PaginationContent.vue b/packages/ui/src/components/pagination/PaginationContent.vue new file mode 100644 index 00000000..6d9d53f3 --- /dev/null +++ b/packages/ui/src/components/pagination/PaginationContent.vue @@ -0,0 +1,22 @@ + + + diff --git a/packages/ui/src/components/pagination/PaginationEllipsis.vue b/packages/ui/src/components/pagination/PaginationEllipsis.vue new file mode 100644 index 00000000..d9ffd4e4 --- /dev/null +++ b/packages/ui/src/components/pagination/PaginationEllipsis.vue @@ -0,0 +1,25 @@ + + + diff --git a/packages/ui/src/components/pagination/PaginationFirst.vue b/packages/ui/src/components/pagination/PaginationFirst.vue new file mode 100644 index 00000000..62f0913c --- /dev/null +++ b/packages/ui/src/components/pagination/PaginationFirst.vue @@ -0,0 +1,33 @@ + + + diff --git a/packages/ui/src/components/pagination/PaginationItem.vue b/packages/ui/src/components/pagination/PaginationItem.vue new file mode 100644 index 00000000..35664efa --- /dev/null +++ b/packages/ui/src/components/pagination/PaginationItem.vue @@ -0,0 +1,34 @@ + + + diff --git a/packages/ui/src/components/pagination/PaginationLast.vue b/packages/ui/src/components/pagination/PaginationLast.vue new file mode 100644 index 00000000..ae2a5046 --- /dev/null +++ b/packages/ui/src/components/pagination/PaginationLast.vue @@ -0,0 +1,33 @@ + + + diff --git a/packages/ui/src/components/pagination/PaginationNext.vue b/packages/ui/src/components/pagination/PaginationNext.vue new file mode 100644 index 00000000..626a4db5 --- /dev/null +++ b/packages/ui/src/components/pagination/PaginationNext.vue @@ -0,0 +1,33 @@ + + + diff --git a/packages/ui/src/components/pagination/PaginationPrevious.vue b/packages/ui/src/components/pagination/PaginationPrevious.vue new file mode 100644 index 00000000..e29b0bfc --- /dev/null +++ b/packages/ui/src/components/pagination/PaginationPrevious.vue @@ -0,0 +1,33 @@ + + + diff --git a/packages/ui/src/components/pagination/index.ts b/packages/ui/src/components/pagination/index.ts new file mode 100644 index 00000000..51ae7fdd --- /dev/null +++ b/packages/ui/src/components/pagination/index.ts @@ -0,0 +1,8 @@ +export { default as Pagination } from "./Pagination.vue" +export { default as PaginationContent } from "./PaginationContent.vue" +export { default as PaginationEllipsis } from "./PaginationEllipsis.vue" +export { default as PaginationFirst } from "./PaginationFirst.vue" +export { default as PaginationItem } from "./PaginationItem.vue" +export { default as PaginationLast } from "./PaginationLast.vue" +export { default as PaginationNext } from "./PaginationNext.vue" +export { default as PaginationPrevious } from "./PaginationPrevious.vue" diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index 82898938..f2732178 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -17,6 +17,7 @@ export * from './components/input-group/index' export * from './components/kbd/index' export * from './components/label/index' export * from './components/native-select/index' +export * from './components/pagination/index' export * from './components/radio-group/index' export * from './components/scroll-area/index' export * from './components/select/index' diff --git a/packages/web/src/pages/models/index.vue b/packages/web/src/pages/models/index.vue index 1d2332fb..2f5b12c3 100644 --- a/packages/web/src/pages/models/index.vue +++ b/packages/web/src/pages/models/index.vue @@ -2,9 +2,16 @@ // import type { Payment } from '@/components/columns' import { h, computed, ref, provide, watch } from 'vue' import CreateModel from '@/components/CreateModel/index.vue' -import { useQuery,useMutation,useQueryCache } from '@pinia/colada' +import { useQuery, useMutation, useQueryCache } from '@pinia/colada' import { Button, + Pagination, + PaginationContent, + PaginationEllipsis, + PaginationItem, + PaginationNext, + PaginationPrevious + } from '@memoh/ui' import DataTable from '@/components/DataTable/index.vue' import request from '@/utils/request' @@ -12,6 +19,7 @@ import { type ColumnDef } from '@tanstack/vue-table' + interface ModelType { apiKey: string, baseUrl: string, @@ -19,24 +27,24 @@ interface ModelType { modelId: string, name: string, type: 'chat' | 'embedding', - id:string + id: string } const openDialogModel = ref(false) -const editModelInfo = ref(null) +const editModelInfo = ref(null) provide('open', openDialogModel) provide('editModelInfo', editModelInfo) watch(openDialogModel, () => { if (!openDialogModel.value) { - editModelInfo.value=null + editModelInfo.value = null } }, { - immediate:true + immediate: true }) -const cacheQuery=useQueryCache() +const cacheQuery = useQueryCache() const { mutate: deleteModel, } = useMutation({ @@ -47,9 +55,9 @@ const { }), onSettled: () => { cacheQuery.invalidateQueries({ - key:['models'] - }) - } + key: ['models'] + }) + } }) const columns: ColumnDef[] = [ @@ -83,16 +91,17 @@ const columns: ColumnDef[] = [ { accessorKey: 'control', header: () => h('div', { class: 'text-center' }, '操作'), - cell: ({row}) => h('div', { class: ' w-full flex justify-around' }, [h(Button, { + cell: ({ row }) => h('div', { class: ' w-full flex justify-around' }, [h(Button, { 'onClick': () => { - editModelInfo.value=row.original - openDialogModel.value = true + editModelInfo.value = row.original + openDialogModel.value = true } }, () => '编辑'), h(Button, { variant: 'destructive', onClick() { deleteModel(row.original.id) - - }},()=>'删除')]) + + } + }, () => '删除')]) } ] @@ -107,10 +116,12 @@ const { data: modelData } = useQuery({ const displayFormat = computed(() => { - return modelData.value?.data?.items?.map((currentModel: { model: Omit, id: 'string' }) => ({id:currentModel.id,...currentModel.model})) ?? [] + return modelData.value?.data?.items?.map((currentModel: { model: Omit, id: 'string' }) => ({ id: currentModel.id, ...currentModel.model })) ?? [] }) - +const pagination = computed(() => { + return modelData.value?.data.pagination ?? {} +}) @@ -118,12 +129,47 @@ const displayFormat = computed(() => {
-
+
+ /> +
+
+ + + + + + + +
\ No newline at end of file