diff --git a/src/components/transition/index.less b/src/components/transition/index.less index 1b42fc49..e1b2911a 100644 --- a/src/components/transition/index.less +++ b/src/components/transition/index.less @@ -23,6 +23,18 @@ .content-wrapper { overflow: hidden; - transition: height 300ms ease-in-out; + transition: all 300ms ease-in-out; + .content { + height: max-content; + background-color: var(--color-white-1); + border-radius: var(--border-radius-base); + } + } + .ant-input { + /* 只隐藏垂直滚动条轨道 */ + &::-webkit-scrollbar-track { + width: 0px !important; + color: transparent; + } } } diff --git a/src/components/transition/index.tsx b/src/components/transition/index.tsx index 11b2c590..4bdb37ae 100644 --- a/src/components/transition/index.tsx +++ b/src/components/transition/index.tsx @@ -1,5 +1,11 @@ import classNames from 'classnames'; -import { useEffect, useRef, useState } from 'react'; +import { + forwardRef, + useEffect, + useImperativeHandle, + useRef, + useState +} from 'react'; import './index.less'; interface TransitionWrapProps { @@ -7,50 +13,67 @@ interface TransitionWrapProps { header?: React.ReactNode; variant?: 'bordered' | 'filled'; children: React.ReactNode; + ref?: any; } -const TransitionWrapper: React.FC = (props) => { - const { minHeight = 50, header, variant = 'bordered', children } = props; - const [isOpen, setIsOpen] = useState(true); - const [height, setHeight] = useState(0); - const contentRef = useRef(null); +const TransitionWrapper: React.FC = forwardRef( + (props, ref) => { + const { minHeight = 50, header, variant = 'bordered', children } = props; + const [isOpen, setIsOpen] = useState(true); + const [height, setHeight] = useState(0); + const contentRef = useRef(null); - useEffect(() => { - if (isOpen) { - setHeight(contentRef?.current?.scrollHeight); - } else { - setHeight(0); - } - }, [isOpen]); + useEffect(() => { + if (isOpen) { + setHeight(contentRef?.current?.scrollHeight || 0); + } else { + setHeight(0); + } + }, [isOpen]); - const toggleOpen = () => { - setIsOpen(!isOpen); - }; + const toggleOpen = () => { + setIsOpen(!isOpen); + }; - return ( -
-
- {header} -
+ const setHeightByContent = () => { + setHeight(contentRef?.current?.scrollHeight || 0); + }; + + useImperativeHandle(ref, () => { + return { + setHeightByContent + }; + }); + + return (
-
{children}
+
+ {header} +
+
+
{children}
+
-
- ); -}; + ); + } +); export default TransitionWrapper; diff --git a/src/pages/Resources/components/gpus.tsx b/src/pages/Resources/components/gpus.tsx index 417a0dda..7a52b761 100644 --- a/src/pages/Resources/components/gpus.tsx +++ b/src/pages/Resources/components/gpus.tsx @@ -191,44 +191,16 @@ const Models: React.FC = () => { ); }} /> - - { - return ( - - ); - }} - /> - { - return ( - - ); - }} - /> - { - return ( - - ); - }} - /> + + + + + + { return ( diff --git a/src/pages/Resources/components/nodes.tsx b/src/pages/Resources/components/nodes.tsx index edf85840..2effef6c 100644 --- a/src/pages/Resources/components/nodes.tsx +++ b/src/pages/Resources/components/nodes.tsx @@ -191,7 +191,7 @@ const Models: React.FC = () => { ); }} /> - + { }} /> { return ( diff --git a/src/pages/Resources/index.tsx b/src/pages/Resources/index.tsx index f00e4261..e5418e1d 100644 --- a/src/pages/Resources/index.tsx +++ b/src/pages/Resources/index.tsx @@ -32,13 +32,15 @@ const Resources = () => { }} extra={[]} > - +
+ +
); }; diff --git a/src/pages/api-keys/components/add-apikey.tsx b/src/pages/api-keys/components/add-apikey.tsx index 61653d93..b7ccdbce 100644 --- a/src/pages/api-keys/components/add-apikey.tsx +++ b/src/pages/api-keys/components/add-apikey.tsx @@ -1,6 +1,7 @@ import CopyButton from '@/components/copy-button'; import ModalFooter from '@/components/modal-footer'; import SealInput from '@/components/seal-form/seal-input'; +import SealSelect from '@/components/seal-form/seal-select'; import { PageActionType } from '@/config/types'; import { SyncOutlined } from '@ant-design/icons'; import { Form, Modal } from 'antd'; @@ -12,6 +13,12 @@ type AddModalProps = { onOk: () => void; onCancel: () => void; }; + +const expirationOptions = [ + { label: '1 Month', value: '1m' }, + { label: '6 Months', value: '6m' }, + { label: 'Never', value: 'never' } +]; const AddModal: React.FC = ({ title, action, @@ -55,6 +62,13 @@ const AddModal: React.FC = ({ } > + + + ); diff --git a/src/pages/playground/components/ground-left.tsx b/src/pages/playground/components/ground-left.tsx index 63924df6..e7f2f777 100644 --- a/src/pages/playground/components/ground-left.tsx +++ b/src/pages/playground/components/ground-left.tsx @@ -2,7 +2,7 @@ import TransitionWrapper from '@/components/transition'; import { EyeInvisibleOutlined } from '@ant-design/icons'; import { PageContainer } from '@ant-design/pro-components'; import { Button, Input } from 'antd'; -import { useState } from 'react'; +import { useRef, useState } from 'react'; import '../style/ground-left.less'; import '../style/system-message-wrap.less'; import ChatFooter from './chat-footer'; @@ -24,9 +24,9 @@ const MessageList: React.FC = () => { const [systemMessage, setSystemMessage] = useState(''); const [show, setShow] = useState(false); const [activeIndex, setActiveIndex] = useState(-1); + const systemRef = useRef(null); const handleSystemMessageChange = (e: any) => { - console.log('system message:', e.target.value); setSystemMessage(e.target.value); }; const handleNewMessage = () => { @@ -74,11 +74,16 @@ const MessageList: React.FC = () => {
- + diff --git a/src/pages/playground/style/system-message-wrap.less b/src/pages/playground/style/system-message-wrap.less index bc29dc80..b1aeb9c8 100644 --- a/src/pages/playground/style/system-message-wrap.less +++ b/src/pages/playground/style/system-message-wrap.less @@ -2,4 +2,5 @@ display: flex; justify-content: space-between; align-items: center; + height: 100%; }