- 价格表单位从 "per 1K tokens" 改为 "per 1M tokens"(价格×1000显示) - 移除 footer "Powered by SubRouter" 字样 - 默认站名从 "SubRouter" 改为 "AI Platform" - HTML title 从 "SubRouter Dist Site" 改为 "AI Platform" - 分站不再包含任何主站品牌标识 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2 lines
7.1 KiB
JavaScript
2 lines
7.1 KiB
JavaScript
import{r as a,h as D,j as e,z as o,i as I,k as A,l as P}from"./index-CJw6IpTa.js";function z(){const[x,N]=a.useState([]),[g,u]=a.useState(!0),[v,l]=a.useState(!1),[m,h]=a.useState(""),[p,b]=a.useState(!1),[w,j]=a.useState(null),[c,y]=a.useState(null),[i,d]=a.useState(null),n=a.useCallback(async()=>{u(!0);try{const s=await D();s.data.success&&N(s.data.data||[])}catch{}u(!1)},[]);a.useEffect(()=>{n()},[n]);const k=async s=>{var r;if(s.preventDefault(),!m.trim()){o.error("Please enter a name");return}b(!0);try{const t=await I({name:m.trim()});if(t.data.success){h(""),l(!1);const f=(r=t.data.data)==null?void 0:r.key;f&&y(f),await n()}}catch{}b(!1)},C=async s=>{try{(await A(s.id,{status:s.status===1?2:1})).data.success&&(o.success(s.status===1?"Token disabled":"Token enabled"),await n())}catch{}},T=async()=>{if(i)try{(await P(i.id)).data.success&&(o.success("Token deleted"),d(null),await n())}catch{}},S=async s=>{try{await navigator.clipboard.writeText(s)}catch{const t=document.createElement("textarea");t.value=s,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}j(s),o.success("Copied to clipboard!"),setTimeout(()=>j(null),2e3)};return g?e.jsx("div",{className:"flex items-center justify-center min-h-[50vh]",children:e.jsx("div",{className:"w-8 h-8 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}):e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-heading font-bold text-white",children:"API Keys"}),e.jsx("p",{className:"text-sm text-neutral-400 mt-1",children:"Manage your API access tokens"})]}),e.jsx("button",{onClick:()=>l(!0),className:"btn-primary",children:"+ New Key"})]}),v&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>l(!1),children:e.jsxs("div",{className:"glass rounded-2xl p-6 w-full max-w-md",onClick:s=>s.stopPropagation(),children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-4",children:"Create API Key"}),e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-neutral-300 mb-1.5",children:"Name"}),e.jsx("input",{type:"text",value:m,onChange:s=>h(s.target.value),className:"input",placeholder:"e.g. my-app-key",autoFocus:!0,required:!0})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>l(!1),className:"btn-secondary",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"btn-primary",children:p?"Creating...":"Create"})]})]})]})}),c&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"glass rounded-2xl p-6 w-full max-w-lg",children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-2",children:"Your New API Key"}),e.jsx("div",{className:"bg-yellow-500/10 border border-yellow-500/20 rounded-xl p-3 mb-4",children:e.jsx("p",{className:"text-sm text-yellow-300",children:"This is the only time you'll see this key. Copy it now and store it securely."})}),e.jsxs("div",{className:"bg-black/40 rounded-xl p-4 flex items-center gap-3",children:[e.jsx("code",{className:"text-sm font-mono text-green-400 flex-1 break-all select-all",children:c}),e.jsx("button",{onClick:()=>S(c),className:"btn-primary !px-4 !py-1.5 flex-shrink-0",children:w===c?"Copied!":"Copy"})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>y(null),className:"btn-secondary",children:"I've saved my key"})})]})}),i&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>d(null),children:e.jsxs("div",{className:"glass rounded-2xl p-6 w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[e.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Delete Token"}),e.jsxs("p",{className:"text-sm text-neutral-400 mb-4",children:["Delete ",e.jsxs("span",{className:"text-white font-medium",children:['"',i.name,'"']}),"? This cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>d(null),className:"btn-secondary",children:"Cancel"}),e.jsx("button",{onClick:T,className:"px-6 py-2.5 rounded-xl bg-red-600 text-white text-sm font-medium hover:bg-red-500 transition-colors",children:"Delete"})]})]})}),x.length===0?e.jsxs("div",{className:"glass rounded-2xl p-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-neutral-800/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-neutral-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"})})}),e.jsx("p",{className:"text-neutral-400 mb-4",children:"No API keys yet"}),e.jsx("button",{onClick:()=>l(!0),className:"btn-primary",children:"Create Your First Key"})]}):e.jsx("div",{className:"space-y-3",children:x.map(s=>e.jsxs("div",{className:"glass-sm rounded-xl p-5 flex items-center gap-4",children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${s.status===1?"bg-green-500":"bg-neutral-600"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-white",children:s.name}),e.jsx("p",{className:"text-xs font-mono text-neutral-500 mt-1",children:"sk-***"})]}),e.jsx("span",{className:"text-xs text-neutral-500 hidden md:block",children:s.created_time?new Date(s.created_time*1e3).toLocaleDateString():""}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>C(s),className:`px-3 py-1 text-xs rounded-lg border transition-colors ${s.status===1?"border-green-500/30 text-green-400 hover:bg-green-500/10":"border-neutral-600 text-neutral-400 hover:bg-neutral-800"}`,children:s.status===1?"Enabled":"Disabled"}),e.jsx("button",{onClick:()=>d(s),className:"px-3 py-1 text-xs rounded-lg border border-red-500/20 text-red-400 hover:bg-red-500/10 transition-colors",children:"Delete"})]})]},s.id))}),e.jsxs("div",{className:"glass rounded-2xl p-6 mt-8",children:[e.jsx("h3",{className:"text-sm font-semibold text-white mb-3",children:"Quick Start"}),e.jsxs("div",{className:"bg-black/40 rounded-xl p-4 font-mono text-sm",children:[e.jsx("p",{className:"text-neutral-500",children:"# Use your API key with OpenAI-compatible endpoint"}),e.jsxs("p",{className:"text-green-400 mt-2",children:["curl ",window.location.origin,"/v1/chat/completions \\"]}),e.jsx("p",{className:"text-neutral-300 pl-4",children:'-H "Authorization: Bearer sk-your-key" \\'}),e.jsx("p",{className:"text-neutral-300 pl-4",children:'-H "Content-Type: application/json" \\'}),e.jsxs("p",{className:"text-neutral-300 pl-4",children:["-d '",'{"model":"gpt-4o","messages":[{"role":"user","content":"Hello!"}]}',"'"]})]})]})]})}export{z as default};
|