PageSourceSearch

https://nickz.ai/assets/js/Detail-D1WrhRKL.js

js nickz.ai collected 2026-10-05 14:21:00 UTC 7,362 bytes, 1 lines download raw bytes

1import{i as e,r as s,j as t,L as r}from"./vendor-react-DejgYtBM.js";import{l as a}from"./vendor-semi-D8d7bTtM.js";import{u as n,s as l,v as i,w as d}from"./index-BeIIFw6E.js";import{b as o,c,d as m,r as x}from"./api-CrGMGlHj.js";import{f as h,s as b}from"./utils-BVu1rv8Y.js";import{J as u,U as f,$ as g,A as p,a3 as j,C as k,a2 as y}from"./vendor-icons-EJvJ5X-w.js";import{M as w}from"./index-B_PxGnmD.js";import"./vendor-motion-Chfy_MiU.js";function N(e){if(!e||!e.trimStart().startsWith("---"))return e;const s=e.trimStart(),t=s.indexOf("---",3);return-1===t?e:s.slice(t+3).trimStart()}function v(e){if(!e||"string"!=typeof e)return!1;const s=e.trim();if(!s)return!1;if(/^(javascript|data|vbscript|file):/i.test(s))return!1;if(s.startsWith("/")||s.startsWith("./")||s.startsWith("../")||s.startsWith("//"))return!0;if(!/^[a-z][a-z0-9+.-]*:/i.test(s))return!0;try{const e=new URL(s);return"http:"===e.protocol||"https:"===e.protocol}catch{return!1}}const z={a:function({href:e,children:s,...r}){return v(e)?t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",...r,children:s}):t.jsx("span",{...r,children:s})},img:function({src:e,alt:s,...r}){return v(e)?t.jsx("img",{src:e,alt:s||"",loading:"lazy",...r}):null}};function S(){const{t:S,i18n:F}=n(),L=F.language?.startsWith("en")?"en":"zh",{slug:C}=e(),[E,U]=s.useState(!0),[W,A]=s.useState(null),[I,_]=s.useState(""),[T,D]=s.useState(!1),[K,R]=s.useState(!1),[H,G]=s.useState([]);s.useEffect(()=>{if(!C)return;const e=new AbortController;let s=!1;return(async()=>{U(!0),R(!1);try{const t={signal:e.signal},[r,a,n]=await Promise.all([o(C,t),c(C,L,t),m(C,t)]);if(s)return;if(!r.success)return void l(r.message||S("加载失败"));A(r.data?.skill||null),_(a.data?.content||a.data?.originalContent||""),D(!!a.data?.isTranslated),R(!!a.data?.translating),G(n.data?.items||[]),x(C).catch(()=>{})}catch(t){if(s||"ERR_CANCELED"===t.code||"CanceledError"===t.name)return;l(t.message||S("加载失败"))}finally{s||U(!1)}})(),()=>{s=!0,e.abort()}},[C,L,S]),s.useEffect(()=>{if(!C||"zh"!==L||!K||T)return;let e=!1,s=0,t=null;const r=a=>{!e&&a&&(t=setTimeout(async()=>{const t=await(async()=>{if(s+=1,s>20)return e||R(!1),!1;try{const s=await c(C,"zh",{skipErrorHandler:!0});if(e||!s?.success)return!0;const t=s.data||{};t.content&&_(t.content);const r=!!t.isTranslated;D(r);const a=!!t.translating&&!r;return R(a),a}catch(t){const s=t?.response?.status;return 429!==s||(e||R(!1),!1)}})();r(t)},8e3))};return r(!0),()=>{e=!0,t&&clearTimeout(t)}},[C,L,K,T]);const J="zh"!==L?null:T?t.jsx("span",{className:"text-xs px-2.5 py-1 rounded-full bg-emerald-50 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300",children:S("已翻译")}):K?t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs px-2.5 py-1 rounded-full bg-amber-50 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",children:[t.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),S("翻译中")]}):t.jsx("span",{className:"text-xs px-2.5 py-1 rounded-full bg-gray-100 text-gray-600 dark:bg-white/10 dark:text-gray-300",children:S("暂无中文")});return E?t.jsx("div",{className:"flex justify-center py-24",children:t.jsx(a,{size:"large"})}):W?t.jsxs("div",{children:[t.jsxs(r,{to:"/skills/browse",className:"inline-flex items-center gap-2 text-sm text-gray-500 hover:text-[#0084FF] mb-6 transition-colors",children:[t.jsx(u,{size:16}),S("返回列表")]}),t.jsx("p",{className:"mb-4 text-xs text-gray-400 dark:text-gray-500",children:S("skill_disclaimer")}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_280px] gap-8 items-start",children:[t.jsxs("div",{children:[t.jsx("div",{className:"rounded-2xl border border-black/[0.06] dark:border-white/10 bg-white dark:bg-[#151b26] p-6 sm:p-8 shadow-sm",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-6",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h1",{className:"text-3xl font-bold text-[#181d27] dark:text-gray-50 break-words",children:W.name}),t.jsx("p",{className:"mt-3 text-base text-gray-500 dark:text-gray-400 leading-relaxed",children:W.description}),t.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-4 text-sm text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(f,{size:15}),W.author]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(g,{size:15,className:"text-amber-500"}),h(W.stars??0)]}),W.category&&t.jsxs("span",{children:["• ",S(W.category)]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(p,{size:15}),W.publishedAt?new Date(W.publishedAt).toLocaleDateString():"-"]})]})]}),t.jsx("div",{className:"shrink-0",children:v(W.coverImageUrl)?t.jsx("img",{src:W.coverImageUrl,alt:W.name,loading:"lazy",className:"w-32 h-32 rounded-2xl object-cover border border-black/[0.06]"}):t.jsx("div",{className:"w-32 h-32 rounded-2xl bg-gradient-to-br from-[#dbeafe] to-[#93c5fd] dark:from-[#1e3a5f] dark:to-[#172554] flex items-center justify-center text-4xl font-bold text-[#0084FF]",children:b(W.name)})})]})}),t.jsxs("div",{className:"mt-6 rounded-2xl border border-black/[0.06] dark:border-white/10 bg-white dark:bg-[#151b26] overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-black/[0.06] dark:border-white/10 bg-[#f9fafb] dark:bg-[#0f141d]",children:[t.jsx("span",{className:"font-mono text-sm font-semibold",children:"SKILL.md"}),J]}),t.jsx("div",{className:"p-6 skills-markdown prose dark:prose-invert max-w-none text-sm leading-relaxed",children:t.jsx(w,{components:z,children:N(I)})})]})]}),t.jsxs("aside",{className:"space-y-4 lg:sticky lg:top-24",children:[t.jsxs("div",{className:"rounded-2xl border border-black/[0.06] dark:border-white/10 bg-white dark:bg-[#151b26] p-4 shadow-sm space-y-2",children:[W.githubUrl&&v(W.githubUrl)&&t.jsxs("a",{href:W.githubUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full rounded-xl border border-black/[0.08] dark:border-white/10 px-4 py-3 text-sm font-medium hover:border-[#0084FF] hover:text-[#0084FF] transition-colors",children:[t.jsx(j,{size:16}),S("在 GitHub 查看")]}),t.jsxs("button",{type:"button",onClick:async()=>{await i(I)?d(S("已复制 SKILL.md")):l(S("复制失败"))},className:"flex items-center justify-center gap-2 w-full rounded-xl bg-[#0084FF] hover:bg-[#0070d9] text-white px-4 py-3 text-sm font-medium transition-colors",children:[t.jsx(k,{size:16}),S("复制 SKILL.md")]})]}),H?.length>0&&t.jsxs("div",{className:"rounded-2xl border border-black/[0.06] dark:border-white/10 bg-white dark:bg-[#151b26] p-4 shadow-sm",children:[t.jsxs("div",{className:"flex items-center gap-2 font-semibold text-sm mb-3",children:[t.jsx(y,{size:16}),S("目录结构")]}),t.jsx("ul",{className:"text-xs font-mono space-y-1.5 text-gray-500 dark:text-gray-400 max-h-64 overflow-y-auto",children:H.map((e,s)=>t.jsx("li",{className:"truncate",children:e.path||e.name},s))})]})]})]})]}):t.jsxs("div",{className:"py-16 text-center",children:[t.jsx("p",{className:"text-gray-500",children:S("Skill 不存在")}),t.jsx(r,{to:"/skills/browse",className:"inline-block mt-4 text-[#0084FF] hover:underline",children:S("返回列表")})]})}export{S 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.