Files
Sub-Router/dist/assets/Home-CQcmK1T0.js
T
abingyydsandClaude Sonnet 4.6 914ddf0a26 fix: 套餐购买系统修复 - 事务安全、购买记录、前端错误处理
- 新增 PackageOrder 模型,记录每次套餐购买的详细信息
- 将套餐扣费和充值操作改为数据库事务(原子操作),防止部分失败导致数据不一致
- 使用行级锁(FOR UPDATE)确保并发安全
- 添加 ErrInsufficientQuota 哨兵错误,提升错误处理可靠性
- 购买成功后记录操作日志(RecordLog)
- 前端 Packages.jsx 增加失败时的错误提示
- 分站模型管理和设置页面小幅修正

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 16:47:29 +09:00

2 lines
12 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{r as l,j as e,u as L,a as E,l as P,k as A,L as f}from"./index-p6W69obe.js";import{u as R,a as B,C as F}from"./CountUp-CtdzPrSF.js";import{u as I}from"./use-animation-frame-C1v8ASnf.js";import{m as k}from"./proxy-BR1ftHr9.js";import{S as T}from"./SpotlightCard-QennJ1uf.js";import{u as V}from"./useTranslation-BUy5R_Pw.js";function _({children:t,className:n="",colors:o=["#5227FF","#FF9FFC","#B19EEF"],animationSpeed:i=8,showBorder:a=!1,direction:r="horizontal",pauseOnHover:c=!1,yoyo:x=!0}){const[s,g]=l.useState(!1),u=R(0),j=l.useRef(0),m=l.useRef(null),p=i*1e3;I(d=>{if(s){m.current=null;return}if(m.current===null){m.current=d;return}const M=d-m.current;if(m.current=d,j.current+=M,x){const z=p*2,h=j.current%z;h<p?u.set(h/p*100):u.set(100-(h-p)/p*100)}else u.set(j.current/p*100)}),l.useEffect(()=>{j.current=0,u.set(0)},[i,u,x]);const w=B(u,d=>r==="horizontal"?`${d}% 50%`:r==="vertical"?`50% ${d}%`:`${d}% 50%`),v=l.useCallback(()=>{c&&g(!0)},[c]),S=l.useCallback(()=>{c&&g(!1)},[c]),C=r==="horizontal"?"to right":r==="vertical"?"to bottom":"to bottom right",N=[...o,o[0]].join(", "),y={backgroundImage:`linear-gradient(${C}, ${N})`,backgroundSize:r==="horizontal"?"300% 100%":r==="vertical"?"100% 300%":"300% 300%",backgroundRepeat:"repeat"};return e.jsxs(k.div,{className:`relative mx-auto flex max-w-fit flex-row items-center justify-center rounded-[1.25rem] font-medium backdrop-blur transition-shadow duration-500 overflow-hidden cursor-pointer ${a?"py-1 px-2":""} ${n}`,onMouseEnter:v,onMouseLeave:S,children:[a&&e.jsx(k.div,{className:"absolute inset-0 z-0 pointer-events-none rounded-[1.25rem]",style:{...y,backgroundPosition:w},children:e.jsx("div",{className:"absolute bg-black rounded-[1.25rem] z-[-1]",style:{width:"calc(100% - 2px)",height:"calc(100% - 2px)",left:"50%",top:"50%",transform:"translate(-50%, -50%)"}})}),e.jsx(k.div,{className:"inline-block relative z-2 text-transparent bg-clip-text",style:{...y,backgroundPosition:w,WebkitBackgroundClip:"text"},children:t})]})}const W=(t,n)=>{const o=new Set([...Object.keys(t),...n.flatMap(a=>Object.keys(a))]),i={};return o.forEach(a=>{i[a]=[t[a],...n.map(r=>r[a])]}),i},G=({text:t="",delay:n=200,className:o="",animateBy:i="words",direction:a="top",threshold:r=.1,rootMargin:c="0px",animationFrom:x,animationTo:s,easing:g=m=>m,onAnimationComplete:u,stepDuration:j=.35})=>{const m=i==="words"?t.split(" "):t.split(""),[p,w]=l.useState(!1),v=l.useRef(null);l.useEffect(()=>{if(!v.current)return;const h=new IntersectionObserver(([b])=>{b.isIntersecting&&(w(!0),h.unobserve(v.current))},{threshold:r,rootMargin:c});return h.observe(v.current),()=>h.disconnect()},[r,c]);const S=l.useMemo(()=>a==="top"?{filter:"blur(10px)",opacity:0,y:-50}:{filter:"blur(10px)",opacity:0,y:50},[a]),C=l.useMemo(()=>[{filter:"blur(5px)",opacity:.5,y:a==="top"?5:-5},{filter:"blur(0px)",opacity:1,y:0}],[a]),N=x??S,y=s??C,d=y.length+1,M=j*(d-1),z=Array.from({length:d},(h,b)=>d===1?0:b/(d-1));return e.jsx("p",{ref:v,className:`blur-text ${o} flex flex-wrap`,children:m.map((h,b)=>{const D=W(N,y),$={duration:M,times:z,delay:b*n/1e3};return $.ease=g,e.jsxs(k.span,{className:"inline-block will-change-[transform,filter,opacity]",initial:N,animate:p?D:N,transition:$,onAnimationComplete:b===m.length-1?u:void 0,children:[h===" "?" ":h,i==="words"&&b<m.length-1&&" "]},b)})})},U=({as:t="button",className:n="",color:o="white",speed:i="6s",thickness:a=1,children:r,...c})=>e.jsxs(t,{className:`relative inline-block overflow-hidden rounded-[20px] ${n}`,style:{padding:`${a}px 0`,...c.style},...c,children:[e.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0",style:{background:`radial-gradient(circle, ${o}, transparent 10%)`,animationDuration:i}}),e.jsx("div",{className:"absolute w-[300%] h-[50%] opacity-70 top-[-10px] left-[-250%] rounded-full animate-star-movement-top z-0",style:{background:`radial-gradient(circle, ${o}, transparent 10%)`,animationDuration:i}}),e.jsx("div",{className:"relative z-1 bg-gradient-to-b from-black to-gray-900 border border-gray-800 text-white text-center text-[16px] py-[16px] px-[26px] rounded-[20px]",children:r})]});function Q(){const{t}=V(),{user:n}=L(),{site:o}=E(),[i,a]=l.useState([]),[r,c]=l.useState([]);l.useEffect(()=>{P().then(s=>{s.data.success&&a(s.data.data||[])}).catch(()=>{}),A().then(s=>{s.data.success&&c(s.data.data||[])}).catch(()=>{})},[]);const x=i.filter(s=>s.enabled!==!1);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-[800px] h-[600px] bg-gradient-radial from-brand-600/20 via-purple-600/5 to-transparent blur-3xl"}),e.jsx("div",{className:"absolute top-[400px] right-0 w-[500px] h-[500px] bg-gradient-radial from-pink-600/10 to-transparent blur-3xl"})]}),e.jsxs("section",{className:"relative max-w-7xl mx-auto px-6 pt-24 pb-20",children:[e.jsxs("div",{className:"text-center max-w-4xl mx-auto",children:[e.jsx("div",{className:"mb-6",children:e.jsx(_,{colors:["#818cf8","#c084fc","#f472b6","#818cf8"],animationSpeed:6,className:"text-5xl md:text-7xl font-extrabold leading-tight tracking-tight",children:(o==null?void 0:o.name)||t("home.defaultHeroTitle")})}),e.jsx(G,{text:t("home.heroSubtitle"),className:"text-lg md:text-xl text-neutral-400 max-w-2xl mx-auto mb-10 leading-relaxed",delay:50,animateBy:"words"}),e.jsx("div",{className:"flex items-center justify-center gap-4",children:n?e.jsx(f,{to:"/dashboard",children:e.jsx(U,{as:"div",color:"#818cf8",speed:"5s",children:t("home.goToDashboard")})}):e.jsxs(e.Fragment,{children:[e.jsx(f,{to:"/register",className:"btn-primary text-base !px-8 !py-3",children:t("home.getStarted")}),e.jsx(f,{to:"/pricing",className:"btn-secondary text-base !px-8 !py-3",children:t("home.viewPricing")})]})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-6 max-w-xl mx-auto mt-20",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-3xl font-bold text-white",children:[e.jsx(F,{from:0,to:x.length||50,duration:2,separator:""}),"+"]}),e.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:t("home.aiModels")})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-3xl font-bold text-white",children:[e.jsx(F,{from:0,to:99.9,duration:2.5}),"%"]}),e.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:t("home.uptime")})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-3xl font-bold text-white",children:["<",e.jsx(F,{from:200,to:50,duration:2,direction:"down"}),"ms"]}),e.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:t("home.latency")})]})]})]}),e.jsxs("section",{className:"relative max-w-7xl mx-auto px-6 py-20",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h2",{className:"text-3xl font-bold text-white mb-3",children:t("home.whyChooseUs")}),e.jsx("p",{className:"text-neutral-400",children:t("home.whyChooseUsDesc")})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(T,{className:"!bg-neutral-900/60 !border-neutral-800/60",spotlightColor:"rgba(129,140,248,0.15)",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-brand-500/10 flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-6 h-6 text-brand-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("home.lightningFast")}),e.jsx("p",{className:"text-sm text-neutral-400 leading-relaxed",children:t("home.lightningFastDesc")})]}),e.jsxs(T,{className:"!bg-neutral-900/60 !border-neutral-800/60",spotlightColor:"rgba(192,132,252,0.15)",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/10 flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-6 h-6 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("home.securePrivate")}),e.jsx("p",{className:"text-sm text-neutral-400 leading-relaxed",children:t("home.securePrivateDesc")})]}),e.jsxs(T,{className:"!bg-neutral-900/60 !border-neutral-800/60",spotlightColor:"rgba(244,114,182,0.15)",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-pink-500/10 flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-6 h-6 text-pink-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("home.payAsYouGo")}),e.jsx("p",{className:"text-sm text-neutral-400 leading-relaxed",children:t("home.payAsYouGoDesc")})]})]})]}),x.length>0&&e.jsxs("section",{className:"relative max-w-7xl mx-auto px-6 py-20",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h2",{className:"text-3xl font-bold text-white mb-3",children:t("home.availableModels")}),e.jsx("p",{className:"text-neutral-400",children:t("home.availableModelsDesc",{count:x.length})})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3",children:x.slice(0,12).map((s,g)=>e.jsxs("div",{className:"glass-sm px-4 py-3 flex items-center gap-3 hover:bg-white/[0.06] transition-colors group",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-neutral-300 group-hover:text-white transition-colors truncate",children:s.display_name||s.model_name})]},s.id||g))}),x.length>12&&e.jsx("div",{className:"text-center mt-6",children:e.jsxs(f,{to:"/pricing",className:"text-sm text-brand-400 hover:text-brand-300 transition-colors",children:[t("home.viewAllModels",{count:x.length})," →"]})})]}),r.length>0&&e.jsxs("section",{className:"relative max-w-7xl mx-auto px-6 py-20",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h2",{className:"text-3xl font-bold text-white mb-3",children:t("home.plansPackages")}),e.jsx("p",{className:"text-neutral-400",children:t("home.choosePlan")})]}),e.jsx("div",{className:"grid md:grid-cols-3 gap-6 max-w-4xl mx-auto",children:r.filter(s=>s.enabled).slice(0,3).map(s=>e.jsxs("div",{className:"glass rounded-2xl p-6 flex flex-col hover:border-brand-500/30 transition-colors",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-1",children:s.name}),s.description&&e.jsx("p",{className:"text-sm text-neutral-400 mb-4",children:s.description}),e.jsxs("div",{className:"mt-auto pt-4",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsxs("span",{className:"text-3xl font-bold text-white",children:["$",s.price]}),s.original_price>s.price&&e.jsxs("span",{className:"text-sm text-neutral-500 line-through",children:["$",s.original_price]})]}),s.duration>0&&e.jsx("p",{className:"text-xs text-neutral-500 mt-1",children:t("home.days",{count:s.duration})})]}),e.jsx(f,{to:n?"/packages":"/register",className:"btn-primary text-center mt-4 !py-2",children:t(n?"home.subscribe":"home.getStarted")})]},s.id))})]}),e.jsx("section",{className:"relative max-w-7xl mx-auto px-6 py-24",children:e.jsxs("div",{className:"glass rounded-3xl p-12 text-center relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-brand-600/10 via-transparent to-purple-600/10"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("h2",{className:"text-3xl font-bold text-white mb-4",children:t("home.readyToStart")}),e.jsx("p",{className:"text-neutral-400 mb-8 max-w-md mx-auto",children:t("home.readyToStartDesc")}),e.jsx("div",{className:"flex items-center justify-center gap-4",children:n?e.jsx(f,{to:"/dashboard",className:"btn-primary text-base !px-8 !py-3",children:t("home.goToDashboard")}):e.jsxs(e.Fragment,{children:[e.jsx(f,{to:"/register",className:"btn-primary text-base !px-8 !py-3",children:t("home.createFreeAccount")}),e.jsx(f,{to:"/login",className:"btn-secondary text-base !px-8 !py-3",children:t("home.signIn")})]})})]})]})})]})}export{Q as default};