ConfigExporter 模型下拉改为可搜索的自定义 combobox, 新增 config.searchModel / config.noModelMatch i18n 键。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2 lines
8.0 KiB
JavaScript
2 lines
8.0 KiB
JavaScript
import{u as A,a as D,b as E,r as l,l as W,m as k,j as e,Q as d,L as z,s as I,z as v}from"./index-EC_zKUeV.js";import{S as Q}from"./SpotlightCard-CLwtgnEt.js";import{u as R}from"./useTranslation-DATAnSaR.js";const y={never:"packages.resetNever",daily:"packages.resetDaily",weekly:"packages.resetWeekly",monthly:"packages.resetMonthly"};function w(a){return a?new Date(a*1e3).toLocaleDateString():""}function K(){const{t:a}=R(),{user:i,refreshUser:S}=A(),{site:p}=D(),x=(p==null?void 0:p.currency_symbol)||"¥",_=E(),[L,C]=l.useState([]),[P,F]=l.useState(!0),[o,h]=l.useState(null),[b,f]=l.useState([]),[n,m]=l.useState(null),u=s=>a(y[s]||y.never);l.useEffect(()=>{W().then(s=>{s.data.success&&C(s.data.data||[])}).catch(()=>{}).finally(()=>F(!1))},[]),l.useEffect(()=>{i&&k().then(s=>{s.data.success&&f(s.data.data||[])}).catch(()=>{})},[i]);const q=async s=>{if(!i){_("/register");return}m(s)},M=async()=>{if(!n)return;const s=n.id;h(s);try{const t=await I(s);t.data.success?(v.success(a("packages.subscribedSuccess")),m(null),await S(),k().then(r=>{r.data.success&&f(r.data.data||[])}).catch(()=>{})):v.error(t.data.message||a("common.requestFailed"))}catch{}h(null)};if(P)return 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"})});const j=L.filter(s=>s.enabled),N=["rgba(129,140,248,0.15)","rgba(192,132,252,0.15)","rgba(244,114,182,0.15)","rgba(34,197,94,0.15)"];return e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-10",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h1",{className:"text-3xl font-heading font-bold text-page mb-3",children:a("packages.title")}),e.jsx("p",{className:"text-page-secondary max-w-xl mx-auto",children:a("packages.subtitle")})]}),b.length>0&&e.jsxs("div",{className:"max-w-3xl mx-auto mb-10",children:[e.jsx("h2",{className:"text-lg font-semibold text-page mb-4",children:a("packages.mySubscriptions")}),e.jsx("div",{className:"space-y-3",children:b.map(s=>{const t=s.amount_total||0,r=s.amount_used||0,c=Math.max(0,t-r),g=t>0?Math.min(100,r/t*100):0;return e.jsxs("div",{className:"glass rounded-xl p-4 border border-neutral-800/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-page",children:a("packages.subscriptionId",{id:s.id})}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-green-500/10 text-green-400 border border-green-500/20",children:a("packages.active")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-page-secondary mb-3",children:[e.jsxs("span",{children:[a("packages.expires"),": ",w(s.end_time)]}),s.next_reset_time>0&&e.jsxs("span",{children:[a("packages.nextReset"),": ",w(s.next_reset_time)]})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("div",{className:"flex-1 h-2 bg-neutral-800 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-brand-500 to-purple-500 transition-all",style:{width:`${g}%`}})}),e.jsxs("span",{className:"text-xs text-page-secondary whitespace-nowrap",children:[x,(c/d).toFixed(2)," / ",x,(t/d).toFixed(2)]})]})]},s.id)})})]}),j.length===0?e.jsxs("div",{className:"text-center py-12 text-page-secondary",children:[e.jsx("p",{children:a("packages.noPackages")}),e.jsxs(z,{to:"/pricing",className:"text-page-link hover:text-page-link transition-colors mt-2 inline-block",children:[a("packages.checkPricing")," →"]})]}):e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6 max-w-5xl mx-auto",children:j.map((s,t)=>{const r=s.quota_reset_period||"never",c=r!=="never";return e.jsx(Q,{className:"!bg-neutral-900/60 !border-neutral-800/60 !p-0 !rounded-2xl flex flex-col",spotlightColor:N[t%N.length],children:e.jsxs("div",{className:"p-6 flex-1 flex flex-col",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-xl font-semibold text-page",children:s.name}),c&&e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-purple-500/10 text-purple-400 border border-purple-500/20",children:u(r)})]}),s.description&&e.jsx("p",{className:"text-sm text-page-secondary mt-1",children:s.description})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-4xl font-bold text-page",children:[x,Number(s.price).toFixed(2)]}),s.original_price>0&&s.original_price>s.price&&e.jsxs("span",{className:"text-lg text-page-muted line-through",children:[x,Number(s.original_price).toFixed(2)]})]}),s.duration>0&&e.jsx("p",{className:"text-sm text-page-muted mt-1",children:a("packages.daysAccess",{count:s.duration})})]}),e.jsxs("ul",{className:"space-y-2 mb-6 flex-1",children:[s.quota_amount>0&&e.jsxs("li",{className:"flex items-center gap-2 text-sm text-page-label",children:[e.jsx("svg",{className:"w-4 h-4 text-green-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),c?a("packages.periodicQuota",{amount:(s.quota_amount/d).toFixed(2),period:u(r)}):a("packages.creditIncluded",{amount:(s.quota_amount/d).toFixed(2)})]}),c&&e.jsxs("li",{className:"flex items-center gap-2 text-sm text-page-label",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),a("packages.unusedQuotaExpires")]}),e.jsxs("li",{className:"flex items-center gap-2 text-sm text-page-label",children:[e.jsx("svg",{className:"w-4 h-4 text-green-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),a("packages.allModels")]}),e.jsxs("li",{className:"flex items-center gap-2 text-sm text-page-label",children:[e.jsx("svg",{className:"w-4 h-4 text-green-500 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),a("packages.openaiApi")]})]}),e.jsx("button",{onClick:()=>q(s),disabled:o===s.id,className:"btn-primary w-full text-center",children:o===s.id?a("packages.processing"):a(i?"packages.subscribeNow":"packages.signUpToSubscribe")})]})},s.id)})}),n&&(()=>{const s=((i==null?void 0:i.quota)||0)/d,t=Number(n.price),r=s<t,c=n.quota_reset_period||"never",g=c!=="never";return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>!o&&m(null),children:e.jsxs("div",{className:"glass rounded-2xl p-6 w-full max-w-sm",onClick:B=>B.stopPropagation(),children:[e.jsx("h2",{className:"text-lg font-semibold text-page mb-3",children:a("packages.confirmTitle")}),e.jsx("p",{className:"text-sm text-page-secondary mb-2",children:a("packages.confirmDesc",{name:n.name,price:t.toFixed(2)})}),g&&e.jsx("div",{className:"bg-purple-500/10 border border-purple-500/20 rounded-xl p-3 mb-3",children:e.jsx("p",{className:"text-xs text-purple-300",children:a("packages.subscriptionInfo",{period:u(c),days:n.duration||30,amount:(n.quota_amount/d).toFixed(2)})})}),e.jsxs("p",{className:"text-sm text-page-secondary mb-4",children:[a("packages.yourBalance")," ",e.jsxs("span",{className:`font-medium ${r?"text-red-400":"text-green-400"}`,children:[x,s.toFixed(2)]})]}),r&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 rounded-xl p-3 mb-4",children:e.jsx("p",{className:"text-sm text-red-300",children:a("packages.insufficientBalance")})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>m(null),disabled:o,className:"btn-secondary",children:a("tokens.cancel")}),e.jsx("button",{onClick:M,disabled:r||o,className:"btn-primary",children:a(o?"packages.processing":"packages.confirm")})]})]})})})()]})}export{K as default};
|