1import{r as i,j as e}from"./react-vendor-BxoUhqX6.js";import{F as p}from"./file-text-CY3NwblJ.js";import{b as h,c as u,G as w,L as g,y}from"./index-Bj3wZDOH.js";import{S as b}from"./search-Dha66dDk.js";import"./clsx-B-dksMZM.js";import"./i18n-vendor-Coo-X0AG.js";const T=()=>{const{t:r}=h(),l=u(),[a,x]=i.useState(""),[c,o]=i.useState(!1),[n,d]=i.useState(null),m=async()=>{if(!a.trim()){l.warning(r("crawler.error.urlRequired"));return}o(!0),d(null);try{const s=await y("/mainserver/api/crawler",{method:"POST",body:JSON.stringify({url:a})});if(s.ok){const t=await s.json();d(t.content||t.html||r("crawler.result.empty"))}else{const t=await s.json();l.error(t.message||r("crawler.error.failed"))}}catch(s){console.error("æå失败:",s),l.error(r("crawler.error.failed"))}finally{o(!1)}};return e.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 mb-2",children:r("crawler.title")}),e.jsx("p",{className:"text-gray-500 mb-8",children:r("crawler.subtitle")}),e.jsx("div",{className:"bg-white rounded-xl border border-gray-200 p-6 mb-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(w,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400"}),e.jsx("input",{type:"url",value:a,onChange:s=>x(s.target.value),placeholder:"https://example.com",className:"w-full pl-10 pr-4 py-3 border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent",onKeyDown:s=>s.key==="Enter"&&m()})]}),e.jsxs("button",{onClick:m,disabled:c||!a.trim(),className:"px-6 py-3 bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-colors disabled:opacity-50 flex items-center gap-2",children:[c?e.jsx(g,{className:"w-5 h-5 animate-spin"}):e.jsx(b,{className:"w-5 h-5"}),r("crawler.button.crawl")]})]})}),n&&e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(p,{className:"w-5 h-5 text-primary-500"}),e.jsx("h3",{className:"font-semibold text-gray-800",children:r("crawler.section.result")})]}),e.jsx("pre",{className:"bg-gray-50 rounded-lg p-4 overflow-auto max-h-[500px] text-sm text-gray-700 whitespace-pre-wrap",children:n})]}),e.jsxs("div",{className:"mt-8 text-sm text-gray-500",children:[e.jsx("h4",{className:"font-medium text-gray-700 mb-2",children:r("crawler.section.help")}),e.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[e.jsx("li",{children:r("crawler.help.http")}),e.jsx("li",{children:r("crawler.help.extract")}),e.jsx("li",{children:r("crawler.help.robots")})]})]})]})};export{T as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.