import { useEffect, useRef } from 'react' import { useTranslation } from '@/i18n.ts' import { useStyle } from './style.ts' import { Alert, Button, Divider, Form, Input, InputNumber, InputRef, notification, Flex } from 'antd' import { useAtom, useAtomValue } from 'jotai' import TwoColPageLayout from '@/layout/TwoColPageLayout.tsx' import { ProCard } from '@ant-design/pro-components' import { PlusOutlined } from '@ant-design/icons' import Glass from '@/components/glass' import { categoryAtom, saveOrUpdateCategoryAtom } from '@/store/videos/category.ts' import Switch from '@/components/switch' import CategoryTree from './components/CategoryTree.tsx' const Category = () => { const { t } = useTranslation() const { styles, cx } = useStyle() const [ form ] = Form.useForm() const inputRef = useRef() const { mutate, isPending, isError, error } = useAtomValue(saveOrUpdateCategoryAtom) const [ current, setCurrent ] = useAtom(categoryAtom) useEffect(() => { if (isError) { notification.error({ message: t('message.error', '错误'), description: (error as any).message ?? t('message.saveFail', '保存失败'), }) } }, [ isError ]) useEffect(() => { if (current?.id === 0 && inputRef.current) { inputRef.current.focus() } }, [ current ]) return (
} > } >
) } export default Category