- 新增 RotatingEquiv 组件,3秒间隔淡入淡出切换 - calcOfficialEquivList 返回所有匹配模型(含 Gemini 系列) - Packages 页面和 7 个 Home 模板全部适配轮播 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2 lines
8.3 KiB
JavaScript
2 lines
8.3 KiB
JavaScript
import{u as D,b as $,r as c,l as A,f as R,m as k,j as e,Q as o,L as W,s as z,z as v}from"./index-DFGOoM5s.js";import{c as I,R as Q}from"./RotatingEquiv-CHmr77Cm.js";import{u as T}from"./useTranslation-qO7M9u1f.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 G(){const{t:a}=T(),{user:l,refreshUser:S}=D(),_=$(),[L,q]=c.useState([]),[g,P]=c.useState([]),[M,C]=c.useState(!0),[d,h]=c.useState(null),[b,f]=c.useState([]),[i,m]=c.useState(null),p=s=>a(y[s]||y.never);c.useEffect(()=>{Promise.all([A().then(s=>{s.data.success&&q(s.data.data||[])}).catch(()=>{}),R().then(s=>{s.data.success&&P(s.data.data||[])}).catch(()=>{})]).finally(()=>C(!1))},[]),c.useEffect(()=>{l&&k().then(s=>{s.data.success&&f(s.data.data||[])}).catch(()=>{})},[l]);const F=async s=>{if(!l){_("/register");return}m(s)},E=async()=>{if(!i)return;const s=i.id;h(s);try{const n=await z(s);n.data.success?(v.success(a("packages.subscribedSuccess")),m(null),await S(),k().then(t=>{t.data.success&&f(t.data.data||[])}).catch(()=>{})):v.error(n.data.message||a("common.requestFailed"))}catch{}h(null)},B=c.useMemo(()=>g.filter(s=>s.enabled!==!1),[g]);if(M)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);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 n=s.amount_total||0,t=s.amount_used||0,r=Math.max(0,n-t),x=n>0?Math.min(100,t/n*100):0;return e.jsxs("div",{className:"glass rounded-xl p-4 border border-page-divider",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-page-success 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-page-surface 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:`${x}%`}})}),e.jsxs("span",{className:"text-xs text-page-secondary whitespace-nowrap",children:["$",(r/o).toFixed(2)," / $",(n/o).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(W,{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,n)=>{const t=s.quota_reset_period||"never",r=t!=="never",x=s.quota_amount>0?s.quota_amount/o:0,u=I(B,x);return e.jsx("div",{className:"glass rounded-2xl flex flex-col",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}),r&&e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-purple-500/10 text-page-info border border-purple-500/20",children:p(t)})]}),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:["$",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:["$",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})})]}),u.length>0&&e.jsx("div",{className:"bg-gradient-to-r from-amber-500/10 to-orange-500/10 border border-amber-500/20 rounded-xl p-3 mb-4",children:e.jsxs("p",{className:"text-xs text-page-warning font-medium",children:["🔥 ",e.jsx(Q,{items:u,text:N=>a("packages.officialEquiv",{model:N.label,amount:N.equivDollars})})]})}),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-page-success 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"})}),r?a("packages.periodicQuota",{amount:(s.quota_amount/o).toFixed(2),period:p(t)}):a("packages.creditIncluded",{amount:(s.quota_amount/o).toFixed(2)})]}),r&&e.jsxs("li",{className:"flex items-center gap-2 text-sm text-page-label",children:[e.jsx("svg",{className:"w-4 h-4 text-page-warning 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-page-success 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-page-success 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:()=>F(s),disabled:d===s.id,className:"btn-primary w-full text-center",children:d===s.id?a("packages.processing"):a(l?"packages.subscribeNow":"packages.signUpToSubscribe")})]})},s.id)})}),i&&(()=>{const s=((l==null?void 0:l.quota)||0)/o,n=Number(i.price),t=s<n,r=i.quota_reset_period||"never",x=r!=="never";return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>!d&&m(null),children:e.jsxs("div",{className:"glass rounded-2xl p-6 w-full max-w-sm",onClick:u=>u.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:i.name,price:n.toFixed(2)})}),x&&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-page-info",children:a("packages.subscriptionInfo",{period:p(r),days:i.duration||30,amount:(i.quota_amount/o).toFixed(2)})})}),e.jsxs("p",{className:"text-sm text-page-secondary mb-4",children:[a("packages.yourBalance")," ",e.jsxs("span",{className:`font-medium ${t?"text-page-danger":"text-page-success"}`,children:["$",s.toFixed(2)]})]}),t&&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-page-danger",children:a("packages.insufficientBalance")})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>m(null),disabled:d,className:"btn-secondary",children:a("tokens.cancel")}),e.jsx("button",{onClick:E,disabled:t||d,className:"btn-primary",children:a(d?"packages.processing":"packages.confirm")})]})]})})})()]})}export{G as default};
|