import{d as be,o as he,v as we,c as _,a as s,t as f,e as l,w as t,F as A,r as oe,K as H,L as M,u as Ce,g as c,h as p,i as u,k as r,m as te,x as S,b as P,B as xe,q as U,E as m,_ as Ne}from"./index-CBbTXmzV.js";import{a as Se}from"./index-DZ_Kha3d.js";import{a as le}from"./index-Bn7NwETH.js";import{C as ze}from"./CloudBadge-BfaOZ4G4.js";const Ve={class:"user-layout"},De={class:"user-header"},Fe={class:"header-right"},Ie={class:"user-account"},Ue={class:"user-body"},Ee={class:"user-sidebar"},Re=["onClick"],$e={class:"user-content"},Le={style:{"margin-bottom":"12px"}},Be={key:0},Te={key:1,style:{color:"#909399","font-size":"12px"}},Oe={key:0},qe={key:1,style:{color:"#909399","font-size":"12px"}},Ae={key:0},He={key:1,style:{color:"#909399"}},Me={class:"cookie-tips-header"},Pe={class:"cookie-tips-title"},Ke=["innerHTML"],je=be({__name:"UserDashboard",setup(Je){const E=Ce(),R=c("");function v(){const a=localStorage.getItem("user_token");return Se.create({baseURL:"/api/user",headers:{Authorization:`Bearer ${a}`}})}he(async()=>{if(!localStorage.getItem("user_token")){E.push("/user/login");return}try{const{data:e}=await v().get("/profile");R.value=e.account}catch{localStorage.removeItem("user_token"),localStorage.removeItem("user_account"),E.push("/user/login")}});function ae(){localStorage.removeItem("user_token"),localStorage.removeItem("user_account"),E.push("/user/login")}const w=c("records"),ie=[{key:"records",icon:"📋",label:"转存日志"},{key:"drives",icon:"💾",label:"网盘管理"},{key:"notify",icon:"🔔",label:"消息推送"}],K=c([]),$=c(0),L=c(1),j=c(20);async function J(){try{const{data:a}=await v().get("/save-records",{params:{page:L.value,pageSize:j.value}});K.value=a.records,$.value=a.total}catch{}}const W=c([]),C=c(!1),k=c(null),x=c(!1),G=c(),B=c([]),Q=()=>({cloud_type:"",cookie:""}),i=xe(Q()),se=U(()=>({cloud_type:[{required:!0,message:"请选择网盘类型",trigger:"change"}]})),ne=U(()=>{if(!i.cloud_type)return"请先选择网盘类型";const a=i.cloud_type;return a==="quark"||a==="baidu"?`请输入 ${le[a]||a} 的完整 Cookie`:k.value?"留空则保持原有":"输入完整 Cookie"}),de=U(()=>le[i.cloud_type]||i.cloud_type||""),re=U(()=>{const a=i.cloud_type;return a?{quark:`<li>在电脑上打开 <a href="https://pan.quark.cn" target="_blank">pan.quark.cn</a> 并登录你的夸克账号</li>
<li>按 <code>F12</code> 打开开发者工具 → 切换到 <strong>网络 (Network)</strong> 选项卡</li>
<li>刷新页面，在请求列表中点击任意一个请求（如 <code>account/info</code>）</li>
<li>在右侧 <strong>请求头 (Request Headers)</strong> 中找到 <code>Cookie</code> 字段</li>
<li>复制整个 Cookie 值（<b>从开头到结束的完整内容</b>），粘贴到上方输入框</li>
<li>点击「<b>保存</b>」按钮提交配置</li>
<div class="cookie-tips-note">⚠️ 必须包含 <code>__st=s%...</code> 字段！请复制浏览器请求头的 <b>整个 Cookie</b>（F12 → Network → 请求头 → Cookie 项），不要只复制部分。</div>`,baidu:`<li>在电脑上打开 <a href="https://pan.baidu.com" target="_blank">pan.baidu.com</a> 并登录你的百度账号</li>
<li>按 <code>F12</code> 打开开发者工具 → 切换到 <strong>网络 (Network)</strong> 选项卡</li>
<li>刷新页面，在请求列表中点击任意一个请求</li>
<li>在右侧 <strong>请求头 (Request Headers)</strong> 中找到 <code>Cookie</code> 字段</li>
<li>复制整个 Cookie 值，粘贴到上方输入框</li>
<li>点击「<b>保存</b>」按钮提交配置</li>
<div class="cookie-tips-note">💡 需要包含 <code>BDUSS</code> 和 <code>STOKEN</code></div>`,aliyun:`<li>在电脑上打开 <a href="https://www.aliyundrive.com" target="_blank">aliyundrive.com</a> 并登录</li>
<li>按 <code>F12</code> 打开开发者工具 → <strong>网络 (Network)</strong></li>
<li>刷新页面，找到任意请求 → 复制 <code>Cookie</code></li>
<li>粘贴到上方输入框，点击「保存」提交</li>
<div class="cookie-tips-note">💡 需包含 <code>token</code> 等有效字段</div>`,115:`<li>在电脑上打开 <a href="https://115.com" target="_blank">115.com</a> 并登录</li>
<li>按 <code>F12</code> 打开开发者工具 → <strong>网络 (Network)</strong></li>
<li>刷新页面，找到任意请求 → 复制 <code>Cookie</code></li>
<li>粘贴到上方输入框，点击「保存」提交</li>
<div class="cookie-tips-note">💡 需包含 <code>UID</code>、<code>CID</code>、<code>SEID</code> 等字段</div>`,tianyi:`<li>在电脑上打开 <a href="https://cloud.189.cn" target="_blank">cloud.189.cn</a> 并登录</li>
<li>按 <code>F12</code> 打开开发者工具 → <strong>网络 (Network)</strong></li>
<li>刷新页面，找到任意请求 → 复制 <code>Cookie</code></li>
<li>粘贴到上方输入框，点击「保存」提交</li>
<div class="cookie-tips-note">💡 需包含 <code>COOKIE_LOGIN_USER</code>、<code>SESSION</code> 等字段</div>`,"123pan":`<li>在电脑上打开 <a href="https://www.123pan.com" target="_blank">123pan.com</a> 并登录</li>
<li>按 <code>F12</code> 打开开发者工具 → <strong>网络 (Network)</strong></li>
<li>刷新页面，找到任意请求 → 复制 <code>Cookie</code></li>
<li>粘贴到上方输入框，点击「保存」提交</li>`,uc:`<li>在电脑上打开 <a href="https://drive.uc.cn" target="_blank">drive.uc.cn</a> 并登录</li>
<li>按 <code>F12</code> 打开开发者工具 → <strong>网络 (Network)</strong></li>
<li>刷新页面，找到任意请求 → 复制 <code>Cookie</code></li>
<li>粘贴到上方输入框，点击「保存」提交</li>`,xunlei:`<li>在电脑上打开 <a href="https://pan.xunlei.com" target="_blank">pan.xunlei.com</a> 并登录</li>
<li>按 <code>F12</code> 打开开发者工具 → <strong>网络 (Network)</strong></li>
<li>刷新页面，找到任意请求 → 复制 <code>Cookie</code></li>
<li>粘贴到上方输入框，点击「保存」提交</li>`,pikpak:`<li>在电脑上打开 <a href="https://www.mypikpak.com" target="_blank">mypikpak.com</a> 并登录</li>
<li>按 <code>F12</code> 打开开发者工具 → <strong>网络 (Network)</strong></li>
<li>刷新页面，找到任意请求 → 复制 <code>Cookie</code></li>
<li>粘贴到上方输入框，点击「保存」提交</li>`}[a]||`<li>在电脑上打开该网盘网站并登录</li>
<li>按 <code>F12</code> 打开开发者工具 → <strong>网络 (Network)</strong></li>
<li>刷新页面，复制任意请求的 <code>Cookie</code></li>
<li>粘贴到上方输入框，点击「保存」提交</li>`:""});async function ce(){try{const{data:a}=await v().get("/enabled-cloud-types");B.value=a}catch{B.value=[]}}async function T(){try{const{data:a}=await v().get("/cloud-configs");W.value=a}catch{}}function ue(){k.value=null,Object.assign(i,Q()),C.value=!0}function pe(a){k.value=a,i.cloud_type=a.cloud_type,i.cookie="",C.value=!0}function fe(){}async function ve(){var e,d,n,y,V;if(await((e=G.value)==null?void 0:e.validate().catch(()=>!1))){x.value=!0;try{let g="";if(i.cookie)try{const D=v(),{data:b}=await D.post(`/cloud-configs/${i.cloud_type}/test`,{cookie:i.cookie});if(!b.success){m.error(`Cookie验证失败：${b.message}`),x.value=!1;return}b.nickname&&(g=b.nickname)}catch(D){m.error(`Cookie验证失败：${((n=(d=D.response)==null?void 0:d.data)==null?void 0:n.error)||"网络错误"}`),x.value=!1;return}const N=R.value;if(k.value)await v().put(`/cloud-configs/${k.value.id}`,{cloud_type:i.cloud_type,nickname:g||void 0,promotion_account:N,cookie:i.cookie||void 0}),m.success("更新成功");else{if(!i.cookie){m.warning("请填写Cookie"),x.value=!1;return}await v().post("/cloud-configs",{cloud_type:i.cloud_type,cookie:i.cookie,nickname:g||void 0,promotion_account:N}),m.success("添加成功")}C.value=!1,k.value=null,T()}catch(g){m.error(((V=(y=g.response)==null?void 0:y.data)==null?void 0:V.error)||"保存失败")}finally{x.value=!1}}}async function _e(a){var e,d;try{await v().delete(`/cloud-configs/${a}`),m.success("已删除"),T()}catch(n){m.error(((d=(e=n.response)==null?void 0:e.data)==null?void 0:d.error)||"删除失败")}}const z=c(""),F=c(""),I=c([]),O=c(!1);async function me(){try{const{data:a}=await v().get("/notify-config"),e=JSON.parse(a.notifyConfig||"{}");e.webhook&&(z.value="feishu",F.value=e.webhook,I.value=e.events||[])}catch{}}async function ke(){var a,e;O.value=!0;try{const d=z.value==="feishu"?JSON.stringify({webhook:F.value,events:I.value}):"{}";await v().put("/notify-config",{notifyConfig:d}),m.success("推送配置已保存")}catch(d){m.error(((e=(a=d.response)==null?void 0:a.data)==null?void 0:e.error)||"保存失败")}finally{O.value=!1}}return we(w,a=>{a==="records"?J():a==="drives"?(ce(),T()):a==="notify"&&me()},{immediate:!0}),(a,e)=>{const d=p("el-button"),n=p("el-table-column"),y=p("el-tag"),V=p("el-table"),g=p("el-pagination"),N=p("el-card"),D=p("el-popconfirm"),b=p("el-option"),X=p("el-select"),h=p("el-form-item"),Y=p("el-input"),q=p("el-checkbox"),ye=p("el-checkbox-group"),Z=p("el-form"),ge=p("el-dialog");return u(),_("div",Ve,[s("div",De,[e[9]||(e[9]=s("span",{class:"user-title"},"CloudSearch 用户中心",-1)),s("div",Fe,[s("span",Ie,f(R.value),1),l(d,{size:"small",onClick:ae},{default:t(()=>[...e[8]||(e[8]=[r("退出登录",-1)])]),_:1})])]),s("div",Ue,[s("div",Ee,[(u(),_(A,null,oe(ie,o=>s("div",{key:o.key,class:te(["sidebar-item",{active:w.value===o.key}]),onClick:ee=>w.value=o.key},[s("span",null,f(o.icon)+" "+f(o.label),1)],10,Re)),64))]),s("div",$e,[H(s("div",null,[l(N,{shadow:"never"},{header:t(()=>[...e[10]||(e[10]=[s("span",null,"📋 转存日志",-1)])]),default:t(()=>[l(V,{data:K.value,stripe:"","empty-text":"暂无转存记录",size:"small"},{default:t(()=>[l(n,{prop:"source_title",label:"资源名称","min-width":"200","show-overflow-tooltip":""}),l(n,{prop:"source_type",label:"来源",width:"80"}),l(n,{label:"状态",width:"80"},{default:t(({row:o})=>[l(y,{type:o.status==="success"?"success":"danger",size:"small"},{default:t(()=>[r(f(o.status==="success"?"成功":"失败"),1)]),_:2},1032,["type"])]),_:1}),l(n,{prop:"file_size",label:"大小",width:"90"}),l(n,{label:"耗时",width:"90"},{default:t(({row:o})=>[r(f(o.duration_ms?(o.duration_ms/1e3).toFixed(1)+"s":"-"),1)]),_:1}),l(n,{label:"时间",width:"170"},{default:t(({row:o})=>[r(f(o.created_at),1)]),_:1})]),_:1},8,["data"]),$.value>0?(u(),S(g,{key:0,"current-page":L.value,"onUpdate:currentPage":e[0]||(e[0]=o=>L.value=o),"page-size":j.value,total:$.value,layout:"prev, pager, next",small:"",style:{"margin-top":"16px","justify-content":"center"},onCurrentChange:J},null,8,["current-page","page-size","total"])):P("",!0)]),_:1})],512),[[M,w.value==="records"]]),H(s("div",null,[l(N,{shadow:"never"},{header:t(()=>[...e[11]||(e[11]=[s("span",null,"💾 我的网盘",-1)])]),default:t(()=>[s("div",Le,[l(d,{type:"primary",size:"small",onClick:ue},{default:t(()=>[...e[12]||(e[12]=[r("新增配置",-1)])]),_:1})]),l(V,{data:W.value,stripe:"","empty-text":"暂无网盘配置",size:"small"},{default:t(()=>[l(n,{label:"网盘类型",width:"110"},{default:t(({row:o})=>[l(ze,{cloud_type:o.cloud_type},null,8,["cloud_type"])]),_:1}),l(n,{prop:"nickname",label:"昵称",width:"140"},{default:t(({row:o})=>[o.nickname?(u(),_("span",Be,f(o.nickname),1)):(u(),_("span",Te,"未设置"))]),_:1}),l(n,{prop:"promotion_account",label:"推广账号",width:"160"},{default:t(({row:o})=>[o.promotion_account?(u(),_("span",Oe,f(o.promotion_account),1)):(u(),_("span",qe,"-"))]),_:1}),l(n,{label:"验证",width:"80",align:"center"},{default:t(({row:o})=>[o.verification_status==="valid"?(u(),S(y,{key:0,type:"success",size:"small"},{default:t(()=>[...e[13]||(e[13]=[r("有效",-1)])]),_:1})):o.verification_status==="invalid"?(u(),S(y,{key:1,type:"danger",size:"small"},{default:t(()=>[...e[14]||(e[14]=[r("无效",-1)])]),_:1})):(u(),S(y,{key:2,type:"info",size:"small"},{default:t(()=>[...e[15]||(e[15]=[r("未验证",-1)])]),_:1}))]),_:1}),l(n,{label:"空间",width:"200"},{default:t(({row:o})=>[o.storage_total&&o.storage_total!=="-"?(u(),_("div",Ae,f(o.storage_used||"计算中...")+" / "+f(o.storage_total),1)):(u(),_("span",He,"—"))]),_:1}),l(n,{label:"转存数",width:"80",align:"center"},{default:t(({row:o})=>[r(f(o.total_saves>0?o.total_saves+"次":"-"),1)]),_:1}),l(n,{label:"操作",width:"160",align:"center"},{default:t(({row:o})=>[l(d,{size:"small",text:"",type:"primary",onClick:ee=>pe(o)},{default:t(()=>[...e[16]||(e[16]=[r("编辑",-1)])]),_:1},8,["onClick"]),l(D,{title:"确定删除该配置？",onConfirm:ee=>_e(o.id)},{reference:t(()=>[l(d,{size:"small",text:"",type:"danger"},{default:t(()=>[...e[17]||(e[17]=[r("删除",-1)])]),_:1})]),_:1},8,["onConfirm"])]),_:1})]),_:1},8,["data"])]),_:1})],512),[[M,w.value==="drives"]]),H(s("div",null,[l(N,{shadow:"never"},{header:t(()=>[...e[18]||(e[18]=[s("span",null,"🔔 消息推送配置",-1)])]),default:t(()=>[l(Z,{"label-width":"120px",size:"small"},{default:t(()=>[l(h,{label:"推送通道"},{default:t(()=>[l(X,{modelValue:z.value,"onUpdate:modelValue":e[1]||(e[1]=o=>z.value=o),style:{width:"200px"},placeholder:"选择推送通道"},{default:t(()=>[l(b,{label:"Feishu Bot",value:"feishu"})]),_:1},8,["modelValue"])]),_:1}),z.value==="feishu"?(u(),_(A,{key:0},[l(h,{label:"Webhook 地址"},{default:t(()=>[l(Y,{modelValue:F.value,"onUpdate:modelValue":e[2]||(e[2]=o=>F.value=o),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",style:{width:"420px"}},null,8,["modelValue"])]),_:1}),l(h,{label:"推送事件"},{default:t(()=>[l(ye,{modelValue:I.value,"onUpdate:modelValue":e[3]||(e[3]=o=>I.value=o)},{default:t(()=>[l(q,{label:"on_save_success"},{default:t(()=>[...e[19]||(e[19]=[r("转存成功",-1)])]),_:1}),l(q,{label:"on_save_fail"},{default:t(()=>[...e[20]||(e[20]=[r("转存失败",-1)])]),_:1}),l(q,{label:"on_cookie_expire"},{default:t(()=>[...e[21]||(e[21]=[r("Cookie过期",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1})],64)):P("",!0),l(h,null,{default:t(()=>[l(d,{type:"primary",loading:O.value,onClick:ke},{default:t(()=>[...e[22]||(e[22]=[r("保存推送配置",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1})],512),[[M,w.value==="notify"]])])]),l(ge,{modelValue:C.value,"onUpdate:modelValue":e[7]||(e[7]=o=>C.value=o),title:k.value?"编辑网盘配置":"新增网盘配置",width:"560px"},{footer:t(()=>[l(d,{onClick:e[6]||(e[6]=o=>{C.value=!1,k.value=null})},{default:t(()=>[...e[23]||(e[23]=[r("取消",-1)])]),_:1}),l(d,{type:"primary",loading:x.value,onClick:ve},{default:t(()=>[...e[24]||(e[24]=[r("保存",-1)])]),_:1},8,["loading"])]),default:t(()=>[l(Z,{ref_key:"driveFormRef",ref:G,model:i,rules:se.value,"label-width":"120px"},{default:t(()=>[l(h,{label:"网盘类型",prop:"cloud_type"},{default:t(()=>[l(X,{modelValue:i.cloud_type,"onUpdate:modelValue":e[4]||(e[4]=o=>i.cloud_type=o),style:{width:"100%"},disabled:!!k.value,onChange:fe},{default:t(()=>[(u(!0),_(A,null,oe(B.value,o=>(u(),S(b,{key:o.type,label:o.label,value:o.type},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1}),l(h,{label:"Cookie",prop:"cookie"},{default:t(()=>[l(Y,{modelValue:i.cookie,"onUpdate:modelValue":e[5]||(e[5]=o=>i.cookie=o),type:"textarea",autosize:{minRows:2,maxRows:4},placeholder:ne.value,"input-style":"font-family: monospace; font-size: 12px;"},null,8,["modelValue","placeholder"])]),_:1}),i.cloud_type&&i.cloud_type!==""?(u(),S(h,{key:0,label:" ",class:"cookie-tips-item"},{default:t(()=>[s("div",{class:te(["cookie-tips",`cookie-tips-${i.cloud_type}`])},[s("div",Me,[s("span",Pe,"📖 "+f(de.value)+" Cookie 获取教程",1)]),s("ol",{class:"cookie-tips-steps",innerHTML:re.value},null,8,Ke)],2)]),_:1})):P("",!0)]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])])}}}),Ye=Ne(je,[["__scopeId","data-v-dc9eacf1"]]);export{Ye as default};
