27da842a20
关闭 notify_* 后通过 Redis 广播同步各 worker 内存设置;修复 expanded id 类型不匹配导致点击名称无法展开详情。 Co-authored-by: Cursor <cursoragent@cursor.com>
4 lines
32 KiB
JavaScript
4 lines
32 KiB
JavaScript
import{_ as e,t,v as n}from"./VSelect-DCVEXXlg.js";import{n as r,t as ee}from"./VRow-D_fBpDV4.js";import{$r as i,Br as a,Ct as o,Jt as s,Nr as c,P as l,St as te,W as ne,Wt as re,X as u,_ as d,_r as f,cr as p,dr as ie,fr as m,g as ae,h,hr as g,jr as _,kr as oe,l as se,m as ce,mr as v,pr as y,qr as b,ri as x,v as S,vr as C,wt as w,xt as le,y as T,yr as E}from"./index-BDmfR_V6.js";import{t as D}from"./usePageActivateRefresh-BZD3eqy9.js";import{_ as O,t as k,v as A,x as j,y as M}from"./VTextField-20zRHFVo.js";import{t as N}from"./VDialog-CedSVCX4.js";import{i as P,n as F,r as I,t as L}from"./validation-DMwOxx4a.js";import{t as R}from"./VSwitch-Bpv1rcwn.js";import{t as ue}from"./VTextarea-Cug6VIQ1.js";import{n as z,r as de}from"./useTerminalQuickCommands--pHRzUnM.js";var B={key:1,class:`text-medium-emphasis text-body-2 mb-4`},V={class:`text-caption text-medium-emphasis mr-2`,style:{"min-width":`1.5rem`}},fe={class:`d-flex flex-wrap ga-2`},pe=E({__name:`TerminalQuickCommandsSettings`,setup(t){let n=e(),{commands:r,loading:ee,load:o,create:s,update:te,remove:re,reorder:ie,customCommands:w,builtinCommands:le}=z(),E=b(!1),D=b(null),P=b(``),F=b(``),I=b(!1),L=b(!1),R=b(!1),ue=b(null),pe=b(``);function me(){D.value=null,P.value=``,F.value=``,E.value=!0}function he(e){D.value=e.id,P.value=e.name,F.value=e.cmd.replace(/\r$/,``),E.value=!0}async function ge(){if(!P.value.trim()||!F.value.trim()){n(`名称和命令不能为空`,`warning`);return}let e=F.value.trim();e.endsWith(`\r`)||(e+=`\r`),I.value=!0;try{D.value?await te(D.value,P.value,e):await s(P.value,e),E.value=!1,n(`已保存`)}catch(e){n(e instanceof Error?e.message:`保存失败`,`error`)}finally{I.value=!1}}function _e(e){ue.value=e.id,pe.value=e.name,R.value=!0}async function ve(){if(ue.value){I.value=!0;try{await re(ue.value),R.value=!1,n(`已删除`)}catch(e){n(e instanceof Error?e.message:`删除失败`,`error`)}finally{I.value=!1}}}async function ye(e){let t=w();if(e<=0)return;let n=t.map(e=>e.id),r=n[e-1];n[e-1]=n[e],n[e]=r,await xe(n)}async function be(e){let t=w();if(e>=t.length-1)return;let n=t.map(e=>e.id),r=n[e+1];n[e+1]=n[e],n[e]=r,await xe(n)}async function xe(e){L.value=!0;try{await ie(e)}catch(e){n(e instanceof Error?e.message:`排序失败`,`error`)}finally{L.value=!1}}return oe(()=>{o().catch(e=>n(e.message,`error`))}),(e,t)=>(_(),y(O,{id:`terminal-quick-commands`,elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:a(()=>[C(M,{class:`d-flex align-center flex-wrap ga-2`},{default:a(()=>[C(u,{class:`mr-1`},{default:a(()=>[...t[6]||=[f(`mdi-flash`,-1)]]),_:1}),t[8]||=f(` 终端快捷命令 `,-1),C(d),C(l,{size:`small`,color:`primary`,variant:`flat`,"prepend-icon":`mdi-plus`,onClick:me},{default:a(()=>[...t[7]||=[f(` 添加命令 `,-1)]]),_:1})]),_:1}),C(S),C(A,null,{default:a(()=>[t[9]||=m(`div`,{class:`text-body-2 text-medium-emphasis mb-4`},` 自定义命令显示在终端栏最前(优先级最高)。终端页仅可点击执行;在此添加、编辑、删除与调整顺序。 `,-1),i(ee)?(_(),y(ne,{key:0,indeterminate:``,color:`primary`,class:`mb-3`})):v(``,!0),i(w)().length===0&&!i(ee)?(_(),g(`div`,B,` 暂无自定义命令,点击「添加命令」创建。 `)):v(``,!0),i(w)().length?(_(),y(se,{key:2,density:`compact`,class:`mb-4 pa-0`},{default:a(()=>[(_(!0),g(p,null,c(i(w)(),(e,t)=>(_(),y(ce,{key:e.id,border:``,rounded:`lg`,class:`mb-2`},{prepend:a(()=>[m(`span`,V,x(t+1),1)]),append:a(()=>[C(l,{icon:`mdi-arrow-up`,size:`x-small`,variant:`text`,disabled:t===0||L.value,onClick:e=>ye(t)},null,8,[`disabled`,`onClick`]),C(l,{icon:`mdi-arrow-down`,size:`x-small`,variant:`text`,disabled:t===i(w)().length-1||L.value,onClick:e=>be(t)},null,8,[`disabled`,`onClick`]),C(l,{icon:`mdi-pencil`,size:`x-small`,variant:`text`,onClick:t=>he(e)},null,8,[`onClick`]),C(l,{icon:`mdi-delete`,size:`x-small`,variant:`text`,color:`error`,onClick:t=>_e(e)},null,8,[`onClick`])]),default:a(()=>[C(h,null,{default:a(()=>[f(x(e.name),1)]),_:2},1024),C(ae,{class:`font-mono text-truncate`},{default:a(()=>[f(x(e.cmd),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})):v(``,!0),t[10]||=m(`div`,{class:`text-subtitle-2 mb-2`},`系统内置(不可编辑)`,-1),m(`div`,fe,[(_(!0),g(p,null,c(i(le)(),e=>(_(),y(T,{key:e.id,size:`small`,variant:`outlined`,label:``},{default:a(()=>[f(x(e.name),1)]),_:2},1024))),128))])]),_:1}),C(N,{modelValue:E.value,"onUpdate:modelValue":t[3]||=e=>E.value=e,"max-width":`520`},{default:a(()=>[C(O,{border:``},{default:a(()=>[C(M,null,{default:a(()=>[f(x(D.value?`编辑命令`:`添加快捷命令`),1)]),_:1}),C(A,null,{default:a(()=>[C(k,{modelValue:P.value,"onUpdate:modelValue":t[0]||=e=>P.value=e,label:`显示名称`,variant:`outlined`,density:`compact`,class:`mb-3`},null,8,[`modelValue`]),t[11]||=m(`div`,{class:`text-body-2 text-medium-emphasis mb-2`},`命令内容(发送时自动追加回车)`,-1),C(de,{modelValue:F.value,"onUpdate:modelValue":t[1]||=e=>F.value=e,multiline:``,rows:4,placeholder:`systemctl status nginx`},null,8,[`modelValue`])]),_:1}),C(j,null,{default:a(()=>[C(d),C(l,{variant:`text`,onClick:t[2]||=e=>E.value=!1},{default:a(()=>[...t[12]||=[f(`取消`,-1)]]),_:1}),C(l,{color:`primary`,variant:`flat`,loading:I.value,onClick:ge},{default:a(()=>[...t[13]||=[f(`保存`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]),C(N,{modelValue:R.value,"onUpdate:modelValue":t[5]||=e=>R.value=e,"max-width":`400`},{default:a(()=>[C(O,{border:``},{default:a(()=>[C(M,null,{default:a(()=>[...t[14]||=[f(`删除命令`,-1)]]),_:1}),C(A,null,{default:a(()=>[f(`确定删除「`+x(pe.value)+`」?`,1)]),_:1}),C(j,null,{default:a(()=>[C(d),C(l,{variant:`text`,onClick:t[4]||=e=>R.value=!1},{default:a(()=>[...t[15]||=[f(`取消`,-1)]]),_:1}),C(l,{color:`error`,variant:`flat`,loading:I.value,onClick:ve},{default:a(()=>[...t[16]||=[f(`删除`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}}),me=[{key:`notify_alert_cpu`,label:`CPU 超阈值告警`,desc:`CPU 使用率超过设定阈值时推送`,group:`服务器资源`},{key:`notify_alert_mem`,label:`内存超阈值告警`,desc:`内存使用率超过设定阈值时推送`,group:`服务器资源`},{key:`notify_alert_disk`,label:`磁盘超阈值告警`,desc:`磁盘使用率超过设定阈值时推送`,group:`服务器资源`},{key:`notify_recovery`,label:`资源恢复正常`,desc:`CPU/内存/磁盘告警解除时推送`,group:`服务器资源`},{key:`notify_time_drift`,label:`时钟偏差严重 (≥60s)`,desc:`子机与主机时间偏差过大影响 TOTP/cron`,group:`服务器`},{key:`notify_system_redis`,label:`Redis 连接异常 / 恢复`,desc:`Redis 不可达或恢复时推送`,group:`系统`},{key:`notify_system_mysql`,label:`MySQL 连接异常 / 恢复`,desc:`MySQL 不可达或恢复时推送`,group:`系统`},{key:`notify_restart`,label:`Nexus 后端重启`,desc:`Python 服务崩溃重启成功/失败时推送`,group:`系统`},{key:`notify_script_complete`,label:`脚本执行完成`,desc:`脚本批量执行结束时推送汇总与看板链接(不含失败明细)`,group:`运维`}],he={class:`d-flex flex-wrap ga-2 mb-4`},ge={class:`text-caption text-medium-emphasis font-weight-medium mt-2 mb-1`},_e={class:`d-flex flex-wrap align-center ga-2 mb-3`},ve={class:`d-flex flex-wrap ga-2`},ye={key:1,class:`text-caption text-medium-emphasis mt-2 mb-0`},be={class:`d-flex align-center mb-3`},xe={key:0,class:`text-center mb-3`},Se=[`src`],Ce={key:0,class:`d-flex align-center justify-center ga-2 mt-2`},we={class:`text-caption pa-1 bg-grey-lighten-4 rounded`,style:{"user-select":`all`}},Te={key:1},Ee={key:1,class:`d-flex ga-2 align-center`},De={class:`d-flex align-center ga-2`},Oe={class:`d-flex flex-wrap ga-2 mb-3`},ke={key:0,class:`mb-4`},Ae={class:`text-caption text-medium-emphasis mb-2`},je={key:0},Me={class:`d-flex flex-wrap ga-1`},Ne={key:1,class:`text-caption text-medium-emphasis mb-4`},Pe={class:`text-caption text-medium-emphasis`},Fe={class:`text-body-2 mb-2`},Ie={class:`d-flex flex-wrap ga-1 mb-2`,style:{"max-height":`240px`,"overflow-y":`auto`}},Le={key:0,class:`text-body-2 text-medium-emphasis`},H=E({name:`SettingsPage`,__name:`SettingsPage`,setup(ae){let h=e(),{saveToServer:oe,previewSound:E}=le(),z=re(),de=o,B=b(te),V=b(!1),fe=b(!1),H=b({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:``}),U=b(``),W=b(!1),Re=b(!1),ze=b(!1),Be=b(!1),G=b(!1),Ve=b([]),K=b(!1),He=b(!1),Ue=b({}),We=b(null),q=b(null),Ge=b(!1),Ke=b(!1),qe=ie(()=>{let e={};for(let t of me)e[t.group]||(e[t.group]=[]),e[t.group].push(t);return e});function Je(e){let t=String(e??`true`).trim().toLowerCase();return![`false`,`0`,`no`,`off`].includes(t)}let J=b({current:``,new_pw:``,confirm:``,totp_code:``}),Ye=b(!1),Xe=b(``),Ze=b(``),Qe=b(``),$e=b(!1),et=b(!1),tt=b(``),nt=b(``),rt=b(!1),Y=b(!1),it=b(``),at=b(!1),ot=b(!1),st=b(!1),X=b(``),ct=b(``),Z=b([]),Q=b(null),lt=b(0),ut=b(!1),dt=b(!1),$=b(!1),ft=b([]),pt=ie(()=>Z.value.slice(0,24));async function mt(e=!1){e||(fe.value=!0);try{let e=await s.get(`/settings/`),t=Array.isArray(e)?e:[],n=Object.keys(H.value);for(let e of t){let t=e.key;if(t===`telegram_bot_token`){W.value=!!e.value_set,U.value=``;continue}if(t===`script_exec_complete_sound`){B.value=w(e.value);continue}if(t&&me.some(e=>e.key===t)){Ue.value[t]=Je(e.value);continue}if(t&&n.includes(t)){let n=e.value;typeof n==`string`&&/^\d+(\.\d+)?$/.test(n)?H.value[t]=Number(n):H.value[t]=n}}}catch{h(`加载设置失败`,`error`)}finally{e||(fe.value=!1)}}async function ht(){try{let e=await s.get(`/settings/ip-allowlist`);st.value=e.enabled||!1,X.value=e.subscription_url||``,ct.value=(e.manual_ips||[]).join(`
|
||
`),Z.value=e.subscription_ips||[],Q.value=e.last_refresh||null,lt.value=e.total_count??new Set([...e.manual_ips||[],...e.subscription_ips||[]]).size}catch{h(`加载白名单失败`,`error`)}}async function gt(){Re.value=!0;try{let e=Object.entries(H.value).filter(([e])=>[`system_name`,`system_title`,`cpu_alert_threshold`,`mem_alert_threshold`,`disk_alert_threshold`,`db_pool_size`,`db_max_overflow`].includes(e));for(let[t,n]of e)await s.put(`/settings/${t}`,{value:n});h(`设置已保存`)}catch(e){h(e instanceof Error?e.message:`保存失败`,`error`)}finally{Re.value=!1}}async function _t(e){let t=U.value.trim(),n=String(H.value.telegram_chat_id||``).trim();return e?.requireToken&&!t&&!W.value?(h(`请先填写 Bot Token`,`error`),!1):e?.requireChatId&&!n?(h(`请先填写或检测 Chat ID`,`error`),!1):(t&&(await s.put(`/settings/telegram_bot_token`,{value:t}),W.value=!0,U.value=``,K.value=!1),n&&await s.put(`/settings/telegram_chat_id`,{value:n}),!0)}async function vt(e=!1){e||(Ge.value=!0);try{q.value=await s.get(`/settings/ops-patrol/status`)}catch{q.value=null}finally{e||(Ge.value=!1)}}async function yt(){Ke.value=!0;try{if(!await _t({requireToken:!0,requireChatId:!0}))return;let e=await s.post(`/settings/ops-patrol/sync-telegram`,{});q.value={...q.value||{},telegram_layer3_ready:e.telegram_layer3_ready,telegram_env_synced:e.env_status.env_synced,env_status:e.env_status,telegram_app_configured:!0},h(`巡检 Telegram 已同步至 .env`),await vt()}catch(e){h(e instanceof Error?e.message:`同步失败`,`error`)}finally{Ke.value=!1}}async function bt(){He.value=!0;try{let e=U.value.trim(),t=String(H.value.telegram_chat_id||``).trim();if(!e&&!t&&!W.value){h(`请先填写 Bot Token 或 Chat ID`,`warning`);return}await _t(),await vt(),h(`Telegram 配置已保存`)}catch(e){h(e instanceof Error?e.message:`保存失败`,`error`)}finally{He.value=!1}}async function xt(e){if(!e||V.value)return;let t=B.value;B.value=e,V.value=!0;try{await oe(e),h(`提示音设置已保存`)}catch(e){B.value=t,h(e instanceof Error?e.message:`保存失败`,`error`)}finally{V.value=!1}}function St(){E(B.value)}async function Ct(e,t){let n=Ue.value[e];Ue.value[e]=t,We.value=e;try{await s.put(`/settings/${e}`,{value:t?`true`:`false`})}catch(t){Ue.value[e]=n,h(t instanceof Error?t.message:`保存失败,已撤销`,`error`)}finally{We.value=null}}async function wt(){ze.value=!0;try{if(!await _t({requireToken:!0,requireChatId:!0}))return;await s.post(`/settings/telegram/test`),h(`测试消息已发送`)}catch(e){h(e instanceof Error?e.message:`发送失败`,`error`)}finally{ze.value=!1}}async function Tt(){Be.value=!0;try{if(!await _t({requireToken:!0}))return;if(Ve.value=(await s.get(`/settings/telegram/chats`)).chats||[],!Ve.value.length){h(`未检测到对话,请先向 Bot 发送一条消息后再试`,`warning`);return}G.value=!0}catch(e){h(e instanceof Error?e.message:`检测失败`,`error`)}finally{Be.value=!1}}async function Et(e){let t=String(e.id);H.value.telegram_chat_id=t,G.value=!1;try{await s.put(`/settings/telegram_chat_id`,{value:t}),h(`已选择 Chat ID: ${t}`)}catch(e){h(e instanceof Error?e.message:`保存 Chat ID 失败`,`error`)}}async function Dt(){if(J.value.new_pw!==J.value.confirm){h(`两次密码不一致`,`error`);return}Ye.value=!0;try{let e={current_password:J.value.current,new_password:J.value.new_pw};z.admin?.totp_enabled&&J.value.totp_code&&(e.totp_code=J.value.totp_code),await s.put(`/auth/password`,e),J.value={current:``,new_pw:``,confirm:``,totp_code:``},h(`密码已修改`)}catch(e){h(e instanceof Error?e.message:`修改失败`,`error`)}finally{Ye.value=!1}}async function Ot(){try{let e=await s.post(`/auth/totp/setup`);Xe.value=e.qr_code,Ze.value=e.secret||``}catch(e){h(e instanceof Error?e.message:`生成失败`,`error`)}}async function kt(){$e.value=!0;try{await s.post(`/auth/totp/enable`,{code:Qe.value}),await z.fetchProfile(),Xe.value=``,Qe.value=``,h(`TOTP 已启用`)}catch(e){h(e.message||`启用失败`,`error`)}finally{$e.value=!1}}function At(){et.value=!0}async function jt(){rt.value=!0;try{await s.post(`/auth/totp/disable`,{admin_id:z.admin?.id,current_password:tt.value,totp_code:nt.value}),await z.fetchProfile(),et.value=!1,tt.value=``,nt.value=``,h(`TOTP 已禁用`)}catch(e){h(e.message||`禁用失败`,`error`)}finally{rt.value=!1}}function Mt(){Ze.value&&(navigator.clipboard.writeText(Ze.value),h(`密钥已复制`))}async function Nt(){if(Y.value){Y.value=!1;return}at.value=!0;try{it.value=(await s.post(`/settings/api-key/reveal`,{})).value,Y.value=!0}catch(e){h(e instanceof Error?e.message:`获取 API Key 失败`,`error`)}finally{at.value=!1}}async function Pt(){if(K.value){K.value=!1,W.value&&(U.value=``);return}if(U.value.trim()){K.value=!0;return}if(!W.value){K.value=!0;return}ot.value=!0;try{U.value=(await s.post(`/settings/telegram/reveal-token`,{})).value,K.value=!0}catch(e){h(e instanceof Error?e.message:`获取 Bot Token 失败`,`error`)}finally{ot.value=!1}}function Ft(){if(!Y.value||!it.value){h(`请先点击眼睛图标显示 API Key`,`warning`);return}navigator.clipboard.writeText(it.value),h(`已复制到剪贴板`)}async function It(){try{await s.post(`/settings/ip-allowlist/toggle?enabled=${st.value?`true`:`false`}`)}catch(e){h(e instanceof Error?e.message:`操作失败`,`error`)}}async function Lt(){let e=X.value.trim();if(!e){h(`请先填写订阅 URL`,`error`);return}dt.value=!0;try{if(ft.value=(await s.post(`/settings/ip-allowlist/parse-subscription`,{url:e})).hosts||[],!ft.value.length){h(`未能解析出任何节点`,`warning`);return}$.value=!0}catch(e){h(e instanceof Error?e.message:`解析失败`,`error`)}finally{dt.value=!1}}async function Rt(){ut.value=!0;try{let e={manual_ips:ct.value.split(`
|
||
`).map(e=>e.trim()).filter(Boolean),subscription_url:X.value.trim(),enabled:st.value};await s.post(`/settings/ip-allowlist`,e),h(`白名单已保存`),$.value=!1,await ht()}catch(e){h(e instanceof Error?e.message:`保存失败`,`error`)}finally{ut.value=!1}}async function zt(e=!1){await Promise.all([mt(e),ht(),vt(e),z.fetchProfile()])}return D(e=>zt(e)),(e,o)=>(_(),y(n,{fluid:``,class:`pa-6`},{default:a(()=>[C(ee,null,{default:a(()=>[C(r,{cols:`12`,lg:`6`},{default:a(()=>[C(O,{elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:a(()=>[C(M,{class:`d-flex align-center`},{default:a(()=>[C(u,{class:`mr-2`},{default:a(()=>[...o[27]||=[f(`mdi-cog`,-1)]]),_:1}),o[28]||=f(` 系统设置 `,-1)]),_:1}),fe.value?(_(),y(ne,{key:0,indeterminate:``,color:`primary`})):v(``,!0),C(S),C(A,null,{default:a(()=>[C(k,{modelValue:H.value.system_name,"onUpdate:modelValue":o[0]||=e=>H.value.system_name=e,label:`系统名称`,variant:`outlined`,density:`compact`,class:`mb-3`,rules:[i(P)(`系统名称`)]},null,8,[`modelValue`,`rules`]),C(k,{modelValue:H.value.system_title,"onUpdate:modelValue":o[1]||=e=>H.value.system_title=e,label:`系统标题`,variant:`outlined`,density:`compact`,class:`mb-3`,rules:[i(P)(`系统标题`)]},null,8,[`modelValue`,`rules`]),C(S,{class:`my-4`}),o[29]||=m(`div`,{class:`text-subtitle-2 mb-3`},`告警阈值`,-1),C(ee,{dense:``},{default:a(()=>[C(r,{cols:`4`},{default:a(()=>[C(k,{modelValue:H.value.cpu_alert_threshold,"onUpdate:modelValue":o[2]||=e=>H.value.cpu_alert_threshold=e,label:`CPU %`,variant:`outlined`,density:`compact`,type:`number`,rules:[i(P)(`阈值`),i(I)(1,100,`阈值`)]},null,8,[`modelValue`,`rules`])]),_:1}),C(r,{cols:`4`},{default:a(()=>[C(k,{modelValue:H.value.mem_alert_threshold,"onUpdate:modelValue":o[3]||=e=>H.value.mem_alert_threshold=e,label:`内存 %`,variant:`outlined`,density:`compact`,type:`number`,rules:[i(P)(`阈值`),i(I)(1,100,`阈值`)]},null,8,[`modelValue`,`rules`])]),_:1}),C(r,{cols:`4`},{default:a(()=>[C(k,{modelValue:H.value.disk_alert_threshold,"onUpdate:modelValue":o[4]||=e=>H.value.disk_alert_threshold=e,label:`磁盘 %`,variant:`outlined`,density:`compact`,type:`number`,rules:[i(P)(`阈值`),i(I)(1,100,`阈值`)]},null,8,[`modelValue`,`rules`])]),_:1})]),_:1}),C(S,{class:`my-4`}),o[30]||=m(`div`,{class:`text-subtitle-2 mb-3`},`连接池`,-1),C(ee,{dense:``},{default:a(()=>[C(r,{cols:`6`},{default:a(()=>[C(k,{modelValue:H.value.db_pool_size,"onUpdate:modelValue":o[5]||=e=>H.value.db_pool_size=e,label:`连接池大小`,variant:`outlined`,density:`compact`,type:`number`,rules:[i(P)(),i(L)()]},null,8,[`modelValue`,`rules`])]),_:1}),C(r,{cols:`6`},{default:a(()=>[C(k,{modelValue:H.value.db_max_overflow,"onUpdate:modelValue":o[6]||=e=>H.value.db_max_overflow=e,label:`溢出连接数`,variant:`outlined`,density:`compact`,type:`number`,rules:[i(P)(),i(L)()]},null,8,[`modelValue`,`rules`])]),_:1})]),_:1})]),_:1}),C(j,{class:`px-4 pb-4`},{default:a(()=>[C(d),C(l,{color:`primary`,variant:`flat`,onClick:gt,loading:Re.value},{default:a(()=>[...o[31]||=[f(`保存设置`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1}),C(pe),C(O,{elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:a(()=>[C(M,{class:`d-flex align-center`},{default:a(()=>[C(u,{class:`mr-2`},{default:a(()=>[...o[32]||=[f(`mdi-bell-ring-outline`,-1)]]),_:1}),o[33]||=f(` 界面提示 `,-1)]),_:1}),C(S),C(A,null,{default:a(()=>[o[35]||=m(`p`,{class:`text-caption text-medium-emphasis mb-3`},` 脚本批量执行全部结束时,在浏览器播放提示音(仅当前登录的管理员会话,与 Telegram 推送无关)。 `,-1),C(t,{modelValue:B.value,"onUpdate:modelValue":[o[7]||=e=>B.value=e,xt],items:i(de),"item-title":`title`,"item-value":`value`,label:`脚本执行完成提示音`,variant:`outlined`,density:`compact`,"hide-details":``,class:`mb-3`,loading:V.value,disabled:V.value},null,8,[`modelValue`,`items`,`loading`,`disabled`]),C(l,{size:`small`,variant:`tonal`,"prepend-icon":`mdi-volume-high`,disabled:B.value===`off`||V.value,onClick:St},{default:a(()=>[...o[34]||=[f(` 试听 `,-1)]]),_:1},8,[`disabled`])]),_:1})]),_:1}),C(O,{elevation:`0`,border:``,rounded:`lg`},{default:a(()=>[C(M,{class:`d-flex align-center`},{default:a(()=>[C(u,{class:`mr-2`},{default:a(()=>[...o[36]||=[f(`mdi-send`,-1)]]),_:1}),o[37]||=f(` Telegram 推送 `,-1)]),_:1}),C(S),C(A,null,{default:a(()=>[C(k,{modelValue:U.value,"onUpdate:modelValue":o[8]||=e=>U.value=e,label:`Bot Token`,variant:`outlined`,density:`compact`,class:`mb-3`,placeholder:W.value?`已配置(留空保持不变)`:`输入 Bot Token`,type:K.value?`text`:`password`,"append-inner-icon":K.value?`mdi-eye-off`:`mdi-eye`,"onClick:appendInner":Pt},null,8,[`modelValue`,`placeholder`,`type`,`append-inner-icon`]),W.value&&!U.value?(_(),y(T,{key:0,size:`small`,color:`success`,variant:`tonal`,class:`mb-3`},{default:a(()=>[...o[38]||=[f(`Token 已配置`,-1)]]),_:1})):v(``,!0),C(k,{modelValue:H.value.telegram_chat_id,"onUpdate:modelValue":o[9]||=e=>H.value.telegram_chat_id=e,label:`Chat ID`,variant:`outlined`,density:`compact`,class:`mb-3`},null,8,[`modelValue`]),o[46]||=m(`p`,{class:`text-caption text-medium-emphasis mb-3`},` 在 Telegram 向 Bot 发送任意消息后,可点击下方按钮自动检测 Chat ID。 `,-1),m(`div`,he,[C(l,{size:`small`,variant:`tonal`,"prepend-icon":`mdi-radar`,onClick:Tt,loading:Be.value},{default:a(()=>[...o[39]||=[f(`检测 Chat ID`,-1)]]),_:1},8,[`loading`]),C(l,{size:`small`,variant:`tonal`,"prepend-icon":`mdi-message-text`,onClick:wt,loading:ze.value},{default:a(()=>[...o[40]||=[f(`发送测试消息`,-1)]]),_:1},8,[`loading`]),C(l,{size:`small`,variant:`tonal`,color:`primary`,"prepend-icon":`mdi-content-save`,onClick:bt,loading:He.value},{default:a(()=>[...o[41]||=[f(`保存 Telegram 配置`,-1)]]),_:1},8,[`loading`])]),C(S,{class:`my-3`}),o[47]||=m(`div`,{class:`text-subtitle-2 mb-1`},`告警通知项目`,-1),o[48]||=m(`p`,{class:`text-caption text-medium-emphasis mb-3`},` 关闭后该类告警仍记录日志,但不发送 Telegram 消息。Bot Token 未配置时全部静默。 `,-1),(_(!0),g(p,null,c(qe.value,(e,t)=>(_(),g(p,{key:t},[m(`div`,ge,x(t),1),(_(!0),g(p,null,c(e,e=>(_(),y(R,{key:e.key,"model-value":Ue.value[e.key]??!0,label:e.label,hint:e.desc,"persistent-hint":``,color:`primary`,density:`compact`,"hide-details":`auto`,class:`mb-1`,disabled:We.value===e.key,"onUpdate:modelValue":t=>Ct(e.key,!!t)},null,8,[`model-value`,`label`,`hint`,`disabled`,`onUpdate:modelValue`]))),128))],64))),128)),C(S,{class:`my-4`}),o[49]||=m(`div`,{class:`text-subtitle-2 mb-1`},`Layer 3 宿主机巡检`,-1),o[50]||=m(`p`,{class:`text-caption text-medium-emphasis mb-3`},[f(` 每分钟由宿主机 cron 执行 `),m(`code`,null,`health_monitor.sh`),f(`:连续 3 次 /health 失败则自动重启并推送 Telegram。 配置保存后会自动同步至 .env;亦可手动同步。未同步时脚本会从数据库读取 Telegram 配置。 `)],-1),m(`div`,_e,[C(T,{size:`small`,color:q.value?.telegram_layer3_ready?`success`:`warning`,variant:`tonal`},{default:a(()=>[f(x(q.value?.telegram_layer3_ready?`巡检 Telegram 就绪`:`请先配置 Telegram`),1)]),_:1},8,[`color`]),q.value?(_(),y(T,{key:0,size:`small`,color:q.value.telegram_env_synced?`success`:`grey`,variant:`tonal`},{default:a(()=>[f(x(q.value.telegram_env_synced?`.env 已同步`:`.env 未同步(可用 DB 回退)`),1)]),_:1},8,[`color`])):v(``,!0)]),m(`div`,ve,[C(l,{size:`small`,variant:`tonal`,"prepend-icon":`mdi-sync`,onClick:yt,loading:Ke.value,disabled:!q.value?.telegram_app_configured},{default:a(()=>[...o[42]||=[f(` 同步巡检 Telegram `,-1)]]),_:1},8,[`loading`,`disabled`]),C(l,{size:`small`,variant:`text`,"prepend-icon":`mdi-refresh`,onClick:vt,loading:Ge.value},{default:a(()=>[...o[43]||=[f(` 刷新状态 `,-1)]]),_:1},8,[`loading`])]),q.value?(_(),g(`p`,ye,[o[44]||=f(` 宿主机安装 cron:`,-1),m(`code`,null,x(q.value.cron_install_command),1),o[45]||=f(` · 日志:`,-1),m(`code`,null,x(q.value.health_log_path),1)])):v(``,!0)]),_:1})]),_:1})]),_:1}),C(r,{cols:`12`,lg:`6`},{default:a(()=>[C(O,{elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:a(()=>[C(M,{class:`d-flex align-center`},{default:a(()=>[C(u,{class:`mr-2`},{default:a(()=>[...o[51]||=[f(`mdi-lock`,-1)]]),_:1}),o[52]||=f(` 修改密码 `,-1)]),_:1}),C(S),C(A,null,{default:a(()=>[C(k,{modelValue:J.value.current,"onUpdate:modelValue":o[10]||=e=>J.value.current=e,label:`当前密码`,variant:`outlined`,density:`compact`,type:`password`,class:`mb-3`,rules:[i(P)(`密码`)]},null,8,[`modelValue`,`rules`]),C(k,{modelValue:J.value.new_pw,"onUpdate:modelValue":o[11]||=e=>J.value.new_pw=e,label:`新密码`,variant:`outlined`,density:`compact`,type:`password`,class:`mb-3`,rules:[i(P)(`密码`)]},null,8,[`modelValue`,`rules`]),C(k,{modelValue:J.value.confirm,"onUpdate:modelValue":o[12]||=e=>J.value.confirm=e,label:`确认新密码`,variant:`outlined`,density:`compact`,type:`password`,class:`mb-3`,rules:[i(P)(`确认密码`),i(F)(()=>J.value.new_pw)]},null,8,[`modelValue`,`rules`]),i(z).admin?.totp_enabled?(_(),y(k,{key:0,modelValue:J.value.totp_code,"onUpdate:modelValue":o[13]||=e=>J.value.totp_code=e,label:`TOTP 验证码`,variant:`outlined`,density:`compact`,type:`text`,inputmode:`numeric`,maxlength:`6`,class:`mb-3`,rules:i(z).admin?.totp_enabled?[i(P)(`验证码`)]:[]},null,8,[`modelValue`,`rules`])):v(``,!0)]),_:1}),C(j,{class:`px-4 pb-4`},{default:a(()=>[C(d),C(l,{color:`primary`,variant:`flat`,onClick:Dt,loading:Ye.value},{default:a(()=>[...o[53]||=[f(`修改密码`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1}),C(O,{elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:a(()=>[C(M,{class:`d-flex align-center`},{default:a(()=>[C(u,{class:`mr-2`},{default:a(()=>[...o[54]||=[f(`mdi-shield-key`,-1)]]),_:1}),o[55]||=f(` 双因素认证 (TOTP) `,-1)]),_:1}),C(S),C(A,null,{default:a(()=>[m(`div`,be,[o[56]||=m(`span`,{class:`text-body-2`},`状态:`,-1),C(T,{color:i(z).admin?.totp_enabled?`success`:`grey`,size:`small`,variant:`tonal`,label:``,class:`ml-2`},{default:a(()=>[f(x(i(z).admin?.totp_enabled?`已启用`:`未启用`),1)]),_:1},8,[`color`])]),Xe.value?(_(),g(`div`,xe,[m(`img`,{src:Xe.value,alt:`TOTP QR`,style:{"max-width":`200px`}},null,8,Se),Ze.value?(_(),g(`div`,Ce,[m(`code`,we,x(Ze.value),1),C(l,{size:`x-small`,variant:`text`,icon:`mdi-content-copy`,onClick:Mt})])):v(``,!0),o[57]||=m(`div`,{class:`text-caption text-medium-emphasis mt-1`},`用认证器 App 扫描二维码或手动输入密钥`,-1)])):v(``,!0),i(z).admin?.totp_enabled?(_(),y(l,{key:2,size:`small`,variant:`tonal`,color:`error`,"prepend-icon":`mdi-shield-off`,onClick:At},{default:a(()=>[...o[60]||=[f(`禁用 TOTP`,-1)]]),_:1})):(_(),g(`div`,Te,[Xe.value?(_(),g(`div`,Ee,[C(k,{modelValue:Qe.value,"onUpdate:modelValue":o[14]||=e=>Qe.value=e,label:`验证码`,variant:`outlined`,density:`compact`,style:{"max-width":`160px`}},null,8,[`modelValue`]),C(l,{color:`primary`,variant:`flat`,size:`small`,onClick:kt,loading:$e.value},{default:a(()=>[...o[59]||=[f(`启用`,-1)]]),_:1},8,[`loading`])])):(_(),y(l,{key:0,size:`small`,variant:`tonal`,"prepend-icon":`mdi-qrcode`,onClick:Ot},{default:a(()=>[...o[58]||=[f(`生成二维码`,-1)]]),_:1}))]))]),_:1})]),_:1}),C(O,{elevation:`0`,border:``,rounded:`lg`,class:`mb-4`},{default:a(()=>[C(M,{class:`d-flex align-center`},{default:a(()=>[C(u,{class:`mr-2`},{default:a(()=>[...o[61]||=[f(`mdi-key`,-1)]]),_:1}),o[62]||=f(` API Key `,-1)]),_:1}),C(S),C(A,null,{default:a(()=>[m(`div`,De,[C(k,{"model-value":Y.value?it.value:`••••••••`,label:`API Key`,variant:`outlined`,density:`compact`,readonly:``,type:Y.value?`text`:`password`,style:{"max-width":`320px`}},null,8,[`model-value`,`type`]),C(l,{variant:`text`,size:`small`,icon:Y.value?`mdi-eye-off`:`mdi-eye`,onClick:Nt,loading:at.value},null,8,[`icon`,`loading`]),C(l,{variant:`text`,size:`small`,icon:`mdi-content-copy`,onClick:Ft})])]),_:1})]),_:1}),C(O,{elevation:`0`,border:``,rounded:`lg`},{default:a(()=>[C(M,{class:`d-flex align-center`},{default:a(()=>[C(u,{class:`mr-2`},{default:a(()=>[...o[63]||=[f(`mdi-ip-network`,-1)]]),_:1}),o[64]||=f(` 登录 IP 白名单 `,-1)]),_:1}),C(S),C(A,null,{default:a(()=>[C(R,{modelValue:st.value,"onUpdate:modelValue":[o[15]||=e=>st.value=e,It],label:`启用 IP 白名单(仅白名单 IP 可登录)`,color:`primary`,density:`compact`,"hide-details":``,class:`mb-4`},null,8,[`modelValue`]),o[67]||=m(`div`,{class:`text-subtitle-2 mb-2`},`代理订阅`,-1),o[68]||=m(`p`,{class:`text-caption text-medium-emphasis mb-2`},` 填写 SS/VMess/VLESS 等订阅链接,保存后每 2 小时自动刷新节点 IP 并合并进白名单。 `,-1),C(k,{modelValue:X.value,"onUpdate:modelValue":o[16]||=e=>X.value=e,label:`订阅 URL`,variant:`outlined`,density:`compact`,class:`mb-2`,placeholder:`https://example.com/sub?token=...`},null,8,[`modelValue`]),m(`div`,Oe,[C(l,{size:`small`,variant:`tonal`,"prepend-icon":`mdi-cloud-download`,onClick:Lt,loading:dt.value},{default:a(()=>[...o[65]||=[f(`解析预览`,-1)]]),_:1},8,[`loading`]),C(l,{size:`small`,variant:`tonal`,color:`primary`,"prepend-icon":`mdi-content-save`,onClick:Rt,loading:ut.value},{default:a(()=>[...o[66]||=[f(`保存白名单`,-1)]]),_:1},8,[`loading`])]),Z.value.length?(_(),g(`div`,ke,[m(`div`,Ae,[f(` 订阅节点 `+x(Z.value.length)+` 个 `,1),Q.value?(_(),g(`span`,je,` · 上次刷新 `+x(Q.value),1)):v(``,!0)]),m(`div`,Me,[(_(!0),g(p,null,c(pt.value,e=>(_(),y(T,{key:e,size:`x-small`,variant:`tonal`,label:``},{default:a(()=>[f(x(e),1)]),_:2},1024))),128)),Z.value.length>pt.value.length?(_(),y(T,{key:0,size:`x-small`,variant:`text`,label:``},{default:a(()=>[f(` +`+x(Z.value.length-pt.value.length)+` 更多 `,1)]),_:1})):v(``,!0)])])):X.value?(_(),g(`div`,Ne,x(Q.value?`上次刷新 ${Q.value},暂无节点`:`等待首次刷新…保存订阅 URL 后将自动拉取`),1)):v(``,!0),C(S,{class:`my-3`}),o[69]||=m(`div`,{class:`text-subtitle-2 mb-2`},`手动 IP`,-1),C(ue,{modelValue:ct.value,"onUpdate:modelValue":o[17]||=e=>ct.value=e,label:`手动 IP / CIDR(每行一个)`,variant:`outlined`,density:`compact`,rows:`4`,class:`mb-2`,placeholder:`1.2.3.4
|
||
10.0.0.0/24`},null,8,[`modelValue`]),m(`div`,Pe,` 手动 IP 与订阅节点合并生效;共 `+x(lt.value)+` 条(去重后)。 `,1)]),_:1})]),_:1})]),_:1})]),_:1}),C(N,{modelValue:$.value,"onUpdate:modelValue":o[20]||=e=>$.value=e,"max-width":`520`},{default:a(()=>[C(O,{border:``},{default:a(()=>[C(M,null,{default:a(()=>[...o[70]||=[f(`订阅解析预览`,-1)]]),_:1}),C(A,null,{default:a(()=>[m(`div`,Fe,[o[71]||=f(`共解析出 `,-1),m(`strong`,null,x(ft.value.length),1),o[72]||=f(` 个节点 IP / 域名:`,-1)]),m(`div`,Ie,[(_(!0),g(p,null,c(ft.value,e=>(_(),y(T,{key:e,size:`small`,variant:`tonal`,label:``},{default:a(()=>[f(x(e),1)]),_:2},1024))),128))]),o[73]||=m(`div`,{class:`text-caption text-medium-emphasis`},`点击「保存白名单」后才会写入订阅 URL 并触发后台刷新。`,-1)]),_:1}),C(j,null,{default:a(()=>[C(d),C(l,{variant:`text`,onClick:o[18]||=e=>$.value=!1},{default:a(()=>[...o[74]||=[f(`关闭`,-1)]]),_:1}),C(l,{color:`primary`,variant:`flat`,onClick:o[19]||=e=>{$.value=!1,Rt()}},{default:a(()=>[...o[75]||=[f(`保存白名单`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`]),C(N,{modelValue:G.value,"onUpdate:modelValue":o[22]||=e=>G.value=e,"max-width":`480`},{default:a(()=>[C(O,{border:``},{default:a(()=>[C(M,null,{default:a(()=>[...o[76]||=[f(`选择 Chat ID`,-1)]]),_:1}),C(A,null,{default:a(()=>[Ve.value.length?(_(),y(se,{key:1,density:`compact`,lines:`two`},{default:a(()=>[(_(!0),g(p,null,c(Ve.value,e=>(_(),y(ce,{key:e.id,title:e.title||e.username||`Chat ${e.id}`,subtitle:`${e.type}${e.username?` · @`+e.username:``} · ID ${e.id}`,onClick:t=>Et(e)},null,8,[`title`,`subtitle`,`onClick`]))),128))]),_:1})):(_(),g(`div`,Le,` 未检测到对话。请先在 Telegram 向 Bot 发送一条消息,然后重新检测。 `))]),_:1}),C(j,null,{default:a(()=>[C(d),C(l,{variant:`text`,onClick:o[21]||=e=>G.value=!1},{default:a(()=>[...o[77]||=[f(`关闭`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`]),C(N,{modelValue:et.value,"onUpdate:modelValue":o[26]||=e=>et.value=e,"max-width":`400`},{default:a(()=>[C(O,{border:``},{default:a(()=>[C(M,null,{default:a(()=>[...o[78]||=[f(`禁用 TOTP`,-1)]]),_:1}),C(A,null,{default:a(()=>[C(k,{modelValue:tt.value,"onUpdate:modelValue":o[23]||=e=>tt.value=e,label:`当前密码`,variant:`outlined`,density:`compact`,type:`password`,class:`mb-2`,rules:[i(P)()]},null,8,[`modelValue`,`rules`]),C(k,{modelValue:nt.value,"onUpdate:modelValue":o[24]||=e=>nt.value=e,label:`验证码`,variant:`outlined`,density:`compact`,rules:[i(P)()]},null,8,[`modelValue`,`rules`])]),_:1}),C(j,null,{default:a(()=>[C(d),C(l,{variant:`text`,onClick:o[25]||=e=>et.value=!1},{default:a(()=>[...o[79]||=[f(`取消`,-1)]]),_:1}),C(l,{color:`error`,variant:`flat`,onClick:jt,loading:rt.value},{default:a(()=>[...o[80]||=[f(`禁用`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}});export{H as default}; |