@chenpu17/cc-gw 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/server/dist/index.js +101 -78
- package/src/web/dist/assets/{About-DK242vw9.js → About-R4GuiAOC.js} +2 -2
- package/src/web/dist/assets/{ApiKeys-BGROxK6-.js → ApiKeys-CNNwIRTy.js} +1 -1
- package/src/web/dist/assets/{Button-Bnnxe9ep.js → Button-CgdNhVeu.js} +1 -1
- package/src/web/dist/assets/{Dashboard-B7zokimB.js → Dashboard-U1EC6qmF.js} +1 -1
- package/src/web/dist/assets/{FormField-BzT4FGj8.js → FormField-DJjnoGU0.js} +1 -1
- package/src/web/dist/assets/{Help-CJooSMdJ.js → Help-COAfsR6K.js} +1 -1
- package/src/web/dist/assets/{Input-B-P-J4xQ.js → Input-CkTJl-fF.js} +1 -1
- package/src/web/dist/assets/{Login-B9RgxiYX.js → Login-BbRStE3M.js} +1 -1
- package/src/web/dist/assets/{Logs-CsJCTftU.js → Logs-C-7diPqf.js} +1 -1
- package/src/web/dist/assets/{ModelManagement-dDhNa_5z.js → ModelManagement-BWX0w6Wu.js} +1 -1
- package/src/web/dist/assets/{PageSection-Dzvd3cKD.js → PageSection-BT-depe5.js} +1 -1
- package/src/web/dist/assets/{Settings-BcMQ79b0.js → Settings-CLM0Srx1.js} +1 -1
- package/src/web/dist/assets/{StatusBadge-CAkVtC--.js → StatusBadge-CgBAXD_S.js} +1 -1
- package/src/web/dist/assets/{copy-D6cuJHzh.js → copy-OD9YQ85H.js} +1 -1
- package/src/web/dist/assets/{index-agm-2asf.js → index-3UByifOG.js} +2 -2
- package/src/web/dist/assets/{index-Cm-hZvRJ.js → index-DVBy-Kka.js} +1 -1
- package/src/web/dist/assets/{info-CfAuBePJ.js → info-DAG4KwRm.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-ns68sM2H.js → useApiQuery-7KXAW9hB.js} +1 -1
- package/src/web/dist/index.html +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as te,a as ae,r as u,j as e,d as c,T as re,L as O,b as N,k as C,E as V,K as y,m as h,J as B}from"./index-agm-2asf.js";import{u as _}from"./useApiQuery-ns68sM2H.js";import{P as ne,a as w}from"./PageSection-Dzvd3cKD.js";import{C as le}from"./copy-D6cuJHzh.js";const oe=[{value:"fatal",labelKey:"fatal"},{value:"error",labelKey:"error"},{value:"warn",labelKey:"warn"},{value:"info",labelKey:"info"},{value:"debug",labelKey:"debug"},{value:"trace",labelKey:"trace"}];function me(){const{t:s}=te(),{pushToast:g}=ae(),n=_(["config","info"],{url:"/api/config/info",method:"GET"}),x=_(["auth","web"],{url:"/api/auth/web",method:"GET"}),[r,F]=u.useState(null),[L,G]=u.useState(""),[o,p]=u.useState({port:"",host:"",logRetentionDays:"",storeRequestPayloads:!0,storeResponsePayloads:!0,logLevel:"info",requestLogging:!0,responseLogging:!0,bodyLimitMb:"10",enableRoutingFallback:!1}),[b,q]=u.useState({}),[P,E]=u.useState(!1),[S,A]=u.useState(!1),[M,D]=u.useState(!1),[i,H]=u.useState(null),[l,f]=u.useState({enabled:!1,username:"",password:"",confirmPassword:""}),[k,v]=u.useState({}),[R,T]=u.useState(!1),Q=u.useMemo(()=>{if(!r)return null;const t=r.defaults;if(!t)return null;const a=[];return t.completion&&a.push(s("settings.defaults.completion",{model:t.completion})),t.reasoning&&a.push(s("settings.defaults.reasoning",{model:t.reasoning})),t.background&&a.push(s("settings.defaults.background",{model:t.background})),a.length>0?a.join(" | "):s("settings.defaults.none")},[r,s]),K=u.useMemo(()=>l.enabled?i!=null&&i.hasPassword?l.username.trim()!==((i==null?void 0:i.username)??""):!0:!1,[l.enabled,l.username,i]);u.useEffect(()=>{if(n.data){F(n.data.config),G(n.data.path);const t=n.data.config.storePayloads,a=d=>typeof d=="boolean"?d:typeof t=="boolean"?t:!0;p({port:String(n.data.config.port??""),host:n.data.config.host??"127.0.0.1",logRetentionDays:String(n.data.config.logRetentionDays??30),storeRequestPayloads:a(n.data.config.storeRequestPayloads),storeResponsePayloads:a(n.data.config.storeResponsePayloads),logLevel:n.data.config.logLevel??"info",requestLogging:n.data.config.requestLogging!==!1,responseLogging:n.data.config.responseLogging??n.data.config.requestLogging!==!1,bodyLimitMb:(()=>{const d=n.data.config.bodyLimit;return typeof d=="number"&&Number.isFinite(d)&&d>0?String(Math.max(1,Math.round(d/(1024*1024)))):"10"})(),enableRoutingFallback:n.data.config.enableRoutingFallback===!0})}},[n.data]),u.useEffect(()=>{x.data&&(H(x.data),f({enabled:x.data.enabled,username:x.data.username??"",password:"",confirmPassword:""}),v({}))},[x.data]),u.useEffect(()=>{n.isError&&n.error&&g({title:s("settings.toast.loadFailure",{message:n.error.message}),variant:"error"})},[n.isError,n.error,g,s]),u.useEffect(()=>{x.isError&&x.error&&g({title:s("settings.toast.authLoadFailure",{message:x.error.message}),variant:"error"})},[x.isError,x.error,g,s]);const j=t=>a=>{p(d=>({...d,[t]:a}))},I=()=>{const t={},a=Number(o.port);(!Number.isFinite(a)||a<1||a>65535)&&(t.port=s("settings.validation.port"));const d=Number(o.logRetentionDays);(!Number.isFinite(d)||d<1||d>365)&&(t.logRetentionDays=s("settings.validation.retention"));const m=Number(o.bodyLimitMb);return(!Number.isFinite(m)||m<1||m>2048)&&(t.bodyLimitMb=s("settings.validation.bodyLimit")),q(t),Object.keys(t).length===0},J=()=>{const t={},a=l.username.trim(),d=i?a!==(i.username??""):!0,m=l.enabled&&(!(i!=null&&i.hasPassword)||d);return l.enabled&&!a&&(t.username=s("settings.auth.validation.username")),l.password&&l.password.length<6&&(t.password=s("settings.auth.validation.minLength")),m&&!l.password&&(t.password=s("settings.auth.validation.passwordRequired")),(l.password||l.confirmPassword)&&l.password!==l.confirmPassword&&(t.confirmPassword=s("settings.auth.validation.confirmMismatch")),v(t),Object.keys(t).length===0},W=async()=>{if(!r){g({title:s("settings.toast.loadFailure",{message:s("settings.toast.missingConfig")}),variant:"error"});return}if(I()){E(!0);try{const t=Number(o.port),a=Number(o.logRetentionDays),d=Number(o.bodyLimitMb),m={...r,port:t,host:o.host.trim()||void 0,logRetentionDays:a,storeRequestPayloads:o.storeRequestPayloads,storeResponsePayloads:o.storeResponsePayloads,logLevel:o.logLevel,requestLogging:o.requestLogging,responseLogging:o.responseLogging,bodyLimit:Math.max(1,Math.floor(d*1024*1024)),enableRoutingFallback:o.enableRoutingFallback},{webAuth:ie,...se}=m;await N.put("/api/config",se),F({...m,webAuth:r.webAuth}),g({title:s("settings.toast.saveSuccess"),variant:"success"}),n.refetch()}catch(t){g({title:s("settings.toast.saveFailure",{message:t instanceof Error?t.message:"unknown"}),variant:"error"})}finally{E(!1)}}},$=()=>{r&&(p({port:String(r.port??""),host:r.host??"",logRetentionDays:String(r.logRetentionDays??30),storeRequestPayloads:typeof r.storeRequestPayloads=="boolean"?r.storeRequestPayloads:typeof r.storePayloads=="boolean"?r.storePayloads:!0,storeResponsePayloads:typeof r.storeResponsePayloads=="boolean"?r.storeResponsePayloads:typeof r.storePayloads=="boolean"?r.storePayloads:!0,logLevel:r.logLevel??"info",requestLogging:r.requestLogging!==!1,responseLogging:r.responseLogging??r.requestLogging!==!1,bodyLimitMb:(()=>{const t=r.bodyLimit;return typeof t=="number"&&Number.isFinite(t)&&t>0?String(Math.max(1,Math.round(t/(1024*1024)))):"10"})(),enableRoutingFallback:r.enableRoutingFallback===!0}),q({}))},z=async()=>{var t;if(J()){T(!0);try{const a={enabled:l.enabled,username:l.username.trim()||void 0};l.password&&(a.password=l.password);const m=(t=(await N.post("/api/auth/web",a)).data)==null?void 0:t.auth;m&&(H(m),f({enabled:m.enabled,username:m.username??"",password:"",confirmPassword:""}),v({})),g({title:s("settings.auth.toast.success"),variant:"success"}),x.refetch()}catch(a){const d=a instanceof Error?a.message:"unknown";g({title:s("settings.auth.toast.failure",{message:d}),variant:"error"})}finally{T(!1)}}},U=()=>{i&&(f({enabled:i.enabled,username:i.username??"",password:"",confirmPassword:""}),v({}))},X=async()=>{if(!L){g({title:s("settings.toast.copyFailure",{message:s("settings.file.unknown")}),variant:"error"});return}try{await navigator.clipboard.writeText(L),g({title:s("settings.toast.copySuccess"),variant:"success"})}catch(t){g({title:s("settings.toast.copyFailure",{message:t instanceof Error?t.message:"unknown"}),variant:"error"})}},Y=async()=>{A(!0);try{const a=(await N.post("/api/logs/cleanup")).data.deleted??0;g({title:a>0?s("settings.toast.cleanupSuccess",{count:a}):s("settings.toast.cleanupNone"),variant:"success"})}catch(t){g({title:s("settings.toast.cleanupFailure",{message:t instanceof Error?t.message:"unknown"}),variant:"error"})}finally{A(!1)}},Z=async()=>{D(!0);try{const t=await N.post("/api/logs/clear"),{deleted:a,metricsCleared:d}=t.data;g({title:s("settings.toast.clearAllSuccess",{logs:a,metrics:d}),variant:"success"})}catch(t){g({title:s("settings.toast.clearAllFailure",{message:t instanceof Error?t.message:"unknown"}),variant:"error"})}finally{D(!1)}},ee=n.isPending||!r&&n.isFetching;return e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(ne,{icon:e.jsx(re,{className:"h-6 w-6","aria-hidden":"true"}),title:s("settings.title"),description:s("settings.description"),actions:r?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:$,className:c(C,"h-10 rounded-full px-4"),disabled:P,children:s("common.actions.reset")}),e.jsx("button",{type:"button",onClick:W,className:c(V,"h-10 rounded-full px-4"),disabled:P,children:s(P?"common.actions.saving":"common.actions.save")})]}):null}),ee?e.jsx(w,{className:"flex min-h-[220px] items-center justify-center",children:e.jsx(O,{})}):r?e.jsxs(e.Fragment,{children:[e.jsxs(w,{title:s("settings.sections.basics"),contentClassName:"grid w-full gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.port")}),e.jsx("input",{type:"number",min:1,max:65535,value:o.port,onChange:t=>j("port")(t.target.value),className:c(y,"h-11"),"aria-invalid":!!b.port}),b.port?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:b.port}):null]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.host")}),e.jsx("input",{value:o.host,onChange:t=>j("host")(t.target.value),placeholder:s("settings.fields.hostPlaceholder"),className:c(y,"h-11")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.retention")}),e.jsx("input",{type:"number",min:1,max:365,value:o.logRetentionDays,onChange:t=>j("logRetentionDays")(t.target.value),className:c(y,"h-11"),"aria-invalid":!!b.logRetentionDays}),b.logRetentionDays?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:b.logRetentionDays}):null]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.bodyLimit")}),e.jsx("input",{type:"number",min:1,max:2048,value:o.bodyLimitMb,onChange:t=>j("bodyLimitMb")(t.target.value),className:c(y,"h-11"),"aria-invalid":!!b.bodyLimitMb}),e.jsx("p",{className:c(h,"text-[11px] leading-relaxed"),children:s("settings.fields.bodyLimitHint")}),b.bodyLimitMb?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:b.bodyLimitMb}):null]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.logLevel")}),e.jsx("select",{value:o.logLevel,onChange:t=>p(a=>({...a,logLevel:t.target.value})),className:"h-10",children:oe.map(t=>e.jsx("option",{value:t.value,children:s(`settings.fields.logLevelOption.${t.labelKey}`)},t.value))})]}),e.jsxs("div",{className:"md:col-span-2 grid gap-4 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 shadow-sm shadow-slate-200/60 transition hover:border-slate-300 dark:border-slate-700/60 dark:bg-slate-900/70 dark:hover:border-slate-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.storeRequestPayloads,onChange:t=>p(a=>({...a,storeRequestPayloads:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-400 dark:border-slate-600"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-100",children:s("settings.fields.storeRequestPayloads")}),e.jsx("p",{className:c(h,"text-xs"),children:s("settings.fields.storeRequestPayloadsHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 shadow-sm shadow-slate-200/60 transition hover:border-slate-300 dark:border-slate-700/60 dark:bg-slate-900/70 dark:hover:border-slate-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.storeResponsePayloads,onChange:t=>p(a=>({...a,storeResponsePayloads:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-400 dark:border-slate-600"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-100",children:s("settings.fields.storeResponsePayloads")}),e.jsx("p",{className:c(h,"text-xs"),children:s("settings.fields.storeResponsePayloadsHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 shadow-sm shadow-slate-200/60 transition hover:border-slate-300 dark:border-slate-700/60 dark:bg-slate-900/70 dark:hover:border-slate-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.requestLogging,onChange:t=>p(a=>({...a,requestLogging:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-400 dark:border-slate-600"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-100",children:s("settings.fields.requestLogging")}),e.jsx("p",{className:c(h,"text-xs"),children:s("settings.fields.requestLoggingHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 shadow-sm shadow-slate-200/60 transition hover:border-slate-300 dark:border-slate-700/60 dark:bg-slate-900/70 dark:hover:border-slate-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.responseLogging,onChange:t=>p(a=>({...a,responseLogging:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-400 dark:border-slate-600"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-100",children:s("settings.fields.responseLogging")}),e.jsx("p",{className:c(h,"text-xs"),children:s("settings.fields.responseLoggingHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-amber-200/70 bg-amber-50/80 px-4 py-3 shadow-sm shadow-amber-200/60 transition hover:border-amber-300 dark:border-amber-700/60 dark:bg-amber-900/30 dark:hover:border-amber-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.enableRoutingFallback,onChange:t=>p(a=>({...a,enableRoutingFallback:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-amber-300 text-amber-600 focus:ring-amber-400 dark:border-amber-500"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-amber-700 dark:text-amber-200",children:s("settings.fields.enableRoutingFallback")}),e.jsx("p",{className:c(h,"text-xs text-amber-800/80 dark:text-amber-200/80"),children:s("settings.fields.enableRoutingFallbackHint")})]})]})]}),e.jsxs("div",{className:"md:col-span-2 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 text-sm text-slate-700 shadow-sm shadow-slate-200/60 dark:border-slate-700/60 dark:bg-slate-900/70 dark:text-slate-200",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.defaults")}),e.jsx("p",{className:"mt-2 text-sm",children:Q??s("settings.defaults.none")})]})]}),e.jsx(w,{title:s("settings.sections.security"),description:s("settings.auth.description"),contentClassName:"space-y-5",children:x.isPending&&!i?e.jsx("div",{className:"flex min-h-[120px] items-center justify-center",children:e.jsx(O,{})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-2xl border border-slate-200/70 bg-white/90 p-5 shadow-sm shadow-slate-200/50 transition dark:border-slate-700/60 dark:bg-slate-900/80 dark:shadow-slate-900/40",children:e.jsxs("label",{className:"flex cursor-pointer select-none items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:t=>f(a=>({...a,enabled:t.target.checked})),className:"mt-1 h-5 w-5 rounded border-slate-300 bg-white text-blue-600 shadow-sm transition focus:ring-blue-400/40 dark:border-slate-600 dark:bg-slate-900 dark:text-blue-200"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-800 dark:text-slate-100",children:s("settings.auth.enable")}),e.jsx("p",{className:c(h,"text-xs leading-relaxed"),children:s("settings.auth.enableHint")}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[11px] font-medium text-slate-500 dark:text-slate-400",children:[e.jsx("span",{className:"rounded-full bg-slate-100/90 px-3 py-1 shadow-sm shadow-slate-200/40 dark:bg-slate-800/70",children:"/ui"}),e.jsx("span",{className:"rounded-full bg-slate-100/90 px-3 py-1 shadow-sm shadow-slate-200/40 dark:bg-slate-800/70",children:"/api/*"}),e.jsx("span",{className:"rounded-full bg-slate-100/90 px-3 py-1 shadow-sm shadow-slate-200/40 dark:bg-slate-800/70",children:"Cookie Session"})]})]})]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:col-span-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.auth.username")}),e.jsx("input",{value:l.username,onChange:t=>f(a=>({...a,username:t.target.value})),placeholder:s("settings.auth.usernamePlaceholder"),className:c(y,"h-11 font-medium")}),k.username?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:k.username}):null]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.auth.password")}),e.jsx("input",{type:"password",value:l.password,disabled:!l.enabled,onChange:t=>f(a=>({...a,password:t.target.value})),placeholder:s("settings.auth.passwordPlaceholder"),className:c(y,"h-11 disabled:cursor-not-allowed disabled:bg-slate-100 dark:disabled:bg-slate-900/40")}),k.password?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:k.password}):e.jsx("span",{className:c(h,"text-xs leading-relaxed"),children:s(K?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.auth.confirmPassword")}),e.jsx("input",{type:"password",value:l.confirmPassword,disabled:!l.enabled,onChange:t=>f(a=>({...a,confirmPassword:t.target.value})),placeholder:s("settings.auth.confirmPasswordPlaceholder"),className:c(y,"h-11 disabled:cursor-not-allowed disabled:bg-slate-100 dark:disabled:bg-slate-900/40")}),k.confirmPassword?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:k.confirmPassword}):null]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-2xl border border-slate-200/70 bg-white/95 px-5 py-4 text-sm shadow-sm shadow-slate-200/40 dark:border-slate-700/60 dark:bg-slate-900/75 dark:text-slate-200 dark:shadow-slate-900/40",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500/90 dark:text-slate-400",children:s("settings.auth.status")}),e.jsx("div",{className:"mt-2 text-base font-semibold text-slate-800 dark:text-slate-100",children:i!=null&&i.enabled?s("settings.auth.statusEnabled"):s("settings.auth.statusDisabled")}),i!=null&&i.username?e.jsxs("div",{className:"mt-3 rounded-2xl bg-blue-50/80 px-3 py-2 text-xs font-medium text-blue-700 shadow-sm shadow-blue-200/40 dark:bg-blue-500/20 dark:text-blue-100",children:[s("settings.auth.username"),": ",i.username]}):null]}),e.jsx("div",{className:"rounded-2xl border border-slate-200/60 bg-slate-50/80 px-5 py-4 text-xs leading-relaxed text-slate-600 shadow-sm shadow-slate-200/40 dark:border-slate-700/50 dark:bg-slate-800/60 dark:text-slate-300",children:s(K?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:z,className:c(V,"h-10 rounded-full px-6"),disabled:R,children:s(R?"common.actions.saving":"settings.auth.actions.save")}),e.jsx("button",{type:"button",onClick:U,className:c(C,"h-10 rounded-full px-4"),disabled:R,children:s("common.actions.reset")})]})]})}),e.jsx(w,{title:s("settings.sections.configFile"),description:s("settings.file.description"),actions:e.jsxs("button",{type:"button",onClick:X,className:c(C,"h-10 rounded-full px-4"),children:[e.jsx(le,{className:"h-4 w-4","aria-hidden":"true"}),s("common.actions.copy")]}),contentClassName:"gap-3",children:e.jsx("code",{className:"block break-all rounded-2xl border border-slate-200/60 bg-slate-100 px-4 py-3 text-xs text-slate-700 dark:border-slate-700/60 dark:bg-slate-900 dark:text-slate-200",children:L||s("settings.file.unknown")})}),e.jsxs(w,{title:s("settings.sections.cleanup"),description:s("settings.cleanup.description"),contentClassName:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",onClick:Y,className:c(B,"px-5"),disabled:S,children:s(S?"common.actions.cleaning":"common.actions.cleanup")}),e.jsx("button",{type:"button",onClick:Z,className:c(B,"px-5 border-red-500/70 bg-red-600 text-white hover:bg-red-600/90 dark:border-red-500 dark:bg-red-500 dark:text-white"),disabled:M,children:s(M?"settings.cleanup.clearingAll":"settings.cleanup.clearAll")})]}),e.jsx("p",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:s("settings.cleanup.clearAllWarning")})]})]}):e.jsx(w,{children:e.jsx("p",{className:"text-sm font-medium text-red-500 dark:text-red-300",children:s("settings.toast.missingConfig")})})]})}export{me as default};
|
|
1
|
+
import{u as te,a as ae,r as u,j as e,d as c,T as re,L as O,b as N,k as C,E as V,K as y,m as h,J as B}from"./index-3UByifOG.js";import{u as _}from"./useApiQuery-7KXAW9hB.js";import{P as ne,a as w}from"./PageSection-BT-depe5.js";import{C as le}from"./copy-OD9YQ85H.js";const oe=[{value:"fatal",labelKey:"fatal"},{value:"error",labelKey:"error"},{value:"warn",labelKey:"warn"},{value:"info",labelKey:"info"},{value:"debug",labelKey:"debug"},{value:"trace",labelKey:"trace"}];function me(){const{t:s}=te(),{pushToast:g}=ae(),n=_(["config","info"],{url:"/api/config/info",method:"GET"}),x=_(["auth","web"],{url:"/api/auth/web",method:"GET"}),[r,F]=u.useState(null),[L,G]=u.useState(""),[o,p]=u.useState({port:"",host:"",logRetentionDays:"",storeRequestPayloads:!0,storeResponsePayloads:!0,logLevel:"info",requestLogging:!0,responseLogging:!0,bodyLimitMb:"10",enableRoutingFallback:!1}),[b,q]=u.useState({}),[P,E]=u.useState(!1),[S,A]=u.useState(!1),[M,D]=u.useState(!1),[i,H]=u.useState(null),[l,f]=u.useState({enabled:!1,username:"",password:"",confirmPassword:""}),[k,v]=u.useState({}),[R,T]=u.useState(!1),Q=u.useMemo(()=>{if(!r)return null;const t=r.defaults;if(!t)return null;const a=[];return t.completion&&a.push(s("settings.defaults.completion",{model:t.completion})),t.reasoning&&a.push(s("settings.defaults.reasoning",{model:t.reasoning})),t.background&&a.push(s("settings.defaults.background",{model:t.background})),a.length>0?a.join(" | "):s("settings.defaults.none")},[r,s]),K=u.useMemo(()=>l.enabled?i!=null&&i.hasPassword?l.username.trim()!==((i==null?void 0:i.username)??""):!0:!1,[l.enabled,l.username,i]);u.useEffect(()=>{if(n.data){F(n.data.config),G(n.data.path);const t=n.data.config.storePayloads,a=d=>typeof d=="boolean"?d:typeof t=="boolean"?t:!0;p({port:String(n.data.config.port??""),host:n.data.config.host??"127.0.0.1",logRetentionDays:String(n.data.config.logRetentionDays??30),storeRequestPayloads:a(n.data.config.storeRequestPayloads),storeResponsePayloads:a(n.data.config.storeResponsePayloads),logLevel:n.data.config.logLevel??"info",requestLogging:n.data.config.requestLogging!==!1,responseLogging:n.data.config.responseLogging??n.data.config.requestLogging!==!1,bodyLimitMb:(()=>{const d=n.data.config.bodyLimit;return typeof d=="number"&&Number.isFinite(d)&&d>0?String(Math.max(1,Math.round(d/(1024*1024)))):"10"})(),enableRoutingFallback:n.data.config.enableRoutingFallback===!0})}},[n.data]),u.useEffect(()=>{x.data&&(H(x.data),f({enabled:x.data.enabled,username:x.data.username??"",password:"",confirmPassword:""}),v({}))},[x.data]),u.useEffect(()=>{n.isError&&n.error&&g({title:s("settings.toast.loadFailure",{message:n.error.message}),variant:"error"})},[n.isError,n.error,g,s]),u.useEffect(()=>{x.isError&&x.error&&g({title:s("settings.toast.authLoadFailure",{message:x.error.message}),variant:"error"})},[x.isError,x.error,g,s]);const j=t=>a=>{p(d=>({...d,[t]:a}))},I=()=>{const t={},a=Number(o.port);(!Number.isFinite(a)||a<1||a>65535)&&(t.port=s("settings.validation.port"));const d=Number(o.logRetentionDays);(!Number.isFinite(d)||d<1||d>365)&&(t.logRetentionDays=s("settings.validation.retention"));const m=Number(o.bodyLimitMb);return(!Number.isFinite(m)||m<1||m>2048)&&(t.bodyLimitMb=s("settings.validation.bodyLimit")),q(t),Object.keys(t).length===0},J=()=>{const t={},a=l.username.trim(),d=i?a!==(i.username??""):!0,m=l.enabled&&(!(i!=null&&i.hasPassword)||d);return l.enabled&&!a&&(t.username=s("settings.auth.validation.username")),l.password&&l.password.length<6&&(t.password=s("settings.auth.validation.minLength")),m&&!l.password&&(t.password=s("settings.auth.validation.passwordRequired")),(l.password||l.confirmPassword)&&l.password!==l.confirmPassword&&(t.confirmPassword=s("settings.auth.validation.confirmMismatch")),v(t),Object.keys(t).length===0},W=async()=>{if(!r){g({title:s("settings.toast.loadFailure",{message:s("settings.toast.missingConfig")}),variant:"error"});return}if(I()){E(!0);try{const t=Number(o.port),a=Number(o.logRetentionDays),d=Number(o.bodyLimitMb),m={...r,port:t,host:o.host.trim()||void 0,logRetentionDays:a,storeRequestPayloads:o.storeRequestPayloads,storeResponsePayloads:o.storeResponsePayloads,logLevel:o.logLevel,requestLogging:o.requestLogging,responseLogging:o.responseLogging,bodyLimit:Math.max(1,Math.floor(d*1024*1024)),enableRoutingFallback:o.enableRoutingFallback},{webAuth:ie,...se}=m;await N.put("/api/config",se),F({...m,webAuth:r.webAuth}),g({title:s("settings.toast.saveSuccess"),variant:"success"}),n.refetch()}catch(t){g({title:s("settings.toast.saveFailure",{message:t instanceof Error?t.message:"unknown"}),variant:"error"})}finally{E(!1)}}},$=()=>{r&&(p({port:String(r.port??""),host:r.host??"",logRetentionDays:String(r.logRetentionDays??30),storeRequestPayloads:typeof r.storeRequestPayloads=="boolean"?r.storeRequestPayloads:typeof r.storePayloads=="boolean"?r.storePayloads:!0,storeResponsePayloads:typeof r.storeResponsePayloads=="boolean"?r.storeResponsePayloads:typeof r.storePayloads=="boolean"?r.storePayloads:!0,logLevel:r.logLevel??"info",requestLogging:r.requestLogging!==!1,responseLogging:r.responseLogging??r.requestLogging!==!1,bodyLimitMb:(()=>{const t=r.bodyLimit;return typeof t=="number"&&Number.isFinite(t)&&t>0?String(Math.max(1,Math.round(t/(1024*1024)))):"10"})(),enableRoutingFallback:r.enableRoutingFallback===!0}),q({}))},z=async()=>{var t;if(J()){T(!0);try{const a={enabled:l.enabled,username:l.username.trim()||void 0};l.password&&(a.password=l.password);const m=(t=(await N.post("/api/auth/web",a)).data)==null?void 0:t.auth;m&&(H(m),f({enabled:m.enabled,username:m.username??"",password:"",confirmPassword:""}),v({})),g({title:s("settings.auth.toast.success"),variant:"success"}),x.refetch()}catch(a){const d=a instanceof Error?a.message:"unknown";g({title:s("settings.auth.toast.failure",{message:d}),variant:"error"})}finally{T(!1)}}},U=()=>{i&&(f({enabled:i.enabled,username:i.username??"",password:"",confirmPassword:""}),v({}))},X=async()=>{if(!L){g({title:s("settings.toast.copyFailure",{message:s("settings.file.unknown")}),variant:"error"});return}try{await navigator.clipboard.writeText(L),g({title:s("settings.toast.copySuccess"),variant:"success"})}catch(t){g({title:s("settings.toast.copyFailure",{message:t instanceof Error?t.message:"unknown"}),variant:"error"})}},Y=async()=>{A(!0);try{const a=(await N.post("/api/logs/cleanup")).data.deleted??0;g({title:a>0?s("settings.toast.cleanupSuccess",{count:a}):s("settings.toast.cleanupNone"),variant:"success"})}catch(t){g({title:s("settings.toast.cleanupFailure",{message:t instanceof Error?t.message:"unknown"}),variant:"error"})}finally{A(!1)}},Z=async()=>{D(!0);try{const t=await N.post("/api/logs/clear"),{deleted:a,metricsCleared:d}=t.data;g({title:s("settings.toast.clearAllSuccess",{logs:a,metrics:d}),variant:"success"})}catch(t){g({title:s("settings.toast.clearAllFailure",{message:t instanceof Error?t.message:"unknown"}),variant:"error"})}finally{D(!1)}},ee=n.isPending||!r&&n.isFetching;return e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(ne,{icon:e.jsx(re,{className:"h-6 w-6","aria-hidden":"true"}),title:s("settings.title"),description:s("settings.description"),actions:r?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:$,className:c(C,"h-10 rounded-full px-4"),disabled:P,children:s("common.actions.reset")}),e.jsx("button",{type:"button",onClick:W,className:c(V,"h-10 rounded-full px-4"),disabled:P,children:s(P?"common.actions.saving":"common.actions.save")})]}):null}),ee?e.jsx(w,{className:"flex min-h-[220px] items-center justify-center",children:e.jsx(O,{})}):r?e.jsxs(e.Fragment,{children:[e.jsxs(w,{title:s("settings.sections.basics"),contentClassName:"grid w-full gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.port")}),e.jsx("input",{type:"number",min:1,max:65535,value:o.port,onChange:t=>j("port")(t.target.value),className:c(y,"h-11"),"aria-invalid":!!b.port}),b.port?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:b.port}):null]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.host")}),e.jsx("input",{value:o.host,onChange:t=>j("host")(t.target.value),placeholder:s("settings.fields.hostPlaceholder"),className:c(y,"h-11")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.retention")}),e.jsx("input",{type:"number",min:1,max:365,value:o.logRetentionDays,onChange:t=>j("logRetentionDays")(t.target.value),className:c(y,"h-11"),"aria-invalid":!!b.logRetentionDays}),b.logRetentionDays?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:b.logRetentionDays}):null]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.bodyLimit")}),e.jsx("input",{type:"number",min:1,max:2048,value:o.bodyLimitMb,onChange:t=>j("bodyLimitMb")(t.target.value),className:c(y,"h-11"),"aria-invalid":!!b.bodyLimitMb}),e.jsx("p",{className:c(h,"text-[11px] leading-relaxed"),children:s("settings.fields.bodyLimitHint")}),b.bodyLimitMb?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:b.bodyLimitMb}):null]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.logLevel")}),e.jsx("select",{value:o.logLevel,onChange:t=>p(a=>({...a,logLevel:t.target.value})),className:"h-10",children:oe.map(t=>e.jsx("option",{value:t.value,children:s(`settings.fields.logLevelOption.${t.labelKey}`)},t.value))})]}),e.jsxs("div",{className:"md:col-span-2 grid gap-4 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 shadow-sm shadow-slate-200/60 transition hover:border-slate-300 dark:border-slate-700/60 dark:bg-slate-900/70 dark:hover:border-slate-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.storeRequestPayloads,onChange:t=>p(a=>({...a,storeRequestPayloads:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-400 dark:border-slate-600"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-100",children:s("settings.fields.storeRequestPayloads")}),e.jsx("p",{className:c(h,"text-xs"),children:s("settings.fields.storeRequestPayloadsHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 shadow-sm shadow-slate-200/60 transition hover:border-slate-300 dark:border-slate-700/60 dark:bg-slate-900/70 dark:hover:border-slate-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.storeResponsePayloads,onChange:t=>p(a=>({...a,storeResponsePayloads:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-400 dark:border-slate-600"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-100",children:s("settings.fields.storeResponsePayloads")}),e.jsx("p",{className:c(h,"text-xs"),children:s("settings.fields.storeResponsePayloadsHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 shadow-sm shadow-slate-200/60 transition hover:border-slate-300 dark:border-slate-700/60 dark:bg-slate-900/70 dark:hover:border-slate-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.requestLogging,onChange:t=>p(a=>({...a,requestLogging:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-400 dark:border-slate-600"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-100",children:s("settings.fields.requestLogging")}),e.jsx("p",{className:c(h,"text-xs"),children:s("settings.fields.requestLoggingHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 shadow-sm shadow-slate-200/60 transition hover:border-slate-300 dark:border-slate-700/60 dark:bg-slate-900/70 dark:hover:border-slate-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.responseLogging,onChange:t=>p(a=>({...a,responseLogging:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-slate-300 text-blue-600 focus:ring-blue-400 dark:border-slate-600"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-100",children:s("settings.fields.responseLogging")}),e.jsx("p",{className:c(h,"text-xs"),children:s("settings.fields.responseLoggingHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-2xl border border-amber-200/70 bg-amber-50/80 px-4 py-3 shadow-sm shadow-amber-200/60 transition hover:border-amber-300 dark:border-amber-700/60 dark:bg-amber-900/30 dark:hover:border-amber-500/60",children:[e.jsx("input",{type:"checkbox",checked:o.enableRoutingFallback,onChange:t=>p(a=>({...a,enableRoutingFallback:t.target.checked})),className:"mt-1 h-4 w-4 rounded border-amber-300 text-amber-600 focus:ring-amber-400 dark:border-amber-500"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-semibold text-amber-700 dark:text-amber-200",children:s("settings.fields.enableRoutingFallback")}),e.jsx("p",{className:c(h,"text-xs text-amber-800/80 dark:text-amber-200/80"),children:s("settings.fields.enableRoutingFallbackHint")})]})]})]}),e.jsxs("div",{className:"md:col-span-2 rounded-2xl border border-slate-200/70 bg-white/80 px-4 py-3 text-sm text-slate-700 shadow-sm shadow-slate-200/60 dark:border-slate-700/60 dark:bg-slate-900/70 dark:text-slate-200",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.fields.defaults")}),e.jsx("p",{className:"mt-2 text-sm",children:Q??s("settings.defaults.none")})]})]}),e.jsx(w,{title:s("settings.sections.security"),description:s("settings.auth.description"),contentClassName:"space-y-5",children:x.isPending&&!i?e.jsx("div",{className:"flex min-h-[120px] items-center justify-center",children:e.jsx(O,{})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-2xl border border-slate-200/70 bg-white/90 p-5 shadow-sm shadow-slate-200/50 transition dark:border-slate-700/60 dark:bg-slate-900/80 dark:shadow-slate-900/40",children:e.jsxs("label",{className:"flex cursor-pointer select-none items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:t=>f(a=>({...a,enabled:t.target.checked})),className:"mt-1 h-5 w-5 rounded border-slate-300 bg-white text-blue-600 shadow-sm transition focus:ring-blue-400/40 dark:border-slate-600 dark:bg-slate-900 dark:text-blue-200"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-800 dark:text-slate-100",children:s("settings.auth.enable")}),e.jsx("p",{className:c(h,"text-xs leading-relaxed"),children:s("settings.auth.enableHint")}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[11px] font-medium text-slate-500 dark:text-slate-400",children:[e.jsx("span",{className:"rounded-full bg-slate-100/90 px-3 py-1 shadow-sm shadow-slate-200/40 dark:bg-slate-800/70",children:"/ui"}),e.jsx("span",{className:"rounded-full bg-slate-100/90 px-3 py-1 shadow-sm shadow-slate-200/40 dark:bg-slate-800/70",children:"/api/*"}),e.jsx("span",{className:"rounded-full bg-slate-100/90 px-3 py-1 shadow-sm shadow-slate-200/40 dark:bg-slate-800/70",children:"Cookie Session"})]})]})]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:col-span-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.auth.username")}),e.jsx("input",{value:l.username,onChange:t=>f(a=>({...a,username:t.target.value})),placeholder:s("settings.auth.usernamePlaceholder"),className:c(y,"h-11 font-medium")}),k.username?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:k.username}):null]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.auth.password")}),e.jsx("input",{type:"password",value:l.password,disabled:!l.enabled,onChange:t=>f(a=>({...a,password:t.target.value})),placeholder:s("settings.auth.passwordPlaceholder"),className:c(y,"h-11 disabled:cursor-not-allowed disabled:bg-slate-100 dark:disabled:bg-slate-900/40")}),k.password?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:k.password}):e.jsx("span",{className:c(h,"text-xs leading-relaxed"),children:s(K?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",children:s("settings.auth.confirmPassword")}),e.jsx("input",{type:"password",value:l.confirmPassword,disabled:!l.enabled,onChange:t=>f(a=>({...a,confirmPassword:t.target.value})),placeholder:s("settings.auth.confirmPasswordPlaceholder"),className:c(y,"h-11 disabled:cursor-not-allowed disabled:bg-slate-100 dark:disabled:bg-slate-900/40")}),k.confirmPassword?e.jsx("span",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:k.confirmPassword}):null]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-2xl border border-slate-200/70 bg-white/95 px-5 py-4 text-sm shadow-sm shadow-slate-200/40 dark:border-slate-700/60 dark:bg-slate-900/75 dark:text-slate-200 dark:shadow-slate-900/40",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500/90 dark:text-slate-400",children:s("settings.auth.status")}),e.jsx("div",{className:"mt-2 text-base font-semibold text-slate-800 dark:text-slate-100",children:i!=null&&i.enabled?s("settings.auth.statusEnabled"):s("settings.auth.statusDisabled")}),i!=null&&i.username?e.jsxs("div",{className:"mt-3 rounded-2xl bg-blue-50/80 px-3 py-2 text-xs font-medium text-blue-700 shadow-sm shadow-blue-200/40 dark:bg-blue-500/20 dark:text-blue-100",children:[s("settings.auth.username"),": ",i.username]}):null]}),e.jsx("div",{className:"rounded-2xl border border-slate-200/60 bg-slate-50/80 px-5 py-4 text-xs leading-relaxed text-slate-600 shadow-sm shadow-slate-200/40 dark:border-slate-700/50 dark:bg-slate-800/60 dark:text-slate-300",children:s(K?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:z,className:c(V,"h-10 rounded-full px-6"),disabled:R,children:s(R?"common.actions.saving":"settings.auth.actions.save")}),e.jsx("button",{type:"button",onClick:U,className:c(C,"h-10 rounded-full px-4"),disabled:R,children:s("common.actions.reset")})]})]})}),e.jsx(w,{title:s("settings.sections.configFile"),description:s("settings.file.description"),actions:e.jsxs("button",{type:"button",onClick:X,className:c(C,"h-10 rounded-full px-4"),children:[e.jsx(le,{className:"h-4 w-4","aria-hidden":"true"}),s("common.actions.copy")]}),contentClassName:"gap-3",children:e.jsx("code",{className:"block break-all rounded-2xl border border-slate-200/60 bg-slate-100 px-4 py-3 text-xs text-slate-700 dark:border-slate-700/60 dark:bg-slate-900 dark:text-slate-200",children:L||s("settings.file.unknown")})}),e.jsxs(w,{title:s("settings.sections.cleanup"),description:s("settings.cleanup.description"),contentClassName:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",onClick:Y,className:c(B,"px-5"),disabled:S,children:s(S?"common.actions.cleaning":"common.actions.cleanup")}),e.jsx("button",{type:"button",onClick:Z,className:c(B,"px-5 border-red-500/70 bg-red-600 text-white hover:bg-red-600/90 dark:border-red-500 dark:bg-red-500 dark:text-white"),disabled:M,children:s(M?"settings.cleanup.clearingAll":"settings.cleanup.clearAll")})]}),e.jsx("p",{className:"text-xs font-medium text-red-500 dark:text-red-300",children:s("settings.cleanup.clearAllWarning")})]})]}):e.jsx(w,{children:e.jsx("p",{className:"text-sm font-medium text-red-500 dark:text-red-300",children:s("settings.toast.missingConfig")})})]})}export{me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,d as n,I as u}from"./index-
|
|
1
|
+
import{j as s,d as n,I as u}from"./index-3UByifOG.js";function c({variant:a,children:e,icon:r,className:t}){return s.jsxs("span",{className:n(u[a],t),children:[r||s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current","aria-hidden":"true"}),e]})}export{c as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-U1EC6qmF.js","assets/index-DVBy-Kka.js","assets/PageSection-BT-depe5.js","assets/Input-CkTJl-fF.js","assets/StatusBadge-CgBAXD_S.js","assets/useApiQuery-7KXAW9hB.js","assets/Logs-C-7diPqf.js","assets/FormField-DJjnoGU0.js","assets/Button-CgdNhVeu.js","assets/ModelManagement-BWX0w6Wu.js","assets/ApiKeys-CNNwIRTy.js","assets/copy-OD9YQ85H.js","assets/Settings-CLM0Srx1.js","assets/About-R4GuiAOC.js","assets/info-DAG4KwRm.js","assets/Help-COAfsR6K.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var nm=Object.defineProperty;var wu=e=>{throw TypeError(e)};var rm=(e,t,n)=>t in e?nm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var xu=(e,t,n)=>rm(e,typeof t!="symbol"?t+"":t,n),Ro=(e,t,n)=>t.has(e)||wu("Cannot "+n);var P=(e,t,n)=>(Ro(e,t,"read from private field"),n?n.call(e):t.get(e)),z=(e,t,n)=>t.has(e)?wu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),_=(e,t,n,r)=>(Ro(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ge=(e,t,n)=>(Ro(e,t,"access private method"),n);var zs=(e,t,n,r)=>({set _(s){_(e,t,s,n)},get _(){return P(e,t,r)}});function sm(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function im(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jd={exports:{}},eo={},Md={exports:{}},M={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -204,4 +204,4 @@ env_key = "cc_gw_key"
|
|
|
204
204
|
"protocol": "anthropic"
|
|
205
205
|
}
|
|
206
206
|
\`\`\`
|
|
207
|
-
After configuration, clients access via \`http://127.0.0.1:4100/claude/v1/messages\` (path auto-expansion).`,'Enable "Store request/response bodies" to copy raw payloads from the log drawer when troubleshooting.',"Turn off request or response logs individually to keep the console quiet while preserving metrics and database records.","Use **routing presets** to save common routing configurations and quickly switch between different provider setups.","If you edit ~/.cc-gw/config.json manually, refresh the Settings page or restart cc-gw so the UI reflects the latest configuration."]}},faq:{title:"Frequently asked questions",items:[{q:"How can I change the default model for each endpoint?",a:'Go to "Model Management → Routing" and choose defaults for /anthropic and /openai. Saving applies the change right away.'},{q:"How do I use custom endpoints?",a:'Create a custom endpoint in the "Model Management" page by configuring a base path (e.g., `/my-endpoint`) and protocol type. The system automatically registers full API paths based on the protocol. For example, after configuring `/claude` + `anthropic` protocol, clients access via `http://127.0.0.1:4100/claude/v1/messages`.\n\nIf you encounter 404 errors, check:\n1) Is the endpoint enabled?\n2) Are clients using the complete path (including protocol subpath)?\n3) Check server logs to confirm route registration'},{q:"Why are cached token numbers missing?",a:"Upstream providers must return cached_tokens or input_tokens_details.cached_tokens. Enable cache metrics on the provider if supported."},{q:"How can I use different models for different clients?",a:'Create separate API keys for each client and configure different routing rules in "Model Management → Routing". You can also create dedicated custom endpoints for different clients.'}]}},apiKeys:{title:"API Keys Management",description:"Create and manage API keys for gateway access",createNew:"Create New Key",createAction:"Create",createDescription:"Create a new API key for authentication and optionally add a description.",descriptionLabel:"Key description (optional)",keyDescriptionPlaceholder:"e.g. Internal staging access only",keyNamePlaceholder:"Enter key name",keyCreated:"API Key Created",saveKeyWarning:"This is the only time you'll see the full key. Save it securely!",wildcard:"Any Key",wildcardHint:"When enabled, any custom key — including an empty key — is accepted. Disable this key to enforce strict authentication.",status:{enabled:"Enabled",disabled:"Disabled"},actions:{enable:"Enable",disable:"Disable",delete:"Delete"},created:"Created",lastUsed:"Last Used",requestCount:"Requests",totalTokens:"Total Tokens",confirmDelete:"Are you sure you want to delete this API key? This action cannot be undone.",errors:{nameRequired:"Key name is required"},analytics:{title:"Key Usage Analytics",description:"Highlights for the past {{days}} days of API key activity",range:{today:"Today",week:"Last 7 days",month:"Last 30 days"},cards:{total:"Total keys",enabled:"Enabled keys",active:"Active keys ({{days}} days)"},charts:{requests:"Top 10 keys by request count",tokens:"Top 10 keys by token usage"},tokens:{input:"Input tokens",output:"Output tokens"},requestsSeries:"Requests",empty:"No activity for the selected range.",unknownKey:"Unknown key"},list:{title:"Key Inventory",empty:"No API keys found. Use the button above to create one."},toast:{keyCreated:"API key created successfully",keyUpdated:"API key updated successfully",keyDeleted:"API key deleted successfully",keyCopied:"Key copied to clipboard",createFailure:"Failed to create: {{message}}",updateFailure:"Failed to update: {{message}}",deleteFailure:"Failed to delete: {{message}}"}},about:{title:"About",description:"Review cc-gw version details, build metadata, and current runtime status.",app:{title:"Application",subtitle:"Gateway build metadata at a glance.",labels:{name:"Name",version:"Version",buildTime:"Build time",node:"Node version"},hint:{buildTime:"Timestamps are recorded in UTC so you can trace deployments easily."}},status:{title:"Runtime status",subtitle:"Live metrics reported by the running gateway.",loading:"Fetching status...",empty:"Unable to retrieve status information.",labels:{host:"Listen host",port:"Listen port",providers:"Providers configured",active:"Active requests"},hint:{active:"Active request totals refresh roughly every minute."}},support:{title:"Operational notes",subtitle:"Maintenance guidance",description:"Manage providers, routing, and logs in the Web UI; advanced settings live in ~/.cc-gw/config.json.",tip:"Consider keeping ~/.cc-gw/config.json under version control or managing it via automation scripts.",actions:{checkUpdates:"Check for updates"}},toast:{statusError:{title:"Failed to load status"},updatesPlanned:"Update checks will arrive in a future release."}},endpoints:{title:"Custom Endpoints",description:"Manage custom API endpoints with multiple protocol support.",createButton:"Add Endpoint",createTitle:"Create Endpoint",editTitle:"Edit Endpoint",emptyTitle:"No custom endpoints",emptyDescription:'Click "Add Endpoint" to create your first custom endpoint.',loadError:"Failed to load endpoints",id:"ID",path:"Path",disabled:"Disabled",hasRouting:"Routing configured",protocols:{anthropic:"Anthropic Protocol","openai-chat":"OpenAI Chat","openai-responses":"OpenAI Responses"},protocolHints:{anthropic:"Anthropic Messages API protocol (/v1/messages)","openai-chat":"OpenAI Chat Completions API protocol (/v1/chat/completions)","openai-responses":"OpenAI Responses API protocol (/v1/responses)"},form:{id:"Endpoint ID",idPlaceholder:"e.g. custom-api",idHint:"ID cannot be changed after creation, used for internal identification.",label:"Display Name",labelPlaceholder:"e.g. My Custom API",path:"Access Path",pathPlaceholder:"e.g. /custom/api",pathHint:"Path must start with /. Changes take effect immediately.",protocol:"Protocol Type",enabled:"Enable this endpoint"},routing:{title:"Routing Configuration (Optional)",modelRoutes:"Model Routing Rules",addRoute:"Add Rule",noRoutes:"No routing rules",sourceModelPlaceholder:"Source model (e.g. claude-3-5-sonnet-20241022)",targetPlaceholder:"Target (e.g. anthropic:claude-3-5-sonnet-20241022)",modelRoutesHint:"Format: source model → provider:model, wildcards supported (e.g. gpt-* → openai:*)",defaults:"Default Model Configuration",defaultCompletion:"Default for completion tasks",defaultReasoning:"Default for reasoning tasks",defaultBackground:"Default for background tasks",longContextThreshold:"Long context threshold (tokens)",defaultPlaceholder:"e.g. anthropic:claude-3-5-sonnet-20241022"},createSuccess:"Endpoint created successfully",createError:"Failed to create: {{error}}",updateSuccess:"Endpoint updated successfully",updateError:"Failed to update: {{error}}",deleteSuccess:"Endpoint deleted successfully",deleteError:"Failed to delete: {{error}}",deleteConfirm:'Are you sure you want to delete endpoint "{{label}}"? This action cannot be undone.',validationError:"Please fill in all required fields"}}}};de.isInitialized||de.use(ev).init({resources:Gw,lng:"zh",fallbackLng:"en",interpolation:{escapeValue:!1}});const Zh=S.createContext(void 0);function Yw(){return`toast_${Math.random().toString(36).slice(2)}`}function Xw({children:e}){const[t,n]=S.useState([]),r=S.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=S.useCallback(o=>{const a=o.id??Yw();n(u=>[...u,{...o,id:a}]);const l=o.durationMs??3e3;l>0&&setTimeout(()=>r(a),l)},[r]),i=S.useMemo(()=>({toasts:t,pushToast:s,dismissToast:r}),[t,r,s]);return E.jsxs(Zh.Provider,{value:i,children:[e,E.jsx("div",{className:"fixed right-6 top-6 z-50 flex w-80 flex-col gap-3",children:t.map(o=>E.jsx("div",{className:`rounded-md border border-slate-200 bg-white p-4 shadow-lg dark:border-slate-700 dark:bg-slate-800 ${o.variant==="error"?"border-red-200 bg-red-50 text-red-900 dark:border-red-700 dark:bg-red-900/40 dark:text-red-200":o.variant==="success"?"border-emerald-200 bg-emerald-50 text-emerald-900 dark:border-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-200":""}`,children:E.jsxs("div",{className:"flex items-start justify-between gap-4",children:[E.jsxs("div",{children:[E.jsx("p",{className:"text-sm font-semibold",children:o.title}),o.description?E.jsx("p",{className:"mt-1 text-sm opacity-75",children:o.description}):null]}),E.jsx("button",{type:"button",className:"text-sm text-slate-500 hover:text-slate-900 dark:text-slate-400 dark:hover:text-slate-100",onClick:()=>r(o.id),children:"×"})]})},o.id))})]})}function rk(){const e=S.useContext(Zh);if(!e)throw new Error("useToast must be used within ToastProvider");return e}function Zw({children:e}){const[t]=S.useState(()=>new Ew);return E.jsx(bw,{client:t,children:E.jsx(sv,{i18n:de,children:E.jsx(vv,{children:E.jsx(Xw,{children:E.jsx(Y1,{children:e})})})})})}function em(){const{t:e}=Fs();return E.jsx("div",{className:"flex h-full items-center justify-center p-12",role:"status","aria-live":"polite",children:E.jsxs("div",{className:"flex flex-col items-center gap-4",children:[E.jsx("div",{className:"h-12 w-12 animate-spin rounded-full border-4 border-primary border-t-transparent"}),E.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:e("common.loading")})]})})}const ex=S.lazy(()=>mn(()=>import("./Dashboard-B7zokimB.js"),__vite__mapDeps([0,1,2,3,4,5]))),tx=S.lazy(()=>mn(()=>import("./Logs-CsJCTftU.js"),__vite__mapDeps([6,5,2,7,3,8,4]))),Td=S.lazy(()=>mn(()=>import("./ModelManagement-dDhNa_5z.js"),__vite__mapDeps([9,5]))),nx=S.lazy(()=>mn(()=>import("./ApiKeys-BGROxK6-.js"),__vite__mapDeps([10,1,5,2,7,3,8,4,11]))),rx=S.lazy(()=>mn(()=>import("./Settings-BcMQ79b0.js"),__vite__mapDeps([12,5,2,11]))),sx=S.lazy(()=>mn(()=>import("./About-DK242vw9.js"),__vite__mapDeps([13,5,2,3,8,14]))),ix=S.lazy(()=>mn(()=>import("./Help-CJooSMdJ.js"),__vite__mapDeps([15,2,14]))),ox=S.lazy(()=>mn(()=>import("./Login-B9RgxiYX.js"),[]));function ax({children:e}){const{authEnabled:t,isAuthenticated:n,loading:r}=Hh(),s=gn();return r?E.jsx(em,{}):!t||n?e:E.jsx(lh,{to:"/login",replace:!0,state:{from:s}})}function lx(){return E.jsx(Zw,{children:E.jsx(Fy,{basename:typeof window<"u"&&window.location.pathname.startsWith("/ui")?"/ui":"/",children:E.jsx(S.Suspense,{fallback:E.jsx(em,{}),children:E.jsxs(by,{children:[E.jsxs(Ke,{path:"/",element:E.jsx(ax,{children:E.jsx(Z1,{})}),children:[E.jsx(Ke,{index:!0,element:E.jsx(ex,{})}),E.jsx(Ke,{path:"logs",element:E.jsx(tx,{})}),E.jsx(Ke,{path:"models",element:E.jsx(Td,{})}),E.jsx(Ke,{path:"providers",element:E.jsx(Td,{})}),E.jsx(Ke,{path:"api-keys",element:E.jsx(nx,{})}),E.jsx(Ke,{path:"settings",element:E.jsx(rx,{})}),E.jsx(Ke,{path:"about",element:E.jsx(sx,{})}),E.jsx(Ke,{path:"help",element:E.jsx(ix,{})})]}),E.jsx(Ke,{path:"/login",element:E.jsx(ox,{})}),E.jsx(Ke,{path:"*",element:E.jsx(lh,{to:"/",replace:!0})})]})})})})}const tm=document.getElementById("root");if(!tm)throw new Error("Root element #root not found");la.createRoot(tm).render(E.jsx(Wd.StrictMode,{children:E.jsx(lx,{})}));export{fl as $,tt as A,av as B,tk as C,cx as D,gx as E,uv as F,Xx as G,fx as H,Rx as I,yx as J,kx as K,em as L,Sx as M,cv as N,im as O,Px as P,Ex as Q,Wd as R,Eo as S,gv as T,pv as U,pw as V,ow as W,pl as X,bo as Y,sw as Z,iw as _,rk as a,Vh as a0,ww as a1,uw as a2,ek as a3,vx as a4,dx as a5,hx as a6,px as a7,sh as a8,gn as a9,Hh as aa,vt as b,Be as c,Lt as d,Ix as e,Lx as f,wx as g,Nx as h,Cx as i,E as j,yh as k,Ox as l,mx as m,Ax as n,Tx as o,bx as p,A0 as q,S as r,xx as s,ia as t,Fs as u,Zx as v,Cs as w,Sw as x,Pe as y,nk as z};
|
|
207
|
+
After configuration, clients access via \`http://127.0.0.1:4100/claude/v1/messages\` (path auto-expansion).`,'Enable "Store request/response bodies" to copy raw payloads from the log drawer when troubleshooting.',"Turn off request or response logs individually to keep the console quiet while preserving metrics and database records.","Use **routing presets** to save common routing configurations and quickly switch between different provider setups.","If you edit ~/.cc-gw/config.json manually, refresh the Settings page or restart cc-gw so the UI reflects the latest configuration."]}},faq:{title:"Frequently asked questions",items:[{q:"How can I change the default model for each endpoint?",a:'Go to "Model Management → Routing" and choose defaults for /anthropic and /openai. Saving applies the change right away.'},{q:"How do I use custom endpoints?",a:'Create a custom endpoint in the "Model Management" page by configuring a base path (e.g., `/my-endpoint`) and protocol type. The system automatically registers full API paths based on the protocol. For example, after configuring `/claude` + `anthropic` protocol, clients access via `http://127.0.0.1:4100/claude/v1/messages`.\n\nIf you encounter 404 errors, check:\n1) Is the endpoint enabled?\n2) Are clients using the complete path (including protocol subpath)?\n3) Check server logs to confirm route registration'},{q:"Why are cached token numbers missing?",a:"Upstream providers must return cached_tokens or input_tokens_details.cached_tokens. Enable cache metrics on the provider if supported."},{q:"How can I use different models for different clients?",a:'Create separate API keys for each client and configure different routing rules in "Model Management → Routing". You can also create dedicated custom endpoints for different clients.'}]}},apiKeys:{title:"API Keys Management",description:"Create and manage API keys for gateway access",createNew:"Create New Key",createAction:"Create",createDescription:"Create a new API key for authentication and optionally add a description.",descriptionLabel:"Key description (optional)",keyDescriptionPlaceholder:"e.g. Internal staging access only",keyNamePlaceholder:"Enter key name",keyCreated:"API Key Created",saveKeyWarning:"This is the only time you'll see the full key. Save it securely!",wildcard:"Any Key",wildcardHint:"When enabled, any custom key — including an empty key — is accepted. Disable this key to enforce strict authentication.",status:{enabled:"Enabled",disabled:"Disabled"},actions:{enable:"Enable",disable:"Disable",delete:"Delete"},created:"Created",lastUsed:"Last Used",requestCount:"Requests",totalTokens:"Total Tokens",confirmDelete:"Are you sure you want to delete this API key? This action cannot be undone.",errors:{nameRequired:"Key name is required"},analytics:{title:"Key Usage Analytics",description:"Highlights for the past {{days}} days of API key activity",range:{today:"Today",week:"Last 7 days",month:"Last 30 days"},cards:{total:"Total keys",enabled:"Enabled keys",active:"Active keys ({{days}} days)"},charts:{requests:"Top 10 keys by request count",tokens:"Top 10 keys by token usage"},tokens:{input:"Input tokens",output:"Output tokens"},requestsSeries:"Requests",empty:"No activity for the selected range.",unknownKey:"Unknown key"},list:{title:"Key Inventory",empty:"No API keys found. Use the button above to create one."},toast:{keyCreated:"API key created successfully",keyUpdated:"API key updated successfully",keyDeleted:"API key deleted successfully",keyCopied:"Key copied to clipboard",createFailure:"Failed to create: {{message}}",updateFailure:"Failed to update: {{message}}",deleteFailure:"Failed to delete: {{message}}"}},about:{title:"About",description:"Review cc-gw version details, build metadata, and current runtime status.",app:{title:"Application",subtitle:"Gateway build metadata at a glance.",labels:{name:"Name",version:"Version",buildTime:"Build time",node:"Node version"},hint:{buildTime:"Timestamps are recorded in UTC so you can trace deployments easily."}},status:{title:"Runtime status",subtitle:"Live metrics reported by the running gateway.",loading:"Fetching status...",empty:"Unable to retrieve status information.",labels:{host:"Listen host",port:"Listen port",providers:"Providers configured",active:"Active requests"},hint:{active:"Active request totals refresh roughly every minute."}},support:{title:"Operational notes",subtitle:"Maintenance guidance",description:"Manage providers, routing, and logs in the Web UI; advanced settings live in ~/.cc-gw/config.json.",tip:"Consider keeping ~/.cc-gw/config.json under version control or managing it via automation scripts.",actions:{checkUpdates:"Check for updates"}},toast:{statusError:{title:"Failed to load status"},updatesPlanned:"Update checks will arrive in a future release."}},endpoints:{title:"Custom Endpoints",description:"Manage custom API endpoints with multiple protocol support.",createButton:"Add Endpoint",createTitle:"Create Endpoint",editTitle:"Edit Endpoint",emptyTitle:"No custom endpoints",emptyDescription:'Click "Add Endpoint" to create your first custom endpoint.',loadError:"Failed to load endpoints",id:"ID",path:"Path",disabled:"Disabled",hasRouting:"Routing configured",protocols:{anthropic:"Anthropic Protocol","openai-chat":"OpenAI Chat","openai-responses":"OpenAI Responses"},protocolHints:{anthropic:"Anthropic Messages API protocol (/v1/messages)","openai-chat":"OpenAI Chat Completions API protocol (/v1/chat/completions)","openai-responses":"OpenAI Responses API protocol (/v1/responses)"},form:{id:"Endpoint ID",idPlaceholder:"e.g. custom-api",idHint:"ID cannot be changed after creation, used for internal identification.",label:"Display Name",labelPlaceholder:"e.g. My Custom API",path:"Access Path",pathPlaceholder:"e.g. /custom/api",pathHint:"Path must start with /. Changes take effect immediately.",protocol:"Protocol Type",enabled:"Enable this endpoint"},routing:{title:"Routing Configuration (Optional)",modelRoutes:"Model Routing Rules",addRoute:"Add Rule",noRoutes:"No routing rules",sourceModelPlaceholder:"Source model (e.g. claude-3-5-sonnet-20241022)",targetPlaceholder:"Target (e.g. anthropic:claude-3-5-sonnet-20241022)",modelRoutesHint:"Format: source model → provider:model, wildcards supported (e.g. gpt-* → openai:*)",defaults:"Default Model Configuration",defaultCompletion:"Default for completion tasks",defaultReasoning:"Default for reasoning tasks",defaultBackground:"Default for background tasks",longContextThreshold:"Long context threshold (tokens)",defaultPlaceholder:"e.g. anthropic:claude-3-5-sonnet-20241022"},createSuccess:"Endpoint created successfully",createError:"Failed to create: {{error}}",updateSuccess:"Endpoint updated successfully",updateError:"Failed to update: {{error}}",deleteSuccess:"Endpoint deleted successfully",deleteError:"Failed to delete: {{error}}",deleteConfirm:'Are you sure you want to delete endpoint "{{label}}"? This action cannot be undone.',validationError:"Please fill in all required fields"}}}};de.isInitialized||de.use(ev).init({resources:Gw,lng:"zh",fallbackLng:"en",interpolation:{escapeValue:!1}});const Zh=S.createContext(void 0);function Yw(){return`toast_${Math.random().toString(36).slice(2)}`}function Xw({children:e}){const[t,n]=S.useState([]),r=S.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=S.useCallback(o=>{const a=o.id??Yw();n(u=>[...u,{...o,id:a}]);const l=o.durationMs??3e3;l>0&&setTimeout(()=>r(a),l)},[r]),i=S.useMemo(()=>({toasts:t,pushToast:s,dismissToast:r}),[t,r,s]);return E.jsxs(Zh.Provider,{value:i,children:[e,E.jsx("div",{className:"fixed right-6 top-6 z-50 flex w-80 flex-col gap-3",children:t.map(o=>E.jsx("div",{className:`rounded-md border border-slate-200 bg-white p-4 shadow-lg dark:border-slate-700 dark:bg-slate-800 ${o.variant==="error"?"border-red-200 bg-red-50 text-red-900 dark:border-red-700 dark:bg-red-900/40 dark:text-red-200":o.variant==="success"?"border-emerald-200 bg-emerald-50 text-emerald-900 dark:border-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-200":""}`,children:E.jsxs("div",{className:"flex items-start justify-between gap-4",children:[E.jsxs("div",{children:[E.jsx("p",{className:"text-sm font-semibold",children:o.title}),o.description?E.jsx("p",{className:"mt-1 text-sm opacity-75",children:o.description}):null]}),E.jsx("button",{type:"button",className:"text-sm text-slate-500 hover:text-slate-900 dark:text-slate-400 dark:hover:text-slate-100",onClick:()=>r(o.id),children:"×"})]})},o.id))})]})}function rk(){const e=S.useContext(Zh);if(!e)throw new Error("useToast must be used within ToastProvider");return e}function Zw({children:e}){const[t]=S.useState(()=>new Ew);return E.jsx(bw,{client:t,children:E.jsx(sv,{i18n:de,children:E.jsx(vv,{children:E.jsx(Xw,{children:E.jsx(Y1,{children:e})})})})})}function em(){const{t:e}=Fs();return E.jsx("div",{className:"flex h-full items-center justify-center p-12",role:"status","aria-live":"polite",children:E.jsxs("div",{className:"flex flex-col items-center gap-4",children:[E.jsx("div",{className:"h-12 w-12 animate-spin rounded-full border-4 border-primary border-t-transparent"}),E.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:e("common.loading")})]})})}const ex=S.lazy(()=>mn(()=>import("./Dashboard-U1EC6qmF.js"),__vite__mapDeps([0,1,2,3,4,5]))),tx=S.lazy(()=>mn(()=>import("./Logs-C-7diPqf.js"),__vite__mapDeps([6,5,2,7,3,8,4]))),Td=S.lazy(()=>mn(()=>import("./ModelManagement-BWX0w6Wu.js"),__vite__mapDeps([9,5]))),nx=S.lazy(()=>mn(()=>import("./ApiKeys-CNNwIRTy.js"),__vite__mapDeps([10,1,5,2,7,3,8,4,11]))),rx=S.lazy(()=>mn(()=>import("./Settings-CLM0Srx1.js"),__vite__mapDeps([12,5,2,11]))),sx=S.lazy(()=>mn(()=>import("./About-R4GuiAOC.js"),__vite__mapDeps([13,5,2,3,8,14]))),ix=S.lazy(()=>mn(()=>import("./Help-COAfsR6K.js"),__vite__mapDeps([15,2,14]))),ox=S.lazy(()=>mn(()=>import("./Login-BbRStE3M.js"),[]));function ax({children:e}){const{authEnabled:t,isAuthenticated:n,loading:r}=Hh(),s=gn();return r?E.jsx(em,{}):!t||n?e:E.jsx(lh,{to:"/login",replace:!0,state:{from:s}})}function lx(){return E.jsx(Zw,{children:E.jsx(Fy,{basename:typeof window<"u"&&window.location.pathname.startsWith("/ui")?"/ui":"/",children:E.jsx(S.Suspense,{fallback:E.jsx(em,{}),children:E.jsxs(by,{children:[E.jsxs(Ke,{path:"/",element:E.jsx(ax,{children:E.jsx(Z1,{})}),children:[E.jsx(Ke,{index:!0,element:E.jsx(ex,{})}),E.jsx(Ke,{path:"logs",element:E.jsx(tx,{})}),E.jsx(Ke,{path:"models",element:E.jsx(Td,{})}),E.jsx(Ke,{path:"providers",element:E.jsx(Td,{})}),E.jsx(Ke,{path:"api-keys",element:E.jsx(nx,{})}),E.jsx(Ke,{path:"settings",element:E.jsx(rx,{})}),E.jsx(Ke,{path:"about",element:E.jsx(sx,{})}),E.jsx(Ke,{path:"help",element:E.jsx(ix,{})})]}),E.jsx(Ke,{path:"/login",element:E.jsx(ox,{})}),E.jsx(Ke,{path:"*",element:E.jsx(lh,{to:"/",replace:!0})})]})})})})}const tm=document.getElementById("root");if(!tm)throw new Error("Root element #root not found");la.createRoot(tm).render(E.jsx(Wd.StrictMode,{children:E.jsx(lx,{})}));export{fl as $,tt as A,av as B,tk as C,cx as D,gx as E,uv as F,Xx as G,fx as H,Rx as I,yx as J,kx as K,em as L,Sx as M,cv as N,im as O,Px as P,Ex as Q,Wd as R,Eo as S,gv as T,pv as U,pw as V,ow as W,pl as X,bo as Y,sw as Z,iw as _,rk as a,Vh as a0,ww as a1,uw as a2,ek as a3,vx as a4,dx as a5,hx as a6,px as a7,sh as a8,gn as a9,Hh as aa,vt as b,Be as c,Lt as d,Ix as e,Lx as f,wx as g,Nx as h,Cx as i,E as j,yh as k,Ox as l,mx as m,Ax as n,Tx as o,bx as p,A0 as q,S as r,xx as s,ia as t,Fs as u,Zx as v,Cs as w,Sw as x,Pe as y,nk as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{O as VL,R as zL,r as GL}from"./index-
|
|
1
|
+
import{O as VL,R as zL,r as GL}from"./index-3UByifOG.js";/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ft=e=>{throw TypeError(e)};var $=(e,t,s)=>t.has(e)||ft("Cannot "+s);var i=(e,t,s)=>($(e,t,"read from private field"),s?s.call(e):t.get(e)),b=(e,t,s)=>t.has(e)?ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),u=(e,t,s,r)=>($(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s),d=(e,t,s)=>($(e,t,"access private method"),s);import{S as It,V as pt,W as S,v as G,X as H,A as J,Y as tt,Z as bt,_ as Ot,$ as q,a0 as Tt,a1 as wt,a2 as yt,y as St,r as I,C as Qt,z as Mt,a3 as _t,b as xt,t as Ut}from"./index-agm-2asf.js";var g,a,j,y,Q,U,E,O,z,F,D,M,_,T,P,n,B,et,st,it,rt,at,nt,ht,Ct,vt,Ft=(vt=class extends It{constructor(t,s){super();b(this,n);b(this,g);b(this,a);b(this,j);b(this,y);b(this,Q);b(this,U);b(this,E);b(this,O);b(this,z);b(this,F);b(this,D);b(this,M);b(this,_);b(this,T);b(this,P,new Set);this.options=s,u(this,g,t),u(this,O,null),u(this,E,pt()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,a).addObserver(this),gt(i(this,a),this.options)?d(this,n,B).call(this):this.updateResult(),d(this,n,rt).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ot(i(this,a),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ot(i(this,a),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,d(this,n,at).call(this),d(this,n,nt).call(this),i(this,a).removeObserver(this)}setOptions(t){const s=this.options,r=i(this,a);if(this.options=i(this,g).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof S(this.options.enabled,i(this,a))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");d(this,n,ht).call(this),i(this,a).setOptions(this.options),s._defaulted&&!G(this.options,s)&&i(this,g).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,a),observer:this});const h=this.hasListeners();h&&mt(i(this,a),r,this.options,s)&&d(this,n,B).call(this),this.updateResult(),h&&(i(this,a)!==r||S(this.options.enabled,i(this,a))!==S(s.enabled,i(this,a))||H(this.options.staleTime,i(this,a))!==H(s.staleTime,i(this,a)))&&d(this,n,et).call(this);const o=d(this,n,st).call(this);h&&(i(this,a)!==r||S(this.options.enabled,i(this,a))!==S(s.enabled,i(this,a))||o!==i(this,T))&&d(this,n,it).call(this,o)}getOptimisticResult(t){const s=i(this,g).getQueryCache().build(i(this,g),t),r=this.createResult(s,t);return Pt(this,r)&&(u(this,y,r),u(this,U,this.options),u(this,Q,i(this,a).state)),r}getCurrentResult(){return i(this,y)}trackResult(t,s){return new Proxy(t,{get:(r,h)=>(this.trackProp(h),s==null||s(h),h==="promise"&&!this.options.experimental_prefetchInRender&&i(this,E).status==="pending"&&i(this,E).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(r,h))})}trackProp(t){i(this,P).add(t)}getCurrentQuery(){return i(this,a)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=i(this,g).defaultQueryOptions(t),r=i(this,g).getQueryCache().build(i(this,g),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(t){return d(this,n,B).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,y)))}createResult(t,s){var dt;const r=i(this,a),h=this.options,o=i(this,y),c=i(this,Q),w=i(this,U),v=t!==r?t.state:i(this,j),{state:L}=t;let l={...L},N=!1,f;if(s._optimisticResults){const R=this.hasListeners(),W=!R&>(t,s),x=R&&mt(t,r,s,h);(W||x)&&(l={...l,...wt(L.data,t.options)}),s._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:A,errorUpdatedAt:k,status:m}=l;f=l.data;let V=!1;if(s.placeholderData!==void 0&&f===void 0&&m==="pending"){let R;o!=null&&o.isPlaceholderData&&s.placeholderData===(w==null?void 0:w.placeholderData)?(R=o.data,V=!0):R=typeof s.placeholderData=="function"?s.placeholderData((dt=i(this,D))==null?void 0:dt.state.data,i(this,D)):s.placeholderData,R!==void 0&&(m="success",f=yt(o==null?void 0:o.data,R,s),N=!0)}if(s.select&&f!==void 0&&!V)if(o&&f===(c==null?void 0:c.data)&&s.select===i(this,z))f=i(this,F);else try{u(this,z,s.select),f=s.select(f),f=yt(o==null?void 0:o.data,f,s),u(this,F,f),u(this,O,null)}catch(R){u(this,O,R)}i(this,O)&&(A=i(this,O),f=i(this,F),k=Date.now(),m="error");const X=l.fetchStatus==="fetching",Y=m==="pending",Z=m==="error",ut=Y&&X,lt=f!==void 0,C={status:m,fetchStatus:l.fetchStatus,isPending:Y,isSuccess:m==="success",isError:Z,isInitialLoading:ut,isLoading:ut,data:f,dataUpdatedAt:l.dataUpdatedAt,error:A,errorUpdatedAt:k,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>v.dataUpdateCount||l.errorUpdateCount>v.errorUpdateCount,isFetching:X,isRefetching:X&&!Y,isLoadingError:Z&&!lt,isPaused:l.fetchStatus==="paused",isPlaceholderData:N,isRefetchError:Z&<,isStale:ct(t,s),refetch:this.refetch,promise:i(this,E),isEnabled:S(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=K=>{C.status==="error"?K.reject(C.error):C.data!==void 0&&K.resolve(C.data)},W=()=>{const K=u(this,E,C.promise=pt());R(K)},x=i(this,E);switch(x.status){case"pending":t.queryHash===r.queryHash&&R(x);break;case"fulfilled":(C.status==="error"||C.data!==x.value)&&W();break;case"rejected":(C.status!=="error"||C.error!==x.reason)&&W();break}}return C}updateResult(){const t=i(this,y),s=this.createResult(i(this,a),this.options);if(u(this,Q,i(this,a).state),u(this,U,this.options),i(this,Q).data!==void 0&&u(this,D,i(this,a)),G(s,t))return;u(this,y,s);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:h}=this.options,o=typeof h=="function"?h():h;if(o==="all"||!o&&!i(this,P).size)return!0;const c=new Set(o??i(this,P));return this.options.throwOnError&&c.add("error"),Object.keys(i(this,y)).some(w=>{const p=w;return i(this,y)[p]!==t[p]&&c.has(p)})};d(this,n,Ct).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&d(this,n,rt).call(this)}},g=new WeakMap,a=new WeakMap,j=new WeakMap,y=new WeakMap,Q=new WeakMap,U=new WeakMap,E=new WeakMap,O=new WeakMap,z=new WeakMap,F=new WeakMap,D=new WeakMap,M=new WeakMap,_=new WeakMap,T=new WeakMap,P=new WeakMap,n=new WeakSet,B=function(t){d(this,n,ht).call(this);let s=i(this,a).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(J)),s},et=function(){d(this,n,at).call(this);const t=H(this.options.staleTime,i(this,a));if(tt||i(this,y).isStale||!bt(t))return;const r=Ot(i(this,y).dataUpdatedAt,t)+1;u(this,M,q.setTimeout(()=>{i(this,y).isStale||this.updateResult()},r))},st=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,a)):this.options.refetchInterval)??!1},it=function(t){d(this,n,nt).call(this),u(this,T,t),!(tt||S(this.options.enabled,i(this,a))===!1||!bt(i(this,T))||i(this,T)===0)&&u(this,_,q.setInterval(()=>{(this.options.refetchIntervalInBackground||Tt.isFocused())&&d(this,n,B).call(this)},i(this,T)))},rt=function(){d(this,n,et).call(this),d(this,n,it).call(this,d(this,n,st).call(this))},at=function(){i(this,M)&&(q.clearTimeout(i(this,M)),u(this,M,void 0))},nt=function(){i(this,_)&&(q.clearInterval(i(this,_)),u(this,_,void 0))},ht=function(){const t=i(this,g).getQueryCache().build(i(this,g),this.options);if(t===i(this,a))return;const s=i(this,a);u(this,a,t),u(this,j,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Ct=function(t){St.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(i(this,y))}),i(this,g).getQueryCache().notify({query:i(this,a),type:"observerResultsUpdated"})})},vt);function Dt(e,t){return S(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function gt(e,t){return Dt(e,t)||e.state.data!==void 0&&ot(e,t,t.refetchOnMount)}function ot(e,t,s){if(S(t.enabled,e)!==!1&&H(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&ct(e,t)}return!1}function mt(e,t,s,r){return(e!==t||S(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&ct(e,s)}function ct(e,t){return S(t.enabled,e)!==!1&&e.isStaleByTime(H(t.staleTime,e))}function Pt(e,t){return!G(e.getCurrentResult(),t)}var Et=I.createContext(!1),Lt=()=>I.useContext(Et);Et.Provider;function Nt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var At=I.createContext(Nt()),kt=()=>I.useContext(At),Bt=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Ht=e=>{I.useEffect(()=>{e.clearReset()},[e])},jt=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:h})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(h&&e.data===void 0||Qt(s,[e.error,r])),zt=e=>{if(e.suspense){const s=h=>h==="static"?h:Math.max(h??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...h)=>s(r(...h)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Vt=(e,t)=>e.isLoading&&e.isFetching&&!t,Wt=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Rt=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Kt(e,t,s){var l,N,f,A,k;const r=Lt(),h=kt(),o=Mt(),c=o.defaultQueryOptions(e);(N=(l=o.getDefaultOptions().queries)==null?void 0:l._experimental_beforeQuery)==null||N.call(l,c),c._optimisticResults=r?"isRestoring":"optimistic",zt(c),Bt(c,h),Ht(h);const w=!o.getQueryCache().get(c.queryHash),[p]=I.useState(()=>new t(o,c)),v=p.getOptimisticResult(c),L=!r&&e.subscribed!==!1;if(I.useSyncExternalStore(I.useCallback(m=>{const V=L?p.subscribe(St.batchCalls(m)):J;return p.updateResult(),V},[p,L]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),I.useEffect(()=>{p.setOptions(c)},[c,p]),Wt(c,v))throw Rt(c,p,h);if(jt({result:v,errorResetBoundary:h,throwOnError:c.throwOnError,query:o.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw v.error;if((A=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||A.call(f,c,v),c.experimental_prefetchInRender&&!tt&&Vt(v,r)){const m=w?Rt(c,p,h):(k=o.getQueryCache().get(c.queryHash))==null?void 0:k.promise;m==null||m.catch(J).finally(()=>{p.updateResult()})}return c.notifyOnChangeProps?v:p.trackResult(v)}function qt(e,t){return Kt(e,Ft)}function $t(e,t,s){return qt({queryKey:e,placeholderData:_t,...s,queryFn:async()=>{try{return(await xt.request(t)).data}catch(r){throw Ut(r)}}})}export{qt as a,$t as u};
|
|
1
|
+
var ft=e=>{throw TypeError(e)};var $=(e,t,s)=>t.has(e)||ft("Cannot "+s);var i=(e,t,s)=>($(e,t,"read from private field"),s?s.call(e):t.get(e)),b=(e,t,s)=>t.has(e)?ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),u=(e,t,s,r)=>($(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s),d=(e,t,s)=>($(e,t,"access private method"),s);import{S as It,V as pt,W as S,v as G,X as H,A as J,Y as tt,Z as bt,_ as Ot,$ as q,a0 as Tt,a1 as wt,a2 as yt,y as St,r as I,C as Qt,z as Mt,a3 as _t,b as xt,t as Ut}from"./index-3UByifOG.js";var g,a,j,y,Q,U,E,O,z,F,D,M,_,T,P,n,B,et,st,it,rt,at,nt,ht,Ct,vt,Ft=(vt=class extends It{constructor(t,s){super();b(this,n);b(this,g);b(this,a);b(this,j);b(this,y);b(this,Q);b(this,U);b(this,E);b(this,O);b(this,z);b(this,F);b(this,D);b(this,M);b(this,_);b(this,T);b(this,P,new Set);this.options=s,u(this,g,t),u(this,O,null),u(this,E,pt()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,a).addObserver(this),gt(i(this,a),this.options)?d(this,n,B).call(this):this.updateResult(),d(this,n,rt).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ot(i(this,a),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ot(i(this,a),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,d(this,n,at).call(this),d(this,n,nt).call(this),i(this,a).removeObserver(this)}setOptions(t){const s=this.options,r=i(this,a);if(this.options=i(this,g).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof S(this.options.enabled,i(this,a))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");d(this,n,ht).call(this),i(this,a).setOptions(this.options),s._defaulted&&!G(this.options,s)&&i(this,g).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,a),observer:this});const h=this.hasListeners();h&&mt(i(this,a),r,this.options,s)&&d(this,n,B).call(this),this.updateResult(),h&&(i(this,a)!==r||S(this.options.enabled,i(this,a))!==S(s.enabled,i(this,a))||H(this.options.staleTime,i(this,a))!==H(s.staleTime,i(this,a)))&&d(this,n,et).call(this);const o=d(this,n,st).call(this);h&&(i(this,a)!==r||S(this.options.enabled,i(this,a))!==S(s.enabled,i(this,a))||o!==i(this,T))&&d(this,n,it).call(this,o)}getOptimisticResult(t){const s=i(this,g).getQueryCache().build(i(this,g),t),r=this.createResult(s,t);return Pt(this,r)&&(u(this,y,r),u(this,U,this.options),u(this,Q,i(this,a).state)),r}getCurrentResult(){return i(this,y)}trackResult(t,s){return new Proxy(t,{get:(r,h)=>(this.trackProp(h),s==null||s(h),h==="promise"&&!this.options.experimental_prefetchInRender&&i(this,E).status==="pending"&&i(this,E).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(r,h))})}trackProp(t){i(this,P).add(t)}getCurrentQuery(){return i(this,a)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=i(this,g).defaultQueryOptions(t),r=i(this,g).getQueryCache().build(i(this,g),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(t){return d(this,n,B).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,y)))}createResult(t,s){var dt;const r=i(this,a),h=this.options,o=i(this,y),c=i(this,Q),w=i(this,U),v=t!==r?t.state:i(this,j),{state:L}=t;let l={...L},N=!1,f;if(s._optimisticResults){const R=this.hasListeners(),W=!R&>(t,s),x=R&&mt(t,r,s,h);(W||x)&&(l={...l,...wt(L.data,t.options)}),s._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:A,errorUpdatedAt:k,status:m}=l;f=l.data;let V=!1;if(s.placeholderData!==void 0&&f===void 0&&m==="pending"){let R;o!=null&&o.isPlaceholderData&&s.placeholderData===(w==null?void 0:w.placeholderData)?(R=o.data,V=!0):R=typeof s.placeholderData=="function"?s.placeholderData((dt=i(this,D))==null?void 0:dt.state.data,i(this,D)):s.placeholderData,R!==void 0&&(m="success",f=yt(o==null?void 0:o.data,R,s),N=!0)}if(s.select&&f!==void 0&&!V)if(o&&f===(c==null?void 0:c.data)&&s.select===i(this,z))f=i(this,F);else try{u(this,z,s.select),f=s.select(f),f=yt(o==null?void 0:o.data,f,s),u(this,F,f),u(this,O,null)}catch(R){u(this,O,R)}i(this,O)&&(A=i(this,O),f=i(this,F),k=Date.now(),m="error");const X=l.fetchStatus==="fetching",Y=m==="pending",Z=m==="error",ut=Y&&X,lt=f!==void 0,C={status:m,fetchStatus:l.fetchStatus,isPending:Y,isSuccess:m==="success",isError:Z,isInitialLoading:ut,isLoading:ut,data:f,dataUpdatedAt:l.dataUpdatedAt,error:A,errorUpdatedAt:k,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>v.dataUpdateCount||l.errorUpdateCount>v.errorUpdateCount,isFetching:X,isRefetching:X&&!Y,isLoadingError:Z&&!lt,isPaused:l.fetchStatus==="paused",isPlaceholderData:N,isRefetchError:Z&<,isStale:ct(t,s),refetch:this.refetch,promise:i(this,E),isEnabled:S(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=K=>{C.status==="error"?K.reject(C.error):C.data!==void 0&&K.resolve(C.data)},W=()=>{const K=u(this,E,C.promise=pt());R(K)},x=i(this,E);switch(x.status){case"pending":t.queryHash===r.queryHash&&R(x);break;case"fulfilled":(C.status==="error"||C.data!==x.value)&&W();break;case"rejected":(C.status!=="error"||C.error!==x.reason)&&W();break}}return C}updateResult(){const t=i(this,y),s=this.createResult(i(this,a),this.options);if(u(this,Q,i(this,a).state),u(this,U,this.options),i(this,Q).data!==void 0&&u(this,D,i(this,a)),G(s,t))return;u(this,y,s);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:h}=this.options,o=typeof h=="function"?h():h;if(o==="all"||!o&&!i(this,P).size)return!0;const c=new Set(o??i(this,P));return this.options.throwOnError&&c.add("error"),Object.keys(i(this,y)).some(w=>{const p=w;return i(this,y)[p]!==t[p]&&c.has(p)})};d(this,n,Ct).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&d(this,n,rt).call(this)}},g=new WeakMap,a=new WeakMap,j=new WeakMap,y=new WeakMap,Q=new WeakMap,U=new WeakMap,E=new WeakMap,O=new WeakMap,z=new WeakMap,F=new WeakMap,D=new WeakMap,M=new WeakMap,_=new WeakMap,T=new WeakMap,P=new WeakMap,n=new WeakSet,B=function(t){d(this,n,ht).call(this);let s=i(this,a).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(J)),s},et=function(){d(this,n,at).call(this);const t=H(this.options.staleTime,i(this,a));if(tt||i(this,y).isStale||!bt(t))return;const r=Ot(i(this,y).dataUpdatedAt,t)+1;u(this,M,q.setTimeout(()=>{i(this,y).isStale||this.updateResult()},r))},st=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,a)):this.options.refetchInterval)??!1},it=function(t){d(this,n,nt).call(this),u(this,T,t),!(tt||S(this.options.enabled,i(this,a))===!1||!bt(i(this,T))||i(this,T)===0)&&u(this,_,q.setInterval(()=>{(this.options.refetchIntervalInBackground||Tt.isFocused())&&d(this,n,B).call(this)},i(this,T)))},rt=function(){d(this,n,et).call(this),d(this,n,it).call(this,d(this,n,st).call(this))},at=function(){i(this,M)&&(q.clearTimeout(i(this,M)),u(this,M,void 0))},nt=function(){i(this,_)&&(q.clearInterval(i(this,_)),u(this,_,void 0))},ht=function(){const t=i(this,g).getQueryCache().build(i(this,g),this.options);if(t===i(this,a))return;const s=i(this,a);u(this,a,t),u(this,j,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Ct=function(t){St.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(i(this,y))}),i(this,g).getQueryCache().notify({query:i(this,a),type:"observerResultsUpdated"})})},vt);function Dt(e,t){return S(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function gt(e,t){return Dt(e,t)||e.state.data!==void 0&&ot(e,t,t.refetchOnMount)}function ot(e,t,s){if(S(t.enabled,e)!==!1&&H(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&ct(e,t)}return!1}function mt(e,t,s,r){return(e!==t||S(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&ct(e,s)}function ct(e,t){return S(t.enabled,e)!==!1&&e.isStaleByTime(H(t.staleTime,e))}function Pt(e,t){return!G(e.getCurrentResult(),t)}var Et=I.createContext(!1),Lt=()=>I.useContext(Et);Et.Provider;function Nt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var At=I.createContext(Nt()),kt=()=>I.useContext(At),Bt=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Ht=e=>{I.useEffect(()=>{e.clearReset()},[e])},jt=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:h})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(h&&e.data===void 0||Qt(s,[e.error,r])),zt=e=>{if(e.suspense){const s=h=>h==="static"?h:Math.max(h??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...h)=>s(r(...h)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Vt=(e,t)=>e.isLoading&&e.isFetching&&!t,Wt=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Rt=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Kt(e,t,s){var l,N,f,A,k;const r=Lt(),h=kt(),o=Mt(),c=o.defaultQueryOptions(e);(N=(l=o.getDefaultOptions().queries)==null?void 0:l._experimental_beforeQuery)==null||N.call(l,c),c._optimisticResults=r?"isRestoring":"optimistic",zt(c),Bt(c,h),Ht(h);const w=!o.getQueryCache().get(c.queryHash),[p]=I.useState(()=>new t(o,c)),v=p.getOptimisticResult(c),L=!r&&e.subscribed!==!1;if(I.useSyncExternalStore(I.useCallback(m=>{const V=L?p.subscribe(St.batchCalls(m)):J;return p.updateResult(),V},[p,L]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),I.useEffect(()=>{p.setOptions(c)},[c,p]),Wt(c,v))throw Rt(c,p,h);if(jt({result:v,errorResetBoundary:h,throwOnError:c.throwOnError,query:o.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw v.error;if((A=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||A.call(f,c,v),c.experimental_prefetchInRender&&!tt&&Vt(v,r)){const m=w?Rt(c,p,h):(k=o.getQueryCache().get(c.queryHash))==null?void 0:k.promise;m==null||m.catch(J).finally(()=>{p.updateResult()})}return c.notifyOnChangeProps?v:p.trackResult(v)}function qt(e,t){return Kt(e,Ft)}function $t(e,t,s){return qt({queryKey:e,placeholderData:_t,...s,queryFn:async()=>{try{return(await xt.request(t)).data}catch(r){throw Ut(r)}}})}export{qt as a,$t as u};
|
package/src/web/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
|
6
6
|
<meta name="format-detection" content="telephone=no" />
|
|
7
7
|
<title>cc-gw 控制台</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-3UByifOG.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-BFd07aus.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body class="bg-slate-50 text-slate-900 dark:bg-slate-900 dark:text-slate-50">
|