diff --git a/src/config/breakpoints.ts b/src/config/breakpoints.ts new file mode 100644 index 00000000..38cf41dc --- /dev/null +++ b/src/config/breakpoints.ts @@ -0,0 +1,8 @@ +export default { + xs: 0, + sm: 576, + md: 768, + lg: 992, + xl: 1200, + xxl: 1600 +}; diff --git a/src/hooks/use-window-resize.ts b/src/hooks/use-window-resize.ts new file mode 100644 index 00000000..9bcebb98 --- /dev/null +++ b/src/hooks/use-window-resize.ts @@ -0,0 +1,60 @@ +import breakpoints from '@/config/breakpoints'; +import { useEffect, useState } from 'react'; + +export default function useWindowResize() { + const [size, setSize] = useState<{ width: number; height: number }>({ + width: window.innerWidth, + height: window.innerHeight + }); + const [isMobile, setIsMobile] = useState(false); + const [isTablet, setIsTablet] = useState(false); + const [isDesktop, setIsDesktop] = useState(false); + const [currentPoint, setCurrentPoint] = useState(''); + + const checkBreakpoint = (width: number) => { + if (width < breakpoints.sm) { + setIsMobile(true); + setIsTablet(false); + setIsDesktop(false); + setCurrentPoint('sm'); + return; + } + if (width < breakpoints.md) { + setIsMobile(false); + setIsTablet(true); + setIsDesktop(false); + setCurrentPoint('md'); + return; + } + if (width < breakpoints.lg) { + setIsMobile(false); + setIsTablet(false); + setIsDesktop(true); + setCurrentPoint('lg'); + return; + } + setIsMobile(false); + setIsTablet(false); + setIsDesktop(true); + setCurrentPoint('xl'); + }; + + useEffect(() => { + const handleResize = () => { + setSize({ + width: window.innerWidth, + height: window.innerHeight + }); + }; + window.addEventListener('resize', handleResize); + return () => { + window.removeEventListener('resize', handleResize); + }; + }, []); + + useEffect(() => { + checkBreakpoint(size.width); + }, [size.width]); + + return { size, isMobile, isTablet, isDesktop, currentPoint }; +} diff --git a/src/pages/dashboard/apis/index.ts b/src/pages/dashboard/apis/index.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/dashboard/components/over-view.tsx b/src/pages/dashboard/components/over-view.tsx index 22d2d833..ed1a8f67 100644 --- a/src/pages/dashboard/components/over-view.tsx +++ b/src/pages/dashboard/components/over-view.tsx @@ -65,7 +65,14 @@ const Overview: React.FC = (props) => {
{overviewConfigs.map((config, index) => ( - + {renderCardItem({ label: config.label, value: renderValue(data[config.key] || 0), diff --git a/src/pages/dashboard/components/system-load.tsx b/src/pages/dashboard/components/system-load.tsx index c875ca0b..edd238c3 100644 --- a/src/pages/dashboard/components/system-load.tsx +++ b/src/pages/dashboard/components/system-load.tsx @@ -1,7 +1,10 @@ import CardWrapper from '@/components/card-wrapper'; import LiquidChart from '@/components/charts/liquid'; import PageTools from '@/components/page-tools'; +import breakpoints from '@/config/breakpoints'; +import useWindowResize from '@/hooks/use-window-resize'; import { Col, DatePicker, Row } from 'antd'; +import { useEffect, useState } from 'react'; import ResourceUtilization from './resource-utilization'; const SystemLoad = () => { @@ -11,11 +14,23 @@ const SystemLoad = () => { 'linear-gradient(90deg, rgba(255, 120, 117,.8) 0%, rgba(255, 120, 117,0.5) 50%, rgba(255, 120, 117,.8) 100%)' ]; + const { size } = useWindowResize(); + const [paddingRight, setPaddingRight] = useState('20px'); + const [smallChartHeight, setSmallChartHeight] = useState(190); + const [largeChartHeight, setLargeChartHeight] = useState(400); const thresholds = [0.5, 0.7, 1]; const height = 400; const handleSelectDate = (date: string) => {}; + useEffect(() => { + if (size.width < breakpoints.xl) { + setPaddingRight('0'); + } else { + setPaddingRight('20px'); + } + }, [size.width]); + return (
@@ -31,15 +46,22 @@ const SystemLoad = () => { } /> - - + + - - - - + + + + { rangColor={colors} > - + { rangColor={colors} > - + { rangColor={colors} > - + { }); const Usage = () => { - const bgColor = '#fff'; - const handleSelectDate = (dateString: string) => { - console.log('dateString============', dateString); - }; + const { size } = useWindowResize(); + const [paddingRight, setPaddingRight] = useState('20px'); + + const handleSelectDate = (dateString: string) => {}; + + useEffect(() => { + if (size.width < breakpoints.xl) { + setPaddingRight('0'); + } else { + setPaddingRight('20px'); + } + }, [size.width]); return ( <> @@ -101,9 +113,16 @@ const Usage = () => { } /> - - - + + + { - + = (props) => { diff --git a/src/pages/playground/style/ground-left.less b/src/pages/playground/style/ground-left.less index 72301e1f..7103c84c 100644 --- a/src/pages/playground/style/ground-left.less +++ b/src/pages/playground/style/ground-left.less @@ -1,6 +1,6 @@ .ground-left { position: relative; - height: 100vh; + height: calc(100vh - 84px); padding-bottom: 120px; .message-list-wrap { diff --git a/src/pages/playground/style/play-ground.less b/src/pages/playground/style/play-ground.less index 9819f80f..9415c724 100644 --- a/src/pages/playground/style/play-ground.less +++ b/src/pages/playground/style/play-ground.less @@ -1,20 +1,24 @@ .play-ground { display: flex; align-items: flex-start; + .chat { flex: 1; display: flex; flex-direction: column; } + .params { // width: 465px; padding: 20px; } + .divider-line { width: 1px; + .ant-divider { margin: 0; - min-height: 100vh; + min-height: calc(100vh - 84px); } } } diff --git a/src/pages/profile/index.tsx b/src/pages/profile/index.tsx index 2b0b50a9..0a2fcc40 100644 --- a/src/pages/profile/index.tsx +++ b/src/pages/profile/index.tsx @@ -1,3 +1,4 @@ +import CardWrapper from '@/components/card-wrapper'; import FormButtons from '@/components/form-buttons'; import SealInput from '@/components/seal-form/seal-input'; import { PasswordReg } from '@/config'; @@ -42,14 +43,17 @@ const Profile: React.FC = () => { }} extra={[]} > -
- {/* + + {/* name="username" rules={[ { @@ -69,50 +73,53 @@ const Profile: React.FC = () => { style={{ width: INPUT_WIDTH.default }} > */} - - name="current_password" - rules={[ - { - required: true, - message: intl.formatMessage( - { id: 'common.form.rule.input' }, - { - name: intl.formatMessage({ - id: 'users.form.currentpassword' - }) - } - ) - } - ]} - > - - - - name="new_password" - rules={[ - { - required: true, - pattern: PasswordReg, - message: intl.formatMessage({ id: 'users.form.rule.password' }) - } - ]} - > - - - - + + name="current_password" + rules={[ + { + required: true, + message: intl.formatMessage( + { id: 'common.form.rule.input' }, + { + name: intl.formatMessage({ + id: 'users.form.currentpassword' + }) + } + ) + } + ]} + > + + + + name="new_password" + rules={[ + { + required: true, + pattern: PasswordReg, + message: intl.formatMessage({ + id: 'users.form.rule.password' + }) + } + ]} + > + + + + +
);