chore: update antd

This commit is contained in:
jialin
2024-10-09 14:08:27 +08:00
parent 2b22481443
commit 3784d86344
6 changed files with 1547 additions and 1090 deletions
+6 -3
View File
@@ -10,9 +10,12 @@
"setup": "max setup", "setup": "max setup",
"start": "npm run dev" "start": "npm run dev"
}, },
"resolutions": {
"immer": "^9.0.6"
},
"dependencies": { "dependencies": {
"@ant-design/icons": "^5.3.7", "@ant-design/icons": "^5.5.1",
"@ant-design/pro-components": "^2.7.1", "@ant-design/pro-components": "^2.7.18",
"@huggingface/gguf": "^0.1.7", "@huggingface/gguf": "^0.1.7",
"@huggingface/hub": "^0.15.1", "@huggingface/hub": "^0.15.1",
"@huggingface/tasks": "^0.11.6", "@huggingface/tasks": "^0.11.6",
@@ -23,7 +26,7 @@
"@xterm/addon-fit": "^0.10.0", "@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0", "@xterm/xterm": "^5.5.0",
"ansi-to-html": "^0.7.2", "ansi-to-html": "^0.7.2",
"antd": "^5.18.3", "antd": "^5.20.6",
"antd-style": "^3.6.2", "antd-style": "^3.6.2",
"axios": "^1.7.2", "axios": "^1.7.2",
"classnames": "^2.5.1", "classnames": "^2.5.1",
+1486 -1024
View File
File diff suppressed because it is too large Load Diff
@@ -64,27 +64,16 @@ const HFModelItem: React.FC<HFModelItemProps> = (props) => {
<div className="info"> <div className="info">
{SUPPORTEDSOURCE.includes(props.source || '') ? ( {SUPPORTEDSOURCE.includes(props.source || '') ? (
<div className="info-item"> <div className="info-item">
{/* {props.task && (
<Tag
className="tag-item"
color="gold"
style={{
marginRight: 0
}}
>
<span style={{ opacity: 0.65 }}>{props.task}</span>
</Tag>
)} */}
<span> <span>
{dayjs().to( {dayjs().to(
dayjs(dayjs(props.updatedAt).format('YYYY-MM-DD HH:mm:ss')) dayjs(dayjs(props.updatedAt).format('YYYY-MM-DD HH:mm:ss'))
)} )}
</span> </span>
<span> <span className="flex-center">
<HeartOutlined className="m-r-5" /> <HeartOutlined className="m-r-5" />
{props.likes} {props.likes}
</span> </span>
<span> <span className="flex-center">
<DownloadOutlined className="m-r-5" /> <DownloadOutlined className="m-r-5" />
{formatNumber(props.downloads)} {formatNumber(props.downloads)}
</span> </span>
@@ -14,6 +14,7 @@ import _ from 'lodash';
import 'overlayscrollbars/overlayscrollbars.css'; import 'overlayscrollbars/overlayscrollbars.css';
import React, { import React, {
forwardRef, forwardRef,
useCallback,
useContext, useContext,
useEffect, useEffect,
useImperativeHandle, useImperativeHandle,
@@ -222,25 +223,25 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef(
} }
}; };
const handleOnValuesChange = ( const handleOnValuesChange = useCallback(
changeValues: any, (changeValues: any, allValues: Record<string, any>) => {
allValues: Record<string, any> if (isApplyToAllModels.current) {
) => { setParams({
if (isApplyToAllModels.current) { ...params,
setParams({ ...allValues
...params, });
...allValues setGlobalParams({
}); ...allValues
setGlobalParams({ });
...allValues } else {
}); setParams({
} else { ...params,
setParams({ ...changeValues
...params, });
...changeValues }
}); },
} [params, isApplyToAllModels.current]
}; );
const handleClearMessage = () => { const handleClearMessage = () => {
setMessageList([]); setMessageList([]);
@@ -6,7 +6,7 @@ import { InfoCircleOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { Form, InputNumber, Slider, Tooltip } from 'antd'; import { Form, InputNumber, Slider, Tooltip } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
import { useEffect, useId, useState } from 'react'; import { memo, useCallback, useEffect, useId } from 'react';
import CustomLabelStyles from '../style/custom-label.less'; import CustomLabelStyles from '../style/custom-label.less';
type ParamsSettingsFormProps = { type ParamsSettingsFormProps = {
@@ -39,7 +39,6 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
showModelSelector = true showModelSelector = true
}) => { }) => {
const intl = useIntl(); const intl = useIntl();
const [ModelList, setModelList] = useState([]);
const initialValues = { const initialValues = {
seed: null, seed: null,
stop: null, stop: null,
@@ -86,7 +85,7 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
setParams?.(allValues); setParams?.(allValues);
onValuesChange?.(changedValues, allValues); onValuesChange?.(changedValues, allValues);
}; };
const handleFieldValueChange = (val: any, field: string) => { const handleFieldValueChange = useCallback((val: any, field: string) => {
const values = form.getFieldsValue(); const values = form.getFieldsValue();
form.setFieldsValue({ form.setFieldsValue({
...values, ...values,
@@ -103,7 +102,7 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
[field]: val [field]: val
} }
); );
}; }, []);
const handleResetParams = () => { const handleResetParams = () => {
form.setFieldsValue(initialValues); form.setFieldsValue(initialValues);
@@ -177,7 +176,7 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
} }
]} ]}
> >
<SealSelect showSearch options={modelList}></SealSelect> <SealSelect showSearch={true} options={modelList}></SealSelect>
</Form.Item> </Form.Item>
</> </>
)} )}
@@ -296,4 +295,4 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
); );
}; };
export default ParamsSettings; export default memo(ParamsSettings);
+28 -25
View File
@@ -16,14 +16,14 @@ const UploadImg: React.FC<UploadImgProps> = ({ handleUpdateImgList }) => {
const intl = useIntl(); const intl = useIntl();
const uploadRef = useRef<any>(null); const uploadRef = useRef<any>(null);
const getBase64 = (file: RcFile): Promise<string> => { const getBase64 = useCallback((file: RcFile): Promise<string> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader(); const reader = new FileReader();
reader.readAsDataURL(file); reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result as string); reader.onload = () => resolve(reader.result as string);
reader.onerror = (error) => reject(error); reader.onerror = (error) => reject(error);
}); });
}; }, []);
const debouncedUpdate = useCallback( const debouncedUpdate = useCallback(
debounce((base64List: { dataUrl: string; uid: number | string }[]) => { debounce((base64List: { dataUrl: string; uid: number | string }[]) => {
@@ -32,32 +32,35 @@ const UploadImg: React.FC<UploadImgProps> = ({ handleUpdateImgList }) => {
[handleUpdateImgList, intl] [handleUpdateImgList, intl]
); );
const handleChange = async (info: any) => { const handleChange = useCallback(
const { fileList } = info; async (info: any) => {
const { fileList } = info;
const newFileList = await Promise.all( const newFileList = await Promise.all(
fileList.map(async (item: UploadFile) => { fileList.map(async (item: UploadFile) => {
if (item.originFileObj && !item.url) { if (item.originFileObj && !item.url) {
const base64 = await getBase64(item.originFileObj as RcFile); const base64 = await getBase64(item.originFileObj as RcFile);
item.url = base64; item.url = base64;
} }
return item; return item;
}) })
); );
if (newFileList.length > 0) { if (newFileList.length > 0) {
const base64List = newFileList const base64List = newFileList
.filter((sitem) => sitem.url) .filter((sitem) => sitem.url)
.map((item: UploadFile) => { .map((item: UploadFile) => {
return { return {
dataUrl: item.url as string, dataUrl: item.url as string,
uid: item.uid uid: item.uid
}; };
}); });
debouncedUpdate(base64List); debouncedUpdate(base64List);
} }
}; },
[debouncedUpdate, getBase64]
);
return ( return (
<> <>