From f046b995a9748dd682601de5b201a859f782ed99 Mon Sep 17 00:00:00 2001 From: Finley Ge <m13203533462@163.com> Date: Sat, 11 Jan 2025 18:29:30 +0800 Subject: [PATCH] chore: adjust code --- packages/global/core/app/type.d.ts | 6 +- packages/global/core/app/version.d.ts | 4 +- packages/global/core/dataset/type.d.ts | 4 +- .../global/support/user/team/controller.d.ts | 1 - packages/global/support/user/type.d.ts | 2 +- packages/service/support/user/schema.ts | 6 +- packages/web/common/fetch/type.d.ts | 2 +- .../web/components/common/MySelect/index.tsx | 74 ++++++++++--------- .../web/components/common/UserBox/index.tsx | 30 ++++++++ packages/web/hooks/usePagination.tsx | 63 ++++++++-------- packages/web/hooks/useScrollPagination.tsx | 24 +++--- .../components/core/app/InputGuideConfig.tsx | 4 +- projects/app/src/global/core/api/appReq.d.ts | 6 +- .../app/src/global/core/api/datasetReq.d.ts | 6 +- .../account/bill/components/BillTable.tsx | 15 ++-- .../account/bill/components/InvoiceTable.tsx | 5 +- projects/app/src/pages/account/inform.tsx | 6 +- projects/app/src/pages/account/promotion.tsx | 5 +- .../account/team/components/MemberTable.tsx | 4 +- .../app/src/pages/account/usage/index.tsx | 7 +- .../app/src/pages/api/core/app/getChatLogs.ts | 10 +-- projects/app/src/pages/api/core/app/list.ts | 9 ++- .../pages/api/core/dataset/collection/list.ts | 26 +++---- .../src/pages/api/core/dataset/data/list.ts | 10 +-- .../app/detail/components/Logs/index.tsx | 16 +--- .../Flow/NodeTemplatesModal.tsx | 2 +- .../components/CollectionCard/Context.tsx | 3 +- projects/app/src/types/index.d.ts | 9 --- projects/app/src/web/core/app/api.ts | 4 +- projects/app/src/web/core/dataset/api.ts | 5 +- .../dataset/components/SelectCollections.tsx | 30 ++++---- .../src/web/support/activity/promotion/api.ts | 11 ++- projects/app/src/web/support/user/api.ts | 2 +- .../app/src/web/support/user/inform/api.ts | 8 +- .../app/src/web/support/wallet/bill/api.ts | 8 +- .../web/support/wallet/bill/invoice/api.ts | 6 +- .../app/src/web/support/wallet/usage/api.ts | 15 +++- 37 files changed, 227 insertions(+), 221 deletions(-) create mode 100644 packages/web/components/common/UserBox/index.tsx diff --git a/packages/global/core/app/type.d.ts b/packages/global/core/app/type.d.ts index d4388c4d1ea5..899628936ed9 100644 --- a/packages/global/core/app/type.d.ts +++ b/packages/global/core/app/type.d.ts @@ -12,9 +12,9 @@ import { TeamTagSchema as TeamTagsSchemaType } from '@fastgpt/global/support/use import { StoreEdgeItemType } from '../workflow/type/edge'; import { AppPermission } from '../../support/permission/app/controller'; import { ParentIdType } from '../../common/parentFolder/type'; -import { FlowNodeInputTypeEnum } from 'core/workflow/node/constant'; +import { FlowNodeInputTypeEnum } from '../../core/workflow/node/constant'; import { WorkflowTemplateBasicType } from '@fastgpt/global/core/workflow/type'; -import { SourceMember } from 'support/user/type'; +import { SourceMemberType } from '../../support/user/type'; export type AppSchema = { _id: string; @@ -64,7 +64,7 @@ export type AppListItemType = { permission: AppPermission; inheritPermission?: boolean; private?: boolean; - sourceMember?: SourceMember; + sourceMember: SourceMemberType; }; export type AppDetailType = AppSchema & { diff --git a/packages/global/core/app/version.d.ts b/packages/global/core/app/version.d.ts index cc93bf57b457..dbf0ae53f1f0 100644 --- a/packages/global/core/app/version.d.ts +++ b/packages/global/core/app/version.d.ts @@ -1,7 +1,7 @@ import { TeamMemberStatusEnum } from 'support/user/team/constant'; import { StoreEdgeItemType } from '../workflow/type/edge'; import { AppChatConfigType, AppSchema } from './type'; -import { SourceMember } from 'support/user/type'; +import { SourceMemberType } from 'support/user/type'; export type AppVersionSchemaType = { _id: string; @@ -22,5 +22,5 @@ export type VersionListItemType = { time: Date; isPublish: boolean | undefined; tmbId: string; - sourceMember: SourceMember; + sourceMember: SourceMemberType; }; diff --git a/packages/global/core/dataset/type.d.ts b/packages/global/core/dataset/type.d.ts index 92f743dd60e3..70d3211d1b8c 100644 --- a/packages/global/core/dataset/type.d.ts +++ b/packages/global/core/dataset/type.d.ts @@ -11,7 +11,7 @@ import { import { DatasetPermission } from '../../support/permission/dataset/controller'; import { Permission } from '../../support/permission/controller'; import { APIFileServer, FeishuServer, YuqueServer } from './apiDataset'; -import { SourceMember } from 'support/user/type'; +import { SourceMemberType } from 'support/user/type'; export type DatasetSchemaType = { _id: string; @@ -166,7 +166,7 @@ export type DatasetListItemType = { vectorModel: VectorModelItemType; inheritPermission: boolean; private?: boolean; - sourceMember?: SourceMember; + sourceMember?: SourceMemberType; }; export type DatasetItemType = Omit<DatasetSchemaType, 'vectorModel' | 'agentModel'> & { diff --git a/packages/global/support/user/team/controller.d.ts b/packages/global/support/user/team/controller.d.ts index 6924ee38f60c..fb331d0de226 100644 --- a/packages/global/support/user/team/controller.d.ts +++ b/packages/global/support/user/team/controller.d.ts @@ -1,5 +1,4 @@ import { PermissionValueType } from '../../permission/type'; -import { SourceMember } from '../type'; import { TeamMemberRoleEnum } from './constant'; import { LafAccountType, TeamMemberSchema, ThirdPartyAccountType } from './type'; diff --git a/packages/global/support/user/type.d.ts b/packages/global/support/user/type.d.ts index 64d935704bff..13f6dd52281a 100644 --- a/packages/global/support/user/type.d.ts +++ b/packages/global/support/user/type.d.ts @@ -31,7 +31,7 @@ export type UserType = { permission: TeamPermission; }; -export type SourceMember = { +export type SourceMemberType = { name: string; avatar: string; status: `${TeamMemberStatusEnum}`; diff --git a/packages/service/support/user/schema.ts b/packages/service/support/user/schema.ts index 00848645eb94..78234fd34bb4 100644 --- a/packages/service/support/user/schema.ts +++ b/packages/service/support/user/schema.ts @@ -3,7 +3,6 @@ const { Schema } = connectionMongo; import { hashStr } from '@fastgpt/global/common/string/tools'; import type { UserModelSchema } from '@fastgpt/global/support/user/type'; import { UserStatusEnum, userStatusMap } from '@fastgpt/global/support/user/constant'; -import { getRandomUserAvatar } from '@fastgpt/global/support/user/utils'; export const userCollectionName = 'users'; @@ -60,10 +59,7 @@ const UserSchema = new Schema({ sourceDomain: String, /** @deprecated */ - avatar: { - type: String, - default: () => getRandomUserAvatar() - } + avatar: String }); try { diff --git a/packages/web/common/fetch/type.d.ts b/packages/web/common/fetch/type.d.ts index bebf822df41d..7f2ea1fbf272 100644 --- a/packages/web/common/fetch/type.d.ts +++ b/packages/web/common/fetch/type.d.ts @@ -7,7 +7,7 @@ type PaginationProps<T = {}> = T & { pageNum: number | string; }>; -type PaginationResponse<T = any> = { +type PaginationResponse<T = {}> = { total: number; list: T[]; }; diff --git a/packages/web/components/common/MySelect/index.tsx b/packages/web/components/common/MySelect/index.tsx index baf8c1bf34aa..d9401b38cf69 100644 --- a/packages/web/components/common/MySelect/index.tsx +++ b/packages/web/components/common/MySelect/index.tsx @@ -164,43 +164,45 @@ const MySelect = <T = any,>( maxH={'40vh'} overflowY={'auto'} > - {ScrollData && ( - <ScrollData> - {list.map((item, i) => ( - <Box key={i}> - <MenuItem - {...menuItemStyles} - {...(value === item.value - ? { - ref: SelectedItemRef, - color: 'primary.700', - bg: 'myGray.100', - fontWeight: '600' - } - : { - color: 'myGray.900' - })} - onClick={() => { - if (onChange && value !== item.value) { - onChange(item.value); + {(() => { + const component = list.map((item, i) => ( + <Box key={i}> + <MenuItem + {...menuItemStyles} + {...(value === item.value + ? { + ref: SelectedItemRef, + color: 'primary.700', + bg: 'myGray.100', + fontWeight: '600' } - }} - whiteSpace={'pre-wrap'} - fontSize={'sm'} - display={'block'} - > - <Box>{item.label}</Box> - {item.description && ( - <Box color={'myGray.500'} fontSize={'xs'}> - {item.description} - </Box> - )} - </MenuItem> - {item.showBorder && <MyDivider my={2} />} - </Box> - ))} - </ScrollData> - )} + : { + color: 'myGray.900' + })} + onClick={() => { + if (onChange && value !== item.value) { + onChange(item.value); + } + }} + whiteSpace={'pre-wrap'} + fontSize={'sm'} + display={'block'} + > + <Box>{item.label}</Box> + {item.description && ( + <Box color={'myGray.500'} fontSize={'xs'}> + {item.description} + </Box> + )} + </MenuItem> + {item.showBorder && <MyDivider my={2} />} + </Box> + )); + if (ScrollData) { + return <ScrollData>{component}</ScrollData>; + } + return component; + })()} </MenuList> </Menu> </Box> diff --git a/packages/web/components/common/UserBox/index.tsx b/packages/web/components/common/UserBox/index.tsx new file mode 100644 index 000000000000..10f20a255ef1 --- /dev/null +++ b/packages/web/components/common/UserBox/index.tsx @@ -0,0 +1,30 @@ +import { Box, HStack } from '@chakra-ui/react'; +import { SourceMemberType } from '@fastgpt/global/support/user/type'; +import React from 'react'; +import Avatar from '../Avatar'; +import { useTranslation } from 'next-i18next'; +import Tag from '../Tag'; + +export type UserBoxProps = { + sourceMember: SourceMemberType; + fontSize?: string; + avatarSize?: string; +}; +function UserBox({ + sourceMember, + fontSize = 'sm', + avatarSize: AvatarWidth = '1.25rem' +}: UserBoxProps) { + const { t } = useTranslation(); + return ( + <HStack> + <Avatar src={sourceMember.avatar} w={AvatarWidth} /> + <Box fontSize={fontSize} ml={1}> + {sourceMember.name} + {sourceMember.status === 'leave' && <Tag color="gray">{t('account_team:leaved')}</Tag>} + </Box> + </HStack> + ); +} + +export default React.memo(UserBox); diff --git a/packages/web/hooks/usePagination.tsx b/packages/web/hooks/usePagination.tsx index 477c3267237b..5e65d11f34e3 100644 --- a/packages/web/hooks/usePagination.tsx +++ b/packages/web/hooks/usePagination.tsx @@ -4,7 +4,6 @@ import { ArrowBackIcon, ArrowForwardIcon } from '@chakra-ui/icons'; import { useTranslation } from 'next-i18next'; import { useToast } from './useToast'; import { getErrText } from '@fastgpt/global/common/error/utils'; - import { useBoolean, useLockFn, @@ -14,37 +13,33 @@ import { useThrottleEffect } from 'ahooks'; -const thresholdVal = 200; +import { PaginationProps, PaginationResponse } from '../common/fetch/type'; -type PagingData<T> = { - pageNum: number; - pageSize: number; - data: T[]; - total?: number; -}; +const thresholdVal = 200; -export function usePagination<ResT = any>({ - api, - pageSize = 10, - params = {}, - defaultRequest = true, - type = 'button', - onChange, - refreshDeps, - scrollLoadType = 'bottom', - EmptyTip -}: { - api: (data: any) => Promise<PagingData<ResT>>; - pageSize?: number; - params?: Record<string, any>; - defaultRequest?: boolean; - type?: 'button' | 'scroll'; - onChange?: (pageNum: number) => void; - refreshDeps?: any[]; - throttleWait?: number; - scrollLoadType?: 'top' | 'bottom'; - EmptyTip?: React.JSX.Element; -}) { +export function usePagination<DataT, ResT = {}>( + api: (data: PaginationProps<DataT>) => Promise<PaginationResponse<ResT>>, + { + pageSize = 10, + params, + defaultRequest = true, + type = 'button', + onChange, + refreshDeps, + scrollLoadType = 'bottom', + EmptyTip + }: { + pageSize?: number; + params?: DataT; + defaultRequest?: boolean; + type?: 'button' | 'scroll'; + onChange?: (pageNum: number) => void; + refreshDeps?: any[]; + throttleWait?: number; + scrollLoadType?: 'top' | 'bottom'; + EmptyTip?: React.JSX.Element; + } +) { const { toast } = useToast(); const { t } = useTranslation(); @@ -64,7 +59,7 @@ export function usePagination<ResT = any>({ setTrue(); try { - const res: PagingData<ResT> = await api({ + const res = await api({ pageNum: num, pageSize, ...params @@ -93,13 +88,13 @@ export function usePagination<ResT = any>({ ); } - setData((prevData) => (num === 1 ? res.data : [...res.data, ...prevData])); + setData((prevData) => (num === 1 ? res.list : [...res.list, ...prevData])); adjustScrollPosition(); } else { - setData((prevData) => (num === 1 ? res.data : [...prevData, ...res.data])); + setData((prevData) => (num === 1 ? res.list : [...prevData, ...res.list])); } } else { - setData(res.data); + setData(res.list); } onChange?.(num); diff --git a/packages/web/hooks/useScrollPagination.tsx b/packages/web/hooks/useScrollPagination.tsx index d7b4e93bb304..83a5ad11b350 100644 --- a/packages/web/hooks/useScrollPagination.tsx +++ b/packages/web/hooks/useScrollPagination.tsx @@ -2,7 +2,7 @@ import React, { ReactNode, RefObject, useMemo, useRef, useState } from 'react'; import { Box, BoxProps } from '@chakra-ui/react'; import { useToast } from './useToast'; import { getErrText } from '@fastgpt/global/common/error/utils'; -import { PaginationResponse } from '../common/fetch/type'; +import { PaginationProps, PaginationResponse } from '../common/fetch/type'; import { useBoolean, useLockFn, @@ -29,8 +29,11 @@ export type ScrollListType = ({ isLoading?: boolean; } & BoxProps) => React.JSX.Element; -export function useVirtualScrollPagination<TParams, TData>( - api: (data: TParams) => Promise<PaginationResponse<TData>>, +export function useVirtualScrollPagination< + TParams extends PaginationProps, + TData extends PaginationResponse +>( + api: (data: TParams) => Promise<TData>, { refreshDeps, itemHeight = 50, @@ -41,7 +44,7 @@ export function useVirtualScrollPagination<TParams, TData>( }: { refreshDeps?: any[]; - itemHeight: number | ItemHeight<PaginationResponse<TData>['list'][0]>; + itemHeight: number | ItemHeight<TData['list'][0]>; overscan?: number; pageSize?: number; @@ -53,13 +56,13 @@ export function useVirtualScrollPagination<TParams, TData>( const wrapperRef = useRef(null); const { toast } = useToast(); - const [data, setData] = useState<PaginationResponse<TData>['list']>([]); + const [data, setData] = useState<TData['list']>([]); const [total, setTotal] = useState(0); const [isLoading, { setTrue, setFalse }] = useBoolean(false); const noMore = data.length >= total; - const [list] = useVirtualList<PaginationResponse<TData>['list'][0]>(data, { + const [list] = useVirtualList<TData['list'][0]>(data, { containerTarget: containerRef, wrapperTarget: wrapperRef, itemHeight, @@ -174,8 +177,11 @@ export function useVirtualScrollPagination<TParams, TData>( }; } -export function useScrollPagination<TParams, TData>( - api: (data: TParams) => Promise<PaginationResponse<TData>>, +export function useScrollPagination< + TParams extends PaginationProps, + TData extends PaginationResponse +>( + api: (data: TParams) => Promise<TData>, { refreshDeps, scrollLoadType = 'bottom', @@ -197,7 +203,7 @@ export function useScrollPagination<TParams, TData>( const { t } = useTranslation(); const { toast } = useToast(); - const [data, setData] = useState<PaginationResponse<TData>['list']>([]); + const [data, setData] = useState<TData['list']>([]); const [total, setTotal] = useState(0); const [isLoading, { setTrue, setFalse }] = useBoolean(false); const isEmpty = total === 0 && !isLoading; diff --git a/projects/app/src/components/core/app/InputGuideConfig.tsx b/projects/app/src/components/core/app/InputGuideConfig.tsx index 13c3920ba2c0..91a83d24af2e 100644 --- a/projects/app/src/components/core/app/InputGuideConfig.tsx +++ b/projects/app/src/components/core/app/InputGuideConfig.tsx @@ -54,7 +54,7 @@ const InputGuideConfig = ({ onChange: (e: ChatInputGuideConfigType) => void; }) => { const { t } = useTranslation(); - const { chatT, commonT } = useI18n(); + const { chatT } = useI18n(); const { isOpen, onOpen, onClose } = useDisclosure(); const { isOpen: isOpenLexiconConfig, @@ -220,7 +220,7 @@ const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () => }); const { run: createNewData, loading: isCreating } = useRequest2( - (textList: string[]) => { + async (textList: string[]) => { if (textList.filter(Boolean).length === 0) { return Promise.resolve(); } diff --git a/projects/app/src/global/core/api/appReq.d.ts b/projects/app/src/global/core/api/appReq.d.ts index 7668e5355fa8..59a039afc158 100644 --- a/projects/app/src/global/core/api/appReq.d.ts +++ b/projects/app/src/global/core/api/appReq.d.ts @@ -1,7 +1,7 @@ -import { RequestPaging } from '@/types'; +import { PaginationProps } from '@fastgpt/web/common/fetch/type'; -export type GetAppChatLogsParams = RequestPaging & { +export type GetAppChatLogsParams = PaginationProps<{ appId: string; dateStart: Date; dateEnd: Date; -}; +}>; diff --git a/projects/app/src/global/core/api/datasetReq.d.ts b/projects/app/src/global/core/api/datasetReq.d.ts index e896df0e2066..22c69146640f 100644 --- a/projects/app/src/global/core/api/datasetReq.d.ts +++ b/projects/app/src/global/core/api/datasetReq.d.ts @@ -3,24 +3,24 @@ import { DatasetCollectionTypeEnum, DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants'; -import type { RequestPaging } from '@/types'; import { TrainingModeEnum } from '@fastgpt/global/core/dataset/constants'; import type { SearchTestItemType } from '@/types/core/dataset'; import { UploadChunkItemType } from '@fastgpt/global/core/dataset/type'; import { DatasetCollectionSchemaType } from '@fastgpt/global/core/dataset/type'; import { PermissionTypeEnum } from '@fastgpt/global/support/permission/constant'; import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; +import { PaginationProps } from '@fastgpt/web/common/fetch/type'; /* ===== dataset ===== */ /* ======= collections =========== */ -export type GetDatasetCollectionsProps = RequestPaging & { +export type GetDatasetCollectionsProps = PaginationProps<{ datasetId: string; parentId?: string; searchText?: string; filterTags?: string[]; simple?: boolean; selectFolder?: boolean; -}; +}>; /* ==== data ===== */ diff --git a/projects/app/src/pages/account/bill/components/BillTable.tsx b/projects/app/src/pages/account/bill/components/BillTable.tsx index d0ee4e914c73..228de85cb68d 100644 --- a/projects/app/src/pages/account/bill/components/BillTable.tsx +++ b/projects/app/src/pages/account/bill/components/BillTable.tsx @@ -1,4 +1,4 @@ -import React, { useState, useCallback, useMemo, useEffect } from 'react'; +import React, { useState, useMemo, useEffect } from 'react'; import { Button, Table, @@ -32,24 +32,23 @@ import MySelect from '@fastgpt/web/components/common/MySelect'; import MyModal from '@fastgpt/web/components/common/MyModal'; import { usePagination } from '@fastgpt/web/hooks/usePagination'; import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel'; -import { useI18n } from '@/web/context/I18n'; const BillTable = () => { const { t } = useTranslation(); const { toast } = useToast(); - const [billType, setBillType] = useState<BillTypeEnum | ''>(''); + const [billType, setBillType] = useState<BillTypeEnum | undefined>(undefined); const [billDetail, setBillDetail] = useState<BillSchemaType>(); const billTypeList = useMemo( () => [ - { label: t('account_bill:all'), value: '' }, + { label: t('account_bill:all'), value: undefined }, ...Object.entries(billTypeMap).map(([key, value]) => ({ label: t(value.label as any), value: key })) ] as { label: string; - value: BillTypeEnum | ''; + value: BillTypeEnum | undefined; }[], [t] ); @@ -60,8 +59,7 @@ const BillTable = () => { Pagination, getData, total - } = usePagination({ - api: getBills, + } = usePagination(getBills, { pageSize: 20, params: { type: billType @@ -108,7 +106,7 @@ const BillTable = () => { <Tr> <Th>#</Th> <Th> - <MySelect<BillTypeEnum | ''> + <MySelect list={billTypeList} value={billType} size={'sm'} @@ -179,7 +177,6 @@ export default BillTable; function BillDetailModal({ bill, onClose }: { bill: BillSchemaType; onClose: () => void }) { const { t } = useTranslation(); - const { commonT } = useI18n(); return ( <MyModal isOpen={true} diff --git a/projects/app/src/pages/account/bill/components/InvoiceTable.tsx b/projects/app/src/pages/account/bill/components/InvoiceTable.tsx index 7f039aa760b3..d3797a3afb7f 100644 --- a/projects/app/src/pages/account/bill/components/InvoiceTable.tsx +++ b/projects/app/src/pages/account/bill/components/InvoiceTable.tsx @@ -1,7 +1,7 @@ import { getInvoiceRecords } from '@/web/support/wallet/bill/invoice/api'; import MyBox from '@fastgpt/web/components/common/MyBox'; import { useTranslation } from 'next-i18next'; -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import { Box, Button, @@ -30,8 +30,7 @@ const InvoiceTable = () => { isLoading, Pagination, total - } = usePagination({ - api: getInvoiceRecords, + } = usePagination(getInvoiceRecords, { pageSize: 20 }); diff --git a/projects/app/src/pages/account/inform.tsx b/projects/app/src/pages/account/inform.tsx index 176abe602ced..d0612c3385f7 100644 --- a/projects/app/src/pages/account/inform.tsx +++ b/projects/app/src/pages/account/inform.tsx @@ -1,13 +1,12 @@ import React from 'react'; import { Box, Button, Flex, useTheme } from '@chakra-ui/react'; import { getInforms, readInform } from '@/web/support/user/inform/api'; -import type { UserInformSchema } from '@fastgpt/global/support/user/inform/type'; import { formatTimeToChatTime } from '@fastgpt/global/common/string/time'; import { usePagination } from '@fastgpt/web/hooks/usePagination'; import { useLoading } from '@fastgpt/web/hooks/useLoading'; import { useTranslation } from 'next-i18next'; import EmptyTip from '@fastgpt/web/components/common/EmptyTip'; -import AccountContainer, { TabEnum } from './components/AccountContainer'; +import AccountContainer from './components/AccountContainer'; import { serviceSideProps } from '@fastgpt/web/common/system/nextjs'; const InformTable = () => { @@ -23,8 +22,7 @@ const InformTable = () => { Pagination, getData, pageNum - } = usePagination<UserInformSchema>({ - api: getInforms, + } = usePagination(getInforms, { pageSize: 20 }); diff --git a/projects/app/src/pages/account/promotion.tsx b/projects/app/src/pages/account/promotion.tsx index be9ed529d191..5da3e0b48815 100644 --- a/projects/app/src/pages/account/promotion.tsx +++ b/projects/app/src/pages/account/promotion.tsx @@ -25,7 +25,7 @@ import { usePagination } from '@fastgpt/web/hooks/usePagination'; import { useLoading } from '@fastgpt/web/hooks/useLoading'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; import EmptyTip from '@fastgpt/web/components/common/EmptyTip'; -import AccountContainer, { TabEnum } from './components/AccountContainer'; +import AccountContainer from './components/AccountContainer'; import { serviceSideProps } from '@fastgpt/web/common/system/nextjs'; const Promotion = () => { @@ -41,8 +41,7 @@ const Promotion = () => { total, pageSize, Pagination - } = usePagination({ - api: getPromotionRecords, + } = usePagination(getPromotionRecords, { pageSize: 20 }); diff --git a/projects/app/src/pages/account/team/components/MemberTable.tsx b/projects/app/src/pages/account/team/components/MemberTable.tsx index 46a3bf19b100..da2aa1532f9b 100644 --- a/projects/app/src/pages/account/team/components/MemberTable.tsx +++ b/projects/app/src/pages/account/team/components/MemberTable.tsx @@ -29,7 +29,7 @@ import { useToast } from '@fastgpt/web/hooks/useToast'; import { TeamErrEnum } from '@fastgpt/global/common/error/code/team'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { delLeaveTeam } from '@/web/support/user/team/api'; -import { syncMembers } from '@/web/support/user/api'; +import { postSyncMembers } from '@/web/support/user/api'; import MyLoading from '@fastgpt/web/components/common/MyLoading'; const InviteModal = dynamic(() => import('./InviteModal')); @@ -83,7 +83,7 @@ function MemberTable({ Tabs }: { Tabs: React.ReactNode }) { content: t('account_team:confirm_leave_team') }); - const { runAsync: onSyncMember, loading: isSyncing } = useRequest2(syncMembers, { + const { runAsync: onSyncMember, loading: isSyncing } = useRequest2(postSyncMembers, { onSuccess() { refetchMembers(); }, diff --git a/projects/app/src/pages/account/usage/index.tsx b/projects/app/src/pages/account/usage/index.tsx index 10c72feb569c..8db661730fea 100644 --- a/projects/app/src/pages/account/usage/index.tsx +++ b/projects/app/src/pages/account/usage/index.tsx @@ -84,14 +84,13 @@ const UsageTable = () => { isLoading, Pagination, getData - } = usePagination<UsageItemType>({ - api: getUserUsages, + } = usePagination(getUserUsages, { pageSize: isPc ? 20 : 10, params: { dateStart: dateRange.from || new Date(), dateEnd: addDays(dateRange.to || new Date(), 1), - source: usageSource, - teamMemberId: selectTmbId + source: usageSource as UsageSourceEnum, + teamMemberId: selectTmbId ?? '' }, defaultRequest: false }); diff --git a/projects/app/src/pages/api/core/app/getChatLogs.ts b/projects/app/src/pages/api/core/app/getChatLogs.ts index fcf06cf229af..57b9cdc56bb9 100644 --- a/projects/app/src/pages/api/core/app/getChatLogs.ts +++ b/projects/app/src/pages/api/core/app/getChatLogs.ts @@ -1,6 +1,5 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { MongoChat } from '@fastgpt/service/core/chat/chatSchema'; -import type { PagingData } from '@/types'; import { AppLogsListItemType } from '@/types/app'; import { Types } from '@fastgpt/service/common/mongo'; import { addDays } from 'date-fns'; @@ -12,11 +11,12 @@ import { WritePermissionVal } from '@fastgpt/global/support/permission/constant' import { readFromSecondary } from '@fastgpt/service/common/mongo/utils'; import { parsePaginationRequest } from '@fastgpt/service/common/api/pagination'; import { TeamMemberCollectionName } from '@fastgpt/global/support/user/team/constant'; +import { PaginationResponse } from '@fastgpt/web/common/fetch/type'; async function handler( req: NextApiRequest, _res: NextApiResponse -): Promise<PagingData<AppLogsListItemType>> { +): Promise<PaginationResponse<AppLogsListItemType>> { const { appId, dateStart = addDays(new Date(), -7), @@ -41,7 +41,7 @@ async function handler( } }; - const [data, total] = await Promise.all([ + const [list, total] = await Promise.all([ MongoChat.aggregate( [ { $match: where }, @@ -160,9 +160,7 @@ async function handler( ]); return { - pageNum: offset / pageSize + 1, - pageSize, - data, + list, total }; } diff --git a/projects/app/src/pages/api/core/app/list.ts b/projects/app/src/pages/api/core/app/list.ts index f7dbcf08e049..f6e1b16799cb 100644 --- a/projects/app/src/pages/api/core/app/list.ts +++ b/projects/app/src/pages/api/core/app/list.ts @@ -205,11 +205,11 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy // get member info const memberInfo = await MongoTeamMember.find( { _id: { $in: formatApps.map((app) => app.tmbId) } }, - '_id name avatar' + '_id name avatar status' ).lean(); return formatApps.map((app) => { - const member = memberInfo.find((item) => String(item._id) === String(app.tmbId)); + const member = memberInfo.find((item) => String(item._id) === String(app.tmbId))!; return { _id: app._id, tmbId: app.tmbId, @@ -223,8 +223,9 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy inheritPermission: app.inheritPermission ?? true, private: app.privateApp, sourceMember: { - name: member?.name, - avatar: member?.avatar + name: member.name, + avatar: member.avatar, + status: member.status } }; }); diff --git a/projects/app/src/pages/api/core/dataset/collection/list.ts b/projects/app/src/pages/api/core/dataset/collection/list.ts index 7c7410275f32..8871636ee66d 100644 --- a/projects/app/src/pages/api/core/dataset/collection/list.ts +++ b/projects/app/src/pages/api/core/dataset/collection/list.ts @@ -10,14 +10,15 @@ import { DatasetDataCollectionName } from '@fastgpt/service/core/dataset/data/sc import { startTrainingQueue } from '@/service/core/dataset/training/utils'; import { NextAPI } from '@/service/middleware/entry'; import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant'; -import { PagingData } from '@/types'; import { readFromSecondary } from '@fastgpt/service/common/mongo/utils'; import { collectionTagsToTagLabel } from '@fastgpt/service/core/dataset/collection/utils'; +import { PaginationResponse } from '@fastgpt/web/common/fetch/type'; +import { parsePaginationRequest } from '@fastgpt/service/common/api/pagination'; -async function handler(req: NextApiRequest): Promise<PagingData<DatasetCollectionsListItemType>> { +async function handler( + req: NextApiRequest +): Promise<PaginationResponse<DatasetCollectionsListItemType>> { let { - pageNum = 1, - pageSize = 10, datasetId, parentId = null, searchText = '', @@ -25,8 +26,9 @@ async function handler(req: NextApiRequest): Promise<PagingData<DatasetCollectio filterTags = [], simple = false } = req.body as GetDatasetCollectionsProps; - searchText = searchText?.replace(/'/g, ''); + let { pageSize, offset } = parsePaginationRequest(req); pageSize = Math.min(pageSize, 30); + searchText = searchText?.replace(/'/g, ''); // auth dataset and get my role const { teamId, permission } = await authDataset({ @@ -78,9 +80,7 @@ async function handler(req: NextApiRequest): Promise<PagingData<DatasetCollectio .lean(); return { - pageNum, - pageSize, - data: await Promise.all( + list: await Promise.all( collections.map(async (item) => ({ ...item, tags: await collectionTagsToTagLabel({ @@ -105,7 +105,7 @@ async function handler(req: NextApiRequest): Promise<PagingData<DatasetCollectio $sort: { updateTime: -1 } }, { - $skip: (pageNum - 1) * pageSize + $skip: offset }, { $limit: pageSize @@ -167,7 +167,7 @@ async function handler(req: NextApiRequest): Promise<PagingData<DatasetCollectio }) ]); - const data = await Promise.all( + const list = await Promise.all( collections.map(async (item) => ({ ...item, tags: await collectionTagsToTagLabel({ @@ -178,15 +178,13 @@ async function handler(req: NextApiRequest): Promise<PagingData<DatasetCollectio })) ); - if (data.find((item) => item.trainingAmount > 0)) { + if (list.find((item) => item.trainingAmount > 0)) { startTrainingQueue(); } // count collections return { - pageNum, - pageSize, - data, + list, total }; } diff --git a/projects/app/src/pages/api/core/dataset/data/list.ts b/projects/app/src/pages/api/core/dataset/data/list.ts index 45b21e1abae1..a10f7e3ea549 100644 --- a/projects/app/src/pages/api/core/dataset/data/list.ts +++ b/projects/app/src/pages/api/core/dataset/data/list.ts @@ -3,10 +3,10 @@ import { MongoDatasetData } from '@fastgpt/service/core/dataset/data/schema'; import { replaceRegChars } from '@fastgpt/global/common/string/tools'; import { NextAPI } from '@/service/middleware/entry'; import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant'; -import { PagingData } from '@/types'; import { ApiRequestProps } from '@fastgpt/service/type/next'; import { DatasetDataListItemType } from '@/global/core/dataset/type'; import { parsePaginationRequest } from '@fastgpt/service/common/api/pagination'; +import { PaginationResponse } from '@fastgpt/web/common/fetch/type'; export type GetDatasetDataListProps = { searchText?: string; @@ -15,7 +15,7 @@ export type GetDatasetDataListProps = { async function handler( req: ApiRequestProps<GetDatasetDataListProps> -): Promise<PagingData<DatasetDataListItemType>> { +): Promise<PaginationResponse<DatasetDataListItemType>> { let { searchText = '', collectionId } = req.body; let { offset, pageSize } = parsePaginationRequest(req); @@ -42,7 +42,7 @@ async function handler( : {}) }; - const [data, total] = await Promise.all([ + const [list, total] = await Promise.all([ MongoDatasetData.find(match, '_id datasetId collectionId q a chunkIndex') .sort({ chunkIndex: 1, updateTime: -1 }) .skip(offset) @@ -52,9 +52,7 @@ async function handler( ]); return { - pageNum: offset / pageSize + 1, - pageSize, - data, + list, total }; } diff --git a/projects/app/src/pages/app/detail/components/Logs/index.tsx b/projects/app/src/pages/app/detail/components/Logs/index.tsx index d61014bf7ec3..b104da20be10 100644 --- a/projects/app/src/pages/app/detail/components/Logs/index.tsx +++ b/projects/app/src/pages/app/detail/components/Logs/index.tsx @@ -13,7 +13,7 @@ import { ModalBody, HStack } from '@chakra-ui/react'; -import Avatar from '@fastgpt/web/components/common/Avatar'; +import UserBox from '@fastgpt/web/components/common/UserBox'; import MyIcon from '@fastgpt/web/components/common/Icon'; import { useTranslation } from 'next-i18next'; import { getAppChatLogs } from '@/web/core/app/api'; @@ -30,7 +30,6 @@ import { cardStyles } from '../constants'; import dynamic from 'next/dynamic'; import { useSystem } from '@fastgpt/web/hooks/useSystem'; -import Tag from '@fastgpt/web/components/common/Tag'; const DetailLogsModal = dynamic(() => import('./DetailLogsModal')); @@ -56,8 +55,7 @@ const Logs = () => { Pagination, getData, pageNum - } = usePagination({ - api: getAppChatLogs, + } = usePagination(getAppChatLogs, { pageSize: 20, params: { appId, @@ -132,15 +130,7 @@ const Logs = () => { {!!item.outLinkUid ? ( item.outLinkUid ) : ( - <HStack> - <Avatar src={item.sourceMember.avatar} w="1.25rem" /> - <Box fontSize={'sm'} ml={1}> - {item.sourceMember.name} - {item.sourceMember.status === 'leave' && ( - <Tag color="gray">{t('account_team:leaved')}</Tag> - )} - </Box> - </HStack> + <UserBox sourceMember={item.sourceMember} /> )} </Box> </Td> diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/NodeTemplatesModal.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/NodeTemplatesModal.tsx index c4c5028f06c8..b48d715dacb4 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/NodeTemplatesModal.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/NodeTemplatesModal.tsx @@ -155,7 +155,7 @@ const NodeTemplatesModal = ({ isOpen, onClose }: ModuleTemplateListProps) => { searchVal?: string; }) => { if (type === TemplateTypeEnum.teamPlugin) { - return await getTeamPlugTemplates({ + return getTeamPlugTemplates({ parentId, searchKey: searchVal }).then((res) => res.filter((app) => app.id !== appId)); diff --git a/projects/app/src/pages/dataset/detail/components/CollectionCard/Context.tsx b/projects/app/src/pages/dataset/detail/components/CollectionCard/Context.tsx index 3ac4ea160d84..f43bf12bb497 100644 --- a/projects/app/src/pages/dataset/detail/components/CollectionCard/Context.tsx +++ b/projects/app/src/pages/dataset/detail/components/CollectionCard/Context.tsx @@ -111,8 +111,7 @@ const CollectionPageContextProvider = ({ children }: { children: ReactNode }) => isLoading: isGetting, pageNum, pageSize - } = usePagination<DatasetCollectionsListItemType>({ - api: getDatasetCollections, + } = usePagination(getDatasetCollections, { pageSize: 20, params: { datasetId, diff --git a/projects/app/src/types/index.d.ts b/projects/app/src/types/index.d.ts index 228ee1df8164..84dfaf634d23 100644 --- a/projects/app/src/types/index.d.ts +++ b/projects/app/src/types/index.d.ts @@ -10,15 +10,6 @@ import { import { TrackEventName } from '@/web/common/system/constants'; import { SubPlanType } from '@fastgpt/global/support/wallet/sub/type'; -export type PagingData<T> = { - pageNum: number; - pageSize: number; - data: T[]; - total?: number; -}; - -export type RequestPaging = { pageNum: number; pageSize: number; [key]: any }; - declare global { var qaQueueLen: number; var vectorQueueLen: number; diff --git a/projects/app/src/web/core/app/api.ts b/projects/app/src/web/core/app/api.ts index 26675705b940..d1908a48ee4e 100644 --- a/projects/app/src/web/core/app/api.ts +++ b/projects/app/src/web/core/app/api.ts @@ -5,7 +5,7 @@ import { AppUpdateParams, AppChangeOwnerBody } from '@/global/core/app/api'; import type { CreateAppBody } from '@/pages/api/core/app/create'; import type { ListAppBody } from '@/pages/api/core/app/list'; import { AppLogsListItemType } from '@/types/app'; -import { PagingData } from '@/types'; +import { PaginationResponse } from '@fastgpt/web/common/fetch/type'; /** * 获取应用列表 @@ -39,7 +39,7 @@ export const putAppById = (id: string, data: AppUpdateParams) => // =================== chat logs export const getAppChatLogs = (data: GetAppChatLogsParams) => - POST<PagingData<AppLogsListItemType>>(`/core/app/getChatLogs`, data); + POST<PaginationResponse<AppLogsListItemType>>(`/core/app/getChatLogs`, data); export const resumeInheritPer = (appId: string) => GET(`/core/app/resumeInheritPermission`, { appId }); diff --git a/projects/app/src/web/core/dataset/api.ts b/projects/app/src/web/core/dataset/api.ts index 5a17b7fce889..422b17e228a1 100644 --- a/projects/app/src/web/core/dataset/api.ts +++ b/projects/app/src/web/core/dataset/api.ts @@ -37,7 +37,6 @@ import type { DatasetCollectionItemType } from '@fastgpt/global/core/dataset/typ import { DatasetCollectionSyncResultEnum } from '@fastgpt/global/core/dataset/constants'; import type { DatasetDataItemType } from '@fastgpt/global/core/dataset/type'; import type { DatasetCollectionsListItemType } from '@/global/core/dataset/type.d'; -import { PagingData } from '@/types'; import type { getDatasetTrainingQueueResponse } from '@/pages/api/core/dataset/training/getDatasetTrainingQueue'; import type { rebuildEmbeddingBody } from '@/pages/api/core/dataset/training/rebuildEmbedding'; import type { @@ -66,8 +65,6 @@ import type { listExistIdQuery, listExistIdResponse } from '@/pages/api/core/dataset/apiDataset/listExistId'; -import { FeishuServer, YuqueServer } from '@fastgpt/global/core/dataset/apiDataset'; -import { RequireOnlyOne } from '@fastgpt/global/common/type/utils'; /* ======================== dataset ======================= */ export const getDatasets = (data: GetDatasetListBody) => @@ -110,7 +107,7 @@ export const postSearchText = (data: SearchTestProps) => /* ============================= collections ==================================== */ export const getDatasetCollections = (data: GetDatasetCollectionsProps) => - POST<PagingData<DatasetCollectionsListItemType>>(`/core/dataset/collection/list`, data); + POST<PaginationResponse<DatasetCollectionsListItemType>>(`/core/dataset/collection/list`, data); export const getDatasetCollectionPathById = (parentId: string) => GET<ParentTreePathItemType[]>(`/core/dataset/collection/paths`, { parentId }); export const getDatasetCollectionById = (id: string) => diff --git a/projects/app/src/web/core/dataset/components/SelectCollections.tsx b/projects/app/src/web/core/dataset/components/SelectCollections.tsx index 7b09e0e7a8b3..5ca8b139e771 100644 --- a/projects/app/src/web/core/dataset/components/SelectCollections.tsx +++ b/projects/app/src/web/core/dataset/components/SelectCollections.tsx @@ -1,7 +1,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon'; import MyModal from '@fastgpt/web/components/common/MyModal'; import ParentPaths from '@/components/common/ParentPaths'; -import { useRequest } from '@fastgpt/web/hooks/useRequest'; +import { useRequest, useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { getDatasetCollectionPathById, getDatasetCollections } from '@/web/core/dataset/api'; import { Box, Flex, ModalFooter, Button, useTheme, Grid, Card, ModalBody } from '@chakra-ui/react'; import { DatasetCollectionTypeEnum } from '@fastgpt/global/core/dataset/constants'; @@ -48,20 +48,24 @@ const SelectCollections = ({ useQuery(['loadDatasetDetail', datasetId], () => loadDatasetDetail(datasetId)); - const { data, isLoading } = useQuery(['getDatasetCollections', parentId], () => - getDatasetCollections({ - datasetId, - parentId, - selectFolder: type === 'folder', - simple: true, - pageNum: 1, - pageSize: 50 - }) + const { data, loading: isLoading } = useRequest2( + () => + getDatasetCollections({ + datasetId, + parentId, + selectFolder: type === 'folder', + simple: true, + pageNum: 1, + pageSize: 50 + }), + { + manual: false, + refreshDeps: [datasetId, parentId, type] + } ); - const formatCollections = useMemo( () => - data?.data.map((collection) => { + data?.list.map((collection) => { const icon = getCollectionIcon(collection.type, collection.name); return { @@ -111,7 +115,7 @@ const SelectCollections = ({ title={ <Box> <ParentPaths - paths={paths.map((path, i) => ({ + paths={paths.map((path) => ({ parentId: path.parentId, parentName: path.parentName }))} diff --git a/projects/app/src/web/support/activity/promotion/api.ts b/projects/app/src/web/support/activity/promotion/api.ts index b44cf67cbaf2..abccbee88c73 100644 --- a/projects/app/src/web/support/activity/promotion/api.ts +++ b/projects/app/src/web/support/activity/promotion/api.ts @@ -1,6 +1,6 @@ -import { GET, POST, PUT } from '@/web/common/api/request'; +import { GET, POST } from '@/web/common/api/request'; import type { PromotionRecordType } from '@/global/support/api/userRes.d'; -import { PagingData, type RequestPaging } from '@/types'; +import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type'; /* get promotion init data */ export const getPromotionInitData = () => @@ -10,5 +10,8 @@ export const getPromotionInitData = () => }>('/proApi/support/activity/promotion/getPromotionData'); /* promotion records */ -export const getPromotionRecords = (data: RequestPaging) => - POST<PagingData<PromotionRecordType>>(`/proApi/support/activity/promotion/getPromotions`, data); +export const getPromotionRecords = (data: PaginationProps) => + POST<PaginationResponse<PromotionRecordType>>( + `/proApi/support/activity/promotion/getPromotions`, + data + ); diff --git a/projects/app/src/web/support/user/api.ts b/projects/app/src/web/support/user/api.ts index 86deb5d4499b..b1d076d374bc 100644 --- a/projects/app/src/web/support/user/api.ts +++ b/projects/app/src/web/support/user/api.ts @@ -91,4 +91,4 @@ export const getCaptchaPic = (username: string) => captchaImage: string; }>('/proApi/support/user/account/captcha/getImgCaptcha', { username }); -export const syncMembers = () => GET('/proApi/support/user/team/org/sync'); +export const postSyncMembers = () => POST('/proApi/support/user/team/org/sync'); diff --git a/projects/app/src/web/support/user/inform/api.ts b/projects/app/src/web/support/user/inform/api.ts index fb5d4434dcbe..206ad2ab1e4b 100644 --- a/projects/app/src/web/support/user/inform/api.ts +++ b/projects/app/src/web/support/user/inform/api.ts @@ -1,10 +1,10 @@ -import { GET, POST, PUT } from '@/web/common/api/request'; -import type { PagingData, RequestPaging } from '@/types'; +import { GET, POST } from '@/web/common/api/request'; import type { UserInformSchema } from '@fastgpt/global/support/user/inform/type'; import { SystemMsgModalValueType } from '@fastgpt/service/support/user/inform/type'; +import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type'; -export const getInforms = (data: RequestPaging) => - POST<PagingData<UserInformSchema>>(`/proApi/support/user/inform/list`, data); +export const getInforms = (data: PaginationProps) => + POST<PaginationResponse<UserInformSchema>>(`/proApi/support/user/inform/list`, data); export const getUnreadCount = () => GET<{ diff --git a/projects/app/src/web/support/wallet/bill/api.ts b/projects/app/src/web/support/wallet/bill/api.ts index a04de528c238..3058340b3a27 100644 --- a/projects/app/src/web/support/wallet/bill/api.ts +++ b/projects/app/src/web/support/wallet/bill/api.ts @@ -1,14 +1,14 @@ -import { PagingData, RequestPaging } from '@/types'; import { GET, POST } from '@/web/common/api/request'; import { CreateBillProps, CreateBillResponse } from '@fastgpt/global/support/wallet/bill/api'; import { BillTypeEnum } from '@fastgpt/global/support/wallet/bill/constants'; import type { BillSchemaType } from '@fastgpt/global/support/wallet/bill/type.d'; +import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type'; export const getBills = ( - data: RequestPaging & { + data: PaginationProps<{ type?: BillTypeEnum; - } -) => POST<PagingData<BillSchemaType>>(`/proApi/support/wallet/bill/list`, data); + }> +) => POST<PaginationResponse<BillSchemaType>>(`/proApi/support/wallet/bill/list`, data); export const getWxPayQRCode = (data: CreateBillProps) => POST<CreateBillResponse>(`/proApi/support/wallet/bill/create`, data); diff --git a/projects/app/src/web/support/wallet/bill/invoice/api.ts b/projects/app/src/web/support/wallet/bill/invoice/api.ts index 7ec7772e8427..c5523e8d8fbd 100644 --- a/projects/app/src/web/support/wallet/bill/invoice/api.ts +++ b/projects/app/src/web/support/wallet/bill/invoice/api.ts @@ -1,8 +1,8 @@ -import { PagingData, RequestPaging } from '@/types'; import { GET, POST } from '@/web/common/api/request'; import { BillTypeEnum } from '@fastgpt/global/support/wallet/bill/constants'; import { InvoiceType } from '@fastgpt/global/support/wallet/bill/type'; import { InvoiceSchemaType } from '@fastgpt/global/support/wallet/bill/type'; +import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type'; export type invoiceBillDataType = { type: BillTypeEnum; price: number; @@ -16,5 +16,5 @@ export const getInvoiceBillsList = () => export const submitInvoice = (data: InvoiceType) => POST(`/proApi/support/wallet/bill/invoice/submit`, data); -export const getInvoiceRecords = (data: RequestPaging) => - POST<PagingData<InvoiceSchemaType>>(`/proApi/support/wallet/bill/invoice/records`, data); +export const getInvoiceRecords = (data: PaginationProps) => + POST<PaginationResponse<InvoiceSchemaType>>(`/proApi/support/wallet/bill/invoice/records`, data); diff --git a/projects/app/src/web/support/wallet/usage/api.ts b/projects/app/src/web/support/wallet/usage/api.ts index 41b32be3d208..c4ce4171ac55 100644 --- a/projects/app/src/web/support/wallet/usage/api.ts +++ b/projects/app/src/web/support/wallet/usage/api.ts @@ -1,10 +1,17 @@ -import { GET, POST } from '@/web/common/api/request'; +import { POST } from '@/web/common/api/request'; import { CreateTrainingUsageProps } from '@fastgpt/global/support/wallet/usage/api.d'; -import type { PagingData, RequestPaging } from '@/types'; +import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants'; import type { UsageItemType } from '@fastgpt/global/support/wallet/usage/type'; +import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type'; -export const getUserUsages = (data: RequestPaging) => - POST<PagingData<UsageItemType>>(`/proApi/support/wallet/usage/getUsage`, data); +export const getUserUsages = ( + data: PaginationProps<{ + dateStart: Date; + dateEnd: Date; + source?: UsageSourceEnum; + teamMemberId: string; + }> +) => POST<PaginationResponse<UsageItemType>>(`/proApi/support/wallet/usage/getUsage`, data); export const postCreateTrainingUsage = (data: CreateTrainingUsageProps) => POST<string>(`/support/wallet/usage/createTrainingUsage`, data);