import{f as he,u as X,e as Ie}from"./system-CM-zje4U.js";import{a as C,_ as Se,r as n,c as Ne,U as Ae,T as Be,o as Te,f as c,I as De,J as Ke,h as _,g as k,j as s,m as l,w as o,q as m,B as Y,n as U,F as Ee,v as $e,p as le,K as Z,L as r}from"./index-DD_NUvZR.js";async function ae(p={}){const{data:v}=await C.get("/kdocs/status",{params:p});return v}async function qe(p={}){const v={force:!0,...p},{data:g}=await C.post("/kdocs/qr",v);return g}async function Fe(){const{data:p}=await C.post("/kdocs/clear-login",{});return p}async function He(){const{data:p}=await C.get("/proxy/config");return p}async function Le(p){const{data:v}=await C.post("/proxy/config",p);return v}async function Qe(p){const{data:v}=await C.post("/proxy/test",p);return v}const Me={class:"page-stack"},je={class:"app-page-title"},Oe={class:"row-actions"},ze={class:"row-actions"},Re={class:"row-actions"},We={class:"help"},Ge={key:0},Je={key:1},Xe={key:2},Ye={key:3},Ze={class:"kdocs-qr"},el=["src"],ll={__name:"SystemPage",setup(p){const v=n(!1),g=n(2),B=n(1),T=n(3),f=n(!1),D=n("02:00"),P=n("应读"),b=n(["1","2","3","4","5","6","7"]),h=n(!0),I=n(!1),x=n(""),K=n(3),E=n(!1),$=n(10),q=n(7),F=n(!1),H=n(""),L=n(""),Q=n(""),M=n(0),j=n("A"),O=n("D"),z=n(!1),R=n(""),y=n({}),S=n(!1),W=n(""),te=n(!1);let G=null;const se=[{label:"周一",value:"1"},{label:"周二",value:"2"},{label:"周三",value:"3"},{label:"周四",value:"4"},{label:"周五",value:"5"},{label:"周六",value:"6"},{label:"周日",value:"7"}],de={1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",7:"周日"},re=Ne(()=>(b.value||[]).map(a=>de[Number(a)]||a).join("、"));function ie(a){return String(a)==="注册前未读"?"注册前未读":"应读"}async function oe(){v.value=!0;try{const[a,e,d]=await Promise.all([he(),He(),ae().catch(()=>({}))]);g.value=a.max_concurrent_global??2,B.value=a.max_concurrent_per_account??1,T.value=a.max_screenshot_concurrent??3,f.value=(a.schedule_enabled??0)===1,D.value=a.schedule_time||"02:00",P.value=ie(a.schedule_browse_type);const i=String(a.schedule_weekdays||"1,2,3,4,5,6,7").split(",").map(u=>u.trim()).filter(Boolean);b.value=i.length?i:["1","2","3","4","5","6","7"],h.value=(a.enable_screenshot??1)===1,E.value=(a.auto_approve_enabled??0)===1,$.value=a.auto_approve_hourly_limit??10,q.value=a.auto_approve_vip_days??7,I.value=(e.proxy_enabled??0)===1,x.value=e.proxy_api_url||"",K.value=e.proxy_expire_minutes??3,F.value=(a.kdocs_enabled??0)===1,H.value=a.kdocs_doc_url||"",L.value=a.kdocs_default_unit||"",Q.value=a.kdocs_sheet_name||"",M.value=a.kdocs_sheet_index??0,j.value=(a.kdocs_unit_column||"A").toUpperCase(),O.value=(a.kdocs_image_column||"D").toUpperCase(),z.value=(a.kdocs_admin_notify_enabled??0)===1,R.value=a.kdocs_admin_notify_email||"",y.value=d||{}}catch{}finally{v.value=!1}}async function me(){const a={max_concurrent_global:Number(g.value),max_concurrent_per_account:Number(B.value),max_screenshot_concurrent:Number(T.value)};try{await Z.confirm(`确定更新并发配置吗？

全局并发数: ${a.max_concurrent_global}
单账号并发数: ${a.max_concurrent_per_account}
截图并发数: ${a.max_screenshot_concurrent}`,"保存并发配置",{confirmButtonText:"保存",cancelButtonText:"取消",type:"warning"})}catch{return}try{const e=await X(a);r.success(e?.message||"并发配置已更新")}catch{}}async function ce(){if(f.value&&(!b.value||b.value.length===0)){r.error("请至少选择一个执行日期");return}const a={schedule_enabled:f.value?1:0,schedule_time:D.value,schedule_browse_type:P.value,schedule_weekdays:(b.value||[]).join(","),enable_screenshot:h.value?1:0},e=h.value?"截图":"不截图",d=f.value?`确定启用定时任务吗？

执行时间: 每天 ${a.schedule_time}
执行日期: ${re.value}
浏览类型: ${a.schedule_browse_type}
截图: ${e}

系统将自动执行所有账号的浏览任务`:"确定关闭定时任务吗？";try{await Z.confirm(d,"保存定时任务",{confirmButtonText:"确认",cancelButtonText:"取消",type:"warning"})}catch{return}try{const i=await X(a);r.success(i?.message||(f.value?"定时任务已启用":"定时任务已关闭"))}catch{}}async function pe(){const a=`确定要立即执行定时任务吗？

这将执行所有账号的浏览任务
浏览类型: ${P.value}

注意：无视定时时间和执行日期配置，立即开始执行！`;try{await Z.confirm(a,"立即执行",{confirmButtonText:"立即执行",cancelButtonText:"取消",type:"warning"})}catch{return}try{const e=await Ie();r.success(e?.message||"定时任务已开始执行")}catch{}}async function ve(){if(I.value&&!x.value.trim()){r.error("启用代理时，API地址不能为空");return}const a={proxy_enabled:I.value?1:0,proxy_api_url:x.value.trim(),proxy_expire_minutes:Number(K.value)||3};try{const e=await Le(a);r.success(e?.message||"代理配置已更新")}catch{}}async function fe(){const a={kdocs_enabled:F.value?1:0,kdocs_doc_url:H.value.trim(),kdocs_default_unit:L.value.trim(),kdocs_sheet_name:Q.value.trim(),kdocs_sheet_index:Number(M.value)||0,kdocs_unit_column:j.value.trim().toUpperCase(),kdocs_image_column:O.value.trim().toUpperCase(),kdocs_admin_notify_enabled:z.value?1:0,kdocs_admin_notify_email:R.value.trim()};try{const e=await X(a);r.success(e?.message||"表格配置已更新")}catch{}}async function ee(){try{y.value=await ae({live:1})}catch{}}async function ne(){try{const a=await ae({live:1});y.value=a,(a?.logged_in===!0||a?.last_login_ok===!0)&&(r.success("扫码成功，已登录"),S.value=!1,J())}catch{}}function _e(){J(),te.value=!0,ne(),G=setInterval(ne,2e3)}function J(){G&&(clearInterval(G),G=null),te.value=!1}async function ye(){try{const a=await qe();if(W.value=a?.qr_image||"",!W.value){if(a?.logged_in){r.success("当前已登录，无需扫码"),await ee();return}r.warning("未获取到二维码");return}S.value=!0}catch{}}async function be(){try{await Fe(),r.success("登录态已清除"),await ee()}catch{}}Ae(S,a=>{a?_e():J()}),Be(()=>{J()});async function xe(){if(!x.value.trim()){r.error("请先输入代理API地址");return}try{const a=await Qe({api_url:x.value.trim()});await Z.alert(a?.message||"测试完成","代理测试",{confirmButtonText:"知道了"})}catch{}}async function Ve(){const a=Number($.value),e=Number(q.value);if(!Number.isFinite(a)||a<1){r.error("每小时注册限制必须大于0");return}if(!Number.isFinite(e)||e<0){r.error("VIP天数不能为负数");return}const d={auto_approve_enabled:E.value?1:0,auto_approve_hourly_limit:a,auto_approve_vip_days:e};try{const i=await X(d);r.success(i?.message||"注册设置已保存")}catch{}}return Te(oe),(a,e)=>{const d=c("el-button"),i=c("el-input-number"),u=c("el-form-item"),N=c("el-form"),A=c("el-card"),w=c("el-switch"),ke=c("el-time-picker"),ue=c("el-option"),ge=c("el-select"),we=c("el-checkbox"),Ue=c("el-checkbox-group"),V=c("el-input"),Ce=c("el-dialog"),Pe=De("loading");return Ke((_(),k("div",Me,[s("div",je,[e[25]||(e[25]=s("h2",null,"系统配置",-1)),s("div",null,[l(d,{onClick:oe},{default:o(()=>[...e[24]||(e[24]=[m("刷新",-1)])]),_:1})])]),l(A,{shadow:"never","body-style":{padding:"16px"},class:"card"},{default:o(()=>[e[30]||(e[30]=s("h3",{class:"section-title"},"系统并发配置",-1)),l(N,{"label-width":"130px"},{default:o(()=>[l(u,{label:"全局最大并发数"},{default:o(()=>[l(i,{modelValue:g.value,"onUpdate:modelValue":e[0]||(e[0]=t=>g.value=t),min:1,max:200},null,8,["modelValue"]),e[26]||(e[26]=s("div",{class:"help"},"同时最多运行的账号数量（浏览任务使用 API 方式，资源占用较低）。",-1))]),_:1}),l(u,{label:"单账号最大并发数"},{default:o(()=>[l(i,{modelValue:B.value,"onUpdate:modelValue":e[1]||(e[1]=t=>B.value=t),min:1,max:50},null,8,["modelValue"]),e[27]||(e[27]=s("div",{class:"help"},"单个账号同时最多运行的任务数量（建议设为 1）。",-1))]),_:1}),l(u,{label:"截图最大并发数"},{default:o(()=>[l(i,{modelValue:T.value,"onUpdate:modelValue":e[2]||(e[2]=t=>T.value=t),min:1,max:50},null,8,["modelValue"]),e[28]||(e[28]=s("div",{class:"help"},"同时进行截图的最大数量（wkhtmltoimage 资源占用较低，可按需提高）。",-1))]),_:1})]),_:1}),l(d,{type:"primary",onClick:me},{default:o(()=>[...e[29]||(e[29]=[m("保存并发配置",-1)])]),_:1})]),_:1}),l(A,{shadow:"never","body-style":{padding:"16px"},class:"card"},{default:o(()=>[e[35]||(e[35]=s("h3",{class:"section-title"},"定时任务配置",-1)),l(N,{"label-width":"130px"},{default:o(()=>[l(u,{label:"启用定时任务"},{default:o(()=>[l(w,{modelValue:f.value,"onUpdate:modelValue":e[3]||(e[3]=t=>f.value=t)},null,8,["modelValue"]),e[31]||(e[31]=s("div",{class:"help"},"开启后，系统会按计划自动执行浏览任务。",-1))]),_:1}),f.value?(_(),Y(u,{key:0,label:"执行时间"},{default:o(()=>[l(ke,{modelValue:D.value,"onUpdate:modelValue":e[4]||(e[4]=t=>D.value=t),"value-format":"HH:mm",format:"HH:mm"},null,8,["modelValue"])]),_:1})):U("",!0),f.value?(_(),Y(u,{key:1,label:"浏览类型"},{default:o(()=>[l(ge,{modelValue:P.value,"onUpdate:modelValue":e[5]||(e[5]=t=>P.value=t),style:{width:"220px"}},{default:o(()=>[l(ue,{label:"注册前未读",value:"注册前未读"}),l(ue,{label:"应读",value:"应读"})]),_:1},8,["modelValue"])]),_:1})):U("",!0),f.value?(_(),Y(u,{key:2,label:"执行日期"},{default:o(()=>[l(Ue,{modelValue:b.value,"onUpdate:modelValue":e[6]||(e[6]=t=>b.value=t)},{default:o(()=>[(_(),k(Ee,null,$e(se,t=>l(we,{key:t.value,label:t.value},{default:o(()=>[m(le(t.label),1)]),_:2},1032,["label"])),64))]),_:1},8,["modelValue"])]),_:1})):U("",!0),f.value?(_(),Y(u,{key:3,label:"定时任务截图"},{default:o(()=>[l(w,{modelValue:h.value,"onUpdate:modelValue":e[7]||(e[7]=t=>h.value=t)},null,8,["modelValue"]),e[32]||(e[32]=s("div",{class:"help"},"开启后，定时任务执行时会生成截图。",-1))]),_:1})):U("",!0)]),_:1}),s("div",Oe,[l(d,{type:"primary",onClick:ce},{default:o(()=>[...e[33]||(e[33]=[m("保存定时任务配置",-1)])]),_:1}),l(d,{type:"success",plain:"",onClick:pe},{default:o(()=>[...e[34]||(e[34]=[m("立即执行",-1)])]),_:1})])]),_:1}),l(A,{shadow:"never","body-style":{padding:"16px"},class:"card"},{default:o(()=>[e[40]||(e[40]=s("h3",{class:"section-title"},"代理设置",-1)),l(N,{"label-width":"130px"},{default:o(()=>[l(u,{label:"启用IP代理"},{default:o(()=>[l(w,{modelValue:I.value,"onUpdate:modelValue":e[8]||(e[8]=t=>I.value=t)},null,8,["modelValue"]),e[36]||(e[36]=s("div",{class:"help"},"开启后，所有浏览任务将通过代理IP访问（失败自动重试3次）。",-1))]),_:1}),l(u,{label:"代理API地址"},{default:o(()=>[l(V,{modelValue:x.value,"onUpdate:modelValue":e[9]||(e[9]=t=>x.value=t),placeholder:"http://api.xxx/Tools/IP.ashx?..."},null,8,["modelValue"]),e[37]||(e[37]=s("div",{class:"help"},"API 应返回：IP:PORT（例如 123.45.67.89:8888）。",-1))]),_:1}),l(u,{label:"代理有效期(分钟)"},{default:o(()=>[l(i,{modelValue:K.value,"onUpdate:modelValue":e[10]||(e[10]=t=>K.value=t),min:1,max:60},null,8,["modelValue"])]),_:1})]),_:1}),s("div",ze,[l(d,{type:"primary",onClick:ve},{default:o(()=>[...e[38]||(e[38]=[m("保存代理配置",-1)])]),_:1}),l(d,{onClick:xe},{default:o(()=>[...e[39]||(e[39]=[m("测试代理",-1)])]),_:1})])]),_:1}),l(A,{shadow:"never","body-style":{padding:"16px"},class:"card"},{default:o(()=>[e[43]||(e[43]=s("h3",{class:"section-title"},"注册设置",-1)),l(N,{"label-width":"130px"},{default:o(()=>[l(u,{label:"注册赠送VIP"},{default:o(()=>[l(w,{modelValue:E.value,"onUpdate:modelValue":e[11]||(e[11]=t=>E.value=t)},null,8,["modelValue"]),e[41]||(e[41]=s("div",{class:"help"},"开启后，新用户注册成功后将赠送下方设置的VIP天数（注册已默认无需审核）。",-1))]),_:1}),l(u,{label:"每小时注册限制"},{default:o(()=>[l(i,{modelValue:$.value,"onUpdate:modelValue":e[12]||(e[12]=t=>$.value=t),min:1,max:1e4},null,8,["modelValue"])]),_:1}),l(u,{label:"注册赠送VIP天数"},{default:o(()=>[l(i,{modelValue:q.value,"onUpdate:modelValue":e[13]||(e[13]=t=>q.value=t),min:0,max:999999},null,8,["modelValue"])]),_:1})]),_:1}),l(d,{type:"primary",onClick:Ve},{default:o(()=>[...e[42]||(e[42]=[m("保存注册设置",-1)])]),_:1})]),_:1}),l(A,{shadow:"never","body-style":{padding:"16px"},class:"card"},{default:o(()=>[e[51]||(e[51]=s("h3",{class:"section-title"},"金山文档上传",-1)),l(N,{"label-width":"130px"},{default:o(()=>[l(u,{label:"启用上传"},{default:o(()=>[l(w,{modelValue:F.value,"onUpdate:modelValue":e[14]||(e[14]=t=>F.value=t)},null,8,["modelValue"]),e[44]||(e[44]=s("div",{class:"help"},"表格结构变化时可先关闭，避免错误上传。",-1))]),_:1}),l(u,{label:"文档链接"},{default:o(()=>[l(V,{modelValue:H.value,"onUpdate:modelValue":e[15]||(e[15]=t=>H.value=t),placeholder:"https://kdocs.cn/..."},null,8,["modelValue"])]),_:1}),l(u,{label:"默认县区"},{default:o(()=>[l(V,{modelValue:L.value,"onUpdate:modelValue":e[16]||(e[16]=t=>L.value=t),placeholder:"如：道县（用户可覆盖）"},null,8,["modelValue"])]),_:1}),l(u,{label:"Sheet名称"},{default:o(()=>[l(V,{modelValue:Q.value,"onUpdate:modelValue":e[17]||(e[17]=t=>Q.value=t),placeholder:"留空使用第一个Sheet"},null,8,["modelValue"])]),_:1}),l(u,{label:"Sheet序号"},{default:o(()=>[l(i,{modelValue:M.value,"onUpdate:modelValue":e[18]||(e[18]=t=>M.value=t),min:0,max:50},null,8,["modelValue"]),e[45]||(e[45]=s("div",{class:"help"},"0 表示第一个Sheet。",-1))]),_:1}),l(u,{label:"县区列"},{default:o(()=>[l(V,{modelValue:j.value,"onUpdate:modelValue":e[19]||(e[19]=t=>j.value=t),placeholder:"A",style:{"max-width":"120px"}},null,8,["modelValue"])]),_:1}),l(u,{label:"图片列"},{default:o(()=>[l(V,{modelValue:O.value,"onUpdate:modelValue":e[20]||(e[20]=t=>O.value=t),placeholder:"D",style:{"max-width":"120px"}},null,8,["modelValue"])]),_:1}),l(u,{label:"管理员通知"},{default:o(()=>[l(w,{modelValue:z.value,"onUpdate:modelValue":e[21]||(e[21]=t=>z.value=t)},null,8,["modelValue"])]),_:1}),l(u,{label:"通知邮箱"},{default:o(()=>[l(V,{modelValue:R.value,"onUpdate:modelValue":e[22]||(e[22]=t=>R.value=t),placeholder:"admin@example.com"},null,8,["modelValue"])]),_:1})]),_:1}),s("div",Re,[l(d,{type:"primary",onClick:fe},{default:o(()=>[...e[46]||(e[46]=[m("保存表格配置",-1)])]),_:1}),l(d,{onClick:ee},{default:o(()=>[...e[47]||(e[47]=[m("刷新状态",-1)])]),_:1}),l(d,{type:"success",plain:"",onClick:ye},{default:o(()=>[...e[48]||(e[48]=[m("获取二维码",-1)])]),_:1}),l(d,{type:"danger",plain:"",onClick:be},{default:o(()=>[...e[49]||(e[49]=[m("清除登录",-1)])]),_:1})]),s("div",We,[e[50]||(e[50]=m(" 登录状态： ",-1)),y.value.last_login_ok===!0?(_(),k("span",Ge,"已登录")):y.value.login_required?(_(),k("span",Je,"需要扫码")):(_(),k("span",Xe,"未知")),m(" · 待上传 "+le(y.value.queue_size||0)+" ",1),y.value.last_error?(_(),k("span",Ye,"· 最近错误："+le(y.value.last_error),1)):U("",!0)])]),_:1}),l(Ce,{modelValue:S.value,"onUpdate:modelValue":e[23]||(e[23]=t=>S.value=t),title:"扫码登录",width:"min(420px, 92vw)"},{default:o(()=>[s("div",Ze,[W.value?(_(),k("img",{key:0,src:`data:image/png;base64,${W.value}`,alt:"KDocs QR"},null,8,el)):U("",!0),e[52]||(e[52]=s("div",{class:"help"},"请使用管理员微信扫码登录。",-1))])]),_:1},8,["modelValue"])])),[[Pe,v.value]])}}},ol=Se(ll,[["__scopeId","data-v-5af0394e"]]);export{ol as default};
