refactor(layout): 重构布局组件并添加视频播放功能

-重写 Header 组件,使用新的 OptionLayoutContext 替代 HistoryContext
- 新增 VideoPlayer 组件,用于播放视频
- 更新 Playground 组件,集成新的侧边栏和视频播放功能
- 重构 Layout 组件,支持新的选项布局
- 更新相关路由和导出导入逻辑,以支持上述更改
This commit is contained in:
zhaoweijie
2025-08-25 20:43:27 +08:00
parent c937694d8b
commit 901bc13526
4 changed files with 27 additions and 9 deletions

View File

@@ -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