Files
Nexus/web/app/assets/SettingsPage-mljOMpbv.js
T
Your Name 51948469c2 build(frontend): track Vite output in Git for Gitea deploy
- Stop ignoring web/app/index.html and web/app/assets/
- Bundle index-DBKIQT7H.js from current vite build (~101MB assets)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 00:52:44 +08:00

3 lines
14 KiB
JavaScript

import{$n as e,Ar as t,Er as n,F as r,Ft as ee,Jn as i,L as a,M as o,N as s,P as c,Qn as l,Rt as u,Un as te,Xn as d,Y as f,Yn as p,br as m,cr as ne,gr as h,j as g,q as re,qn as _,t as v,tr as ie,ur as y}from"./index-DGeqMJUY.js";import{t as ae}from"./useSnackbar-D7YOfKok.js";import{t as oe}from"./VChip-C4fNZBKq.js";import{t as b}from"./VDialog-BwAkdsxH.js";import{a as se}from"./VSelectionControl-LeS8GYyn.js";import{n as x,t as S}from"./VRow-Bzc0SVl1.js";import{t as C}from"./VSpacer-mvmej6zi.js";import{a as w,i as T,n as E,r as ce}from"./validation-Yxuom3Du.js";import{t as le}from"./VTextarea-DWbFFWfF.js";import{t as ue}from"./VSwitch-7YaxYqLE.js";var de={class:`d-flex align-center mb-3`},fe={key:0,class:`text-center mb-3`},pe=[`src`],me={key:0,class:`d-flex align-center justify-center ga-2 mt-2`},he={class:`text-caption pa-1 bg-grey-lighten-4 rounded`,style:{"user-select":`all`}},ge={key:1},_e={key:1,class:`d-flex ga-2 align-center`},ve={class:`d-flex align-center ga-2`},D=ie({__name:`SettingsPage`,setup(ie){let D=ae(),O=ee(),k=m(!1),A=m({system_name:``,system_title:``,cpu_alert_threshold:80,mem_alert_threshold:80,disk_alert_threshold:80,db_pool_size:10,db_max_overflow:20,telegram_bot_token:``,telegram_chat_id:``}),j=m(!1),M=m(!1),N=m(!1),P=m({current:``,new_pw:``,confirm:``,totp_code:``}),F=m(!1),I=m(``),L=m(``),R=m(``),z=m(!1),B=m(!1),V=m(``),H=m(``),U=m(!1),W=m(!1),G=m(``),K=m(!1),q=m(``),J=m(!1),Y=m(!1),X=m(``),Z=m(!1);async function ye(){k.value=!0;try{let e=await u.get(`/settings/`),t=Array.isArray(e)?e:[],n=Object.keys(A.value);for(let e of t){let t=e.key;if(t&&n.includes(t)){let n=e.value;typeof n==`string`&&/^\d+(\.\d+)?$/.test(n)?A.value[t]=Number(n):A.value[t]=n}}}catch{D(`加载设置失败`,`error`)}finally{k.value=!1}}async function be(){try{let e=await u.get(`/settings/ip-allowlist`);Y.value=e.enabled||!1,X.value=[...e.manual_ips||[],...e.subscription_ips||[]].join(`
`)}catch{D(`加载白名单失败`,`error`)}}async function xe(){j.value=!0;try{let e=Object.entries(A.value).filter(([e])=>[`system_name`,`system_title`,`cpu_alert_threshold`,`mem_alert_threshold`,`disk_alert_threshold`,`db_pool_size`,`db_max_overflow`,`telegram_bot_token`,`telegram_chat_id`].includes(e));for(let[t,n]of e)await u.put(`/settings/${t}`,{value:n});D(`设置已保存`)}catch(e){D(e instanceof Error?e.message:`保存失败`,`error`)}finally{j.value=!1}}async function Se(){M.value=!0;try{await u.post(`/settings/telegram/test`),D(`测试消息已发送`)}catch(e){D(e.message||`发送失败`,`error`)}finally{M.value=!1}}async function Ce(){if(P.value.new_pw!==P.value.confirm){D(`两次密码不一致`,`error`);return}F.value=!0;try{let e={current_password:P.value.current,new_password:P.value.new_pw};O.admin?.totp_enabled&&P.value.totp_code&&(e.totp_code=P.value.totp_code),await u.put(`/auth/password`,e),P.value={current:``,new_pw:``,confirm:``,totp_code:``},D(`密码已修改`)}catch(e){D(e instanceof Error?e.message:`修改失败`,`error`)}finally{F.value=!1}}async function we(){try{let e=await u.post(`/auth/totp/setup`);I.value=e.qr_code,L.value=e.secret||``}catch(e){D(e instanceof Error?e.message:`生成失败`,`error`)}}async function Q(){z.value=!0;try{await u.post(`/auth/totp/enable`,{code:R.value}),await O.fetchProfile(),I.value=``,R.value=``,D(`TOTP 已启用`)}catch(e){D(e.message||`启用失败`,`error`)}finally{z.value=!1}}function Te(){B.value=!0}async function Ee(){U.value=!0;try{await u.post(`/auth/totp/disable`,{admin_id:O.admin?.id,current_password:V.value,totp_code:H.value}),await O.fetchProfile(),B.value=!1,V.value=``,H.value=``,D(`TOTP 已禁用`)}catch(e){D(e.message||`禁用失败`,`error`)}finally{U.value=!1}}function De(){L.value&&(navigator.clipboard.writeText(L.value),D(`密钥已复制`))}async function Oe(){if(W.value){W.value=!1;return}K.value=!0,q.value=``}async function $(){if(!q.value){D(`请输入密码`,`error`);return}J.value=!0;try{G.value=(await u.post(`/settings/api-key/reveal`,{current_password:q.value})).api_key,W.value=!0,K.value=!1,q.value=``}catch(e){D(e.message||`验证失败`,`error`)}finally{J.value=!1}}function ke(){G.value&&(navigator.clipboard.writeText(G.value),D(`已复制到剪贴板`))}async function Ae(){try{await u.post(`/settings/ip-allowlist/toggle`,{enabled:Y.value})}catch(e){D(e.message||`操作失败`,`error`)}}async function je(){Z.value=!0;try{let e=X.value.split(`
`).map(e=>e.trim()).filter(Boolean);await u.post(`/settings/ip-allowlist`,{ips:e}),D(`白名单已保存`)}catch(e){D(e.message||`保存失败`,`error`)}finally{Z.value=!1}}return ne(()=>{ye(),be(),O.fetchProfile()}),(ee,u)=>(y(),i(se,{fluid:``,class:`pa-6`},{default:h(()=>[e(S,null,{default:h(()=>[e(x,{cols:`12`,lg:`6`},{default:h(()=>[e(o,{elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:h(()=>[e(c,{class:`d-flex align-center`},{default:h(()=>[e(f,{class:`mr-2`},{default:h(()=>[...u[24]||=[l(`mdi-cog`,-1)]]),_:1}),u[25]||=l(` 系统设置 `,-1)]),_:1}),k.value?(y(),i(re,{key:0,indeterminate:``,color:`primary`})):p(``,!0),e(g),e(s,null,{default:h(()=>[e(v,{modelValue:A.value.system_name,"onUpdate:modelValue":u[0]||=e=>A.value.system_name=e,label:`系统名称`,variant:`outlined`,density:`compact`,class:`mb-3`,rules:[n(w)(`系统名称`)]},null,8,[`modelValue`,`rules`]),e(v,{modelValue:A.value.system_title,"onUpdate:modelValue":u[1]||=e=>A.value.system_title=e,label:`系统标题`,variant:`outlined`,density:`compact`,class:`mb-3`,rules:[n(w)(`系统标题`)]},null,8,[`modelValue`,`rules`]),e(g,{class:`my-4`}),u[26]||=_(`div`,{class:`text-subtitle-2 mb-3`},`告警阈值`,-1),e(S,{dense:``},{default:h(()=>[e(x,{cols:`4`},{default:h(()=>[e(v,{modelValue:A.value.cpu_alert_threshold,"onUpdate:modelValue":u[2]||=e=>A.value.cpu_alert_threshold=e,label:`CPU %`,variant:`outlined`,density:`compact`,type:`number`,rules:[n(w)(`阈值`),n(T)(1,100,`阈值`)]},null,8,[`modelValue`,`rules`])]),_:1}),e(x,{cols:`4`},{default:h(()=>[e(v,{modelValue:A.value.mem_alert_threshold,"onUpdate:modelValue":u[3]||=e=>A.value.mem_alert_threshold=e,label:`内存 %`,variant:`outlined`,density:`compact`,type:`number`,rules:[n(w)(`阈值`),n(T)(1,100,`阈值`)]},null,8,[`modelValue`,`rules`])]),_:1}),e(x,{cols:`4`},{default:h(()=>[e(v,{modelValue:A.value.disk_alert_threshold,"onUpdate:modelValue":u[4]||=e=>A.value.disk_alert_threshold=e,label:`磁盘 %`,variant:`outlined`,density:`compact`,type:`number`,rules:[n(w)(`阈值`),n(T)(1,100,`阈值`)]},null,8,[`modelValue`,`rules`])]),_:1})]),_:1}),e(g,{class:`my-4`}),u[27]||=_(`div`,{class:`text-subtitle-2 mb-3`},`连接池`,-1),e(S,{dense:``},{default:h(()=>[e(x,{cols:`6`},{default:h(()=>[e(v,{modelValue:A.value.db_pool_size,"onUpdate:modelValue":u[5]||=e=>A.value.db_pool_size=e,label:`连接池大小`,variant:`outlined`,density:`compact`,type:`number`,rules:[n(w)(),n(E)()]},null,8,[`modelValue`,`rules`])]),_:1}),e(x,{cols:`6`},{default:h(()=>[e(v,{modelValue:A.value.db_max_overflow,"onUpdate:modelValue":u[6]||=e=>A.value.db_max_overflow=e,label:`溢出连接数`,variant:`outlined`,density:`compact`,type:`number`,rules:[n(w)(),n(E)()]},null,8,[`modelValue`,`rules`])]),_:1})]),_:1})]),_:1}),e(r,{class:`px-4 pb-4`},{default:h(()=>[e(C),e(a,{color:`primary`,variant:`flat`,onClick:xe,loading:j.value},{default:h(()=>[...u[28]||=[l(`保存设置`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1}),e(o,{elevation:`0`,border:``,rounded:`lg`},{default:h(()=>[e(c,{class:`d-flex align-center`},{default:h(()=>[e(f,{class:`mr-2`},{default:h(()=>[...u[29]||=[l(`mdi-send`,-1)]]),_:1}),u[30]||=l(` Telegram 推送 `,-1)]),_:1}),e(g),e(s,null,{default:h(()=>[e(v,{modelValue:A.value.telegram_bot_token,"onUpdate:modelValue":u[7]||=e=>A.value.telegram_bot_token=e,label:`Bot Token`,variant:`outlined`,density:`compact`,class:`mb-3`,type:N.value?`text`:`password`,"append-inner-icon":N.value?`mdi-eye`:`mdi-eye-off`,"onClick:appendInner":u[8]||=e=>N.value=!N.value},null,8,[`modelValue`,`type`,`append-inner-icon`]),e(v,{modelValue:A.value.telegram_chat_id,"onUpdate:modelValue":u[9]||=e=>A.value.telegram_chat_id=e,label:`Chat ID`,variant:`outlined`,density:`compact`,class:`mb-3`},null,8,[`modelValue`]),e(a,{size:`small`,variant:`tonal`,"prepend-icon":`mdi-message-text`,onClick:Se,loading:M.value},{default:h(()=>[...u[31]||=[l(`发送测试消息`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1})]),_:1}),e(x,{cols:`12`,lg:`6`},{default:h(()=>[e(o,{elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:h(()=>[e(c,{class:`d-flex align-center`},{default:h(()=>[e(f,{class:`mr-2`},{default:h(()=>[...u[32]||=[l(`mdi-lock`,-1)]]),_:1}),u[33]||=l(` 修改密码 `,-1)]),_:1}),e(g),e(s,null,{default:h(()=>[e(v,{modelValue:P.value.current,"onUpdate:modelValue":u[10]||=e=>P.value.current=e,label:`当前密码`,variant:`outlined`,density:`compact`,type:`password`,class:`mb-3`,rules:[n(w)(`密码`)]},null,8,[`modelValue`,`rules`]),e(v,{modelValue:P.value.new_pw,"onUpdate:modelValue":u[11]||=e=>P.value.new_pw=e,label:`新密码`,variant:`outlined`,density:`compact`,type:`password`,class:`mb-3`,rules:[n(w)(`密码`)]},null,8,[`modelValue`,`rules`]),e(v,{modelValue:P.value.confirm,"onUpdate:modelValue":u[12]||=e=>P.value.confirm=e,label:`确认新密码`,variant:`outlined`,density:`compact`,type:`password`,class:`mb-3`,rules:[n(w)(`确认密码`),n(ce)(()=>P.value.new_pw)]},null,8,[`modelValue`,`rules`]),n(O).admin?.totp_enabled?(y(),i(v,{key:0,modelValue:P.value.totp_code,"onUpdate:modelValue":u[13]||=e=>P.value.totp_code=e,label:`TOTP 验证码`,variant:`outlined`,density:`compact`,type:`text`,inputmode:`numeric`,maxlength:`6`,class:`mb-3`,rules:n(O).admin?.totp_enabled?[n(w)(`验证码`)]:[]},null,8,[`modelValue`,`rules`])):p(``,!0)]),_:1}),e(r,{class:`px-4 pb-4`},{default:h(()=>[e(C),e(a,{color:`primary`,variant:`flat`,onClick:Ce,loading:F.value},{default:h(()=>[...u[34]||=[l(`修改密码`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1}),e(o,{elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:h(()=>[e(c,{class:`d-flex align-center`},{default:h(()=>[e(f,{class:`mr-2`},{default:h(()=>[...u[35]||=[l(`mdi-shield-key`,-1)]]),_:1}),u[36]||=l(` 双因素认证 (TOTP) `,-1)]),_:1}),e(g),e(s,null,{default:h(()=>[_(`div`,de,[u[37]||=_(`span`,{class:`text-body-2`},`状态:`,-1),e(oe,{color:n(O).admin?.totp_enabled?`success`:`grey`,size:`small`,variant:`tonal`,label:``,class:`ml-2`},{default:h(()=>[l(t(n(O).admin?.totp_enabled?`已启用`:`未启用`),1)]),_:1},8,[`color`])]),I.value?(y(),d(`div`,fe,[_(`img`,{src:I.value,alt:`TOTP QR`,style:{"max-width":`200px`}},null,8,pe),L.value?(y(),d(`div`,me,[_(`code`,he,t(L.value),1),e(a,{size:`x-small`,variant:`text`,icon:`mdi-content-copy`,onClick:De})])):p(``,!0),u[38]||=_(`div`,{class:`text-caption text-medium-emphasis mt-1`},`用认证器 App 扫描二维码或手动输入密钥`,-1)])):p(``,!0),n(O).admin?.totp_enabled?(y(),i(a,{key:2,size:`small`,variant:`tonal`,color:`error`,"prepend-icon":`mdi-shield-off`,onClick:Te},{default:h(()=>[...u[41]||=[l(`禁用 TOTP`,-1)]]),_:1})):(y(),d(`div`,ge,[I.value?(y(),d(`div`,_e,[e(v,{modelValue:R.value,"onUpdate:modelValue":u[14]||=e=>R.value=e,label:`验证码`,variant:`outlined`,density:`compact`,style:{"max-width":`160px`}},null,8,[`modelValue`]),e(a,{color:`primary`,variant:`flat`,size:`small`,onClick:Q,loading:z.value},{default:h(()=>[...u[40]||=[l(`启用`,-1)]]),_:1},8,[`loading`])])):(y(),i(a,{key:0,size:`small`,variant:`tonal`,"prepend-icon":`mdi-qrcode`,onClick:we},{default:h(()=>[...u[39]||=[l(`生成二维码`,-1)]]),_:1}))]))]),_:1})]),_:1}),e(o,{elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:h(()=>[e(c,{class:`d-flex align-center`},{default:h(()=>[e(f,{class:`mr-2`},{default:h(()=>[...u[42]||=[l(`mdi-key`,-1)]]),_:1}),u[43]||=l(` API Key `,-1)]),_:1}),e(g),e(s,null,{default:h(()=>[_(`div`,ve,[e(v,{"model-value":W.value?G.value:`••••••••`,label:`API Key`,variant:`outlined`,density:`compact`,readonly:``,type:W.value?`text`:`password`,style:{"max-width":`320px`}},null,8,[`model-value`,`type`]),e(a,{variant:`text`,size:`small`,icon:W.value?`mdi-eye-off`:`mdi-eye`,onClick:Oe},null,8,[`icon`]),e(a,{variant:`text`,size:`small`,icon:`mdi-content-copy`,onClick:ke})])]),_:1})]),_:1}),e(o,{elevation:`0`,border:``,rounded:`lg`},{default:h(()=>[e(c,{class:`d-flex align-center`},{default:h(()=>[e(f,{class:`mr-2`},{default:h(()=>[...u[44]||=[l(`mdi-ip-network`,-1)]]),_:1}),u[45]||=l(` IP 白名单 `,-1)]),_:1}),e(g),e(s,null,{default:h(()=>[e(ue,{modelValue:Y.value,"onUpdate:modelValue":[u[15]||=e=>Y.value=e,Ae],label:`启用 IP 白名单`,color:`primary`,density:`compact`,"hide-details":``,class:`mb-3`},null,8,[`modelValue`]),e(le,{modelValue:X.value,"onUpdate:modelValue":u[16]||=e=>X.value=e,label:`IP 列表(每行一个)`,variant:`outlined`,density:`compact`,rows:`4`,class:`mb-2`},null,8,[`modelValue`]),e(a,{size:`small`,variant:`tonal`,onClick:je,loading:Z.value},{default:h(()=>[...u[46]||=[l(`保存`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1})]),_:1})]),_:1}),e(b,{modelValue:K.value,"onUpdate:modelValue":u[19]||=e=>K.value=e,"max-width":`400`},{default:h(()=>[e(o,{border:``},{default:h(()=>[e(c,null,{default:h(()=>[...u[47]||=[l(`验证身份`,-1)]]),_:1}),e(s,null,{default:h(()=>[u[48]||=_(`div`,{class:`text-body-2 text-medium-emphasis mb-3`},`请输入当前密码以查看 API Key`,-1),e(v,{modelValue:q.value,"onUpdate:modelValue":u[17]||=e=>q.value=e,label:`当前密码`,variant:`outlined`,density:`compact`,type:`password`,autofocus:``,onKeydown:te($,[`enter`]),rules:[n(w)(`密码`)]},null,8,[`modelValue`,`rules`])]),_:1}),e(r,null,{default:h(()=>[e(C),e(a,{variant:`text`,onClick:u[18]||=e=>K.value=!1},{default:h(()=>[...u[49]||=[l(`取消`,-1)]]),_:1}),e(a,{color:`primary`,variant:`flat`,onClick:$,loading:J.value},{default:h(()=>[...u[50]||=[l(`确认`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]),e(b,{modelValue:B.value,"onUpdate:modelValue":u[23]||=e=>B.value=e,"max-width":`400`},{default:h(()=>[e(o,{border:``},{default:h(()=>[e(c,null,{default:h(()=>[...u[51]||=[l(`禁用 TOTP`,-1)]]),_:1}),e(s,null,{default:h(()=>[e(v,{modelValue:V.value,"onUpdate:modelValue":u[20]||=e=>V.value=e,label:`当前密码`,variant:`outlined`,density:`compact`,type:`password`,class:`mb-2`,rules:[n(w)()]},null,8,[`modelValue`,`rules`]),e(v,{modelValue:H.value,"onUpdate:modelValue":u[21]||=e=>H.value=e,label:`验证码`,variant:`outlined`,density:`compact`,rules:[n(w)()]},null,8,[`modelValue`,`rules`])]),_:1}),e(r,null,{default:h(()=>[e(C),e(a,{variant:`text`,onClick:u[22]||=e=>B.value=!1},{default:h(()=>[...u[52]||=[l(`取消`,-1)]]),_:1}),e(a,{color:`error`,variant:`flat`,onClick:Ee,loading:U.value},{default:h(()=>[...u[53]||=[l(`禁用`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}});export{D as default};