diff --git a/react-ui/config/proxy.ts b/react-ui/config/proxy.ts index 20769b3c..35e82c68 100644 --- a/react-ui/config/proxy.ts +++ b/react-ui/config/proxy.ts @@ -20,9 +20,9 @@ export default { // localhost:8000/api/** -> https://preview.pro.ant.design/api/** '/api/': { // 要代理的地址 - target: 'http://172.20.32.197:31213', // 开发环境 - // target: 'http://172.20.32.235:31213', // 测试环境 - // target: 'http://172.20.32.44:8082', + // target: 'http://172.20.32.197:31213', // 开发环境 + target: 'http://172.20.32.235:31213', // 测试环境 + // target: 'http://36.103.199.74:31213/', // 公网环境 // target: 'http://172.20.32.164:8082', // 配置了这个可以从 http 代理到 https // 依赖 origin 的功能可能需要这个,比如 cookie diff --git a/react-ui/package.json b/react-ui/package.json index 10086d10..0ec8cbc9 100644 --- a/react-ui/package.json +++ b/react-ui/package.json @@ -75,6 +75,7 @@ "fabric": "^5.3.0", "highlight.js": "^11.7.0", "lodash": "^4.17.21", + "motion": "~12.23.12", "omit.js": "^2.0.2", "pnpm": "^8.9.0", "query-string": "^8.1.0", @@ -82,6 +83,7 @@ "rc-util": "^5.30.0", "react": "^18.2.0", "react-activation": "^0.12.4", + "react-countup": "~6.5.3", "react-cropper": "^2.3.3", "react-dev-inspector": "^1.8.1", "react-dom": "^18.2.0", diff --git a/react-ui/public/mockServiceWorker.js b/react-ui/public/mockServiceWorker.js index ec47a9a5..7f2f4b72 100644 --- a/react-ui/public/mockServiceWorker.js +++ b/react-ui/public/mockServiceWorker.js @@ -8,7 +8,7 @@ * - Please do NOT serve this file on production. */ -const PACKAGE_VERSION = '2.7.0' +const PACKAGE_VERSION = '2.7.1' const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f' const IS_MOCKED_RESPONSE = Symbol('isMockedResponse') const activeClientIds = new Set() diff --git a/react-ui/src/assets/img/home/code-item-bg.png b/react-ui/src/assets/img/home/code-item-bg.png index 194c033a..325500e9 100644 Binary files a/react-ui/src/assets/img/home/code-item-bg.png and b/react-ui/src/assets/img/home/code-item-bg.png differ diff --git a/react-ui/src/assets/img/home/header-bg-mini.png b/react-ui/src/assets/img/home/header-bg-mini.png new file mode 100644 index 00000000..22632022 Binary files /dev/null and b/react-ui/src/assets/img/home/header-bg-mini.png differ diff --git a/react-ui/src/pages/Home/components/CodeConfig/index.less b/react-ui/src/pages/Home/components/CodeConfig/index.less index ad7da9df..89ee9468 100644 --- a/react-ui/src/pages/Home/components/CodeConfig/index.less +++ b/react-ui/src/pages/Home/components/CodeConfig/index.less @@ -3,7 +3,7 @@ display: flex; flex-direction: column; align-items: center; - padding: 4.375rem 16.25rem 9.375rem; + padding: 4.375rem @home-padding-x 9.375rem; .backgroundFullImage(url(@/assets/img/home/code-bg.png)); &__item { diff --git a/react-ui/src/pages/Home/components/Dataset/index.less b/react-ui/src/pages/Home/components/Dataset/index.less index cb662350..686dfa96 100644 --- a/react-ui/src/pages/Home/components/Dataset/index.less +++ b/react-ui/src/pages/Home/components/Dataset/index.less @@ -3,7 +3,7 @@ display: flex; flex-direction: column; align-items: center; - padding: 0 16.25rem 11.625rem; + padding: 0 @home-padding-x 11.125rem; &__item { position: relative; diff --git a/react-ui/src/pages/Home/components/Intro/index.less b/react-ui/src/pages/Home/components/Intro/index.less index 8bf103d0..98e65369 100644 --- a/react-ui/src/pages/Home/components/Intro/index.less +++ b/react-ui/src/pages/Home/components/Intro/index.less @@ -1,15 +1,28 @@ .intro { - position: relative; - z-index: 10; - display: flex; - flex-direction: column; - align-items: center; - background-image: url(@/assets/img/home/header-bg.png); - background-repeat: no-repeat; - background-position: left top; - background-size: 100% 100%; + position: fixed; + top: 0; + right: 0; + left: 0; + z-index: 100; + height: @home-info-height; + overflow: hidden; + background-color: red; + + &__content { + position: relative; + z-index: 10; + display: flex; + flex-direction: column; + align-items: center; + padding: 1.25rem @home-padding-x 0; + background-image: url(@/assets/img/home/header-bg.png); + background-repeat: no-repeat; + background-position: left top; + background-size: 100% 100%; + } &__title { + margin-top: 1.25rem; margin-bottom: 1.125rem; color: #ffffff; font-weight: 400; diff --git a/react-ui/src/pages/Home/components/Intro/index.tsx b/react-ui/src/pages/Home/components/Intro/index.tsx index 2be37d60..2f0b51bd 100644 --- a/react-ui/src/pages/Home/components/Intro/index.tsx +++ b/react-ui/src/pages/Home/components/Intro/index.tsx @@ -1,23 +1,60 @@ +import { convertRemToPx } from '@/utils'; import { useNavigate } from '@umijs/max'; +import { motion, useMotionTemplate, useScroll, useSpring, useTransform } from 'motion/react'; import NavBar from '../NavBar'; import StatisticsBlock from '../Statistics'; import styles from './index.less'; function IntroBlock() { const navigate = useNavigate(); + const { scrollY } = useScroll(); + const springValue = useSpring(scrollY, { + stiffness: 100, + damping: 30, + restDelta: 0.001, + }); + + const initialHeight = convertRemToPx(35); + console.log(initialHeight); + + const height = useTransform(() => `max(calc(35rem - ${springValue.get()}px), 5rem)`); + // const left = useTransform(() => `min(${springValue.get()}px, 16.25rem)`); + const left = useTransform(springValue, [0, initialHeight], [0.0, 16.25]); + const leftRem = useMotionTemplate`${left}rem`; + const radius = useTransform(springValue, [0, initialHeight], [0.0, 2.5]); + const radiusRem = useMotionTemplate`${radius}rem`; + const top = useTransform(springValue, [0, initialHeight], [0, 10]); + const paddingX = useTransform(springValue, [0, initialHeight], [16.25, 10]); + const paddingXRem = useMotionTemplate`1.25rem ${paddingX}rem 0`; + return ( -
- -
智能材料科研平台
-
- 智能材料科研平台是用于材料研究和开发的技术平台,它旨在提供实验数据收集、分析和可视化等功能, - 以支持材料工程师、科学家和研究人员在材料设计、性能评估和工艺优化方面的工作。 -
-
navigate('/workspace')}> - 开始使用 -
- -
+ + + +
智能材料科研平台
+
+ 智能材料科研平台是用于材料研究和开发的技术平台,它旨在提供实验数据收集、分析和可视化等功能, + 以支持材料工程师、科学家和研究人员在材料设计、性能评估和工艺优化方面的工作。 +
+
navigate('/workspace')}> + 开始使用 +
+ +
+
); } diff --git a/react-ui/src/pages/Home/components/Mirror/index.less b/react-ui/src/pages/Home/components/Mirror/index.less index 7137d44f..a88a2393 100644 --- a/react-ui/src/pages/Home/components/Mirror/index.less +++ b/react-ui/src/pages/Home/components/Mirror/index.less @@ -3,7 +3,7 @@ display: flex; flex-direction: column; align-items: center; - padding: 0 16.25rem 11.625rem; + padding: 0 @home-padding-x 11.125rem; &__item { position: relative; diff --git a/react-ui/src/pages/Home/components/Model/index.less b/react-ui/src/pages/Home/components/Model/index.less index 27df6727..7f3898ef 100644 --- a/react-ui/src/pages/Home/components/Model/index.less +++ b/react-ui/src/pages/Home/components/Model/index.less @@ -3,12 +3,21 @@ display: flex; flex-direction: column; align-items: center; - margin-top: 1.25rem; - padding: 4.125rem 16.25rem 14.75rem; + padding: 4.125rem @home-padding-x 14.75rem; .backgroundFullImage(url(@/assets/img/home/model-bg.png)); + &__content { + display: flex; + flex-wrap: wrap; + gap: 1.625rem 1.25rem; + align-items: center; + width: 100%; + } + &__item { position: relative; + display: flex; + align-items: center; width: calc((100% - 2 * 1.25rem) / 3); padding: 1.875rem 1.25rem; color: @home-text-color-tertiary; diff --git a/react-ui/src/pages/Home/components/Model/index.tsx b/react-ui/src/pages/Home/components/Model/index.tsx index 36c72e7f..60c6c348 100644 --- a/react-ui/src/pages/Home/components/Model/index.tsx +++ b/react-ui/src/pages/Home/components/Model/index.tsx @@ -3,10 +3,31 @@ import { getPublicModelsReq } from '@/services/home'; import { to } from '@/utils/promise'; import { useNavigate } from '@umijs/max'; import { Divider, Flex } from 'antd'; +import { motion, type Variants } from 'motion/react'; import { useEffect, useState } from 'react'; import BlockTitle from '../BlockTitle'; import styles from './index.less'; +const modelVariants: Variants = { + offscreen: (index: number) => ({ + y: 0, + opacity: 1, + transition: { + ease: 'linear', + duration: 0.1, + }, + }), + onscreen: { + y: [0, 200, 0], + opacity: [0, 0, 1], + transition: { + ease: 'easeInOut', + duration: 0.5, + times: [0, 0, 1], + }, + }, +}; + function ModelBlock() { const navigate = useNavigate(); const [modelData, setModelData] = useState([]); @@ -30,10 +51,14 @@ function ModelBlock() { style={{ marginBottom: '5.25rem' }} onClick={() => navigate('/dataset/model')} > - +
{modelData.map((item, index) => { return ( - { @@ -64,10 +89,10 @@ function ModelBlock() {
材料研发
*/}
-
+ ); })} - + ); } diff --git a/react-ui/src/pages/Home/components/NavBar/index.less b/react-ui/src/pages/Home/components/NavBar/index.less index 02eeb491..a59aff1e 100644 --- a/react-ui/src/pages/Home/components/NavBar/index.less +++ b/react-ui/src/pages/Home/components/NavBar/index.less @@ -1,9 +1,9 @@ .nav-bar { display: flex; align-items: center; + justify-content: space-between; width: 100%; margin-bottom: 4.375rem; - padding: 1.25rem 15.625rem; color: white; font-size: 0.9375rem; @@ -20,24 +20,30 @@ &__menu-item { margin-right: 3.125rem; + padding: 0.25rem 0.5rem; + border-radius: 0.375rem; cursor: pointer; + &:hover { + background-color: rgba(0, 0, 0, 0.06); + } + &:last-of-type { margin-right: 0; } } - &__avatar { - width: 2rem; - height: 2rem; - margin-right: 0; - margin-left: auto; - cursor: pointer; - } + :global { + .ant-dropdown-trigger { + height: 2.15rem; - &__login { - margin-right: 0; - margin-left: auto; - cursor: pointer; + .ant-avatar { + margin-right: 0 !important; + } + } + + .ant-dropdown-trigger > .anticon { + display: none; + } } } diff --git a/react-ui/src/pages/Home/components/NavBar/index.tsx b/react-ui/src/pages/Home/components/NavBar/index.tsx index 12c00b41..dcb2cac2 100644 --- a/react-ui/src/pages/Home/components/NavBar/index.tsx +++ b/react-ui/src/pages/Home/components/NavBar/index.tsx @@ -2,6 +2,7 @@ import { getAccessToken } from '@/access'; import Avatar from '@/components/RightContent/AvatarDropdown'; import { useNavigate } from '@umijs/max'; import { Flex } from 'antd'; +import classNames from 'classnames'; import styles from './index.less'; function NavBar() { @@ -47,26 +48,30 @@ function NavBar() { className={styles['nav-bar__app-logo']} > 智能材料科研平台 +
gotoPage('service')}> + 服务 +
+
gotoPage('model')}> + 模型 +
+
gotoPage('dataset')}> + 数据集 +
+
gotoPage('mirror')}> + 镜像 +
+
gotoPage('codeConfig')}> + 代码配置 +
-
gotoPage('service')}> - 服务 -
-
gotoPage('model')}> - 模型 -
-
gotoPage('dataset')}> - 数据集 -
-
gotoPage('mirror')}> - 镜像 -
-
gotoPage('codeConfig')}> - 代码配置 -
+ {token ? ( ) : ( -
gotoPage('login')}> +
gotoPage('login')} + > 登录
)} diff --git a/react-ui/src/pages/Home/components/ScrollReveal/index.tsx b/react-ui/src/pages/Home/components/ScrollReveal/index.tsx new file mode 100644 index 00000000..a043234e --- /dev/null +++ b/react-ui/src/pages/Home/components/ScrollReveal/index.tsx @@ -0,0 +1,25 @@ +import { motion, useInView, Variants } from 'motion/react'; +import { ReactNode, useRef } from 'react'; + +type ScrollRevealProps = { + children: ReactNode; + variants: Variants; +}; + +function ScrollReveal({ children, variants }: ScrollRevealProps) { + const ref = useRef(null); + const isInView = useInView(ref, { amount: 'all' }); + + return ( + + {children} + + ); +} + +export default ScrollReveal; diff --git a/react-ui/src/pages/Home/components/Service/index.less b/react-ui/src/pages/Home/components/Service/index.less index a80b8e09..dd83e60b 100644 --- a/react-ui/src/pages/Home/components/Service/index.less +++ b/react-ui/src/pages/Home/components/Service/index.less @@ -4,7 +4,7 @@ flex-direction: column; align-items: center; width: 100%; - padding: 5.625rem 16.25rem 6.25rem; + padding: 5.625rem @home-padding-x 6.25rem; .backgroundFullImage(url(@/assets/img/home/service-bg.png)); &__item { diff --git a/react-ui/src/pages/Home/components/Service/index.tsx b/react-ui/src/pages/Home/components/Service/index.tsx index 5c760665..6d7b469f 100644 --- a/react-ui/src/pages/Home/components/Service/index.tsx +++ b/react-ui/src/pages/Home/components/Service/index.tsx @@ -8,10 +8,31 @@ import { formatDate } from '@/utils/date'; import { to } from '@/utils/promise'; import { useNavigate } from '@umijs/max'; import { Flex } from 'antd'; +import { motion, type Variants } from 'motion/react'; import { useEffect, useState } from 'react'; import BlockTitle from '../BlockTitle'; import styles from './index.less'; +const serviceVariants: Variants = { + offscreen: { + y: -100, + opacity: 0, + transition: { + ease: 'linear', + duration: 0, + }, + }, + onscreen: (index: number) => ({ + y: 0, + opacity: 1, + transition: { + type: 'spring', + duration: 1, + delay: index * 0.3, + }, + }), +}; + function ServiceBlock() { const navigate = useNavigate(); const [serviceData, setServiceData] = useState([]); @@ -38,10 +59,14 @@ function ServiceBlock() { {serviceData.map((item, index) => { return ( -
navigate(`/dataset/modelDeployment/serviceInfo/${item.id}`)} + initial="offscreen" + whileInView="onscreen" + custom={index} >
{item.create_by}
{formatDate(item.create_time)}
-
+ ); })}
diff --git a/react-ui/src/pages/Home/components/Statistics/index.tsx b/react-ui/src/pages/Home/components/Statistics/index.tsx index 953dde78..1357532a 100644 --- a/react-ui/src/pages/Home/components/Statistics/index.tsx +++ b/react-ui/src/pages/Home/components/Statistics/index.tsx @@ -6,6 +6,7 @@ import ServiceIcon from '@/assets/img/home/service.png'; import { getAssetPublicCountReq } from '@/services/home'; import { to } from '@/utils/promise'; import { useEffect, useState } from 'react'; +import CountUp from 'react-countup'; import styles from './index.less'; function StatisticsBlock() { @@ -84,7 +85,14 @@ function StatisticsBlock() {
-
{item.value ?? '--'}
+
+ {item.value ? ( + + ) : ( + '--' + )} +
+
{item.title}
diff --git a/react-ui/src/pages/Home/index.less b/react-ui/src/pages/Home/index.less index 8c291f0d..aed372c8 100644 --- a/react-ui/src/pages/Home/index.less +++ b/react-ui/src/pages/Home/index.less @@ -1,6 +1,5 @@ .home { - height: 100%; - overflow-y: auto; + padding-top: @home-info-height; font-family: Alibaba; &__separator { diff --git a/react-ui/src/styles/theme.less b/react-ui/src/styles/theme.less index 7976a91c..470fa57d 100644 --- a/react-ui/src/styles/theme.less +++ b/react-ui/src/styles/theme.less @@ -31,6 +31,8 @@ @home-text-color-secondary: @text-color-secondary; @home-text-color-tertiary: #8284a4; @home-divider-color: #d8d8d8; +@home-padding-x: 16.25rem; +@home-info-height: 35rem; @workspace-background: linear-gradient( 179.03deg, diff --git a/react-ui/src/utils/index.ts b/react-ui/src/utils/index.ts index fc9eff59..686b6ee9 100644 --- a/react-ui/src/utils/index.ts +++ b/react-ui/src/utils/index.ts @@ -365,3 +365,16 @@ export const trimCharacter = (str: string, ch: string): string => { export const convertEmptyStringToUndefined = (value?: string): string | undefined => { return value === '' ? undefined : value; }; + +/** + * Converts rem to px. + * + * @param {number} rem - The value of rem. + * @return {number} The value of px + */ + +export const convertRemToPx = (rem: number): number => { + const fontSize = document.documentElement.style.fontSize; + const font = parseFloat(fontSize); + return font * rem; +};