From a430284aa21e3ae1f0d5654e55b2ad2852519cc2 Mon Sep 17 00:00:00 2001 From: wwf <yearningwang@iqtogether.com> Date: 星期三, 04 六月 2025 15:17:49 +0800 Subject: [PATCH] 初始化 --- app/components/app/configuration/dataset-config/card-item/item.tsx | 102 +++++++++++++++++++++----------------------------- 1 files changed, 43 insertions(+), 59 deletions(-) diff --git a/app/components/app/configuration/dataset-config/card-item/item.tsx b/app/components/app/configuration/dataset-config/card-item/item.tsx index 4feba8b..7036ae8 100644 --- a/app/components/app/configuration/dataset-config/card-item/item.tsx +++ b/app/components/app/configuration/dataset-config/card-item/item.tsx @@ -12,12 +12,10 @@ import FileIcon from '@/app/components/base/file-icon' import { Folder } from '@/app/components/base/icons/src/vender/solid/files' import { Globe06 } from '@/app/components/base/icons/src/vender/solid/mapsAndTravel' -import ActionButton, { ActionButtonState } from '@/app/components/base/action-button' import Drawer from '@/app/components/base/drawer' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import Badge from '@/app/components/base/badge' import { useKnowledge } from '@/hooks/use-knowledge' -import cn from '@/utils/classnames' type ItemProps = { className?: string @@ -45,77 +43,63 @@ setShowSettingsModal(false) } - const [isDeleting, setIsDeleting] = useState(false) - return ( - <div className={cn( - 'group relative mb-1 flex h-10 w-full cursor-pointer items-center justify-between rounded-lg border-[0.5px] border-components-panel-border-subtle bg-components-panel-on-panel-item-bg px-2 last-of-type:mb-0 hover:bg-components-panel-on-panel-item-bg-hover', - isDeleting && 'border-state-destructive-border hover:bg-state-destructive-hover', - )}> - <div className='flex w-0 grow items-center space-x-1.5'> - { - config.data_source_type === DataSourceType.FILE && ( - <div className='mr-2 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border-[0.5px] border-[#E0EAFF] bg-[#F5F8FF]'> - <Folder className='h-4 w-4 text-[#444CE7]' /> - </div> - ) - } - { - config.data_source_type === DataSourceType.NOTION && ( - <div className='mr-2 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border-[0.5px] border-[#EAECF5]'> - <FileIcon type='notion' className='h-4 w-4' /> - </div> - ) - } - { - config.data_source_type === DataSourceType.WEB && ( - <div className='mr-2 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border-[0.5px] border-blue-100 bg-[#F5FAFF]'> - <Globe06 className='h-4 w-4 text-blue-600' /> - </div> - ) - } - <div className='system-sm-medium w-0 grow truncate text-text-secondary' title={config.name}>{config.name}</div> + <div className='group relative flex items-center mb-1 last-of-type:mb-0 pl-2.5 py-2 pr-3 w-full bg-white rounded-lg border-[0.5px] border-gray-200 shadow-xs'> + { + config.data_source_type === DataSourceType.FILE && ( + <div className='shrink-0 flex items-center justify-center mr-2 w-6 h-6 bg-[#F5F8FF] rounded-md border-[0.5px] border-[#E0EAFF]'> + <Folder className='w-4 h-4 text-[#444CE7]' /> + </div> + ) + } + { + config.data_source_type === DataSourceType.NOTION && ( + <div className='shrink-0 flex items-center justify-center mr-2 w-6 h-6 rounded-md border-[0.5px] border-[#EAECF5]'> + <FileIcon type='notion' className='w-4 h-4' /> + </div> + ) + } + { + config.data_source_type === DataSourceType.WEB && ( + <div className='shrink-0 flex items-center justify-center mr-2 w-6 h-6 bg-[#F5FAFF] border-[0.5px] border-blue-100 rounded-md'> + <Globe06 className='w-4 h-4 text-blue-600' /> + </div> + ) + } + <div className='grow'> + <div className='flex items-center h-[18px]'> + <div className='grow text-[13px] font-medium text-gray-800 truncate' title={config.name}>{config.name}</div> + {config.provider === 'external' + ? <Badge text={t('dataset.externalTag') as string} /> + : <Badge + text={formatIndexingTechniqueAndMethod(config.indexing_technique, config.retrieval_model_dict?.search_method)} + />} + </div> </div> - <div className='ml-2 hidden shrink-0 items-center space-x-1 group-hover:flex'> + <div className='hidden rounded-lg group-hover:flex items-center justify-end absolute right-0 top-0 bottom-0 pr-2 w-[124px] bg-gradient-to-r from-white/50 to-white to-50%'> { - editable && <ActionButton - onClick={(e) => { - e.stopPropagation() - setShowSettingsModal(true) - }} + editable && <div + className='flex items-center justify-center mr-1 w-6 h-6 hover:bg-black/5 rounded-md cursor-pointer' + onClick={() => setShowSettingsModal(true)} > - <RiEditLine className='h-4 w-4 shrink-0 text-text-tertiary' /> - </ActionButton> + <RiEditLine className='w-4 h-4 text-gray-500' /> + </div> } - <ActionButton + <div + className='group/action flex items-center justify-center w-6 h-6 hover:bg-[#FEE4E2] rounded-md cursor-pointer' onClick={() => onRemove(config.id)} - state={isDeleting ? ActionButtonState.Destructive : ActionButtonState.Default} - onMouseEnter={() => setIsDeleting(true)} - onMouseLeave={() => setIsDeleting(false)} > - <RiDeleteBinLine className={cn('h-4 w-4 shrink-0 text-text-tertiary', isDeleting && 'text-text-destructive')} /> - </ActionButton> + <RiDeleteBinLine className='w-4 h-4 text-gray-500 group-hover/action:text-[#D92D20]' /> + </div> </div> - { - config.indexing_technique && <Badge - className='shrink-0 group-hover:hidden' - text={formatIndexingTechniqueAndMethod(config.indexing_technique, config.retrieval_model_dict?.search_method)} - /> - } - { - config.provider === 'external' && <Badge - className='shrink-0 group-hover:hidden' - text={t('dataset.externalTag') as string} - /> - } - <Drawer isOpen={showSettingsModal} onClose={() => setShowSettingsModal(false)} footer={null} mask={isMobile} panelClassName='mt-16 mx-2 sm:mr-2 mb-3 !p-0 !max-w-[640px] rounded-xl'> + <Drawer isOpen={showSettingsModal} onClose={() => setShowSettingsModal(false)} footer={null} mask={isMobile} panelClassname='mt-16 mx-2 sm:mr-2 mb-3 !p-0 !max-w-[640px] rounded-xl'> <SettingsModal currentDataset={config} onCancel={() => setShowSettingsModal(false)} onSave={handleSave} /> </Drawer> - </div > + </div> ) } -- Gitblit v1.8.0