mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
perf: plan
This commit is contained in:
parent
8f1dae4283
commit
ffb7fcd94d
|
|
@ -13,6 +13,7 @@ import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
|||
import MySelect from '@fastgpt/web/components/common/MySelect';
|
||||
import { calculatePrice } from '@fastgpt/global/support/wallet/bill/tools';
|
||||
import { formatNumberWithUnit } from '@fastgpt/global/common/string/tools';
|
||||
import { formatActivityExpirationTime } from './utils';
|
||||
|
||||
const ExtraPlan = ({ onPaySuccess }: { onPaySuccess?: () => void }) => {
|
||||
const { t, i18n } = useTranslation();
|
||||
|
|
@ -103,6 +104,9 @@ const ExtraPlan = ({ onPaySuccess }: { onPaySuccess?: () => void }) => {
|
|||
}
|
||||
);
|
||||
|
||||
// 计算活动时间
|
||||
const activityExpirationTime = formatActivityExpirationTime(subPlans?.activityExpirationTime);
|
||||
|
||||
return (
|
||||
<VStack>
|
||||
<Grid gridTemplateColumns={['1fr', '1fr 1fr']} gap={5} w={['100%', 'auto']}>
|
||||
|
|
@ -167,23 +171,7 @@ const ExtraPlan = ({ onPaySuccess }: { onPaySuccess?: () => void }) => {
|
|||
>
|
||||
{t('common:support.wallet.subscription.Extra ai points')}
|
||||
<Box fontSize={'12px'} fontWeight={'normal'} color={'myGray.600'} mt={0.5}>
|
||||
{subPlans?.activityExpirationTime
|
||||
? (() => {
|
||||
const date = new Date(subPlans.activityExpirationTime);
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;
|
||||
const day = date.getDate();
|
||||
const hour = date.getHours().toString().padStart(2, '0');
|
||||
const minute = date.getMinutes().toString().padStart(2, '0');
|
||||
return t('common:support.wallet.subscription.Activity expiration time', {
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
hour,
|
||||
minute
|
||||
});
|
||||
})()
|
||||
: ''}
|
||||
{activityExpirationTime}
|
||||
</Box>
|
||||
</Box>
|
||||
<Grid
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import {
|
|||
DiscountCouponStatusEnum,
|
||||
DiscountCouponTypeEnum
|
||||
} from '@fastgpt/global/support/wallet/sub/discountCoupon/constants';
|
||||
import { formatActivityExpirationTime } from './utils';
|
||||
|
||||
export enum PackageChangeStatusEnum {
|
||||
buy = 'buy',
|
||||
|
|
@ -47,10 +48,11 @@ const Standard = ({
|
|||
|
||||
const [packageChange, setPackageChange] = useState<PackageChangeStatusEnum>();
|
||||
const { subPlans, feConfigs } = useSystemStore();
|
||||
const hasActivityExpiration = !!subPlans?.activityExpirationTime;
|
||||
const [selectSubMode, setSelectSubMode] = useState<`${SubModeEnum}`>(
|
||||
hasActivityExpiration ? SubModeEnum.year : SubModeEnum.month
|
||||
subPlans?.activityExpirationTime ? SubModeEnum.year : SubModeEnum.month
|
||||
);
|
||||
const hasActivityExpiration =
|
||||
!!subPlans?.activityExpirationTime && selectSubMode === SubModeEnum.year;
|
||||
|
||||
useEffect(() => {
|
||||
setSelectSubMode(hasActivityExpiration ? SubModeEnum.year : SubModeEnum.month);
|
||||
|
|
@ -131,6 +133,9 @@ const Standard = ({
|
|||
}
|
||||
});
|
||||
|
||||
// 计算活动时间
|
||||
const activityExpirationTime = formatActivityExpirationTime(subPlans?.activityExpirationTime);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Flex flexDirection={'column'} alignItems={'center'} position={'relative'}>
|
||||
|
|
@ -270,21 +275,7 @@ const Standard = ({
|
|||
color={'#E45F5F'}
|
||||
textAlign={'center'}
|
||||
>
|
||||
{(() => {
|
||||
const date = new Date(subPlans.activityExpirationTime || '');
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;
|
||||
const day = date.getDate();
|
||||
const hour = date.getHours().toString().padStart(2, '0');
|
||||
const minute = date.getMinutes().toString().padStart(2, '0');
|
||||
return t('common:support.wallet.subscription.Activity expiration time', {
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
hour,
|
||||
minute
|
||||
});
|
||||
})()}
|
||||
{activityExpirationTime}
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
import { useTranslation } from 'next-i18next';
|
||||
|
||||
export const formatActivityExpirationTime = (date?: Date) => {
|
||||
const { t } = useTranslation();
|
||||
if (!date) return '';
|
||||
|
||||
const formatDate = new Date(date);
|
||||
const year = formatDate.getFullYear();
|
||||
const month = formatDate.getMonth() + 1;
|
||||
const day = formatDate.getDate();
|
||||
const hour = formatDate.getHours().toString().padStart(2, '0');
|
||||
const minute = formatDate.getMinutes().toString().padStart(2, '0');
|
||||
return t('common:support.wallet.subscription.Activity expiration time', {
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
hour,
|
||||
minute
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue