This commit is contained in:
Archer
2023-11-09 09:46:57 +08:00
committed by GitHub
parent 661ee79943
commit 8bb5588305
402 changed files with 9899 additions and 5967 deletions

View File

@@ -11,14 +11,14 @@ import {
Td,
TableContainer
} from '@chakra-ui/react';
import { UserBillType } from '@/types/user';
import { BillItemType } from '@fastgpt/global/support/wallet/bill/type.d';
import dayjs from 'dayjs';
import { BillSourceMap } from '@/constants/user';
import { formatPrice } from '@fastgpt/global/common/bill/tools';
import { BillSourceMap } from '@fastgpt/global/support/wallet/bill/constants';
import { formatPrice } from '@fastgpt/global/support/wallet/bill/tools';
import MyModal from '@/components/MyModal';
import { useTranslation } from 'react-i18next';
const BillDetail = ({ bill, onClose }: { bill: UserBillType; onClose: () => void }) => {
const BillDetail = ({ bill, onClose }: { bill: BillItemType; onClose: () => void }) => {
const { t } = useTranslation();
const filterBillList = useMemo(
() => bill.list.filter((item) => item && item.moduleName),
@@ -28,6 +28,10 @@ const BillDetail = ({ bill, onClose }: { bill: UserBillType; onClose: () => void
return (
<MyModal isOpen={true} onClose={onClose} title={t('user.Bill Detail')}>
<ModalBody>
<Flex alignItems={'center'} pb={4}>
<Box flex={'0 0 80px'}>:</Box>
<Box>{bill.username}</Box>
</Flex>
<Flex alignItems={'center'} pb={4}>
<Box flex={'0 0 80px'}>:</Box>
<Box>{bill.id}</Box>
@@ -65,7 +69,7 @@ const BillDetail = ({ bill, onClose }: { bill: UserBillType; onClose: () => void
<Tbody>
{filterBillList.map((item, i) => (
<Tr key={i}>
<Td>{item.moduleName}</Td>
<Td>{t(item.moduleName)}</Td>
<Td>{item.model}</Td>
<Td>{item.tokenLen}</Td>
<Td>{formatPrice(item.amount)}</Td>

View File

@@ -11,9 +11,9 @@ import {
Box,
Button
} from '@chakra-ui/react';
import { BillSourceMap } from '@/constants/user';
import { getUserBills } from '@/web/common/bill/api';
import type { UserBillType } from '@/types/user';
import { BillSourceMap } from '@fastgpt/global/support/wallet/bill/constants';
import { getUserBills } from '@/web/support/wallet/bill/api';
import type { BillItemType } from '@fastgpt/global/support/wallet/bill/type';
import { usePagination } from '@/web/common/hooks/usePagination';
import { useLoading } from '@/web/common/hooks/useLoading';
import dayjs from 'dayjs';
@@ -33,14 +33,14 @@ const BillTable = () => {
to: new Date()
});
const { isPc } = useSystemStore();
const [billDetail, setBillDetail] = useState<UserBillType>();
const [billDetail, setBillDetail] = useState<BillItemType>();
const {
data: bills,
isLoading,
Pagination,
getData
} = usePagination<UserBillType>({
} = usePagination<BillItemType>({
api: getUserBills,
pageSize: isPc ? 20 : 10,
params: {
@@ -55,6 +55,7 @@ const BillTable = () => {
<Table>
<Thead>
<Tr>
<Th>{t('wallet.bill.bill username')}</Th>
<Th>{t('user.Time')}</Th>
<Th>{t('user.Source')}</Th>
<Th>{t('user.Application Name')}</Th>
@@ -65,6 +66,7 @@ const BillTable = () => {
<Tbody fontSize={'sm'}>
{bills.map((item) => (
<Tr key={item.id}>
<Td>{item.username}</Td>
<Td>{dayjs(item.time).format('YYYY/MM/DD HH:mm:ss')}</Td>
<Td>{BillSourceMap[item.source]}</Td>
<Td>{t(item.appName) || '-'}</Td>

View File

@@ -1,26 +1,14 @@
import React, { useCallback, useRef, useState } from 'react';
import {
Box,
Flex,
Button,
useDisclosure,
useTheme,
Divider,
Select,
Menu,
MenuButton,
MenuList,
MenuItem
} from '@chakra-ui/react';
import { Box, Flex, Button, useDisclosure, useTheme, Divider, Select } from '@chakra-ui/react';
import { useForm } from 'react-hook-form';
import { UserUpdateParams } from '@/types/user';
import { useToast } from '@/web/common/hooks/useToast';
import { useUserStore } from '@/web/support/user/useUserStore';
import { UserType } from '@/types/user';
import type { UserType } from '@fastgpt/global/support/user/type.d';
import { useQuery } from '@tanstack/react-query';
import dynamic from 'next/dynamic';
import { useSelectFile } from '@/web/common/file/hooks/useSelectFile';
import { compressImg } from '@/web/common/file/utils';
import { compressImgAndUpload } from '@/web/common/file/controller';
import { feConfigs, systemVersion } from '@/web/common/system/staticData';
import { useTranslation } from 'next-i18next';
import { timezoneList } from '@fastgpt/global/common/time/timezone';
@@ -30,9 +18,10 @@ import MyIcon from '@/components/Icon';
import MyTooltip from '@/components/MyTooltip';
import { getLangStore, LangEnum, langMap, setLangStore } from '@/web/common/utils/i18n';
import { useRouter } from 'next/router';
import MyMenu from '@/components/MyMenu';
import MySelect from '@/components/Select';
import { formatPrice } from '@fastgpt/global/support/wallet/bill/tools';
const TeamMenu = dynamic(() => import('@/components/support/user/team/TeamMenu'));
const PayModal = dynamic(() => import('./PayModal'), {
loading: () => <Loading fixed={false} />,
ssr: false
@@ -97,7 +86,7 @@ const UserInfo = () => {
const file = e[0];
if (!file || !userInfo) return;
try {
const src = await compressImg({
const src = await compressImgAndUpload({
file,
maxW: 100,
maxH: 100
@@ -168,6 +157,12 @@ const UserInfo = () => {
<Box flex={'0 0 80px'}>{t('user.Account')}:&nbsp;</Box>
<Box flex={1}>{userInfo?.username}</Box>
</Flex>
<Flex mt={6} alignItems={'center'} w={['85%', '300px']}>
<Box flex={'0 0 80px'}>{t('user.Team')}:&nbsp;</Box>
<Box flex={1}>
<TeamMenu />
</Box>
</Flex>
<Flex mt={6} alignItems={'center'} w={['85%', '300px']}>
<Box flex={'0 0 80px'}>{t('user.Language')}:&nbsp;</Box>
<Box flex={'1 0 0'}>
@@ -212,11 +207,13 @@ const UserInfo = () => {
</Flex>
<Box mt={6} whiteSpace={'nowrap'} w={['85%', '300px']}>
<Flex alignItems={'center'}>
<Box flex={'0 0 80px'}>{t('user.Balance')}:&nbsp;</Box>
<Box flex={1}>
<strong>{userInfo?.balance.toFixed(3)}</strong>
<Box flex={'0 0 80px'} fontSize={'md'}>
{t('user.team.Balance')}:&nbsp;
</Box>
{feConfigs?.show_pay && (
<Box flex={1}>
<strong>{formatPrice(userInfo?.team?.balance).toFixed(3)}</strong>
</Box>
{feConfigs?.show_pay && userInfo?.team?.canWrite && (
<Button size={['sm', 'md']} ml={5} onClick={onOpenPayModal}>
{t('user.Pay')}
</Button>

View File

@@ -1,9 +1,9 @@
import React from 'react';
import { Box, Flex, useTheme } from '@chakra-ui/react';
import { getInforms, readInform } from '@/web/support/user/api';
import { getInforms, readInform } from '@/web/support/user/inform/api';
import { usePagination } from '@/web/common/hooks/usePagination';
import { useLoading } from '@/web/common/hooks/useLoading';
import type { UserInformSchema } from '@fastgpt/global/support/user/type';
import type { UserInformSchema } from '@fastgpt/global/support/user/inform/type';
import { formatTimeToChatTime } from '@/utils/tools';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import MyIcon from '@/components/Icon';
@@ -67,15 +67,16 @@ const BillTable = () => {
)}
</Box>
))}
{!isLoading && informs.length === 0 && (
<Flex flex={'1 0 0'} flexDirection={'column'} alignItems={'center'} pt={'10vh'}>
<MyIcon name="empty" w={'48px'} h={'48px'} color={'transparent'} />
<Box mt={2} color={'myGray.500'}>
~
</Box>
</Flex>
)}
</Box>
{!isLoading && informs.length === 0 && (
<Flex flex={'1 0 0'} flexDirection={'column'} alignItems={'center'} pt={'-48px'}>
<MyIcon name="empty" w={'48px'} h={'48px'} color={'transparent'} />
<Box mt={2} color={'myGray.500'}>
~
</Box>
</Flex>
)}
{total > pageSize && (
<Flex w={'100%'} mt={4} px={[3, 8]} justifyContent={'flex-end'}>
<Pagination />

View File

@@ -4,7 +4,7 @@ import MyModal from '@/components/MyModal';
import { useTranslation } from 'react-i18next';
import { useForm } from 'react-hook-form';
import { useRequest } from '@/web/common/hooks/useRequest';
import { UserType } from '@/types/user';
import type { UserType } from '@fastgpt/global/support/user/type.d';
const OpenAIAccountModal = ({
defaultData,

View File

@@ -1,6 +1,6 @@
import React, { useState, useCallback } from 'react';
import { ModalFooter, ModalBody, Button, Input, Box, Grid } from '@chakra-ui/react';
import { getPayCode, checkPayResult } from '@/web/common/bill/api';
import { getPayCode, checkPayResult } from '@/web/support/wallet/pay/api';
import { useToast } from '@/web/common/hooks/useToast';
import { useQuery } from '@tanstack/react-query';
import { useRouter } from 'next/router';

View File

@@ -11,11 +11,11 @@ import {
Flex,
Box
} from '@chakra-ui/react';
import { getPayOrders, checkPayResult } from '@/web/common/bill/api';
import type { PaySchema } from '@fastgpt/global/support/wallet/type.d';
import { getPayOrders, checkPayResult } from '@/web/support/wallet/pay/api';
import type { PaySchema } from '@fastgpt/global/support/wallet/pay/type.d';
import dayjs from 'dayjs';
import { useQuery } from '@tanstack/react-query';
import { formatPrice } from '@fastgpt/global/common/bill/tools';
import { formatPrice } from '@fastgpt/global/support/wallet/bill/tools';
import { useToast } from '@/web/common/hooks/useToast';
import { useLoading } from '@/web/common/hooks/useLoading';
import MyIcon from '@/components/Icon';

View File

@@ -16,7 +16,7 @@ import {
} from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';
import { useQuery } from '@tanstack/react-query';
import { getPromotionInitData, getPromotionRecords } from '@/web/support/user/api';
import { getPromotionInitData, getPromotionRecords } from '@/web/support/activity/promotion/api';
import { useUserStore } from '@/web/support/user/useUserStore';
import { useLoading } from '@/web/common/hooks/useLoading';
@@ -42,7 +42,8 @@ const Promotion = () => {
pageSize,
Pagination
} = usePagination<PromotionRecordType>({
api: getPromotionRecords
api: getPromotionRecords,
pageSize: 20
});
const { data: { invitedAmount = 0, earningsAmount = 0 } = {} } = useQuery(

View File

@@ -32,7 +32,7 @@ const UpdatePswModal = ({ onClose }: { onClose: () => void }) => {
onSuccess() {
onClose();
},
successToast: t('user.Update password succseful'),
successToast: t('user.Update password successful'),
errorToast: t('user.Update password failed')
});

View File

@@ -1,4 +1,4 @@
import React, { useCallback, useRef } from 'react';
import React, { useCallback, useMemo, useRef } from 'react';
import { Box, Flex, useTheme } from '@chakra-ui/react';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import { useRouter } from 'next/router';
@@ -33,52 +33,69 @@ enum TabEnum {
const Account = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
const { t } = useTranslation();
const tabList = [
{
icon: 'meLight',
label: t('user.Personal Information'),
id: TabEnum.info
},
const { userInfo, setUserInfo } = useUserStore();
{
icon: 'billRecordLight',
label: t('user.Usage Record'),
id: TabEnum.bill
},
...(feConfigs?.show_promotion
? [
{
icon: 'promotionLight',
label: t('user.Promotion Record'),
id: TabEnum.promotion
}
]
: []),
...(feConfigs?.show_pay
? [
{
icon: 'payRecordLight',
label: t('user.Recharge Record'),
id: TabEnum.pay
}
]
: []),
{
icon: 'apikey',
label: t('user.apikey.key'),
id: TabEnum.apikey
},
{
icon: 'informLight',
label: t('user.Notice'),
id: TabEnum.inform
},
{
icon: 'loginoutLight',
label: t('user.Sign Out'),
id: TabEnum.loginout
}
];
const tabList = useMemo(
() => [
{
icon: 'meLight',
label: t('user.Personal Information'),
id: TabEnum.info
},
...(feConfigs?.isPlus
? [
{
icon: 'billRecordLight',
label: t('user.Usage Record'),
id: TabEnum.bill
}
]
: []),
...(feConfigs?.show_promotion
? [
{
icon: 'promotionLight',
label: t('user.Promotion Record'),
id: TabEnum.promotion
}
]
: []),
...(feConfigs?.show_pay && userInfo?.team.canWrite
? [
{
icon: 'payRecordLight',
label: t('user.Recharge Record'),
id: TabEnum.pay
}
]
: []),
...(userInfo?.team.canWrite
? [
{
icon: 'apikey',
label: t('user.apikey.key'),
id: TabEnum.apikey
}
]
: []),
...(feConfigs.isPlus
? [
{
icon: 'informLight',
label: t('user.Notice'),
id: TabEnum.inform
}
]
: []),
{
icon: 'loginoutLight',
label: t('user.Sign Out'),
id: TabEnum.loginout
}
],
[t, userInfo?.team.canWrite]
);
const { openConfirm, ConfirmModal } = useConfirm({
content: '确认退出登录?'
@@ -87,7 +104,6 @@ const Account = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
const router = useRouter();
const theme = useTheme();
const { isPc } = useSystemStore();
const { setUserInfo } = useUserStore();
const setCurrentTab = useCallback(
(tab: string) => {