PageSourceSearch

https://nickz.ai/assets/js/index-B4y_ypAy.js

js nickz.ai collected 2026-10-05 14:20:49 UTC 14,716 bytes, 1 lines download raw bytes

1import{r as e,j as s}from"./vendor-react-DejgYtBM.js";import{f as l,L as a,m as r,p as i,i as t,o as d,B as c,M as n}from"./vendor-semi-D8d7bTtM.js";import{u as o,A as x,s as m,C as h}from"./index-BeIIFw6E.js";import{S as u,D as f,U as j,k as p,L as g,p as N,q as v,r as b,h as y,s as w,I as z}from"./vendor-icons-EJvJ5X-w.js";import"./vendor-motion-Chfy_MiU.js";const S=()=>{const{t:S}=o(),[k,L]=e.useState(!1),[M,C]=e.useState(!1),[Q,I]=e.useState({status:!1,root_init:!1,database_type:""}),{Text:P,Title:_}=l,R=e.useRef(null),[F,T]=e.useState({username:"",password:"",confirmPassword:"",usageMode:"external"});e.useEffect(()=>{E()},[]);const E=async()=>{try{const e=await x.get("/api/setup"),{success:s,data:l}=e.data;s?(I(l),l.status&&(window.location.href="/")):m(S("获取初始化状态失败"))}catch(e){console.error("Failed to fetch setup status:",e),m(S("获取初始化状态失败"))}};return s.jsxs("div",{className:"bg-gray-50",children:[s.jsx(a,{children:s.jsx(a.Content,{children:s.jsx("div",{className:"flex justify-center px-4 py-8",children:s.jsx("div",{className:"w-full max-w-3xl",children:s.jsxs(r,{className:"!rounded-2xl shadow-lg border-0",children:[s.jsxs(r,{className:"!rounded-2xl !border-0 !shadow-2xl overflow-hidden mb-6",style:{background:"linear-gradient(135deg, #f97316 0%, #f59e0b 25%, #f43f5e 50%, #ec4899 75%, #e879f9 100%)",position:"relative"},bodyStyle:{padding:0},children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute -top-10 -right-10 w-40 h-40 bg-white opacity-10 rounded-full"}),s.jsx("div",{className:"absolute -bottom-16 -left-16 w-48 h-48 bg-white opacity-5 rounded-full"}),s.jsx("div",{className:"absolute top-1/2 right-1/4 w-24 h-24 bg-yellow-400 opacity-10 rounded-full"})]}),s.jsxs("div",{className:"relative py-5 px-6 flex items-center",style:{color:"white"},children:[s.jsx("div",{className:"w-14 h-14 rounded-full bg-white bg-opacity-20 flex items-center justify-center mr-5 shadow-lg flex-shrink-0",children:s.jsx(u,{size:20,style:{color:"white"}})}),s.jsxs("div",{className:"text-left",children:[s.jsx(_,{heading:3,style:{color:"white",marginBottom:"2px"},children:S("系统初始化")}),s.jsx(P,{style:{color:"rgba(255, 255, 255, 0.9)",fontSize:"15px"},children:S("欢迎使用,请完成以下设置以开始使用系统")})]})]}),"sqlite"===Q.database_type&&s.jsx("div",{className:"px-4",children:s.jsx(i,{type:"warning",icon:s.jsx("div",{className:"w-12 h-12 rounded-lg bg-orange-50 flex items-center justify-center",children:s.jsx(f,{size:22,className:"text-orange-500"})}),closeIcon:null,title:s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"font-medium",children:S("数据库警告")}),s.jsx(t,{color:"orange",shape:"circle",className:"ml-2",children:"SQLite"})]}),description:s.jsxs("div",{children:[s.jsx("p",{children:S("您正在使用 SQLite 数据库。如果您在容器环境中运行,请确保已正确设置数据库文件的持久化映射,否则容器重启后所有数据将丢失!")}),s.jsx("p",{className:"mt-1",children:s.jsx("strong",{children:S("建议在生产环境中使用 MySQL 或 PostgreSQL 数据库,或确保 SQLite 数据库文件已映射到宿主机的持久化存储。")})})]}),className:"!rounded-xl mb-6",fullMode:!1,bordered:!0})}),"mysql"===Q.database_type&&s.jsx("div",{className:"px-4",children:s.jsx(i,{type:"info",icon:s.jsx("div",{className:"w-12 h-12 rounded-lg bg-blue-50 flex items-center justify-center",children:s.jsx(f,{size:22,className:"text-blue-500"})}),closeIcon:null,title:s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"font-medium",children:S("数据库信息")}),s.jsx(t,{color:"blue",shape:"circle",className:"ml-2",children:"MySQL"})]}),description:s.jsx("div",{children:s.jsx("p",{children:S("您正在使用 MySQL 数据库。MySQL 是一个可靠的关系型数据库管理系统,适合生产环境使用。")})}),className:"!rounded-xl mb-6",fullMode:!1,bordered:!0})}),"postgres"===Q.database_type&&s.jsx("div",{className:"px-4",children:s.jsx(i,{type:"success",icon:s.jsx("div",{className:"w-12 h-12 rounded-lg bg-green-50 flex items-center justify-center",children:s.jsx(f,{size:22,className:"text-green-500"})}),closeIcon:null,title:s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"font-medium",children:S("数据库信息")}),s.jsx(t,{color:"green",shape:"circle",className:"ml-2",children:"PostgreSQL"})]}),description:s.jsx("div",{children:s.jsx("p",{children:S("您正在使用 PostgreSQL 数据库。PostgreSQL 是一个功能强大的开源关系型数据库系统,提供了出色的可靠性和数据完整性,适合生产环境使用。")})}),className:"!rounded-xl mb-6",fullMode:!1,bordered:!0}
1)})]}),s.jsxs(d,{getFormApi:e=>{R.current=e},initValues:F,children:[s.jsxs(r,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[s.jsxs("div",{className:"flex items-center mb-4 p-6 rounded-xl",style:{background:"linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%)",position:"relative"},children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute -top-10 -right-10 w-40 h-40 bg-white opacity-5 rounded-full"}),s.jsx("div",{className:"absolute -bottom-8 -left-8 w-24 h-24 bg-white opacity-10 rounded-full"})]}),s.jsx("div",{className:"w-10 h-10 rounded-full bg-white/20 flex items-center justify-center mr-4 relative",children:s.jsx(j,{size:20,style:{color:"#ffffff"}})}),s.jsxs("div",{className:"relative",children:[s.jsx(P,{style:{color:"#ffffff"},className:"text-lg font-medium",children:S("管理员账号")}),s.jsx("div",{style:{color:"#ffffff"},className:"text-sm opacity-80",children:S("设置系统管理员的登录信息")})]})]}),Q.root_init?s.jsx(s.Fragment,{children:s.jsx(i,{type:"info",icon:s.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-50 flex items-center justify-center",children:s.jsx(p,{size:20,className:"text-blue-500"})}),closeIcon:null,description:s.jsx("div",{className:"flex items-center",children:s.jsx("span",{children:S("管理员账号已经初始化过,请继续设置其他参数")})}),className:"!rounded-lg"})}):s.jsxs(s.Fragment,{children:[s.jsx(d.Input,{field:"username",label:S("用户名"),placeholder:S("请输入管理员用户名"),prefix:s.jsx(j,{size:16}),showClear:!0,size:"large",className:"mb-4 !rounded-lg",noLabel:!1,validateStatus:"default",onChange:e=>T({...F,username:e})}),s.jsx(d.Input,{field:"password",label:S("密码"),placeholder:S("请输入管理员密码"),type:"password",prefix:s.jsx(g,{size:16}),showClear:!0,size:"large",className:"mb-4 !rounded-lg",noLabel:!1,mode:"password",validateStatus:"default",onChange:e=>T({...F,password:e})}),s.jsx(d.Input,{field:"confirmPassword",label:S("确认密码"),placeholder:S("请确认管理员密码"),type:"password",prefix:s.jsx(g,{size:16}),showClear:!0,size:"large",className:"!rounded-lg",noLabel:!1,mode:"password",validateStatus:"default",onChange:e=>T({...F,confirmPassword:e})})]})]}),s.jsxs(r,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[s.jsxs("div",{className:"flex items-center mb-4 p-6 rounded-xl",style:{background:"linear-gradient(135deg, #4c1d95 0%, #6d28d9 50%, #7c3aed 100%)",position:"relative"},children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute -top-10 -right-10 w-40 h-40 bg-white opacity-5 rounded-full"}),s.jsx("div",{className:"absolute -bottom-8 -left-8 w-24 h-24 bg-white opacity-10 rounded-full"})]}),s.jsx("div",{className:"w-10 h-10 rounded-full bg-white/20 flex items-center justify-center mr-4 relative",children:s.jsx(N,{size:22,style:{color:"#ffffff"}})}),s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx(P,{style:{color:"#ffffff"},className:"text-lg font-medium",children:S("使用模式")}),s.jsx(c,{theme:"borderless",type:"tertiary",icon:s.jsx(v,{size:14,style:{color:"#ffffff"}}),size:"small",onClick:()=>C(!0),className:"!rounded-full"})]}),s.jsx("div",{style:{color:"#ffffff"},className:"text-sm opacity-80",children:S("选择适合您使用场景的模式")})]})]}),s.jsx(d.RadioGroup,{field:"usageMode",noLabel:!0,initValue:"external",onChange:e=>{T({...F,usageMode:e})},type:"pureCard",className:"[&_.semi-radio-addon-buttonRadio-wrapper]:!rounded-xl",validateStatus:"default",children:s.jsxs("div",{className:"space-y-3 mt-2",children:[s.jsx(d.Radio,{value:"external",className:"!p-4 !rounded-xl hover:!bg-blue-50 transition-colors w-full",extra:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-50 flex items-center justify-center mr-3 flex-shrink-0",children:s.jsx(b,{size:20,className:"text-blue-500"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"font-medium text-gray-900 mb-1",children:S("对外运营模式")}),s.jsx("div",{className:"text-sm text-gray-500",children:S("适用于为多个用户提供服务的场景")}),s.jsx(t,{color:"blue",shape:"circle",className:"mt-2",children:S("默认模式")})]})]})}),s.jsx(d.Radio,{value:"self",className:"!p-4 !rounded-xl hover:!bg-green-50 transition-colors w-full",extra:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-green-50 flex items-center justify-center mr-3 flex-shrink-0",children:s.jsx(y,{size:20,className:"text-green-500"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"font-medium text-gray-900 mb-1",children:S("自用模式")}),s.jsx("div",{className:"text-sm text-gray-500",children:S("适用于个人使用的场景,不需要设置模型价格")}),s.jsx(t,{color:"green",shape:"circle",className:"mt-2",children:S("无需计费")})]})]})}),s.jsx(d.Radio,{value:"demo",className:"!p-4 !rounded-xl hover:!bg-purple-50 transition-colors w-full",extra:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-purple-50 flex items-center justify-center mr-3 flex-shrink-0",children:s.jsx(w,{size:20,className:"text-purple-500"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"font-medium text-gray-900 mb-1",children:S("演示站点模式")}),s.jsx("div",{className:"text-sm text-gray-500",children:S("适用于展示系统功能的场景,提供基础功能演示")}),s.jsx(t,{color:"purple",shape:"circle",className:"mt-2",children:S("演示体验")})]})]})})]})})]})]}),s.jsx("div",{className:"flex justify-center mt-6",children:s.jsx(c,{type:"primary",onClick:()=>
1{if(!R.current)return console.error("Form reference is null"),void m(S("表单引用错误,请刷新页面重试"));const e=R.current.getValues();if(!Q.root_init){if(!e.username||!e.username.trim())return void m(S("请输入管理员用户名"));if(!e.password||e.password.length<8)return void m(S("密码长度至少为8个字符"));if(e.password!==e.confirmPassword)return void m(S("两次输入的密码不一致"))}const s={...e};s.SelfUseModeEnabled="self"===e.usageMode,s.DemoSiteEnabled="demo"===e.usageMode,delete s.usageMode,L(!0),x.post("/api/setup",s).then(e=>{const{success:s,message:l}=e.data;e.data,s?(h(S("系统初始化成功,正在跳转...")),setTimeout(()=>{window.location.reload()},1500)):m(l||S("初始化失败,请重试"))}).catch(e=>{console.error("API error:",e),m(S("系统初始化失败,请重试")),L(!1)}).finally(()=>{})},loading:k,size:"large",className:"!rounded-lg !bg-gradient-to-r !from-orange-500 !to-pink-500 hover:!from-orange-600 hover:!to-pink-600 !border-0 !px-8",icon:s.jsx(p,{size:16}),children:S("初始化系统")})})]})})})})}),s.jsx(n,{title:s.jsxs("div",{className:"flex items-center",children:[s.jsx(z,{size:16,className:"mr-2 text-blue-500"}),S("使用模式说明")]}),visible:M,onOk:()=>C(!1),onCancel:()=>C(!1),closeOnEsc:!0,okText:S("我已了解"),cancelText:null,centered:!0,size:"medium",className:"[&_.semi-modal-body]:!p-6",children:s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"bg-blue-50 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3 flex-shrink-0",children:s.jsx(b,{size:20,className:"text-blue-600"})}),s.jsxs("div",{children:[s.jsx(_,{heading:6,className:"text-blue-900 mb-2",children:S("对外运营模式")}),s.jsxs("div",{className:"space-y-2 text-sm text-gray-700",children:[s.jsx("p",{children:S("默认模式,适用于为多个用户提供服务的场景。")}),s.jsx("p",{children:S("此模式下,系统将计算每次调用的用量,您需要对每个模型都设置价格,如果没有设置价格,用户将无法使用该模型。")}),s.jsxs("div",{className:"mt-3",children:[s.jsx(t,{color:"blue",shape:"circle",className:"mr-2",children:S("计费模式")}),s.jsx(t,{color:"blue",shape:"circle",children:S("多用户支持")})]})]})]})]})}),s.jsx("div",{className:"bg-green-50 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-green-100 flex items-center justify-center mr-3 flex-shrink-0",children:s.jsx(y,{size:20,className:"text-green-600"})}),s.jsxs("div",{children:[s.jsx(_,{heading:6,className:"text-green-900 mb-2",children:S("自用模式")}),s.jsxs("div",{className:"space-y-2 text-sm text-gray-700",children:[s.jsx("p",{children:S("适用于个人使用的场景。")}),s.jsx("p",{children:S("不需要设置模型价格,系统将弱化用量计算,您可专注于使用模型。")}),s.jsxs("div",{className:"mt-3",children:[s.jsx(t,{color:"green",shape:"circle",className:"mr-2",children:S("无需计费")}),s.jsx(t,{color:"green",shape:"circle",children:S("个人使用")})]})]})]})]})}),s.jsx("div",{className:"bg-purple-50 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center mr-3 flex-shrink-0",children:s.jsx(w,{size:20,className:"text-purple-600"})}),s.jsxs("div",{children:[s.jsx(_,{heading:6,className:"text-purple-900 mb-2",children:S("演示站点模式")}),s.jsxs("div",{className:"space-y-2 text-sm text-gray-700",children:[s.jsx("p",{children:S("适用于展示系统功能的场景。")}),s.jsx("p",{children:S("提供基础功能演示,方便用户了解系统特性。")}),s.jsxs("div",{className:"mt-3",children:[s.jsx(t,{color:"purple",shape:"circle",className:"mr-2",children:S("功能演示")}),s.jsx(t,{color:"purple",shape:"circle",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.