Skip to content

Commit

Permalink
fix: ts
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Jan 12, 2025
1 parent d5313dc commit 08c1504
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
23 changes: 23 additions & 0 deletions projects/app/src/pageComponents/app/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import { i18nT } from '@fastgpt/web/i18n/utils';

export const appTypeMap = {
[AppTypeEnum.simple]: {
icon: 'core/app/simpleBot',
title: i18nT('app:type.Create simple bot'),
avatar: 'core/app/type/simpleFill',
emptyCreateText: i18nT('app:create_empty_app')
},
[AppTypeEnum.workflow]: {
icon: 'core/app/type/workflowFill',
avatar: 'core/app/type/workflowFill',
title: i18nT('app:type.Create workflow bot'),
emptyCreateText: i18nT('app:create_empty_workflow')
},
[AppTypeEnum.plugin]: {
icon: 'core/app/type/pluginFill',
avatar: 'core/app/type/pluginFill',
title: i18nT('app:type.Create plugin bot'),
emptyCreateText: i18nT('app:create_empty_plugin')
}
};
30 changes: 5 additions & 25 deletions projects/app/src/pages/app/list/components/CreateModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef, useState } from 'react';
import React, { useState } from 'react';
import {
Box,
Flex,
Expand Down Expand Up @@ -32,6 +32,7 @@ import {
} from '@/web/core/app/api/template';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import FillRowTabs from '@fastgpt/web/components/common/Tabs/FillRowTabs';
import { appTypeMap } from '@/pageComponents/app/constants';

type FormType = {
avatar: string;
Expand Down Expand Up @@ -59,28 +60,7 @@ const CreateModal = ({
const [currentCreateType, setCurrentCreateType] = useState<'template' | 'curl'>('template');
const isTemplateMode = currentCreateType === 'template';

const appTypeMap = useRef({
[AppTypeEnum.simple]: {
icon: 'core/app/simpleBot',
title: t('app:type.Create simple bot'),
avatar: 'core/app/type/simpleFill',
emptyCreateText: t('app:create_empty_app')
},
[AppTypeEnum.workflow]: {
icon: 'core/app/type/workflowFill',
avatar: 'core/app/type/workflowFill',
title: t('app:type.Create workflow bot'),
emptyCreateText: t('app:create_empty_workflow')
},
[AppTypeEnum.plugin]: {
icon: 'core/app/type/pluginFill',
avatar: 'core/app/type/pluginFill',
title: t('app:type.Create plugin bot'),
emptyCreateText: t('app:create_empty_plugin')
}
});

const typeData = appTypeMap.current[type];
const typeData = appTypeMap[type];
const { data: templateList = [], loading: isRequestTemplates } = useRequest2(
() => getTemplateMarketItemList({ isQuickTemplate: true, type }),
{
Expand Down Expand Up @@ -162,7 +142,7 @@ const CreateModal = ({
return (
<MyModal
iconSrc={typeData.icon}
title={typeData.title}
title={t(typeData.title)}
isOpen
isCentered={!isPc}
maxW={['90vw', '40rem']}
Expand Down Expand Up @@ -255,7 +235,7 @@ const CreateModal = ({
>
<MyIcon name={'common/addLight'} w={'1.5rem'} />
<Box fontSize={'sm'} mt={2}>
{typeData.emptyCreateText}
{t(typeData.emptyCreateText)}
</Box>
</Card>
{templateList.map((item) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { Box, Button, Flex, Input, ModalBody, ModalFooter } from '@chakra-ui/rea
import Avatar from '@fastgpt/web/components/common/Avatar';
import MyModal from '@fastgpt/web/components/common/MyModal';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import { useTranslation } from 'next-i18next';
import { useForm } from 'react-hook-form';
import { appTypeMap } from './CreateModal';
import { appTypeMap } from '@/pageComponents/app/constants';
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import { useMemo } from 'react';
import { getAppType } from '@fastgpt/global/core/app/utils';
Expand Down

0 comments on commit 08c1504

Please sign in to comment.