* fix metadata and forbid filter

* team plan init

* sync collection tags

* fix json import

* fix code

* fix
This commit is contained in:
heheer
2025-06-26 10:15:51 +08:00
committed by GitHub
parent f31752ccd0
commit e1819f48ee
4 changed files with 98 additions and 79 deletions

View File

@@ -43,8 +43,15 @@ const ImportAppConfigEditor = ({ value, onChange, rows = 16 }: Props) => {
return;
}
if (e.target) {
const res = JSON.parse(e.target.result as string);
onChange(JSON.stringify(res, null, 2));
try {
const res = JSON.parse(e.target.result as string);
onChange(JSON.stringify(res, null, 2));
} catch (error) {
toast({
title: t('app:invalid_json_format'),
status: 'error'
});
}
}
};
reader.readAsText(file);
@@ -63,70 +70,75 @@ const ImportAppConfigEditor = ({ value, onChange, rows = 16 }: Props) => {
const handleDrop = useCallback(
async (e: DragEvent<HTMLDivElement>) => {
e.preventDefault();
setIsDragging(false);
const file = e.dataTransfer.files[0];
console.log(file);
readJSONFile(file);
setIsDragging(false);
},
[readJSONFile]
);
return (
<>
<Box w={['100%', '31rem']}>
{isDragging ? (
<Flex
align={'center'}
justify={'center'}
w={'full'}
h={'17.5rem'}
borderRadius={'md'}
border={'1px dashed'}
borderColor={'myGray.400'}
onDragEnter={handleDragEnter}
onDragOver={(e) => e.preventDefault()}
onDrop={handleDrop}
onDragLeave={handleDragLeave}
>
<Flex align={'center'} justify={'center'} flexDir={'column'} gap={'0.62rem'}>
<MyIcon name={'configmap'} w={'2rem'} color={'primary.500'} />
<Box color={'primary.600'} fontSize={'sm'}>
{t('app:file_recover')}
</Box>
</Flex>
</Flex>
) : (
<Box>
<Flex justify={'space-between'} align={'center'} pb={3}>
<Box fontSize={'sm'} color={'myGray.900'} fontWeight={'500'}>
{t('common:json_config')}
</Box>
<Button onClick={onOpen} variant={'whiteBase'} p={0}>
<Flex px={'0.88rem'} py={'0.44rem'} color={'myGray.600'} fontSize={'mini'}>
<MyIcon name={'file/uploadFile'} w={'1rem'} mr={'0.38rem'} />
{t('common:upload_file')}
</Flex>
</Button>
</Flex>
<Box
onDragEnter={handleDragEnter}
onDragOver={(e) => e.preventDefault()}
onDrop={handleDrop}
onDragLeave={handleDragLeave}
>
<Textarea
bg={'myGray.50'}
border={'1px solid'}
borderRadius={'md'}
borderColor={'myGray.200'}
value={value}
placeholder={t('app:or_drag_JSON')}
rows={rows}
onChange={(e) => onChange(e.target.value)}
/>
</Box>
<Box w={['100%', '31rem']} h={'full'} display={'flex'} flexDir={'column'}>
<Flex justify={'space-between'} align={'center'} pb={3} flexShrink={0}>
<Box fontSize={'sm'} color={'myGray.900'} fontWeight={'500'}>
{t('common:json_config')}
</Box>
)}
<Button onClick={onOpen} variant={'whiteBase'} p={0}>
<Flex px={'0.88rem'} py={'0.44rem'} color={'myGray.600'} fontSize={'mini'}>
<MyIcon name={'file/uploadFile'} w={'1rem'} mr={'0.38rem'} />
{t('common:upload_file')}
</Flex>
</Button>
</Flex>
<Box
flex={1}
position={'relative'}
onDragEnter={handleDragEnter}
onDragOver={(e) => e.preventDefault()}
onDrop={handleDrop}
onDragLeave={handleDragLeave}
>
<Textarea
bg={'myGray.50'}
border={'1px solid'}
borderRadius={'md'}
borderColor={'myGray.200'}
value={value}
placeholder={t('app:or_drag_JSON')}
rows={rows}
onChange={(e) => onChange(e.target.value)}
h={'full'}
resize={'none'}
opacity={isDragging ? 0.3 : 1}
transition={'opacity 0.2s'}
/>
{isDragging && (
<Flex
position={'absolute'}
top={0}
left={0}
right={0}
bottom={0}
align={'center'}
justify={'center'}
bg={'rgba(255, 255, 255, 0.95)'}
borderRadius={'md'}
border={'2px dashed'}
borderColor={'primary.400'}
zIndex={1}
pointerEvents={'none'}
>
<Flex align={'center'} justify={'center'} flexDir={'column'} gap={'0.62rem'}>
<MyIcon name={'configmap'} w={'2rem'} color={'primary.500'} />
<Box color={'primary.600'} fontSize={'sm'} fontWeight={'medium'}>
{t('app:file_recover')}
</Box>
</Flex>
</Flex>
)}
</Box>
</Box>
{File && <File onSelect={onSelectFile} />}
</>

View File

@@ -17,7 +17,6 @@ import { type UserUpdateParams } from '@/types/user';
import { useToast } from '@fastgpt/web/hooks/useToast';
import { useUserStore } from '@/web/support/user/useUserStore';
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 { useSystemStore } from '@/web/common/system/useSystemStore';
@@ -26,7 +25,7 @@ import Avatar from '@fastgpt/web/components/common/Avatar';
import MyIcon from '@fastgpt/web/components/common/Icon';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import { formatStorePrice2Read } from '@fastgpt/global/support/wallet/usage/tools';
import { putUpdateMemberName, redeemCoupon } from '@/web/support/user/team/api';
import { putUpdateMemberName } from '@/web/support/user/team/api';
import { getDocPath } from '@/web/common/system/doc';
import {
StandardSubLevelEnum,
@@ -70,6 +69,10 @@ const Info = () => {
const standardPlan = teamPlanStatus?.standardConstants;
const { isOpen: isOpenContact, onClose: onCloseContact, onOpen: onOpenContact } = useDisclosure();
useMount(() => {
initUserInfo();
});
return (
<AccountContainer>
<Box py={[3, '28px']} px={[5, 10]} mx={'auto'}>
@@ -353,12 +356,8 @@ const MyInfo = ({ onOpenContact }: { onOpenContact: () => void }) => {
const PlanUsage = () => {
const router = useRouter();
const { t } = useTranslation();
const { userInfo, initUserInfo, teamPlanStatus, initTeamPlanStatus } = useUserStore();
const { userInfo, teamPlanStatus, initTeamPlanStatus } = useUserStore();
const { subPlans, feConfigs } = useSystemStore();
const { reset } = useForm<UserUpdateParams>({
defaultValues: userInfo as UserType
});
const {
isOpen: isOpenStandardModal,
onClose: onCloseStandardModal,
@@ -376,6 +375,7 @@ const PlanUsage = () => {
return standardSubLevelMap[teamPlanStatus.standard.currentSubLevel].label;
}, [teamPlanStatus?.standard?.currentSubLevel]);
const standardPlan = teamPlanStatus?.standard;
const isFreeTeam = useMemo(() => {
if (!teamPlanStatus || !teamPlanStatus?.standardConstants) return false;
const hasExtraDatasetSize =
@@ -392,12 +392,6 @@ const PlanUsage = () => {
return false;
}, [teamPlanStatus]);
useQuery(['init'], initUserInfo, {
onSuccess(res) {
reset(res);
}
});
const valueColorSchema = useCallback((val: number) => {
if (val < 50) return 'green';
if (val < 80) return 'yellow';