feat: 添加store
This commit is contained in:
		| @@ -18,6 +18,7 @@ import { toast } from 'react-toastify'; | ||||
| import { isEmpty, pick } from 'lodash-es'; | ||||
| import { usePermissionModal } from '@kevisual/resources/index.ts'; | ||||
| import React from 'react'; | ||||
| import { queryLogin } from '@/modules'; | ||||
| type DataYamlEditProps = { | ||||
|   onSave: (data: any) => Promise<void>; | ||||
|   type?: 'yaml' | 'json'; | ||||
| @@ -188,10 +189,15 @@ export const MyController = React.forwardRef( | ||||
|   }, | ||||
| ); | ||||
| export const List = () => { | ||||
|   const { list, getConfig, setShowEdit, setFormData, deleteConfig, updateData, formData, detectConfig } = useConfigStore(); | ||||
|   const { list, getConfigList, setShowEdit, setFormData, deleteConfig, updateData, formData, detectConfig, onOpenKey } = useConfigStore(); | ||||
|   const [modal, contextHolder] = useModal(); | ||||
|   const [isAdmin, setIsAdmin] = useState<boolean>(false); | ||||
|   useEffect(() => { | ||||
|     getConfig(); | ||||
|     getConfigList(); | ||||
|     queryLogin.cacheStore.getCurrentUser().then((res) => { | ||||
|       const org = res?.orgs || []; | ||||
|       setIsAdmin(org.includes('admin')); | ||||
|     }); | ||||
|   }, []); | ||||
|   const { setOpen, contextHolder: contextHolderPermission } = usePermissionModal({ | ||||
|     onSave: async (values) => { | ||||
| @@ -206,25 +212,27 @@ export const List = () => { | ||||
|       return true; | ||||
|     }, | ||||
|   }); | ||||
|   console.log(list); | ||||
|   const { t } = useTranslation(); | ||||
|  | ||||
|   return ( | ||||
|     <div className='w-full h-full flex bg-gray-100'> | ||||
|       <div className='h-full bg-white'> | ||||
|         <div className='p-2'> | ||||
|           <IconButton | ||||
|             onClick={() => { | ||||
|               setShowEdit(true); | ||||
|               setFormData({}); | ||||
|             }}> | ||||
|             <Plus size={16} /> | ||||
|           </IconButton> | ||||
|           <Tooltip title={t('Add Config Tips')}> | ||||
|             <IconButton | ||||
|               onClick={() => { | ||||
|                 setShowEdit(true); | ||||
|                 setFormData({}); | ||||
|               }}> | ||||
|               <Plus size={16} /> | ||||
|             </IconButton> | ||||
|           </Tooltip> | ||||
|         </div> | ||||
|       </div> | ||||
|  | ||||
|       <div className=' grow p-4 '> | ||||
|         <div className='flex pb-4 gap-4'> | ||||
|           <Tooltip title={t('从config的json的配置的数据同步过来。')}> | ||||
|           <Tooltip title={t('从上传的[config/1.0.0]路径的的json的配置的数据同步过来。')}> | ||||
|             <Button | ||||
|               variant='contained' | ||||
|               color='primary' | ||||
| @@ -235,16 +243,51 @@ export const List = () => { | ||||
|               {t('Detect')} | ||||
|             </Button> | ||||
|           </Tooltip> | ||||
|           <Tooltip title={t('Upload Config Tips')}> | ||||
|             <Button | ||||
|               variant='contained' | ||||
|               color='primary' | ||||
|               size='small' | ||||
|               onClick={() => { | ||||
|                 onOpenKey('upload.json'); | ||||
|               }}> | ||||
|               {t('Upload Config')} | ||||
|             </Button> | ||||
|           </Tooltip> | ||||
|           <Tooltip title={t('Workspace Config Tips')}> | ||||
|             <Button | ||||
|               variant='contained' | ||||
|               color='primary' | ||||
|               size='small' | ||||
|               onClick={() => { | ||||
|                 onOpenKey('workspace.json'); | ||||
|               }}> | ||||
|               {t('Workspace Config')} | ||||
|             </Button> | ||||
|           </Tooltip> | ||||
|           {isAdmin && ( | ||||
|             <Tooltip title={t('VIP Config Tips')}> | ||||
|               <Button | ||||
|                 variant='contained' | ||||
|                 color='primary' | ||||
|                 size='small' | ||||
|                 onClick={() => { | ||||
|                   onOpenKey('vip.json'); | ||||
|                 }}> | ||||
|                 {t('VIP Config')} | ||||
|               </Button> | ||||
|             </Tooltip> | ||||
|           )} | ||||
|         </div> | ||||
|         <div className='w-full bg-white rounded-lg p-2 scrollbar ' style={{ height: 'calc(100% - 80px)' }}> | ||||
|           <div className='flex flex-wrap gap-2 '> | ||||
|             {list.map((item) => ( | ||||
|               <div className='card w-[300px] ' key={item.id}> | ||||
|                 <div className='card-title flex font-bold justify-between'>{item.title}</div> | ||||
|                 <div className='card-content'> | ||||
|                   <div className='flex gap-2'> | ||||
|                     <div>{t('Description')}:</div> | ||||
|                     <div>{item.description}</div> | ||||
|                 <div className='t'> | ||||
|                   <div className='flex gap-2 '> | ||||
|                     <div className='shrink-0'>{t('Description')}:</div> | ||||
|                     <div className='break-all grow'>{item.description}</div> | ||||
|                   </div> | ||||
|                   <div className='flex gap-2'> | ||||
|                     <div>{t('Key')}:</div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user