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