diff --git a/src/pages/KnowledgeAreasPage.tsx b/src/pages/KnowledgeAreasPage.tsx index e812d6b..db8c7bb 100644 --- a/src/pages/KnowledgeAreasPage.tsx +++ b/src/pages/KnowledgeAreasPage.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef } from 'react' import { Link, useParams } from 'react-router-dom' import { motion } from 'framer-motion' import { ArrowRight, FileText, Wrench, FileOutput } from 'lucide-react' @@ -13,11 +14,29 @@ const itemVariants = { visible: { opacity: 1, y: 0 }, } +// 跳过动画时的变体(立即显示) +const skipAnimationVariants = { + hidden: { opacity: 1, y: 0 }, + visible: { opacity: 1, y: 0 }, +} + export function KnowledgeAreasPage() { const { id } = useParams() const selectedKA = id ? knowledgeAreaMap.get(id) : null const processes = id ? processesByKnowledgeArea.get(id) || [] : [] + // 检测是否应该跳过动画(返回页面时) + const hasVisitedRef = useRef(false) + const shouldSkipAnimation = hasVisitedRef.current + + useEffect(() => { + // 标记已访问,下次渲染时跳过动画 + hasVisitedRef.current = true + }, []) + + // 根据是否跳过动画选择变体 + const activeItemVariants = shouldSkipAnimation ? skipAnimationVariants : itemVariants + if (selectedKA) { return (
@@ -59,7 +78,7 @@ export function KnowledgeAreasPage() { {processes.map((process) => { const pg = processGroupMap.get(process.processGroupId) return ( - + {knowledgeAreas.map((ka) => ( - +