import{d as ke,o as L,m as ve,E as _,a as c,c as k,f as n,w as a,b as r,h as C,j as p,i as be,F as R,r as K,t as v,y as g,l as d,e as A,k as Ce,M as he,p as xe,n as H,K as Be,L as Te,v as h}from"./index-CK-9TfWb.js";import{a as x}from"./index-Bn7NwETH.js";import{c as we,k as Fe,h as Ne,l as G,t as Ve,u as P,m as ze,n as Se,o as $e,_ as Ue}from"./_plugin-vue_export-helper-D4DENoBS.js";import{C as De}from"./CloudBadge-OCEQ2GP-.js";const Ie={class:"cloud-config"},Me={class:"cloud-toggle-grid"},Oe=["src"],qe={class:"cloud-label"},Ee={class:"toolbar"},Le={key:0,class:"nickname-text"},Re={key:0,class:"promotion-text"},Ke={key:0,class:"uid-cell"},Ae={key:0,class:"verifying"},He={key:0,class:"storage-cell"},Ge={class:"storage-bar-wrap"},Pe={class:"storage-text"},je={class:"storage-used"},Je={class:"storage-total"},Qe={class:"storage-free"},We={key:0,class:"save-count"},Xe={style:{"line-height":"1.6"}},Ye={class:"cookie-tips-header"},Ze={class:"cookie-tips-title"},et=["innerHTML"],tt=ke({__name:"CloudConfig",setup(ot){const z=C([]),D=C(),F=C([]),B=C(!1),T=C(!1),b=C(null),l=be({cloud_type:"",nickname:"",promotion_account:"",is_transfer_enabled:!1,cookie:"",_verifying:!1,_storageUsed:"",_storageTotal:""}),j=h(()=>({cloud_type:[{required:!0,message:"请选择网盘类型",trigger:"change"}],nickname:[{required:!1,message:"请填写昵称（区分多个同类型网盘）",trigger:"blur"}],promotion_account:[{required:!0,message:"请填写推广平台及账号",trigger:"blur"}]})),J=h(()=>Object.entries(x)),Q=h(()=>{if(!l.cloud_type)return"请先选择网盘类型";const t=l.cloud_type;return t==="quark"||t==="baidu"?`请输入 ${x[t]||t} 的完整 Cookie`:b.value?"留空则保持原有":"输入完整 Cookie"}),W=h(()=>x[l.cloud_type]||l.cloud_type||""),X=h(()=>{const t=l.cloud_type;return t?{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>」按钮验证 Cookie 是否有效</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>」按钮验证 Cookie 是否有效</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>`}[t]||`<li>在电脑上打开该网盘网站并登录</li>
<li>按 <code>F12</code> 打开开发者工具 → <strong>网络 (Network)</strong></li>
<li>刷新页面，复制任意请求的 <code>Cookie</code></li>
<li>粘贴到上方输入框，点击「自动获取」验证</li>`:""});L(async()=>{await $(),await Y(),await Z()});let S=null;L(()=>{S=setInterval(()=>{le()},30*60*1e3)}),ve(()=>{S&&clearInterval(S)});async function Y(){try{const t=await we();z.value=t.types}catch(t){console.error("加载网盘类型失败",t)}}const I=C({}),M=h(()=>{try{const t=I.value.cleanup_whitelist_dirs||"[]",e=JSON.parse(t);return Array.isArray(e)&&e.length>0?e:[]}catch{return[]}});async function Z(){try{const t=await Fe(),e={};for(const i of t)e[i.key]=i.value;I.value=e}catch(t){console.error("加载系统配置失败",t)}}async function ee(t,e){const i=z.value.find(s=>s.type===t);if(i)try{await Ve(t,e),i.enabled=e}catch(s){_.error(s.message||"切换失败"),i.enabled=!e}}async function $(){try{F.value=await Ne()}catch(t){console.error("加载网盘配置失败",t)}}async function te(t,e){var s,m;const i=e?1:0;try{await P({id:t.id,cloud_type:t.cloud_type,nickname:t.nickname||"",promotion_account:t.promotion_account||"",is_transfer_enabled:i,is_active:t.is_active,cookie:void 0}),t.is_transfer_enabled=i,_.success(e?"转存已开启":"转存已关闭")}catch(f){_.error(((m=(s=f.response)==null?void 0:s.data)==null?void 0:m.error)||"操作失败")}}async function oe(t,e){var i,s;try{await ze(t.id,e),t.is_primary=e?1:0,_.success(e?`已将「${t.nickname||t.cloud_type}」设为默认账号`:"已取消默认账号")}catch(m){_.error(((s=(i=m.response)==null?void 0:i.data)==null?void 0:s.error)||m.message||"操作失败")}}async function le(){for(const t of F.value)(t.cookie_preview||t.nickname)&&await U(t,!0)}async function ae(){for(const t of F.value)(t.cookie_preview||t.nickname)&&!t._verifying&&await U(t,!1);_.success("全部验证完成")}async function U(t,e=!1){if(!t.cookie_preview&&!t.nickname){e||_.warning("该配置没有 Cookie，请先编辑保存后再验证");return}t._verifying=!0;try{const i=await G(t.cloud_type,void 0,t.id);t.verification_status=i.success?"valid":"invalid",i.success?(i.nickname&&!t.nickname&&(t.nickname=i.nickname),i.storage_used&&(t.storage_used=i.storage_used),i.storage_total&&(t.storage_total=i.storage_total),e||_.success(`${x[t.cloud_type]}：${i.message}`)):e||_.error(`${x[t.cloud_type]}：${i.message}`)}catch{t.verification_status="invalid",e||_.error(`${x[t.cloud_type]}：验证失败`)}finally{t._verifying=!1}}function O(t){t?(b.value=t.id??null,l.cloud_type=t.cloud_type,l.nickname=t.nickname||"",l.promotion_account=t.promotion_account||"",l.is_transfer_enabled=t.is_transfer_enabled!==0,l.cookie=t.cookie||"",l._verifying=!1,l._storageUsed="",l._storageTotal=""):(b.value=null,l.cloud_type="",l.nickname="",l.promotion_account="",l.is_transfer_enabled=!1,l.cookie="",l._verifying=!1,l._storageUsed="",l._storageTotal=""),B.value=!0}function ie(){}async function ne(){var e,i,s,m,f;if(await((e=D.value)==null?void 0:e.validate().catch(()=>!1))){T.value=!0;try{if(l.cookie)try{const u=await G(l.cloud_type,l.cookie);if(!u.success){_.error(`Cookie验证失败：${u.message}`),T.value=!1;return}}catch(u){_.error(`Cookie验证失败：${((s=(i=u.response)==null?void 0:i.data)==null?void 0:s.error)||"网络错误"}`),T.value=!1;return}if(b.value)await P({id:b.value,cloud_type:l.cloud_type,nickname:l.nickname,promotion_account:l.promotion_account,is_transfer_enabled:l.is_transfer_enabled?1:0,cookie:l.cookie||void 0,is_active:1}),_.success("配置更新成功");else{const u=await Se({cloud_type:l.cloud_type,nickname:l.nickname,promotion_account:l.promotion_account,is_transfer_enabled:l.is_transfer_enabled?1:0,cookie:l.cookie,is_active:1});_.success("配置保存成功")}B.value=!1,b.value=null,await $()}catch(u){_.error(((f=(m=u.response)==null?void 0:m.data)==null?void 0:f.error)||"保存失败")}finally{T.value=!1}}}async function se(t){try{await $e(t.id),_.success("删除成功"),await $()}catch{_.error("删除失败")}}function N(t){const e=t.match(/^([\d.]+)\s*(B|KB|MB|GB|TB)$/i);if(!e)return 0;const i=parseFloat(e[1]),s={B:1,KB:1024,MB:1024**2,GB:1024**3,TB:1024**4};return i*(s[e[2].toUpperCase()]||1)}function q(t){if(!t.storage_total||t.storage_total==="-"||!t.storage_used)return 0;const e=N(t.storage_total),i=N(t.storage_used);return e===0?0:Math.min(100,Math.round(i/e*100))}function re(t){const e=q(t);return e>=90?"bar-danger":e>=70?"bar-warning":"bar-normal"}function ce(t){if(!t.storage_total||t.storage_total==="-")return"?";if(!t.storage_used)return"计算中...";const e=N(t.storage_total),i=N(t.storage_used);if(e===0)return"?";const s=e-i;return s<1024?"小于 1 KB":s<1024*1024?(s/1024).toFixed(1)+" KB":s<1024*1024*1024?(s/(1024*1024)).toFixed(1)+" MB":s<1024*1024*1024*1024?(s/(1024*1024*1024)).toFixed(1)+" GB":(s/(1024*1024*1024*1024)).toFixed(1)+" TB"}return(t,e)=>{const i=p("el-tag"),s=p("el-switch"),m=p("el-card"),f=p("el-button"),u=p("el-table-column"),w=p("el-text"),de=p("el-icon"),ue=p("el-popconfirm"),_e=p("el-table"),pe=p("el-alert"),fe=p("el-option"),me=p("el-select"),V=p("el-form-item"),E=p("el-input"),ge=p("el-form"),ye=p("el-dialog");return c(),k("div",Ie,[n(m,{class:"toggle-card",style:{"margin-bottom":"20px"}},{header:a(()=>[...e[6]||(e[6]=[r("span",null,"📂 网盘设置及授权",-1)])]),default:a(()=>[r("div",Me,[(c(!0),k(R,null,K(z.value,o=>(c(),k("div",{key:o.type,class:"cloud-toggle-chip"},[r("img",{src:o.icon,class:"cloud-icon-img"},null,8,Oe),r("span",qe,v(o.label),1),o.type==="others"?(c(),g(i,{key:0,size:"small",type:"info"},{default:a(()=>[...e[7]||(e[7]=[d("关",-1)])]),_:1})):A("",!0),n(s,{"model-value":o.enabled,size:"small",onChange:y=>ee(o.type,y)},null,8,["model-value","onChange"])]))),128))]),e[8]||(e[8]=r("div",{class:"form-tip",style:{"margin-top":"12px"}}," 关闭的网盘类型在搜索结果中不会展示。修改后立即生效，无需点击保存。 ",-1))]),_:1}),r("div",Ee,[n(f,{type:"primary",onClick:e[0]||(e[0]=o=>O(null))},{default:a(()=>[...e[9]||(e[9]=[d("新增配置",-1)])]),_:1}),n(f,{onClick:ae},{default:a(()=>[...e[10]||(e[10]=[d("全部重新验证",-1)])]),_:1})]),n(m,{shadow:"never",class:"table-card"},{header:a(()=>[...e[11]||(e[11]=[r("span",null,"📋 网盘配置列表",-1)])]),default:a(()=>[n(_e,{data:F.value,stripe:"",style:{width:"100%"},"empty-text":"暂无网盘配置，点击上方「新增配置」添加"},{default:a(()=>[n(u,{label:"网盘类型",width:"110"},{default:a(({row:o})=>[n(De,{cloud_type:o.cloud_type},null,8,["cloud_type"])]),_:1}),n(u,{prop:"nickname",label:"昵称",width:"140"},{default:a(({row:o})=>[o.nickname?(c(),k("span",Le,v(o.nickname),1)):(c(),g(w,{key:1,type:"info",size:"small"},{default:a(()=>[...e[12]||(e[12]=[d("未设置",-1)])]),_:1}))]),_:1}),n(u,{prop:"promotion_account",label:"推广账号",width:"160"},{default:a(({row:o})=>[o.promotion_account?(c(),k("span",Re,v(o.promotion_account),1)):(c(),g(w,{key:1,type:"info",size:"small"},{default:a(()=>[...e[13]||(e[13]=[d("-",-1)])]),_:1}))]),_:1}),n(u,{prop:"cloud_type_uid",label:"标识(__uid)",width:"180"},{default:a(({row:o})=>[o.cloud_type_uid?(c(),k("span",Ke,v(o.cloud_type_uid),1)):(c(),g(w,{key:1,type:"info",size:"small"},{default:a(()=>[...e[14]||(e[14]=[d("-",-1)])]),_:1}))]),_:1}),n(u,{label:"验证",width:"80",align:"center"},{default:a(({row:o})=>[o._verifying?(c(),k("span",Ae,[n(de,{class:"is-loading"},{default:a(()=>[n(Ce(he))]),_:1})])):o.verification_status==="valid"?(c(),g(i,{key:1,type:"success",size:"small"},{default:a(()=>[...e[15]||(e[15]=[d("有效",-1)])]),_:1})):o.verification_status==="invalid"?(c(),g(i,{key:2,type:"danger",size:"small"},{default:a(()=>[...e[16]||(e[16]=[d("无效",-1)])]),_:1})):(c(),g(i,{key:3,type:"info",size:"small"},{default:a(()=>[...e[17]||(e[17]=[d("未验证",-1)])]),_:1}))]),_:1}),n(u,{label:"空间",width:"200"},{default:a(({row:o})=>[o.storage_total&&o.storage_total!=="-"?(c(),k("div",He,[r("div",Ge,[r("div",{class:H(["storage-bar-fill",re(o)]),style:xe({width:q(o)+"%"})},null,6)]),r("div",Pe,[r("span",je,v(o.storage_used||"计算中..."),1),e[18]||(e[18]=r("span",{class:"storage-sep"},"/",-1)),r("span",Je,v(o.storage_total),1),r("span",Qe,"(可用 "+v(ce(o))+")",1)])])):(c(),g(w,{key:1,type:"info",size:"small"},{default:a(()=>[...e[19]||(e[19]=[d("—",-1)])]),_:1}))]),_:1}),n(u,{label:"转存数",width:"80",align:"center"},{default:a(({row:o})=>[o.total_saves>0?(c(),k("span",We,v(o.total_saves)+"次",1)):(c(),g(w,{key:1,type:"info",size:"small"},{default:a(()=>[...e[20]||(e[20]=[d("-",-1)])]),_:1}))]),_:1}),n(u,{label:"转存启用",width:"80",align:"center"},{default:a(({row:o})=>[n(s,{"model-value":o.is_transfer_enabled!==0,size:"small",onChange:y=>te(o,y)},null,8,["model-value","onChange"])]),_:1}),n(u,{label:"默认账号",width:"100",align:"center"},{default:a(({row:o})=>[n(s,{"model-value":o.is_primary===1,disabled:!o.is_transfer_enabled,size:"small",onChange:y=>oe(o,y)},null,8,["model-value","disabled","onChange"])]),_:1}),n(u,{label:"操作",width:"390",align:"center"},{default:a(({row:o})=>[n(f,{text:"",type:"primary",onClick:y=>O(o)},{default:a(()=>[...e[21]||(e[21]=[d("编辑",-1)])]),_:1},8,["onClick"]),n(f,{text:"",type:"primary",onClick:y=>U(o)},{default:a(()=>[...e[22]||(e[22]=[d("验证",-1)])]),_:1},8,["onClick"]),n(ue,{title:"确定删除该配置？",onConfirm:y=>se(o)},{reference:a(()=>[n(f,{text:"",type:"danger"},{default:a(()=>[...e[23]||(e[23]=[d("删除",-1)])]),_:1})]),_:1},8,["onConfirm"])]),_:1})]),_:1},8,["data"])]),_:1}),n(ye,{modelValue:B.value,"onUpdate:modelValue":e[5]||(e[5]=o=>B.value=o),title:b.value?"编辑配置":"新增配置",width:"560px"},{footer:a(()=>[n(f,{onClick:e[4]||(e[4]=o=>B.value=!1)},{default:a(()=>[...e[27]||(e[27]=[d("取消",-1)])]),_:1}),n(f,{type:"primary",loading:T.value,onClick:ne},{default:a(()=>[...e[28]||(e[28]=[d("保存",-1)])]),_:1},8,["loading"])]),default:a(()=>[n(ge,{ref_key:"formRef",ref:D,model:l,rules:j.value,"label-width":"120px"},{default:a(()=>[Be(n(pe,{type:"warning","show-icon":"",closable:!1,style:{"margin-bottom":"18px"}},{title:a(()=>[r("div",Xe,[r("div",null,[e[24]||(e[24]=d("🧹 请在网盘主目录内创建：",-1)),r("b",null,v(M.value.join("、")),1),e[25]||(e[25]=d(" 目录",-1))]),e[26]||(e[26]=r("div",null,[d("并将你的重要文件移至该目录，"),r("b",null,"只有这个目录不会被自动清理")],-1))])]),_:1},512),[[Te,M.value.length>0]]),n(V,{label:"网盘类型",prop:"cloud_type"},{default:a(()=>[n(me,{modelValue:l.cloud_type,"onUpdate:modelValue":e[1]||(e[1]=o=>l.cloud_type=o),style:{width:"100%"},disabled:!!b.value,onChange:ie},{default:a(()=>[(c(!0),k(R,null,K(J.value,([o,y])=>(c(),g(fe,{key:o,label:y,value:o},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1}),n(V,{label:"推广平台及账号",prop:"promotion_account",style:{"margin-bottom":"18px"}},{default:a(()=>[n(E,{modelValue:l.promotion_account,"onUpdate:modelValue":e[2]||(e[2]=o=>l.promotion_account=o),placeholder:"请填写您的推广平台及账号，例：蜂小推-13288889999",clearable:""},null,8,["modelValue"])]),_:1}),n(V,{label:"Cookie",prop:"cookie"},{default:a(()=>[n(E,{modelValue:l.cookie,"onUpdate:modelValue":e[3]||(e[3]=o=>l.cookie=o),type:"textarea",autosize:{minRows:2,maxRows:4},placeholder:Q.value,"input-style":"font-family: monospace; font-size: 12px;"},null,8,["modelValue","placeholder"])]),_:1}),l.cloud_type&&l.cloud_type!==""?(c(),g(V,{key:0,label:" ",class:"cookie-tips-item"},{default:a(()=>[r("div",{class:H(["cookie-tips",`cookie-tips-${l.cloud_type}`])},[r("div",Ye,[r("span",Ze,"📖 "+v(W.value)+" Cookie 获取教程",1)]),r("ol",{class:"cookie-tips-steps",innerHTML:X.value},null,8,et)],2)]),_:1})):A("",!0)]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])])}}}),rt=Ue(tt,[["__scopeId","data-v-f03a9373"]]);export{rt as default};
