'use client'; import {useEffect,useRef,useState} from 'react'; import {FolderOpen,FileText,Download,X} from 'lucide-react'; import {downloadSkill} from '@/lib/lease-library'; export default function SkillPackageDialog({card,send,onClose}:any) { const dialog=useRef(null); const [data,setData]=useState(null),[error,setError]=useState(''),[file,setFile]=useState('SKILL.md'),[busy,setBusy]=useState(false); useEffect(()=>{dialog.current?.showModal(); let live=true; send('GET',`/library/skills/${encodeURIComponent(card.id)}/package`).then((result:any)=>{if(live)setData(result);}).catch((e:any)=>{if(live)setError(e.message);}); return()=>{live=false;}; },[card.id]); const entry=data?.files.find((item:any)=>item.path===file); async function openFolder(){setBusy(true);setError('');try{await send('POST',`/library/skills/${encodeURIComponent(card.id)}/open`,{});}catch(e:any){setError(e.message);}finally{setBusy(false);}} return
STANDARD SKILL PACKAGE

{card.name}

{data?.name || '正在读取标准文件夹…'} · v{card.version}

{error&&

{error}

} {data&&<>
{data.manifest.length} 个原始文件 · 哈希 {data.content_hash.slice(0,16)}

{file}

{entry?.text ?? '此文件是二进制资源,可下载标准包查看。'}

卡片对应实际托管文件夹。原始文件与版本哈希保留;scripts 仅保存,不会在导入时运行。

} {!data&&!error&&

正在读取文件清单…

}
; }