diff --git a/config/theme.ts b/config/theme.ts index e7101de9..717a9db8 100644 --- a/config/theme.ts +++ b/config/theme.ts @@ -22,6 +22,9 @@ export default { Progress: { lineBorderRadius: 4 }, + Select: { + itemSelectedBg: 'rgba(0,0,0,0.06)' + }, Slider: { handleSize: 8, handleSizeHover: 8, diff --git a/src/components/icon-font/index.tsx b/src/components/icon-font/index.tsx new file mode 100644 index 00000000..dc877a99 --- /dev/null +++ b/src/components/icon-font/index.tsx @@ -0,0 +1,7 @@ +import { createFromIconfontCN } from '@ant-design/icons'; + +const IconFont = createFromIconfontCN({ + scriptUrl: '//at.alicdn.com/t/c/font_4613488_clxjnjvlf6m.js' +}); + +export default IconFont; diff --git a/src/components/status-tag/index.less b/src/components/status-tag/index.less index 63715a16..3214807b 100644 --- a/src/components/status-tag/index.less +++ b/src/components/status-tag/index.less @@ -12,7 +12,7 @@ overflow: hidden; &.download { - background-color: var(--ant-blue-2); + border: 1px solid var(--ant-color-border) !important; } .download { @@ -24,12 +24,12 @@ top: 0; bottom: 0; height: 100%; - background-color: var(--ant-color-primary); + background-color: rgba(0, 0, 0, 15%); } .progress { position: relative; z-index: 10; - color: var(--color-white-1); + color: var(--ant-color-text); } } diff --git a/src/components/status-tag/index.tsx b/src/components/status-tag/index.tsx index 2f18c572..eb035d3d 100644 --- a/src/components/status-tag/index.tsx +++ b/src/components/status-tag/index.tsx @@ -51,17 +51,10 @@ const StatusTag: React.FC = ({ statusValue, download }) => { className={classNames('status-tag', { download: download?.percent })} - style={ - download - ? { - color: StatusColorMap['success']['text'], - border: `1px solid ${StatusColorMap['success']['text']}` - } - : { - color: statusColor?.text, - border: `1px solid ${statusColor?.text}` - } - } + style={{ + color: statusColor?.text, + border: `1px solid ${statusColor?.text}` + }} > {renderContent()} diff --git a/src/components/transition/index.less b/src/components/transition/index.less index ccc12fc4..3f32d75a 100644 --- a/src/components/transition/index.less +++ b/src/components/transition/index.less @@ -16,7 +16,6 @@ .transition-content-wrapper { background-color: var(--color-fill-1); - padding: 8px; } } diff --git a/src/components/transition/index.tsx b/src/components/transition/index.tsx index b0d3dd5d..8c611915 100644 --- a/src/components/transition/index.tsx +++ b/src/components/transition/index.tsx @@ -73,7 +73,8 @@ const TransitionWrapper: React.FC = forwardRef( className="transition-content-wrapper" style={{ minHeight: isOpen ? height : 0, - height: isOpen ? 'auto' : 0 + height: isOpen ? 'auto' : 0, + padding: isOpen ? '8px' : '0 8px' }} ref={contentRef} > diff --git a/src/config/index.ts b/src/config/index.ts index 79940db3..2d022125 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -25,7 +25,7 @@ export const StatusColorMap: Record = bg: `var(--ant-green-1)` }, inactive: { - text: `var(--ant-color-border)`, + text: `var(--ant-color-text-secondary)`, bg: `var(--ant-color-fill)` } }; diff --git a/src/layouts/rightRender.tsx b/src/layouts/rightRender.tsx index c9bed6ad..9a2faf7d 100644 --- a/src/layouts/rightRender.tsx +++ b/src/layouts/rightRender.tsx @@ -117,7 +117,8 @@ export function getRightRenderContent(opts: { {_.toUpper(opts.initialState?.currentUser?.username?.charAt(0))} diff --git a/src/locales/en-US/playground.ts b/src/locales/en-US/playground.ts index c8a5095e..5e8e9bc8 100644 --- a/src/locales/en-US/playground.ts +++ b/src/locales/en-US/playground.ts @@ -1,5 +1,5 @@ export default { - 'playground.system.tips': 'Enter system message here...', + 'playground.system.tips': 'Enter system message here', 'playground.title': 'Playground', 'playground.system': 'System', 'playground.user': 'User', diff --git a/src/locales/zh-CN/playground.ts b/src/locales/zh-CN/playground.ts index 28e295aa..95379da7 100644 --- a/src/locales/zh-CN/playground.ts +++ b/src/locales/zh-CN/playground.ts @@ -1,5 +1,5 @@ export default { - 'playground.system.tips': '在这里输入系统消息...', + 'playground.system.tips': '在这里输入系统消息', 'playground.title': '试验场', 'playground.system': '系统', 'playground.user': '用户', diff --git a/src/pages/api-keys/components/add-apikey.tsx b/src/pages/api-keys/components/add-apikey.tsx index ab63e124..69bbb668 100644 --- a/src/pages/api-keys/components/add-apikey.tsx +++ b/src/pages/api-keys/components/add-apikey.tsx @@ -89,6 +89,7 @@ const AddModal: React.FC = ({ { return dayjs(text).format('YYYY-MM-DD HH:mm:ss'); }} /> + = (props) => { = ({ icon: } ]; + const testStatus = { + state: InstanceStatusMap.Scheduled + }; + const getWorkerIp = (item: ModelInstanceListItem) => { + if (item.worker_ip) { + return item.port ? `${item.worker_ip}:${item.port}` : item.worker_ip; + } + return '-'; + }; return ( {_.map(list, (item: ModelInstanceListItem, index: number) => { @@ -40,18 +49,11 @@ const InstanceItem: React.FC = ({
{item.name} - - {item.worker_ip ? `${item.worker_ip}:${item.port}` : '-'} - + {getWorkerIp(item)} {item.source === 'huggingface' @@ -68,7 +70,7 @@ const InstanceItem: React.FC = ({ {item.state && ( = (props) => { = { s3: 'S3' }; +export const InstanceStatusMap = { + Initializing: 'Initializing', + Pending: 'Pending', + Running: 'Running', + Scheduled: 'Scheduled', + Error: 'Error', + Downloading: 'Downloading', + Unknown: 'Unknown' +}; + export const status: any = { - Running: StatusMaps.success, - Pending: StatusMaps.transitioning + [InstanceStatusMap.Running]: StatusMaps.success, + [InstanceStatusMap.Pending]: StatusMaps.transitioning, + [InstanceStatusMap.Initializing]: StatusMaps.transitioning, + [InstanceStatusMap.Scheduled]: StatusMaps.success, + [InstanceStatusMap.Error]: StatusMaps.error, + [InstanceStatusMap.Downloading]: StatusMaps.transitioning, + [InstanceStatusMap.Unknown]: StatusMaps.inactive }; export const ActionList = [ @@ -40,12 +55,3 @@ export const ActionList = [ icon: EditOutlined } ]; - -export const InstanceStatusMap = { - Initializing: 'Initializing', - Pending: 'Pending', - Running: 'Running', - Scheduled: 'Scheduled', - Error: 'Error', - Downloading: 'Downloading' -}; diff --git a/src/pages/playground/components/chat-footer.tsx b/src/pages/playground/components/chat-footer.tsx index d77b6df1..5b3bb9ed 100644 --- a/src/pages/playground/components/chat-footer.tsx +++ b/src/pages/playground/components/chat-footer.tsx @@ -1,9 +1,9 @@ +import IconFont from '@/components/icon-font'; import HotKeys from '@/config/hotkeys'; import { CodeOutlined, DeleteOutlined, EnterOutlined, - MacCommandOutlined, PlusOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; @@ -74,7 +74,7 @@ const ChatFooter: React.FC = (props) => { diff --git a/src/pages/playground/components/ground-left.tsx b/src/pages/playground/components/ground-left.tsx index 02a87846..4c8f60dd 100644 --- a/src/pages/playground/components/ground-left.tsx +++ b/src/pages/playground/components/ground-left.tsx @@ -85,6 +85,7 @@ const MessageList: React.FC = (props) => { uid: messageId.current } ]); + console.log('messageList=====', messageList, messageId.current, chunk); return false; }; const submitMessage = async () => { @@ -115,7 +116,6 @@ const MessageList: React.FC = (props) => { return; } const { reader, decoder } = result; - await readStreamData(reader, decoder, (chunk: any) => { joinMessage(chunk); }); @@ -207,7 +207,10 @@ const MessageList: React.FC = (props) => { autoSize={true} onFocus={handleFocus} onBlur={handleBlur} - placeholder={intl.formatMessage({ id: 'playground.system.tips' })} + style={{ minHeight: 40 }} + placeholder={intl.formatMessage({ + id: 'playground.system.tips' + })} onChange={handleSystemMessageChange} > diff --git a/src/pages/playground/components/message-item.tsx b/src/pages/playground/components/message-item.tsx index a27cf9e2..741597ce 100644 --- a/src/pages/playground/components/message-item.tsx +++ b/src/pages/playground/components/message-item.tsx @@ -31,18 +31,6 @@ const MessageItem: React.FC<{ const [currentIsFocus, setCurrentIsFocus] = useState(isFocus); const inputRef = useRef(null); - useHotkeys( - HotKeys.SUBMIT, - () => { - onSubmit(); - }, - { - enabled: currentIsFocus && !loading, - enableOnFormTags: currentIsFocus && !loading, - preventDefault: true - } - ); - useEffect(() => { if (inputRef.current && isFocus) { inputRef.current.focus(); @@ -110,6 +98,20 @@ const MessageItem: React.FC<{ const handleDelete = () => { onDelete(); }; + + useHotkeys( + HotKeys.SUBMIT, + () => { + inputRef.current.blur(); + onSubmit(); + }, + { + enabled: currentIsFocus, + enableOnFormTags: currentIsFocus, + preventDefault: true + } + ); + return (
@@ -124,6 +126,7 @@ const MessageItem: React.FC<{ value={messageContent} autoSize={true} variant="filled" + readOnly={loading} onChange={handleMessageChange} onFocus={handleFocus} onBlur={handleBlur} diff --git a/src/pages/playground/components/view-code-modal.tsx b/src/pages/playground/components/view-code-modal.tsx index c873f2d4..5a5f7082 100644 --- a/src/pages/playground/components/view-code-modal.tsx +++ b/src/pages/playground/components/view-code-modal.tsx @@ -116,6 +116,7 @@ const ViewCodeModal: React.FC = (props) => { }, formatOnType: true, formatOnPaste: true, + fontWeight: '700', scrollbar: { verticalSliderSize: 8 } @@ -130,13 +131,13 @@ const ViewCodeModal: React.FC = (props) => {
@@ -151,7 +152,7 @@ const ViewCodeModal: React.FC = (props) => { onChangeLang={handleOnChangeLang} > { onFinish={handleOnFinish} onFinishFailed={handleOnFinishFailed} > - {/* - name="username" - rules={[ - { - required: true, - message: intl.formatMessage( - { id: 'common.form.rule.input' }, - { - name: intl.formatMessage({ id: 'common.form.username' }) - } - ) - } - ]} - > - - */} name="current_password" rules={[ @@ -135,6 +115,7 @@ const Profile: React.FC = () => { ]} > diff --git a/src/pages/table/components/CreateForm.tsx b/src/pages/table/components/CreateForm.tsx index e5233db3..3e9d8f2c 100644 --- a/src/pages/table/components/CreateForm.tsx +++ b/src/pages/table/components/CreateForm.tsx @@ -14,6 +14,7 @@ const CreateForm: React.FC> = (props) => { destroyOnClose title="新建" width={420} + centered={true} open={modalVisible} onCancel={() => onCancel()} footer={null} diff --git a/src/pages/users/components/add-modal.tsx b/src/pages/users/components/add-modal.tsx index 046a9f5e..c594c4f9 100644 --- a/src/pages/users/components/add-modal.tsx +++ b/src/pages/users/components/add-modal.tsx @@ -54,6 +54,7 @@ const AddModal: React.FC = ({ void ) => { const { done, value } = await reader.read(); - + console.log('done====', done, value); if (done) { return; } diff --git a/src/utils/index.ts b/src/utils/index.ts index 5e078d7e..840fec4a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -141,3 +141,17 @@ export const generateFluctuatingData = ({ return y; }; + +export const platformCall = () => { + const platform = navigator.userAgent; + const isMac = () => { + return platform.indexOf('Mac') !== -1; + }; + const isWin = () => { + return platform.indexOf('Win') !== -1; + }; + return { + isMac: isMac(), + isWin: isWin() + }; +};