Files
claude-relay-service/web/admin-spa/dist/assets/SettingsView-CGiHEBiz.js
2025-09-03 09:30:41 +00:00

4 lines
35 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{aP as fe,r as y,aX as be,o as q,c as ve,q as ye,Z as me,x as i,z as e,L as k,C as T,O as u,u as v,K as f,S as z,aq as U,P as C,al as B,Q as R,ac as H,aV as F,aT as O,R as pe,J as xe,T as ke,Y as he,y as d}from"./vue-vendor-Bsazo-x0.js";import{c as _,_ as we,s as n}from"./index-BdoSYlER.js";import"./element-plus-C5sO7D8l.js";import"./vendor-C8JtMHuO.js";const Se=fe("settings",()=>{const p=y({siteName:"Claude Relay Service",siteIcon:"",siteIconData:"",updatedAt:null}),I=y(!1),W=y(!1),A=async()=>{I.value=!0;try{const l=await _.get("/admin/oem-settings");return l&&l.success&&(p.value={...p.value,...l.data},h()),l}catch(l){throw console.error("Failed to load OEM settings:",l),l}finally{I.value=!1}},b=async l=>{W.value=!0;try{const c=await _.put("/admin/oem-settings",l);return c&&c.success&&(p.value={...p.value,...c.data},h()),c}catch(c){throw console.error("Failed to save OEM settings:",c),c}finally{W.value=!1}},P=async()=>{const l={siteName:"Claude Relay Service",siteIcon:"",siteIconData:"",updatedAt:null};return p.value={...l},await b(l)},h=()=>{if(p.value.siteName&&(document.title=`${p.value.siteName} - 管理后台`),p.value.siteIconData||p.value.siteIcon){const l=document.querySelector('link[rel="icon"]')||document.createElement("link");l.rel="icon",l.href=p.value.siteIconData||p.value.siteIcon,document.querySelector('link[rel="icon"]')||document.head.appendChild(l)}};return{oemSettings:p,loading:I,saving:W,loadOemSettings:A,saveOemSettings:b,resetOemSettings:P,applyOemSettings:h,formatDateTime:l=>l?new Date(l).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"",validateIconFile:l=>{const c=[];return l.size>350*1024&&c.push("图标文件大小不能超过 350KB"),["image/x-icon","image/png","image/jpeg","image/jpg","image/svg+xml"].includes(l.type)||c.push("不支持的文件类型,请选择 .ico, .png, .jpg 或 .svg 文件"),{isValid:c.length===0,errors:c}},fileToBase64:l=>new Promise((c,V)=>{const g=new FileReader;g.onload=D=>c(D.target.result),g.onerror=V,g.readAsDataURL(l)})}}),Ce={class:"settings-container"},Ie={class:"card p-4 sm:p-6"},_e={class:"mb-6"},Ue={class:"flex space-x-8"},Ve={key:0,class:"py-12 text-center"},De={key:1},Ae={class:"table-container hidden sm:block"},Te={class:"min-w-full"},We={class:"divide-y divide-gray-200/50 dark:divide-gray-600/50"},Ee={class:"table-row"},Ne={class:"px-6 py-4"},je={class:"table-row"},Pe={class:"px-6 py-4"},Be={class:"space-y-3"},Re={key:0,class:"inline-flex items-center gap-3 rounded-lg bg-gray-50 p-3 dark:bg-gray-700"},Fe=["src"],Oe={class:"px-6 py-6",colspan:"2"},Ke={class:"flex items-center justify-between"},$e={class:"flex gap-3"},Me=["disabled"],Le={key:0,class:"loading-spinner mr-2"},qe={key:1,class:"fas fa-save mr-2"},ze=["disabled"],He={key:0,class:"text-sm text-gray-500 dark:text-gray-400"},Je={class:"mb-6 rounded-lg bg-white/80 p-6 shadow-lg backdrop-blur-sm dark:bg-gray-800/80"},Xe={class:"flex items-center justify-between"},Qe={class:"relative inline-flex cursor-pointer items-center"},Ye={class:"mb-6 rounded-lg bg-white/80 p-6 shadow-lg backdrop-blur-sm dark:bg-gray-800/80"},Ze={class:"space-y-3"},Ge={class:"font-medium text-gray-700 dark:text-gray-300"},et={class:"ml-2 text-sm text-gray-500 dark:text-gray-400"},tt={class:"relative inline-flex cursor-pointer items-center"},rt=["onUpdate:modelValue"],at={class:"mb-6 rounded-lg bg-white/80 p-6 shadow-lg backdrop-blur-sm dark:bg-gray-800/80"},st={class:"mb-4 flex items-center justify-between"},lt={key:0,class:"space-y-4"},ot={class:"flex items-start justify-between"},nt={class:"flex-1"},it={class:"flex items-center"},dt={class:"font-semibold text-gray-800 dark:text-gray-200"},ut={class:"text-sm text-gray-500 dark:text-gray-400"},ct={class:"mt-3 space-y-1 text-sm"},gt={class:"flex items-center text-gray-600 dark:text-gray-400"},ft={class:"truncate"},bt={key:0,class:"flex items-center text-gray-600 dark:text-gray-400"},vt={class:"ml-4 flex items-center space-x-2"},yt={class:"relative inline-flex cursor-pointer items-center"},mt=["checked","onChange"],pt=["onClick"],xt=["onClick"],kt=["onClick"],ht={key:1,class:"py-8 text-center text-gray-500 dark:text-gray-400"},wt={class:"rounded-lg bg-white/80 p-6 shadow-lg backdrop-blur-sm dark:bg-gray-800/80"},St={class:"grid grid-cols-1 gap-4 md:grid-cols-3"},Ct={class:"dark:to-gray-750 relative border-b border-gray-200 bg-gradient-to-r from-blue-50 to-indigo-50 px-6 py-5 dark:border-gray-700 dark:from-gray-800"},It={class:"flex items-center justify-between"},_t={class:"flex items-center space-x-3"},Ut={class:"text-xl font-semibold text-gray-900 dark:text-white"},Vt={class:"mt-0.5 text-sm text-gray-600 dark:text-gray-400"},Dt={class:"p-6"},At={class:"space-y-5"},Tt={class:"relative"},Wt=["disabled"],Et={key:0,class:"mt-1 text-xs text-amber-600 dark:text-amber-400"},Nt={key:0},jt={class:"relative"},Pt={key:0,class:"absolute inset-y-0 right-0 flex items-center pr-3"},Bt={key:1,class:"absolute inset-y-0 right-0 flex items-center pr-3"},Rt={key:0,class:"mt-2 flex items-start rounded-lg bg-blue-50 p-3 dark:bg-blue-900/20"},Ft={class:"text-sm text-blue-700 dark:text-blue-300"},Ot={key:1,class:"space-y-5"},Kt={key:2,class:"rounded-xl border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-900/50"},$t={class:"space-y-4"},Mt={class:"flex items-center justify-between"},Lt={class:"flex cursor-pointer items-center",for:"enableSign"},qt={key:0,class:"rounded-full bg-green-100 px-2 py-1 text-xs font-medium text-green-700 dark:bg-green-900/50 dark:text-green-400"},zt={key:0},Ht={class:"border-t border-gray-200 bg-gray-50 px-6 py-4 dark:border-gray-700 dark:bg-gray-900/50"},Jt={class:"flex items-center justify-between"},Xt={class:"flex space-x-3"},Qt=["disabled"],Yt=["disabled"],Zt=Object.assign({name:"SettingsView"},{__name:"SettingsView",setup(p){const I=Se(),{loading:W,saving:A,oemSettings:b}=be(I),P=y(),h=y("branding"),o=y(!0),w=y(new AbortController),x=y(!1),l=y(!1),c=y(!1),V=y(!1),g=y({enabled:!1,platforms:[],notificationTypes:{accountAnomaly:!0,quotaWarning:!0,systemError:!0,securityAlert:!0},retrySettings:{maxRetries:3,retryDelay:1e3,timeout:1e4}}),D=y(!1),S=y(null),a=y({type:"wechat_work",name:"",url:"",enableSign:!1,secret:""}),K=q(h,async r=>{o.value&&r==="webhook"&&await E()}),$=q(()=>a.value.type,r=>{x.value=!1,l.value=!1,S.value||(r==="bark"?(a.value.url="",a.value.enableSign=!1,a.value.secret=""):(a.value.deviceKey="",a.value.serverUrl="",a.value.level="",a.value.sound="",a.value.group=""))}),J=ve(()=>a.value.type==="bark"?!!a.value.deviceKey:!!a.value.url&&!x.value);ye(async()=>{try{await I.loadOemSettings(),h.value==="webhook"&&await E()}catch{n("加载设置失败","error")}}),me(()=>{o.value=!1,w.value&&w.value.abort(),K&&K(),$&&$(),D.value&&(D.value=!1,S.value=null)});const E=async()=>{if(o.value)try{const r=await _.get("/admin/webhook/config",{signal:w.value.signal});r.success&&o.value&&(g.value=r.config)}catch(r){if(r.name==="AbortError"||!o.value)return;n("获取webhook配置失败","error"),console.error(r)}},N=async()=>{if(o.value)try{(await _.post("/admin/webhook/config",g.value,{signal:w.value.signal})).success&&o.value&&n("配置已保存","success")}catch(r){if(r.name==="AbortError"||!o.value)return;n("保存配置失败","error"),console.error(r)}},X=()=>{if(a.value.type==="bark"){x.value=!1,l.value=!1;return}const r=a.value.url;if(!r){x.value=!1,l.value=!1;return}try{new URL(r),r.startsWith("http://")||r.startsWith("https://")?(x.value=!1,l.value=!0):(x.value=!0,l.value=!1)}catch{x.value=!0,l.value=!1}},Q=async()=>{if(o.value){if(a.value.type==="bark"){if(!a.value.deviceKey){n("请输入Bark设备密钥","error");return}}else{if(!a.value.url){n("请输入Webhook URL","error");return}if(x.value){n("请输入有效的Webhook URL","error");return}}V.value=!0;try{let r;S.value?r=await _.put(`/admin/webhook/platforms/${S.value.id}`,a.value,{signal:w.value.signal}):r=await _.post("/admin/webhook/platforms",a.value,{signal:w.value.signal}),r.success&&o.value&&(n(S.value?"平台已更新":"平台已添加","success"),await E(),j())}catch(r){if(r.name==="AbortError"||!o.value)return;n(r.message||"操作失败","error"),console.error(r)}finally{o.value&&(V.value=!1)}}},Y=r=>{S.value=r,a.value={...r},D.value=!0},Z=async r=>{if(o.value&&confirm("确定要删除这个平台吗?"))try{(await _.delete(`/admin/webhook/platforms/${r}`,{signal:w.value.signal})).success&&o.value&&(n("平台已删除","success"),await E())}catch(t){if(t.name==="AbortError"||!o.value)return;n("删除失败","error"),console.error(t)}},G=async r=>{if(o.value)try{const t=await _.post(`/admin/webhook/platforms/${r}/toggle`,{},{signal:w.value.signal});t.success&&o.value&&(n(t.message,"success"),await E())}catch(t){if(t.name==="AbortError"||!o.value)return;n("操作失败","error"),console.error(t)}},ee=async r=>{if(o.value)try{const t={type:r.type,secret:r.secret,enableSign:r.enableSign};r.type==="bark"?(t.deviceKey=r.deviceKey,t.serverUrl=r.serverUrl,t.level=r.level,t.sound=r.sound,t.group=r.group):t.url=r.url,(await _.post("/admin/webhook/test",t,{signal:w.value.signal})).success&&o.value&&n("测试成功webhook连接正常","success")}catch(t){if(t.name==="AbortError"||!o.value)return;n(t.error||t.message||"测试失败","error"),console.error(t)}},te=async()=>{if(o.value){if(a.value.type==="bark"){if(!a.value.deviceKey){n("请先输入Bark设备密钥","error");return}}else{if(!a.value.url){n("请先输入Webhook URL","error");return}if(x.value){n("请输入有效的Webhook URL","error");return}}c.value=!0;try{(await _.post("/admin/webhook/test",a.value,{signal:w.value.signal})).success&&o.value&&n("测试成功webhook连接正常","success")}catch(r){if(r.name==="AbortError"||!o.value)return;n(r.error||r.message||"测试失败","error"),console.error(r)}finally{o.value&&(c.value=!1)}}},re=async()=>{if(o.value)try{(await _.post("/admin/webhook/test-notification",{},{signal:w.value.signal})).success&&o.value&&n("测试通知已发送","success")}catch(r){if(r.name==="AbortError"||!o.value)return;n("发送失败","error"),console.error(r)}},j=()=>{o.value&&(D.value=!1,setTimeout(()=>{o.value&&(S.value=null,a.value={type:"wechat_work",name:"",url:"",enableSign:!1,secret:"",deviceKey:"",serverUrl:"",level:"",sound:"",group:""},x.value=!1,l.value=!1,c.value=!1,V.value=!1)},0))},M=r=>({wechat_work:"企业微信",dingtalk:"钉钉",feishu:"飞书",slack:"Slack",discord:"Discord",bark:"Bark",custom:"自定义"})[r]||r,ae=r=>({wechat_work:"fab fa-weixin text-green-600",dingtalk:"fas fa-comment-dots text-blue-500",feishu:"fas fa-dove text-blue-600",slack:"fab fa-slack text-purple-600",discord:"fab fa-discord text-indigo-600",bark:"fas fa-bell text-orange-500",custom:"fas fa-webhook text-gray-600"})[r]||"fas fa-bell",L=r=>({wechat_work:"请在企业微信群机器人设置中获取Webhook地址",dingtalk:"请在钉钉群机器人设置中获取Webhook地址",feishu:"请在飞书群机器人设置中获取Webhook地址",slack:"请在Slack应用的Incoming Webhooks中获取地址",discord:"请在Discord服务器的集成设置中创建Webhook",bark:"请在Bark App中查看您的设备密钥",custom:"请输入完整的Webhook接收地址"})[r]||"",se=r=>({accountAnomaly:"账号异常",quotaWarning:"配额警告",systemError:"系统错误",securityAlert:"安全警报"})[r]||r,le=r=>({accountAnomaly:"账号状态异常、认证失败等",quotaWarning:"API调用配额不足警告",systemError:"系统运行错误和故障",securityAlert:"安全相关的警报通知"})[r]||"",oe=async()=>{try{const r={siteName:b.value.siteName,siteIcon:b.value.siteIcon,siteIconData:b.value.siteIconData},t=await I.saveOemSettings(r);t&&t.success?n("OEM设置保存成功","success"):n((t==null?void 0:t.message)||"保存失败","error")}catch{n("保存OEM设置失败","error")}},ne=async()=>{if(confirm(`确定要重置为默认设置吗?
这将清除所有自定义的网站名称和图标设置。`))try{const r=await I.resetOemSettings();r&&r.success?n("已重置为默认设置","success"):n("重置失败","error")}catch{n("重置失败","error")}},ie=async r=>{const t=r.target.files[0];if(!t)return;const s=I.validateIconFile(t);if(!s.isValid){s.errors.forEach(m=>n(m,"error"));return}try{const m=await I.fileToBase64(t);b.value.siteIconData=m}catch{n("文件读取失败","error")}r.target.value=""},de=()=>{b.value.siteIcon="",b.value.siteIconData=""},ue=()=>{console.warn("Icon failed to load")},ce=I.formatDateTime;return(r,t)=>(d(),i(R,null,[e("div",Ce,[e("div",Ie,[t[50]||(t[50]=e("div",{class:"mb-4 sm:mb-6"},[e("h3",{class:"mb-1 text-lg font-bold text-gray-900 dark:text-gray-100 sm:mb-2 sm:text-xl"}," 系统设置 "),e("p",{class:"text-sm text-gray-600 dark:text-gray-400 sm:text-base"},"网站定制和通知配置")],-1)),e("div",_e,[e("nav",Ue,[e("button",{class:T(["border-b-2 pb-2 text-sm font-medium transition-colors",h.value==="branding"?"border-blue-500 text-blue-600 dark:border-blue-400 dark:text-blue-400":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"]),onClick:t[0]||(t[0]=s=>h.value="branding")},t[20]||(t[20]=[e("i",{class:"fas fa-palette mr-2"},null,-1),u(" 品牌设置 ",-1)]),2),e("button",{class:T(["border-b-2 pb-2 text-sm font-medium transition-colors",h.value==="webhook"?"border-blue-500 text-blue-600 dark:border-blue-400 dark:text-blue-400":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"]),onClick:t[1]||(t[1]=s=>h.value="webhook")},t[21]||(t[21]=[e("i",{class:"fas fa-bell mr-2"},null,-1),u(" 通知设置 ",-1)]),2)])]),v(W)?(d(),i("div",Ve,t[22]||(t[22]=[e("div",{class:"loading-spinner mx-auto mb-4"},null,-1),e("p",{class:"text-gray-500 dark:text-gray-400"},"正在加载设置...",-1)]))):(d(),i("div",De,[f(e("div",null,[e("div",Ae,[e("table",Te,[e("tbody",We,[e("tr",Ee,[t[24]||(t[24]=e("td",{class:"w-48 whitespace-nowrap px-6 py-4"},[e("div",{class:"flex items-center"},[e("div",{class:"mr-3 flex h-8 w-8 items-center justify-center rounded-lg bg-gradient-to-br from-blue-500 to-blue-600"},[e("i",{class:"fas fa-font text-xs text-white"})]),e("div",null,[e("div",{class:"text-sm font-semibold text-gray-900 dark:text-gray-100"}," 网站名称 "),e("div",{class:"text-xs text-gray-500 dark:text-gray-400"},"品牌标识")])])],-1)),e("td",Ne,[f(e("input",{"onUpdate:modelValue":t[2]||(t[2]=s=>v(b).siteName=s),class:"form-input w-full max-w-md dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",maxlength:"100",placeholder:"Claude Relay Service",type:"text"},null,512),[[U,v(b).siteName]]),t[23]||(t[23]=e("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," 将显示在浏览器标题和页面头部 ",-1))])]),e("tr",je,[t[29]||(t[29]=e("td",{class:"w-48 whitespace-nowrap px-6 py-4"},[e("div",{class:"flex items-center"},[e("div",{class:"mr-3 flex h-8 w-8 items-center justify-center rounded-lg bg-gradient-to-br from-purple-500 to-purple-600"},[e("i",{class:"fas fa-image text-xs text-white"})]),e("div",null,[e("div",{class:"text-sm font-semibold text-gray-900 dark:text-gray-100"}," 网站图标 "),e("div",{class:"text-xs text-gray-500 dark:text-gray-400"},"Favicon")])])],-1)),e("td",Pe,[e("div",Be,[v(b).siteIconData||v(b).siteIcon?(d(),i("div",Re,[e("img",{alt:"图标预览",class:"h-8 w-8",src:v(b).siteIconData||v(b).siteIcon,onError:ue},null,40,Fe),t[26]||(t[26]=e("span",{class:"text-sm text-gray-600 dark:text-gray-400"},"当前图标",-1)),e("button",{class:"rounded-lg px-3 py-1 font-medium text-red-600 transition-colors hover:bg-red-50 hover:text-red-900",onClick:de},t[25]||(t[25]=[e("i",{class:"fas fa-trash mr-1"},null,-1),u("删除 ",-1)]))])):k("",!0),e("div",null,[e("input",{ref_key:"iconFileInput",ref:P,accept:".ico,.png,.jpg,.jpeg,.svg",class:"hidden",type:"file",onChange:ie},null,544),e("button",{class:"btn btn-success px-4 py-2",onClick:t[3]||(t[3]=s=>r.$refs.iconFileInput.click())},t[27]||(t[27]=[e("i",{class:"fas fa-upload mr-2"},null,-1),u(" 上传图标 ",-1)])),t[28]||(t[28]=e("span",{class:"ml-3 text-xs text-gray-500 dark:text-gray-400"},"支持 .ico, .png, .jpg, .svg 格式,最大 350KB",-1))])])])]),e("tr",null,[e("td",Oe,[e("div",Ke,[e("div",$e,[e("button",{class:T(["btn btn-primary px-6 py-3",{"cursor-not-allowed opacity-50":v(A)}]),disabled:v(A),onClick:oe},[v(A)?(d(),i("div",Le)):(d(),i("i",qe)),u(" "+C(v(A)?"保存中...":"保存设置"),1)],10,Me),e("button",{class:"btn bg-gray-100 px-6 py-3 text-gray-700 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",disabled:v(A),onClick:ne},t[30]||(t[30]=[e("i",{class:"fas fa-undo mr-2"},null,-1),u(" 重置为默认 ",-1)]),8,ze)]),v(b).updatedAt?(d(),i("div",He,[t[31]||(t[31]=e("i",{class:"fas fa-clock mr-1"},null,-1)),u(" 最后更新:"+C(v(ce)(v(b).updatedAt)),1)])):k("",!0)])])])])])]),t[32]||(t[32]=e("div",{class:"space-y-4 sm:hidden"},null,-1))],512),[[z,h.value==="branding"]]),f(e("div",null,[e("div",Je,[e("div",Xe,[t[34]||(t[34]=e("div",null,[e("h2",{class:"text-lg font-semibold text-gray-800 dark:text-gray-200"}," 启用 Webhook 通知 "),e("p",{class:"mt-1 text-sm text-gray-600 dark:text-gray-400"}," 开启后,系统将按配置发送通知到指定平台 ")],-1)),e("label",Qe,[f(e("input",{"onUpdate:modelValue":t[4]||(t[4]=s=>g.value.enabled=s),class:"peer sr-only",type:"checkbox",onChange:N},null,544),[[B,g.value.enabled]]),t[33]||(t[33]=e("div",{class:"peer h-6 w-11 rounded-full bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-blue-600 peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:border-gray-600 dark:bg-gray-700 dark:peer-focus:ring-blue-800"},null,-1))])])]),e("div",Ye,[t[36]||(t[36]=e("h2",{class:"mb-4 text-lg font-semibold text-gray-800 dark:text-gray-200"},"通知类型",-1)),e("div",Ze,[(d(!0),i(R,null,H(g.value.notificationTypes,(s,m)=>(d(),i("div",{key:m,class:"flex items-center justify-between"},[e("div",null,[e("span",Ge,C(se(m)),1),e("span",et,C(le(m)),1)]),e("label",tt,[f(e("input",{"onUpdate:modelValue":ge=>g.value.notificationTypes[m]=ge,class:"peer sr-only",type:"checkbox",onChange:N},null,40,rt),[[B,g.value.notificationTypes[m]]]),t[35]||(t[35]=e("div",{class:"peer h-5 w-9 rounded-full bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-4 after:w-4 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-green-600 peer-checked:after:translate-x-full peer-checked:after:border-white dark:border-gray-600 dark:bg-gray-700"},null,-1))])]))),128))])]),e("div",at,[e("div",st,[t[38]||(t[38]=e("h2",{class:"text-lg font-semibold text-gray-800 dark:text-gray-200"},"通知平台",-1)),e("button",{class:"rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700",onClick:t[5]||(t[5]=s=>D.value=!0)},t[37]||(t[37]=[e("i",{class:"fas fa-plus mr-2"},null,-1),u(" 添加平台 ",-1)]))]),g.value.platforms&&g.value.platforms.length>0?(d(),i("div",lt,[(d(!0),i(R,null,H(g.value.platforms,s=>(d(),i("div",{key:s.id,class:"rounded-lg border border-gray-200 p-4 dark:border-gray-700"},[e("div",ot,[e("div",nt,[e("div",it,[e("i",{class:T(["mr-3 text-xl",ae(s.type)])},null,2),e("div",null,[e("h3",dt,C(s.name||M(s.type)),1),e("p",ut,C(M(s.type)),1)])]),e("div",ct,[e("div",gt,[t[39]||(t[39]=e("i",{class:"fas fa-link mr-2"},null,-1)),e("span",ft,C(s.url),1)]),s.enableSign?(d(),i("div",bt,t[40]||(t[40]=[e("i",{class:"fas fa-shield-alt mr-2"},null,-1),e("span",null,"已启用签名验证",-1)]))):k("",!0)])]),e("div",vt,[e("label",yt,[e("input",{checked:s.enabled,class:"peer sr-only",type:"checkbox",onChange:m=>G(s.id)},null,40,mt),t[41]||(t[41]=e("div",{class:"peer h-5 w-9 rounded-full bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-4 after:w-4 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-green-600 peer-checked:after:translate-x-full peer-checked:after:border-white dark:border-gray-600 dark:bg-gray-700"},null,-1))]),e("button",{class:"rounded-lg bg-blue-100 p-2 text-blue-600 transition-colors hover:bg-blue-200 dark:bg-blue-900 dark:text-blue-400 dark:hover:bg-blue-800",title:"测试连接",onClick:m=>ee(s)},t[42]||(t[42]=[e("i",{class:"fas fa-vial"},null,-1)]),8,pt),e("button",{class:"rounded-lg bg-gray-100 p-2 text-gray-600 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-400 dark:hover:bg-gray-600",title:"编辑",onClick:m=>Y(s)},t[43]||(t[43]=[e("i",{class:"fas fa-edit"},null,-1)]),8,xt),e("button",{class:"rounded-lg bg-red-100 p-2 text-red-600 transition-colors hover:bg-red-200 dark:bg-red-900 dark:text-red-400 dark:hover:bg-red-800",title:"删除",onClick:m=>Z(s.id)},t[44]||(t[44]=[e("i",{class:"fas fa-trash"},null,-1)]),8,kt)])])]))),128))])):(d(),i("div",ht,' 暂无配置的通知平台,请点击"添加平台"按钮添加 '))]),e("div",wt,[t[48]||(t[48]=e("h2",{class:"mb-4 text-lg font-semibold text-gray-800 dark:text-gray-200"},"高级设置",-1)),e("div",St,[e("div",null,[t[45]||(t[45]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300"}," 最大重试次数 ",-1)),f(e("input",{"onUpdate:modelValue":t[6]||(t[6]=s=>g.value.retrySettings.maxRetries=s),class:"mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white sm:text-sm",max:"10",min:"0",type:"number",onChange:N},null,544),[[U,g.value.retrySettings.maxRetries,void 0,{number:!0}]])]),e("div",null,[t[46]||(t[46]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300"}," 重试延迟 (毫秒) ",-1)),f(e("input",{"onUpdate:modelValue":t[7]||(t[7]=s=>g.value.retrySettings.retryDelay=s),class:"mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white sm:text-sm",max:"10000",min:"100",step:"100",type:"number",onChange:N},null,544),[[U,g.value.retrySettings.retryDelay,void 0,{number:!0}]])]),e("div",null,[t[47]||(t[47]=e("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300"}," 超时时间 (毫秒) ",-1)),f(e("input",{"onUpdate:modelValue":t[8]||(t[8]=s=>g.value.retrySettings.timeout=s),class:"mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white sm:text-sm",max:"30000",min:"1000",step:"1000",type:"number",onChange:N},null,544),[[U,g.value.retrySettings.timeout,void 0,{number:!0}]])])])]),e("div",{class:"mt-6 text-center"},[e("button",{class:"rounded-lg bg-green-600 px-6 py-3 text-white shadow-lg transition-all hover:bg-green-700 hover:shadow-xl",onClick:re},t[49]||(t[49]=[e("i",{class:"fas fa-paper-plane mr-2"},null,-1),u(" 发送测试通知 ",-1)]))])],512),[[z,h.value==="webhook"]])]))])]),D.value?(d(),i("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm transition-all duration-300 ease-out",onClick:j},[e("div",{class:"relative mx-4 w-full max-w-2xl overflow-hidden rounded-2xl bg-white shadow-2xl transition-all duration-300 ease-out dark:bg-gray-800",onClick:t[19]||(t[19]=he(()=>{},["stop"]))},[e("div",Ct,[e("div",It,[e("div",_t,[t[51]||(t[51]=e("div",{class:"flex h-10 w-10 items-center justify-center rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 text-white shadow-lg"},[e("i",{class:"fas fa-bell"})],-1)),e("div",null,[e("h3",Ut,C(S.value?"编辑":"添加")+"通知平台 ",1),e("p",Vt," 配置"+C(S.value?"并更新":"新的")+"Webhook通知渠道 ",1)])]),e("button",{class:"rounded-lg p-2 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",onClick:j},t[52]||(t[52]=[e("i",{class:"fas fa-times text-lg"},null,-1)]))])]),e("div",Dt,[e("div",At,[e("div",null,[t[56]||(t[56]=e("label",{class:"mb-2 flex items-center text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-layer-group mr-2 text-gray-400"}),u(" 平台类型 ")],-1)),e("div",Tt,[f(e("select",{"onUpdate:modelValue":t[9]||(t[9]=s=>a.value.type=s),class:"w-full appearance-none rounded-xl border border-gray-300 bg-white px-4 py-3 pr-10 text-gray-900 shadow-sm transition-all focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-600 dark:bg-gray-700 dark:text-white",disabled:S.value},t[53]||(t[53]=[O('<option value="wechat_work" data-v-6a970686>🟢 企业微信</option><option value="dingtalk" data-v-6a970686>🔵 钉钉</option><option value="feishu" data-v-6a970686>🟦 飞书</option><option value="slack" data-v-6a970686>🟣 Slack</option><option value="discord" data-v-6a970686>🟪 Discord</option><option value="bark" data-v-6a970686>🔔 Bark</option><option value="custom" data-v-6a970686>⚙️ 自定义</option>',7)]),8,Wt),[[F,a.value.type]]),t[54]||(t[54]=e("div",{class:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3"},[e("i",{class:"fas fa-chevron-down text-gray-400"})],-1))]),S.value?(d(),i("p",Et,t[55]||(t[55]=[e("i",{class:"fas fa-info-circle mr-1"},null,-1),u(" 编辑模式下不能更改平台类型 ",-1)]))):k("",!0)]),e("div",null,[t[57]||(t[57]=e("label",{class:"mb-2 flex items-center text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-tag mr-2 text-gray-400"}),u(" 名称 "),e("span",{class:"ml-2 text-xs text-gray-500"},"(可选)")],-1)),f(e("input",{"onUpdate:modelValue":t[10]||(t[10]=s=>a.value.name=s),class:"w-full rounded-xl border border-gray-300 bg-white px-4 py-3 text-gray-900 shadow-sm transition-all placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder:text-gray-500",placeholder:"例如:运维群通知、开发测试群",type:"text"},null,512),[[U,a.value.name]])]),a.value.type!=="bark"?(d(),i("div",Nt,[t[61]||(t[61]=e("label",{class:"mb-2 flex items-center text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-link mr-2 text-gray-400"}),u(" Webhook URL "),e("span",{class:"ml-1 text-xs text-red-500"},"*")],-1)),e("div",jt,[f(e("input",{"onUpdate:modelValue":t[11]||(t[11]=s=>a.value.url=s),class:T(["w-full rounded-xl border border-gray-300 bg-white px-4 py-3 pr-10 font-mono text-sm text-gray-900 shadow-sm transition-all placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder:text-gray-500",{"border-red-500 focus:border-red-500 focus:ring-red-500/20":x.value,"border-green-500 focus:border-green-500 focus:ring-green-500/20":l.value}]),placeholder:"https://...",required:"",type:"url",onInput:X},null,34),[[U,a.value.url]]),l.value?(d(),i("div",Pt,t[58]||(t[58]=[e("i",{class:"fas fa-check-circle text-green-500"},null,-1)]))):k("",!0),x.value?(d(),i("div",Bt,t[59]||(t[59]=[e("i",{class:"fas fa-exclamation-circle text-red-500"},null,-1)]))):k("",!0)]),L(a.value.type)?(d(),i("div",Rt,[t[60]||(t[60]=e("i",{class:"fas fa-info-circle mr-2 mt-0.5 text-blue-600 dark:text-blue-400"},null,-1)),e("p",Ft,C(L(a.value.type)),1)])):k("",!0)])):k("",!0),a.value.type==="bark"?(d(),i("div",Ot,[e("div",null,[t[62]||(t[62]=e("label",{class:"mb-2 flex items-center text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-key mr-2 text-gray-400"}),u(" 设备密钥 (Device Key) "),e("span",{class:"ml-1 text-xs text-red-500"},"*")],-1)),f(e("input",{"onUpdate:modelValue":t[12]||(t[12]=s=>a.value.deviceKey=s),class:"w-full rounded-xl border border-gray-300 bg-white px-4 py-3 font-mono text-sm text-gray-900 shadow-sm transition-all placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder:text-gray-500",placeholder:"例如aBcDeFgHiJkLmNoPqRsTuVwX",required:"",type:"text"},null,512),[[U,a.value.deviceKey]]),t[63]||(t[63]=e("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," 在Bark App中查看您的推送密钥 ",-1))]),e("div",null,[t[64]||(t[64]=e("label",{class:"mb-2 flex items-center text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-server mr-2 text-gray-400"}),u(" 服务器地址 "),e("span",{class:"ml-2 text-xs text-gray-500"},"(可选)")],-1)),f(e("input",{"onUpdate:modelValue":t[13]||(t[13]=s=>a.value.serverUrl=s),class:"w-full rounded-xl border border-gray-300 bg-white px-4 py-3 font-mono text-sm text-gray-900 shadow-sm transition-all placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder:text-gray-500",placeholder:"默认: https://api.day.app/push",type:"url"},null,512),[[U,a.value.serverUrl]])]),e("div",null,[t[66]||(t[66]=e("label",{class:"mb-2 flex items-center text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-flag mr-2 text-gray-400"}),u(" 通知级别 ")],-1)),f(e("select",{"onUpdate:modelValue":t[14]||(t[14]=s=>a.value.level=s),class:"w-full appearance-none rounded-xl border border-gray-300 bg-white px-4 py-3 pr-10 text-gray-900 shadow-sm transition-all focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-600 dark:bg-gray-700 dark:text-white"},t[65]||(t[65]=[O('<option value="" data-v-6a970686>自动(根据通知类型)</option><option value="passive" data-v-6a970686>被动</option><option value="active" data-v-6a970686>默认</option><option value="timeSensitive" data-v-6a970686>时效性</option><option value="critical" data-v-6a970686>紧急</option>',5)]),512),[[F,a.value.level]])]),e("div",null,[t[68]||(t[68]=e("label",{class:"mb-2 flex items-center text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-volume-up mr-2 text-gray-400"}),u(" 通知声音 ")],-1)),f(e("select",{"onUpdate:modelValue":t[15]||(t[15]=s=>a.value.sound=s),class:"w-full appearance-none rounded-xl border border-gray-300 bg-white px-4 py-3 pr-10 text-gray-900 shadow-sm transition-all focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-600 dark:bg-gray-700 dark:text-white"},t[67]||(t[67]=[O('<option value="" data-v-6a970686>自动(根据通知类型)</option><option value="default" data-v-6a970686>默认</option><option value="alarm" data-v-6a970686>警报</option><option value="bell" data-v-6a970686>铃声</option><option value="birdsong" data-v-6a970686>鸟鸣</option><option value="electronic" data-v-6a970686>电子音</option><option value="glass" data-v-6a970686>玻璃</option><option value="horn" data-v-6a970686>喇叭</option><option value="silence" data-v-6a970686>静音</option>',9)]),512),[[F,a.value.sound]])]),e("div",null,[t[69]||(t[69]=e("label",{class:"mb-2 flex items-center text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-folder mr-2 text-gray-400"}),u(" 通知分组 "),e("span",{class:"ml-2 text-xs text-gray-500"},"(可选)")],-1)),f(e("input",{"onUpdate:modelValue":t[16]||(t[16]=s=>a.value.group=s),class:"w-full rounded-xl border border-gray-300 bg-white px-4 py-3 text-gray-900 shadow-sm transition-all placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder:text-gray-500",placeholder:"默认: claude-relay",type:"text"},null,512),[[U,a.value.group]])]),t[70]||(t[70]=e("div",{class:"mt-2 flex items-start rounded-lg bg-blue-50 p-3 dark:bg-blue-900/20"},[e("i",{class:"fas fa-info-circle mr-2 mt-0.5 text-blue-600 dark:text-blue-400"}),e("div",{class:"text-sm text-blue-700 dark:text-blue-300"},[e("p",null,"1. 在iPhone上安装Bark App"),e("p",null,"2. 打开App获取您的设备密钥"),e("p",null,"3. 将密钥粘贴到上方输入框")])],-1))])):k("",!0),a.value.type==="dingtalk"||a.value.type==="feishu"?(d(),i("div",Kt,[e("div",$t,[e("div",Mt,[e("label",Lt,[f(e("input",{id:"enableSign","onUpdate:modelValue":t[17]||(t[17]=s=>a.value.enableSign=s),class:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-2 focus:ring-blue-500 focus:ring-offset-0",type:"checkbox"},null,512),[[B,a.value.enableSign]]),t[71]||(t[71]=e("span",{class:"ml-3 flex items-center text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-shield-alt mr-2 text-gray-400"}),u(" 启用签名验证 ")],-1))]),a.value.enableSign?(d(),i("span",qt," 已启用 ")):k("",!0)]),pe(ke,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 -translate-y-2","enter-to-class":"opacity-100 translate-y-0","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 translate-y-0","leave-to-class":"opacity-0 -translate-y-2"},{default:xe(()=>[a.value.enableSign?(d(),i("div",zt,[t[72]||(t[72]=e("label",{class:"mb-2 block text-sm font-medium text-gray-700 dark:text-gray-300"}," 签名密钥 ",-1)),f(e("input",{"onUpdate:modelValue":t[18]||(t[18]=s=>a.value.secret=s),class:"w-full rounded-xl border border-gray-300 bg-white px-4 py-3 font-mono text-sm text-gray-900 shadow-sm transition-all placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-600 dark:bg-gray-800 dark:text-white dark:placeholder:text-gray-500",placeholder:"SEC...",type:"text"},null,512),[[U,a.value.secret]])])):k("",!0)]),_:1})])])):k("",!0)])]),e("div",Ht,[e("div",Jt,[t[74]||(t[74]=e("div",{class:"text-xs text-gray-500 dark:text-gray-400"},[e("i",{class:"fas fa-asterisk mr-1 text-red-500"}),u(" 必填项 ")],-1)),e("div",Xt,[e("button",{class:"group flex items-center rounded-xl border border-gray-300 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 shadow-sm transition-all hover:bg-gray-50 hover:shadow-md dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700",onClick:j},t[73]||(t[73]=[e("i",{class:"fas fa-times mr-2 transition-transform group-hover:scale-110"},null,-1),u(" 取消 ",-1)])),e("button",{class:"group flex items-center rounded-xl border border-blue-200 bg-blue-50 px-4 py-2.5 text-sm font-medium text-blue-700 shadow-sm transition-all hover:bg-blue-100 hover:shadow-md dark:border-blue-800 dark:bg-blue-900/50 dark:text-blue-300 dark:hover:bg-blue-900/70",disabled:c.value,onClick:te},[e("i",{class:T(["mr-2 transition-transform",c.value?"fas fa-spinner fa-spin":"fas fa-vial group-hover:scale-110"])},null,2),u(" "+C(c.value?"测试中...":"测试连接"),1)],8,Qt),e("button",{class:"group flex items-center rounded-xl bg-gradient-to-r from-blue-600 to-indigo-600 px-5 py-2.5 text-sm font-medium text-white shadow-md transition-all hover:from-blue-700 hover:to-indigo-700 hover:shadow-lg disabled:cursor-not-allowed disabled:from-gray-400 disabled:to-gray-500",disabled:!J.value||V.value,onClick:Q},[e("i",{class:T(["mr-2 transition-transform",V.value?"fas fa-spinner fa-spin":"fas fa-save group-hover:scale-110"])},null,2),u(" "+C(V.value?"保存中...":S.value?"保存修改":"添加平台"),1)],8,Yt)])])])])])):k("",!0)],64))}}),ar=we(Zt,[["__scopeId","data-v-6a970686"]]);export{ar as default};