fix: body scrolls to top after opening a modal
This commit is contained in:
@@ -53,7 +53,7 @@ const TagsWrapper: React.FC<TagsWrapperProps> = (props) => {
|
||||
const nodeWidth = sizeList[i];
|
||||
|
||||
if (totalWidth + moreButtonWidth.current >= wrapperWidth) {
|
||||
end = i - 1;
|
||||
end = i - 1 < 0 ? 0 : i - 1;
|
||||
break;
|
||||
}
|
||||
totalWidth += nodeWidth;
|
||||
|
||||
@@ -184,6 +184,7 @@ body {
|
||||
font-family: 'noto sans', sans-serif;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
overflow-y: initial !important;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 0;
|
||||
|
||||
@@ -4,23 +4,11 @@ import breakpoints from '@/config/breakpoints';
|
||||
import { SyncOutlined } from '@ant-design/icons';
|
||||
import { PageContainer } from '@ant-design/pro-components';
|
||||
import { useIntl, useNavigate } from '@umijs/max';
|
||||
import {
|
||||
Button,
|
||||
Col,
|
||||
Input,
|
||||
Pagination,
|
||||
Row,
|
||||
Select,
|
||||
Space,
|
||||
Spin,
|
||||
message
|
||||
} from 'antd';
|
||||
import { Button, Input, Pagination, Select, Space, message } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import ResizeObserver from 'rc-resize-observer';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { createModel, queryCatalogList } from './apis';
|
||||
import CatalogItem from './components/catalog-item';
|
||||
import CatalogSkelton from './components/catalog-skelton';
|
||||
import CatalogList from './components/catalog-list';
|
||||
import DelopyBuiltInModal from './components/deploy-builtin-modal';
|
||||
import { modelCategories, modelSourceMap } from './config';
|
||||
import { CatalogItem as CatalogItemType, FormData } from './config/types';
|
||||
@@ -266,46 +254,13 @@ const Catalog: React.FC = () => {
|
||||
</Space>
|
||||
}
|
||||
></PageTools>
|
||||
<div className="relative" style={{ width: '100%' }}>
|
||||
<ResizeObserver onResize={handleResize}>
|
||||
<Row gutter={[16, 16]}>
|
||||
{dataSource.dataList.map((item: CatalogItemType, index) => {
|
||||
return (
|
||||
<Col span={span} key={item.id}>
|
||||
<CatalogItem
|
||||
onClick={handleOnDeploy}
|
||||
activeId={activeId}
|
||||
data={item}
|
||||
></CatalogItem>
|
||||
</Col>
|
||||
);
|
||||
})}
|
||||
</Row>
|
||||
{dataSource.loading && (
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
position: 'absolute',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
top: 0,
|
||||
left: 0,
|
||||
height: 400,
|
||||
right: 0
|
||||
}}
|
||||
>
|
||||
<Spin
|
||||
spinning={dataSource.loading}
|
||||
style={{ width: '100%' }}
|
||||
wrapperClassName="skelton-wrapper"
|
||||
>
|
||||
{isFirst && <CatalogSkelton span={span}></CatalogSkelton>}
|
||||
</Spin>
|
||||
</div>
|
||||
)}
|
||||
</ResizeObserver>
|
||||
</div>
|
||||
<CatalogList
|
||||
dataList={dataSource.dataList}
|
||||
loading={dataSource.loading}
|
||||
onDeploy={handleOnDeploy}
|
||||
activeId={-1}
|
||||
isFirst={isFirst}
|
||||
></CatalogList>
|
||||
<div style={{ marginBlock: '32px 16px' }}>
|
||||
<Pagination
|
||||
hideOnSinglePage={queryParams.perPage === 100}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import breakpoints from '@/config/breakpoints';
|
||||
import { Col, Row, Spin } from 'antd';
|
||||
import ResizeObserver from 'rc-resize-observer';
|
||||
import React, { useCallback } from 'react';
|
||||
import { CatalogItem as CatalogItemType } from '../config/types';
|
||||
import CatalogItem from './catalog-item';
|
||||
import CatalogSkelton from './catalog-skelton';
|
||||
|
||||
interface CatalogListProps {
|
||||
dataList: any[];
|
||||
loading: boolean;
|
||||
activeId: number;
|
||||
isFirst: boolean;
|
||||
onDeploy: (data: any) => void;
|
||||
}
|
||||
|
||||
const CatalogList: React.FC<CatalogListProps> = (props) => {
|
||||
const { dataList, loading, activeId, isFirst, onDeploy } = props;
|
||||
const [span, setSpan] = React.useState(8);
|
||||
|
||||
const handleResize = useCallback(
|
||||
_.throttle((size: { width: number; height: number }) => {
|
||||
const { width } = size;
|
||||
if (width < breakpoints.xs) {
|
||||
setSpan(24);
|
||||
} else if (width < breakpoints.sm) {
|
||||
setSpan(24);
|
||||
} else if (width < breakpoints.md) {
|
||||
setSpan(12);
|
||||
} else if (width < breakpoints.lg) {
|
||||
setSpan(12);
|
||||
} else {
|
||||
setSpan(8);
|
||||
}
|
||||
}, 100),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="relative" style={{ width: '100%' }}>
|
||||
<ResizeObserver onResize={handleResize}>
|
||||
<div>
|
||||
<Row gutter={[16, 16]}>
|
||||
{dataList.map((item: CatalogItemType, index) => {
|
||||
return (
|
||||
<Col span={span} key={item.id}>
|
||||
<CatalogItem
|
||||
onClick={onDeploy}
|
||||
activeId={activeId}
|
||||
data={item}
|
||||
></CatalogItem>
|
||||
</Col>
|
||||
);
|
||||
})}
|
||||
</Row>
|
||||
{loading && (
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
position: 'absolute',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
top: 0,
|
||||
left: 0,
|
||||
height: 400,
|
||||
right: 0
|
||||
}}
|
||||
>
|
||||
<Spin
|
||||
spinning={loading}
|
||||
style={{
|
||||
width: '100%'
|
||||
}}
|
||||
wrapperClassName="skelton-wrapper"
|
||||
>
|
||||
{isFirst && <CatalogSkelton span={span}></CatalogSkelton>}
|
||||
</Spin>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ResizeObserver>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(CatalogList);
|
||||
@@ -67,7 +67,7 @@ const advancedFieldsDefaultValus = {
|
||||
guidance: 3.5,
|
||||
sampling_steps: 10,
|
||||
negative_prompt: null,
|
||||
schedule_method: 'default',
|
||||
schedule_method: 'discrete',
|
||||
preview: null
|
||||
};
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ const advancedFieldsDefaultValus = {
|
||||
sampling_steps: 10,
|
||||
negative_prompt: null,
|
||||
preview: null,
|
||||
schedule_method: 'default'
|
||||
schedule_method: 'discrete'
|
||||
};
|
||||
|
||||
const openaiCompatibleFieldsDefaultValus = {
|
||||
|
||||
@@ -15,8 +15,8 @@ export const imageSizeOptions: {
|
||||
height: 0
|
||||
},
|
||||
{ label: '512x512', value: '512x512', width: 512, height: 512 },
|
||||
{ label: '768x1024', value: '768x1024', width: 768, height: 1024 },
|
||||
{ label: '1024x768', value: '1024x768', width: 1024, height: 768 },
|
||||
{ label: '768x1024(3:4)', value: '768x1024', width: 768, height: 1024 },
|
||||
{ label: '1024x768(4:3)', value: '1024x768', width: 1024, height: 768 },
|
||||
{ label: '1024x1024', value: '1024x1024', width: 1024, height: 1024 }
|
||||
];
|
||||
|
||||
@@ -278,7 +278,6 @@ export const ImageAdvancedParamsConfig: ParamsSchema[] = [
|
||||
type: 'Select',
|
||||
name: 'schedule_method',
|
||||
options: [
|
||||
{ label: 'default', value: 'default' },
|
||||
{ label: 'discrete', value: 'discrete' },
|
||||
{ label: 'karras', value: 'karras' },
|
||||
{ label: 'exponential', value: 'exponential' },
|
||||
|
||||
Reference in New Issue
Block a user