import { useParams, Link, useLocation, useNavigate } from 'react-router-dom' import { motion } from 'framer-motion' import { ArrowLeft, ArrowRight, FileText, Wrench, FileOutput, LayoutGrid, Workflow, Eye, EyeOff, Info } from 'lucide-react' import { getProcessDetail, processes } from '@/data' import { useState, useEffect } from 'react' type IttoSection = 'inputs' | 'tools' | 'outputs' const STORAGE_KEY = 'ittoview:process-detail:itto-visibility' export function ProcessDetailPage() { const { id } = useParams() const location = useLocation() const navigate = useNavigate() const processDetail = id ? getProcessDetail(id) : null // ITTO 显示/隐藏状态管理 const [visible, setVisible] = useState>(() => { const defaultVisible = { inputs: true, tools: true, outputs: true } try { const raw = localStorage.getItem(STORAGE_KEY) if (!raw) return defaultVisible const parsed = JSON.parse(raw) // 数据校验:确保是对象且包含正确的键 if (typeof parsed !== 'object' || parsed === null) return defaultVisible return { inputs: typeof parsed.inputs === 'boolean' ? parsed.inputs : true, tools: typeof parsed.tools === 'boolean' ? parsed.tools : true, outputs: typeof parsed.outputs === 'boolean' ? parsed.outputs : true, } } catch { return defaultVisible } }) // 持久化状态 useEffect(() => { try { localStorage.setItem(STORAGE_KEY, JSON.stringify(visible)) } catch (error) { // 在隐私模式或受限环境下,localStorage 可能不可用 console.warn('无法保存 ITTO 显示状态:', error) } }, [visible]) const toggleSection = (key: IttoSection) => { setVisible(prev => ({ ...prev, [key]: !prev[key] })) } const allVisible = Object.values(visible).every(Boolean) const toggleAll = () => { const newState = !allVisible setVisible({ inputs: newState, tools: newState, outputs: newState }) } const fromMatrix = location.state?.from === 'matrix' const fromRoadmap = location.state?.from === 'roadmap' if (!processDetail) { return (

未找到该过程

返回知识领域
) } const ka = processDetail.knowledgeArea const pg = processDetail.processGroup const purpose = (processDetail as any).purpose const currentIndex = processes.findIndex(p => p.id === id) const prevProcess = currentIndex > 0 ? processes[currentIndex - 1] : null const nextProcess = currentIndex < processes.length - 1 ? processes[currentIndex + 1] : null return (
{/* 返回按钮 + 面包屑 */}
{fromMatrix && ( )} {fromRoadmap && ( )}
{/* 过程标题 - 更紧凑 */}
{processDetail.code}

{processDetail.name}

{processDetail.nameEn}

{ka && ( {ka.name} )} {pg && ( {pg.name} )}
{/* 主要作用 */} {purpose && (

主要作用

{purpose}

)} {/* 全局控制按钮 */} {/* ITTO表格 - 更紧凑 */} {/* 输入 */}

输入 ({processDetail.inputs.length})

{visible.inputs ? (
    {processDetail.inputDetails?.map((inputDetail: any) => { const hasDetail = inputDetail.detail && inputDetail.detail.length > 0 return (
  • {inputDetail.name || inputDetail.id}
    {inputDetail.nameEn &&
    {inputDetail.nameEn}
    } {hasDetail && (
    {inputDetail.detail.map((item: any, idx: number) => ( {item.label} {idx < inputDetail.detail.length - 1 && '、'} ))}
    )} {inputDetail.note && (
    💡 {inputDetail.note}
    )}
  • ) })}
) : (
)}
{/* 工具与技术 */}

工具与技术 ({processDetail.tools.length})

{visible.tools ? (
    {processDetail.toolDetails?.map((toolDetail: any) => { const hasDetail = toolDetail.detail && toolDetail.detail.length > 0 return (
  • {toolDetail.name || toolDetail.id}
    {toolDetail.nameEn &&
    {toolDetail.nameEn}
    } {hasDetail && (
    {toolDetail.detail.map((item: any, idx: number) => ( {item.label} {idx < toolDetail.detail.length - 1 && '、'} ))}
    )} {toolDetail.note && (
    💡 {toolDetail.note}
    )}
  • ) })}
) : (
)}
{/* 输出 */}

输出 ({processDetail.outputs.length})

{visible.outputs ? (
    {processDetail.outputDetails?.map((outputDetail: any) => { const hasDetail = outputDetail.detail && outputDetail.detail.length > 0 return (
  • {outputDetail.name || outputDetail.id}
    {outputDetail.nameEn &&
    {outputDetail.nameEn}
    } {hasDetail && (
    {outputDetail.detail.map((item: any, idx: number) => ( {item.label} {idx < outputDetail.detail.length - 1 && '、'} ))}
    )} {outputDetail.note && (
    💡 {outputDetail.note}
    )}
  • ) })}
) : (
)}
{/* 前后导航 - 更紧凑 */} {prevProcess ? (
上一个
{prevProcess.code} {prevProcess.name}
) :
} {nextProcess ? (
下一个
{nextProcess.code} {nextProcess.name}
) :
}
) }