@@ -5,17 +5,16 @@ import {
55 Flex ,
66 Button ,
77 Input ,
8- Card ,
98 SimpleGrid ,
10- Collapse ,
119 Table ,
1210 Thead ,
1311 Tbody ,
1412 Tr ,
1513 Th ,
1614 Td ,
1715 TableContainer ,
18- Center
16+ Center ,
17+ Fade
1918} from '@chakra-ui/react' ;
2019import { useForm } from 'react-hook-form' ;
2120import { postCreateApp } from '@/web/core/app/api' ;
@@ -33,7 +32,6 @@ import {
3332 getTemplateMarketItemDetail ,
3433 getTemplateMarketItemList
3534} from '@/web/core/app/api/template' ;
36- import { useSystemStore } from '@/web/common/system/useSystemStore' ;
3735import { createAppTypeMap } from '@/pageComponents/app/constants' ;
3836import { serviceSideProps } from '@/web/common/i18n/utils' ;
3937import MyImage from '@fastgpt/web/components/common/Image/MyImage' ;
@@ -44,6 +42,7 @@ import type { McpToolConfigType } from '@fastgpt/global/core/app/tool/mcpTool/ty
4442import AppTypeCard from '@/pageComponents/app/create/AppTypeCard' ;
4543import type { StoreSecretValueType } from '@fastgpt/global/common/secret/type' ;
4644import { useSystem } from '@fastgpt/web/hooks/useSystem' ;
45+ import MyBox from '@fastgpt/web/components/common/MyBox' ;
4746
4847type FormType = {
4948 avatar : string ;
@@ -66,17 +65,17 @@ export type CreateAppType =
6665const CreateAppsPage = ( ) => {
6766 const { t } = useTranslation ( ) ;
6867 const router = useRouter ( ) ;
69- const { feConfigs } = useSystemStore ( ) ;
7068 const { isPc } = useSystem ( ) ;
7169 const { query } = router ;
7270 const { parentId, appType } = query ;
7371
7472 const [ selectedAppType , setSelectedAppType ] = useState < CreateAppType > (
7573 ( appType as CreateAppType ) || AppTypeEnum . workflow
7674 ) ;
75+ const [ creatingTemplateId , setCreatingTemplateId ] = useState < string | null > ( null ) ;
7776 const isToolType = ToolTypeList . includes ( selectedAppType ) ;
7877
79- const { data : templateData } = useRequest2 (
78+ const { data : templateData , loading : isLoadingTemplates } = useRequest2 (
8079 ( ) => getTemplateMarketItemList ( { isQuickTemplate : true , type : selectedAppType } ) ,
8180 {
8281 manual : false ,
@@ -122,6 +121,10 @@ const CreateAppsPage = () => {
122121 { avatar, name, createType, mcpUrl, mcpHeaderSecret, mcpToolList } : FormType ,
123122 templateId ?: string
124123 ) : Promise < string > => {
124+ if ( templateId ) {
125+ setCreatingTemplateId ( templateId ) ;
126+ }
127+
125128 const appType = selectedAppType ;
126129 const baseParams = {
127130 parentId : parentId as string ,
@@ -310,73 +313,78 @@ const CreateAppsPage = () => {
310313 />
311314 </ Flex >
312315 </ Flex >
313- < SimpleGrid columns = { [ 1 , 3 ] } gridGap = { 2.5 } >
314- { templateData . list . map ( ( item ) => (
315- < Card
316- key = { item . templateId }
317- p = { 4 }
318- borderRadius = { '10px' }
319- border = { '1px solid' }
320- borderColor = { 'myGray.200' }
321- cursor = { 'pointer' }
322- boxShadow = { 'none' }
323- _hover = { {
324- boxShadow :
325- '0 4px 10px 0 rgba(19, 51, 107, 0.08), 0 0 1px 0 rgba(19, 51, 107, 0.08)'
326- } }
327- onClick = { handleSubmit ( ( data ) => onClickCreate ( data , item . templateId ) ) }
328- >
329- < Box
330- position = { 'relative' }
331- h = { 28 }
332- borderRadius = { '12px' }
333- overflow = { 'hidden' }
334- mb = { 2 }
335- >
336- < Avatar
337- src = { item . avatar }
338- position = { 'absolute' }
339- w = { 'full' }
340- opacity = { 0.5 }
341- top = { '50%' }
342- transform = { 'translate(0, -50%)' }
343- filter = { 'blur(20px)' }
344- zIndex = { 0 }
345- />
346- < Box
347- position = { 'absolute' }
348- top = { 0 }
349- left = { 0 }
350- right = { 0 }
351- bottom = { 0 }
352- opacity = { 0.08 }
353- background = {
354- 'linear-gradient(180deg, rgba(51, 51, 51, 0.00) 50%, #333 131.5%)'
316+ < Fade in = { ! isLoadingTemplates && templateData ?. list && templateData . list . length > 0 } >
317+ < SimpleGrid columns = { [ 1 , 3 ] } gridGap = { 2.5 } >
318+ { templateData . list . map ( ( item ) => (
319+ < MyBox
320+ key = { item . templateId }
321+ p = { 4 }
322+ borderRadius = { '10px' }
323+ border = { '1px solid' }
324+ borderColor = { 'myGray.200' }
325+ cursor = { 'pointer' }
326+ boxShadow = { 'none' }
327+ bg = { 'white' }
328+ _hover = { {
329+ boxShadow :
330+ '0 4px 10px 0 rgba(19, 51, 107, 0.08), 0 0 1px 0 rgba(19, 51, 107, 0.08)'
331+ } }
332+ isLoading = { creatingTemplateId === item . templateId }
333+ onClick = { ( ) => {
334+ if ( ! creatingTemplateId ) {
335+ handleSubmit ( ( data ) => onClickCreate ( data , item . templateId ) ) ( ) ;
355336 }
356- zIndex = { 1 }
357- />
358-
337+ } }
338+ >
359339 < Box
360- position = { 'absolute ' }
361- top = { '50%' }
362- left = { '50% ' }
363- transform = { 'translate(-50%, -50%) ' }
364- zIndex = { 2 }
340+ position = { 'relative ' }
341+ h = { 28 }
342+ borderRadius = { '12px ' }
343+ overflow = { 'hidden ' }
344+ mb = { 2 }
365345 >
366- < Avatar src = { item . avatar } w = { 6 } borderRadius = { '4px' } />
346+ < Avatar
347+ src = { item . avatar }
348+ position = { 'absolute' }
349+ w = { 'full' }
350+ opacity = { 0.5 }
351+ top = { '50%' }
352+ transform = { 'translate(0, -50%)' }
353+ filter = { 'blur(20px)' }
354+ zIndex = { 0 }
355+ />
356+ < Box
357+ position = { 'absolute' }
358+ top = { 0 }
359+ left = { 0 }
360+ right = { 0 }
361+ bottom = { 0 }
362+ opacity = { 0.08 }
363+ background = {
364+ 'linear-gradient(180deg, rgba(51, 51, 51, 0.00) 50%, #333 131.5%)'
365+ }
366+ zIndex = { 1 }
367+ />
368+
369+ < Box
370+ position = { 'absolute' }
371+ top = { '50%' }
372+ left = { '50%' }
373+ transform = { 'translate(-50%, -50%)' }
374+ zIndex = { 2 }
375+ >
376+ < Avatar src = { item . avatar } w = { 6 } borderRadius = { '4px' } />
377+ </ Box >
367378 </ Box >
368- </ Box >
369379
370- < Box color = { 'myGray.900' } > { t ( item . name as any ) } </ Box >
371- < Box fontSize = { 'mini' } color = { 'myGray.500' } flex = { 1 } noOfLines = { 2 } mt = { 1 } >
372- { t ( item . intro as any ) }
373- </ Box >
374- < Box fontSize = { 'mini' } color = { 'myGray.500' } mt = { 2 } >
375- by { item . author || feConfigs . systemTitle }
376- </ Box >
377- </ Card >
378- ) ) }
379- </ SimpleGrid >
380+ < Box color = { 'myGray.900' } > { t ( item . name as any ) } </ Box >
381+ < Box fontSize = { 'mini' } color = { 'myGray.500' } flex = { 1 } noOfLines = { 2 } mt = { 1 } >
382+ { t ( item . intro as any ) }
383+ </ Box >
384+ </ MyBox >
385+ ) ) }
386+ </ SimpleGrid >
387+ </ Fade >
380388 </ Box >
381389 ) }
382390
0 commit comments