refactor(layout): 重构布局组件并添加视频播放功能
-重写 Header 组件,使用新的 OptionLayoutContext 替代 HistoryContext - 新增 VideoPlayer 组件,用于播放视频 - 更新 Playground 组件,集成新的侧边栏和视频播放功能 - 重构 Layout 组件,支持新的选项布局 - 更新相关路由和导出导入逻辑,以支持上述更改
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useMemo } from "react"
|
||||
import React, { useEffect, useMemo, useState } from "react"
|
||||
import { Avatar, Card } from "antd"
|
||||
import { AnimatePresence, motion } from "framer-motion" // 使用 CSS-in-JS 方式
|
||||
import styled, { keyframes } from "styled-components"
|
||||
@@ -11,6 +11,7 @@ import { TechCompanyIcon } from "@/components/Icons/TechCompany.tsx"
|
||||
import { ResearchInstitutesIcon } from "@/components/Icons/ResearchInstitutes.tsx"
|
||||
import { NSDCIcon } from "@/components/Icons/NSDC.tsx"
|
||||
import { useIodPlaygroundContext } from "@/components/Option/Playground/PlaygroundIod.tsx"
|
||||
import { totalSearchResults } from "@/services/search.ts"
|
||||
|
||||
const rotate = keyframes`
|
||||
0% {
|
||||
@@ -230,6 +231,18 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
|
||||
return currentIodMessage && !iodLoading
|
||||
}, [currentIodMessage, iodLoading])
|
||||
|
||||
const [count, setCount] = useState<number>(0)
|
||||
|
||||
useEffect(() => {
|
||||
totalSearchResults().then((res) => {
|
||||
setCount(res)
|
||||
})
|
||||
}, [])
|
||||
|
||||
const getMinNum = (n1: number) => {
|
||||
return Math.min(n1, count)
|
||||
}
|
||||
|
||||
const data = useMemo(() => {
|
||||
const loading = iodSearch && iodLoading
|
||||
const text = loading ? "正" : "已"
|
||||
@@ -275,7 +288,7 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
|
||||
/>
|
||||
个{" "}
|
||||
</span>
|
||||
数据集,引用 3个 数据集作为参考
|
||||
数据集,引用 {getMinNum(currentIodMessage?.data.total ?? 0)}个 数据集作为参考
|
||||
</p>
|
||||
) : (
|
||||
""
|
||||
@@ -314,7 +327,7 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
|
||||
/>
|
||||
个{" "}
|
||||
</span>
|
||||
场景,引用 3个 场景作为参考
|
||||
场景,引用 {getMinNum(currentIodMessage?.scenario.total ?? 0)}个 场景作为参考
|
||||
</p>
|
||||
) : (
|
||||
""
|
||||
@@ -358,14 +371,14 @@ export const PlaygroundIodRelevant: React.FC<Props> = ({ className }) => {
|
||||
/>
|
||||
个{" "}
|
||||
</span>
|
||||
组织,引用 3个 组织作为参考
|
||||
组织,引用 {getMinNum(currentIodMessage?.organization.total ?? 0)}个 组织作为参考
|
||||
</p>
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
]
|
||||
}, [showSearchData, iodLoading])
|
||||
}, [showSearchData, iodLoading, count])
|
||||
|
||||
return (
|
||||
<Card
|
||||
|
||||
Reference in New Issue
Block a user