修正错误
This commit is contained in:
parent
c4721528e3
commit
37ff73d009
@ -478,7 +478,7 @@
|
||||
<div class="popup-content">3秒后将开始下载...</div>
|
||||
</div>
|
||||
<script>
|
||||
function getCookie(t){const n=t+"=";const o=document.cookie.split(";");for(let e=0;e<o.length;e++){let t=o[e];while(t.charAt(0)===" ")t=t.substring(1,t.length);if(t.indexOf(n)===0){return t.substring(n.length,t.length)}}return null}async function fetchNoCache(t){const e=(new Date).getTime();const n=`${t}?_t=${e}`;return fetch(n)}function d2(t,e){t=t.replace(/\s/g,"");const n=CryptoJS.enc.Base64.parse(t);const o=CryptoJS.lib.WordArray.create(n.words.slice(0,4));const c=CryptoJS.lib.WordArray.create(n.words.slice(4));const s=CryptoJS.AES.decrypt({ciphertext:c},e,{iv:o,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return s.toString(CryptoJS.enc.Utf8)}let client;async function initOSSClient(){try{const t=await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/upload/json/s.json");const e=await t.json();const n=e.masterKey;const o=CryptoJS.SHA256(n);const c={region:d2(e.encryptedRegion,o),accessKeyId:d2(e.encryptedKeyId,o),accessKeySecret:d2(e.encryptedKeySecret,o),bucket:d2(e.encryptedBucket,o)};client=new OSS(c)}catch(t){console.error("Failed to fetch or decrypt OSS config:",t)}}initOSSClient();document.addEventListener("DOMContentLoaded",function(){const t="download-1";const r= 25 ;const a="王道《数据结构》网课PPT(PDF版)-1";const e="upload_files\/pdf\/d0217732-3575-42aa-b066-2ed0745b3dff.pdf,upload_files\/pdf\/62e3c930-0eec-4649-9c95-93f1293e430c.pdf,upload_files\/pdf\/2f50fc97-4d7b-4285-b2df-57cf2f0b88dd.pdf";let l=[];if(e.indexOf(",")===-1){l=[e]}else{l=e.split(",").map(t=>t.trim()).filter(Boolean)}const d="popup-"+t;const n=document.getElementById(t);n.addEventListener("click",async function(){const t=getCookie("token");if(!t){alert("请登录后下载!");window.location.href="/submission";return}if(r>0){try{const e=await fetch("https://userlogin.xn--xhq44jb2fzpc.com/coin/remain",{method:"GET",headers:{Authorization:t}});if(!e.ok){if(e.status===401||e.status===403){alert("您的登录信息已过期,请重新登录!");window.location.href="/submission";return}throw new Error("无法检查余额")}const n=await e.json();const o=n.coin;if(o<r){alert(`您的东币数量不够!当前资源需要:${r},您的东币数:${o}`);return}const c=confirm(`本次下载将扣除东币:${r},您的东币数:${o}。\n是否继续?`);if(!c)return;const s=await fetch("https://userlogin.xn--xhq44jb2fzpc.com/coin/download",{method:"POST",headers:{"Content-Type":"application/json",Authorization:t},body:JSON.stringify({amount:r,title:a})});const i=await s.json();if(s.ok){startDownloadFlow(l,d)}else if(s.status===400&&i.message==="Insufficient coins."){alert(`您的东币数量不够!需要:${r}`)}else{alert(`下载失败:${i.message}`)}}catch(t){console.error("Error during download request:",t);alert("无法处理您的请求,请稍后重试。")}}else{startDownloadFlow(l,d)}})});function startDownloadFlow(t,e){if(!client){console.error("OSS client is not initialized.");return}const n=document.getElementById(e);const o=n.querySelector(".popup-content");let c=3;const s=t.map(t=>{const e=client.signatureUrl(t,{expires:60,response:{"content-disposition":"attachment"}});return e.replace("emberimg.oss-cn-beijing.aliyuncs.com","download.xn--xhq44jb2fzpc.com")});let i=0;const r=()=>{if(c>0){o.textContent=`${c}秒后将开始下载...`;c--;setTimeout(r,1e3)}else{n.style.display="none";const t=()=>{if(i<s.length){o.textContent=`正在下载第 ${i+1}/${s.length} 个文件...`;window.location.href=s[i];i++;if(i<s.length){setTimeout(t,1e3)}else{o.textContent="所有文件已下载完成!"}}};t()}};n.style.display="block";r()}function getCurrentTime(){const t=new Date;const e=new Date(t.getTime()+8*60*60*1e3);return e.toISOString().replace("T"," ").substring(0,19)}
|
||||
function getCookie(t){const n=t+"=";const o=document.cookie.split(";");for(let e=0;e<o.length;e++){let t=o[e];while(t.charAt(0)===" ")t=t.substring(1,t.length);if(t.indexOf(n)===0){return t.substring(n.length,t.length)}}return null}async function fetchNoCache(t){const e=(new Date).getTime();const n=`${t}?_t=${e}`;return fetch(n)}function d2(t,e){t=t.replace(/\s/g,"");const n=CryptoJS.enc.Base64.parse(t);const o=CryptoJS.lib.WordArray.create(n.words.slice(0,4));const c=CryptoJS.lib.WordArray.create(n.words.slice(4));const s=CryptoJS.AES.decrypt({ciphertext:c},e,{iv:o,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return s.toString(CryptoJS.enc.Utf8)}let client;async function initOSSClient(){try{const t=await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/upload/json/s.json");const e=await t.json();const n=e.masterKey;const o=CryptoJS.SHA256(n);const c={region:d2(e.encryptedRegion,o),accessKeyId:d2(e.encryptedKeyId,o),accessKeySecret:d2(e.encryptedKeySecret,o),bucket:d2(e.encryptedBucket,o)};client=new OSS(c)}catch(t){console.error("Failed to fetch or decrypt OSS config:",t)}}initOSSClient();document.addEventListener("DOMContentLoaded",function(){const t="download-1";const r= 25 ;const a="王道《数据结构》网课PPT(PDF版)";const e="upload_files\/pdf\/d0217732-3575-42aa-b066-2ed0745b3dff.pdf,upload_files\/pdf\/62e3c930-0eec-4649-9c95-93f1293e430c.pdf,upload_files\/pdf\/2f50fc97-4d7b-4285-b2df-57cf2f0b88dd.pdf";let l=[];if(e.indexOf(",")===-1){l=[e]}else{l=e.split(",").map(t=>t.trim()).filter(Boolean)}const d="popup-"+t;const n=document.getElementById(t);n.addEventListener("click",async function(){const t=getCookie("token");if(!t){alert("请登录后下载!");window.location.href="/submission";return}if(r>0){try{const e=await fetch("https://userlogin.xn--xhq44jb2fzpc.com/coin/remain",{method:"GET",headers:{Authorization:t}});if(!e.ok){if(e.status===401||e.status===403){alert("您的登录信息已过期,请重新登录!");window.location.href="/submission";return}throw new Error("无法检查余额")}const n=await e.json();const o=n.coin;if(o<r){alert(`您的东币数量不够!当前资源需要:${r},您的东币数:${o}`);return}const c=confirm(`本次下载将扣除东币:${r},您的东币数:${o}。\n是否继续?`);if(!c)return;const s=await fetch("https://userlogin.xn--xhq44jb2fzpc.com/coin/download",{method:"POST",headers:{"Content-Type":"application/json",Authorization:t},body:JSON.stringify({amount:r,title:a})});const i=await s.json();if(s.ok){startDownloadFlow(l,d)}else if(s.status===400&&i.message==="Insufficient coins."){alert(`您的东币数量不够!需要:${r}`)}else{alert(`下载失败:${i.message}`)}}catch(t){console.error("Error during download request:",t);alert("无法处理您的请求,请稍后重试。")}}else{startDownloadFlow(l,d)}})});function startDownloadFlow(t,e){if(!client){console.error("OSS client is not initialized.");return}const n=document.getElementById(e);const o=n.querySelector(".popup-content");let c=3;const s=t.map(t=>{const e=client.signatureUrl(t,{expires:60,response:{"content-disposition":"attachment"}});return e.replace("emberimg.oss-cn-beijing.aliyuncs.com","download.xn--xhq44jb2fzpc.com")});let i=0;const r=()=>{if(c>0){o.textContent=`${c}秒后将开始下载...`;c--;setTimeout(r,1e3)}else{n.style.display="none";const t=()=>{if(i<s.length){o.textContent=`正在下载第 ${i+1}/${s.length} 个文件...`;window.location.href=s[i];i++;if(i<s.length){setTimeout(t,1e3)}else{o.textContent="所有文件已下载完成!"}}};t()}};n.style.display="block";r()}function getCurrentTime(){const t=new Date;const e=new Date(t.getTime()+8*60*60*1e3);return e.toISOString().replace("T"," ").substring(0,19)}
|
||||
</script>
|
||||
|
||||
<hr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user