import{d as be,o as he,v as we,c as m,a as s,t as _,e as l,w as t,F as H,r as oe,K as M,L as P,u as Ce,g as c,h as v,i as p,k as d,m as te,x as N,b as K,B as xe,q as E,E as k,_ as Se}from"./index-DUvV9NL6.js";import{a as Ne}from"./index-DZ_Kha3d.js";import{a as le}from"./index-Bn7NwETH.js";import{C as ze}from"./CloudBadge-DmRfBynL.js";const Ve={class:"user-layout"},De={class:"user-header"},Fe={class:"header-right"},Ue={class:"user-account"},Ie={class:"user-body"},Ee={class:"user-sidebar"},Re=["onClick"],$e={class:"user-content"},Le={style:{"margin-bottom":"12px"}},Te={key:0},Be={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 R=Ce(),$=c("");function f(){const a=localStorage.getItem("user_token");return Ne.create({baseURL:"/api/user",headers:{Authorization:`Bearer ${a}`}})}he(async()=>{if(!localStorage.getItem("user_token")){R.push("/user/login");return}try{const{data:e}=await f().get("/profile");$.value=e.account}catch{localStorage.removeItem("user_token"),localStorage.removeItem("user_account"),R.push("/user/login")}});function ae(){localStorage.removeItem("user_token"),localStorage.removeItem("user_account"),R.push("/user/login")}const w=c("records"),ie=[{key:"records",icon:"📋",label:"转存日志"},{key:"drives",icon:"💾",label:"网盘管理"},{key:"notify",icon:"🔔",label:"消息推送"}],j=c([]),L=c(0),T=c(1),J=c(20);async function W(){try{const{data:a}=await f().get("/save-records",{params:{page:T.value,pageSize:J.value}});j.value=a.records,L.value=a.total}catch{}}const G=c([]),C=c(!1),y=c(null),x=c(!1),Q=c(),B=c([]),X=()=>({cloud_type:"",cookie:""}),i=xe(X()),se=E(()=>({cloud_type:[{required:!0,message:"请选择网盘类型",trigger:"change"}]})),ne=E(()=>{if(!i.cloud_type)return"请先选择网盘类型";const a=i.cloud_type;return a==="quark"||a==="baidu"?`请输入 ${le[a]||a} 的完整 Cookie`:y.value?"留空则保持原有":"输入完整 Cookie"}),re=E(()=>le[i.cloud_type]||i.cloud_type||""),de=E(()=>{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 ue(){try{const{data:a}=await f().get("/enabled-cloud-types");B.value=a}catch{B.value=[]}}async function O(){try{const{data:a}=await f().get("/cloud-configs");G.value=a}catch{}}function ce(){y.value=null,Object.assign(i,X()),C.value=!0}function pe(a){y.value=a,i.cloud_type=a.cloud_type,i.cookie="",C.value=!0}function ve(){}async function _e(){var e,r,n,g,V;if(await((e=Q.value)==null?void 0:e.validate().catch(()=>!1))){x.value=!0;try{let b="",h="",D="";if(i.cookie)try{const S=f(),{data:u}=await S.post(`/cloud-configs/${i.cloud_type}/test`,{cookie:i.cookie});if(!u.success){k.error(`Cookie验证失败：${u.message}`),x.value=!1;return}u.nickname&&(b=u.nickname),u.storage_used&&(h=u.storage_used),u.storage_total&&(D=u.storage_total)}catch(S){k.error(`Cookie验证失败：${((n=(r=S.response)==null?void 0:r.data)==null?void 0:n.error)||"网络错误"}`),x.value=!1;return}const F=$.value;if(y.value)await f().put(`/cloud-configs/${y.value.id}`,{cloud_type:i.cloud_type,nickname:b||void 0,promotion_account:F,cookie:i.cookie||void 0,storage_used:h||void 0,storage_total:D||void 0}),k.success("更新成功");else{if(!i.cookie){k.warning("请填写Cookie"),x.value=!1;return}await f().post("/cloud-configs",{cloud_type:i.cloud_type,cookie:i.cookie,nickname:b||void 0,promotion_account:F,storage_used:h||void 0,storage_total:D||void 0}),k.success("添加成功")}C.value=!1,y.value=null,O()}catch(b){k.error(((V=(g=b.response)==null?void 0:g.data)==null?void 0:V.error)||"保存失败")}finally{x.value=!1}}}async function fe(a){var e,r;try{await f().delete(`/cloud-configs/${a}`),k.success("已删除"),O()}catch(n){k.error(((r=(e=n.response)==null?void 0:e.data)==null?void 0:r.error)||"删除失败")}}const z=c(""),U=c(""),I=c([]),q=c(!1);async function me(){try{const{data:a}=await f().get("/notify-config"),e=JSON.parse(a.notifyConfig||"{}");e.webhook&&(z.value="feishu",U.value=e.webhook,I.value=e.events||[])}catch{}}async function ke(){var a,e;q.value=!0;try{const r=z.value==="feishu"?JSON.stringify({webhook:U.value,events:I.value}):"{}";await f().put("/notify-config",{notifyConfig:r}),k.success("推送配置已保存")}catch(r){k.error(((e=(a=r.response)==null?void 0:a.data)==null?void 0:e.error)||"保存失败")}finally{q.value=!1}}return we(w,a=>{a==="records"?W():a==="drives"?(ue(),O()):a==="notify"&&me()},{immediate:!0}),(a,e)=>{const r=v("el-button"),n=v("el-table-column"),g=v("el-tag"),V=v("el-table"),b=v("el-pagination"),h=v("el-card"),D=v("el-popconfirm"),F=v("el-option"),S=v("el-select"),u=v("el-form-item"),Y=v("el-input"),A=v("el-checkbox"),ye=v("el-checkbox-group"),Z=v("el-form"),ge=v("el-dialog");return p(),m("div",Ve,[s("div",De,[e[9]||(e[9]=s("span",{class:"user-title"},"CloudSearch 用户中心",-1)),s("div",Fe,[s("span",Ue,_($.value),1),l(r,{size:"small",onClick:ae},{default:t(()=>[...e[8]||(e[8]=[d("退出登录",-1)])]),_:1})])]),s("div",Ie,[s("div",Ee,[(p(),m(H,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,_(o.icon)+" "+_(o.label),1)],10,Re)),64))]),s("div",$e,[M(s("div",null,[l(h,{shadow:"never"},{header:t(()=>[...e[10]||(e[10]=[s("span",null,"📋 转存日志",-1)])]),default:t(()=>[l(V,{data:j.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(g,{type:o.status==="success"?"success":"danger",size:"small"},{default:t(()=>[d(_(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})=>[d(_(o.duration_ms?(o.duration_ms/1e3).toFixed(1)+"s":"-"),1)]),_:1}),l(n,{label:"时间",width:"170"},{default:t(({row:o})=>[d(_(o.created_at),1)]),_:1})]),_:1},8,["data"]),L.value>0?(p(),N(b,{key:0,"current-page":T.value,"onUpdate:currentPage":e[0]||(e[0]=o=>T.value=o),"page-size":J.value,total:L.value,layout:"prev, pager, next",small:"",style:{"margin-top":"16px","justify-content":"center"},onCurrentChange:W},null,8,["current-page","page-size","total"])):K("",!0)]),_:1})],512),[[P,w.value==="records"]]),M(s("div",null,[l(h,{shadow:"never"},{header:t(()=>[...e[11]||(e[11]=[s("span",null,"💾 我的网盘",-1)])]),default:t(()=>[s("div",Le,[l(r,{type:"primary",size:"small",onClick:ce},{default:t(()=>[...e[12]||(e[12]=[d("新增配置",-1)])]),_:1})]),l(V,{data:G.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?(p(),m("span",Te,_(o.nickname),1)):(p(),m("span",Be,"未设置"))]),_:1}),l(n,{prop:"promotion_account",label:"推广账号",width:"160"},{default:t(({row:o})=>[o.promotion_account?(p(),m("span",Oe,_(o.promotion_account),1)):(p(),m("span",qe,"-"))]),_:1}),l(n,{label:"验证",width:"80",align:"center"},{default:t(({row:o})=>[o.verification_status==="valid"?(p(),N(g,{key:0,type:"success",size:"small"},{default:t(()=>[...e[13]||(e[13]=[d("有效",-1)])]),_:1})):o.verification_status==="invalid"?(p(),N(g,{key:1,type:"danger",size:"small"},{default:t(()=>[...e[14]||(e[14]=[d("无效",-1)])]),_:1})):(p(),N(g,{key:2,type:"info",size:"small"},{default:t(()=>[...e[15]||(e[15]=[d("未验证",-1)])]),_:1}))]),_:1}),l(n,{label:"空间",width:"200"},{default:t(({row:o})=>[o.storage_total&&o.storage_total!=="-"?(p(),m("div",Ae,_(o.storage_used||"计算中...")+" / "+_(o.storage_total),1)):(p(),m("span",He,"—"))]),_:1}),l(n,{label:"转存数",width:"80",align:"center"},{default:t(({row:o})=>[d(_(o.total_saves>0?o.total_saves+"次":"-"),1)]),_:1}),l(n,{label:"操作",width:"160",align:"center"},{default:t(({row:o})=>[l(r,{size:"small",text:"",type:"primary",onClick:ee=>pe(o)},{default:t(()=>[...e[16]||(e[16]=[d("编辑",-1)])]),_:1},8,["onClick"]),l(D,{title:"确定删除该配置？",onConfirm:ee=>fe(o.id)},{reference:t(()=>[l(r,{size:"small",text:"",type:"danger"},{default:t(()=>[...e[17]||(e[17]=[d("删除",-1)])]),_:1})]),_:1},8,["onConfirm"])]),_:1})]),_:1},8,["data"])]),_:1})],512),[[P,w.value==="drives"]]),M(s("div",null,[l(h,{shadow:"never"},{header:t(()=>[...e[18]||(e[18]=[s("span",null,"🔔 消息推送配置",-1)])]),default:t(()=>[l(Z,{"label-width":"120px",size:"small"},{default:t(()=>[l(u,{label:"推送通道"},{default:t(()=>[l(S,{modelValue:z.value,"onUpdate:modelValue":e[1]||(e[1]=o=>z.value=o),style:{width:"200px"},placeholder:"选择推送通道"},{default:t(()=>[l(F,{label:"Feishu Bot",value:"feishu"})]),_:1},8,["modelValue"])]),_:1}),z.value==="feishu"?(p(),m(H,{key:0},[l(u,{label:"Webhook 地址"},{default:t(()=>[l(Y,{modelValue:U.value,"onUpdate:modelValue":e[2]||(e[2]=o=>U.value=o),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/xxx",style:{width:"420px"}},null,8,["modelValue"])]),_:1}),l(u,{label:"推送事件"},{default:t(()=>[l(ye,{modelValue:I.value,"onUpdate:modelValue":e[3]||(e[3]=o=>I.value=o)},{default:t(()=>[l(A,{label:"on_save_success"},{default:t(()=>[...e[19]||(e[19]=[d("转存成功",-1)])]),_:1}),l(A,{label:"on_save_fail"},{default:t(()=>[...e[20]||(e[20]=[d("转存失败",-1)])]),_:1}),l(A,{label:"on_cookie_expire"},{default:t(()=>[...e[21]||(e[21]=[d("Cookie过期",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1})],64)):K("",!0),l(u,null,{default:t(()=>[l(r,{type:"primary",loading:q.value,onClick:ke},{default:t(()=>[...e[22]||(e[22]=[d("保存推送配置",-1)])]),_:1},8,["loading"])]),_:1})]),_:1})]),_:1})],512),[[P,w.value==="notify"]])])]),l(ge,{modelValue:C.value,"onUpdate:modelValue":e[7]||(e[7]=o=>C.value=o),title:y.value?"编辑网盘配置":"新增网盘配置",width:"560px"},{footer:t(()=>[l(r,{onClick:e[6]||(e[6]=o=>{C.value=!1,y.value=null})},{default:t(()=>[...e[23]||(e[23]=[d("取消",-1)])]),_:1}),l(r,{type:"primary",loading:x.value,onClick:_e},{default:t(()=>[...e[24]||(e[24]=[d("保存",-1)])]),_:1},8,["loading"])]),default:t(()=>[l(Z,{ref_key:"driveFormRef",ref:Q,model:i,rules:se.value,"label-width":"120px"},{default:t(()=>[l(u,{label:"网盘类型",prop:"cloud_type"},{default:t(()=>[l(S,{modelValue:i.cloud_type,"onUpdate:modelValue":e[4]||(e[4]=o=>i.cloud_type=o),style:{width:"100%"},disabled:!!y.value,onChange:ve},{default:t(()=>[(p(!0),m(H,null,oe(B.value,o=>(p(),N(F,{key:o.type,label:o.label,value:o.type},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1}),l(u,{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!==""?(p(),N(u,{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,"📖 "+_(re.value)+" Cookie 获取教程",1)]),s("ol",{class:"cookie-tips-steps",innerHTML:de.value},null,8,Ke)],2)]),_:1})):K("",!0)]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])])}}}),Ye=Se(je,[["__scopeId","data-v-6e7d6d0e"]]);export{Ye as default};
