mirror of
https://git-qiuchenly.yltfspace.com/QiuChenly/corepatch
synced 2025-11-25 18:07:32 +08:00
### 后端更新 性能优化 - Redis、数据库索引优化, 复杂联表查询查询速度从10秒降低到500ms 功能增强 - 统一文件上传 API - 论坛权限管理优化 ### 前端更新 问题修复 - 统一错误提示、组件复用、图标本地化、密码加密传输、大文件分片上传 新增功能 - 全局通知系统、WebSocket 实时消息、图标批量同步、IP 封禁管理、应用版本批量查询、头像上传、TypeScript 类型完善、讨论区功能增强 代码优化 - 删除冗余组件、统一 API 错误处理、优化代码结构、统一 UI 风格
39 lines
8.7 KiB
JavaScript
39 lines
8.7 KiB
JavaScript
import{d as e,r as s,f as a,o as t,a as l,k as o,m as n,g as c,F as i,y as r,b as u,A as d,v,l as m,q as p,u as g,t as f,e as w}from"./Cf-ihD4f.js"
|
|
import{c as y,A as k,_ as h,M as b,T as C,a as x}from"./C_NDl53k.js"
|
|
function M(e){if(0===e)return"0 B"
|
|
const s=Math.floor(Math.log(e)/Math.log(1024))
|
|
return`${(e/Math.pow(1024,s)).toFixed(2)} ${["B","KB","MB","GB","TB"][s]}`}function T(e){return e<=0?"--":`${M(e)}/s`}function $(e){return e<=0?"完成":e>=3600?`${Math.floor(e/3600)}小时${Math.floor(e%3600/60)}分钟`:e>=60?`${Math.floor(e/60)}分${Math.floor(e%60)}秒`:`${Math.floor(e)}秒`}function D(e){return e<0?"0.00%":e>=100?"100.00%":`${e.toFixed(2)}%`}const S={class:"download-manager"},B={class:"filter-bar"},F=["onClick"],_={class:"filter-count"},z={class:"recent-updates-section"},A={class:"download-list"},E={key:0,class:"empty-state"},I={class:"item-icon"},N={class:"item-content"},j={class:"item-name-row"},q={class:"item-name"},L={class:"item-meta-row"},P={class:"item-type"},R={key:0,class:"item-progress-section"},G={class:"progress-bar"},K={class:"progress-info"},Y={class:"progress-text"},H={class:"progress-stats"},J={class:"progress-speed"},O={class:"progress-time"},Q={key:1,class:"item-progress-section"},U={class:"progress-info"},V={class:"progress-stats"},W={key:2,class:"item-error"},X={class:"item-right"},Z={key:0,class:"item-status-text"},ee={class:"item-actions"},se=["onClick"],ae={class:"btn-more-wrapper"},te=["onClick"],le=["onClick"],oe=["onClick"],ne=["onClick"],ce=["onClick"],ie=x(e({__name:"DownloadManager",setup(e){const{toasts:x,success:ie,error:re,removeToast:ue}=y(),de=s([]),ve=s("all")
|
|
let me=null
|
|
const pe=s(!1),ge=s({title:"",message:"",type:"warning",confirmText:"确认",cancelText:"取消"})
|
|
let fe=null
|
|
const we=s(!1),ye=s(null),ke=[{label:"全部",value:"all"},{label:"下载中",value:"downloading"},{label:"已完成",value:"completed"},{label:"已暂停",value:"paused"},{label:"失败",value:"error"}],he=a(()=>"all"===ve.value?de.value:de.value.filter(e=>e.status===ve.value)),be=e=>"all"===e?de.value.length:de.value.filter(s=>s.status===e).length,Ce=e=>({downloading:"fluent-color:arrow-square-down-32",completed:"fluent-color:checkmark-circle-24",paused:"fluent-color:clock-24",error:"fluent-color:error-circle-24",pending:"fluent-color:hourglass-24"}[e.status]||"fluent-color:document-24"),xe=e=>{if("downloading"===e.status)return"下载中"
|
|
if("completed"===e.status&&e.updateTime){const s=new Date(1e3*e.updateTime),a=(new Date).getTime()-s.getTime()
|
|
return 0===Math.floor(a/864e5)?"今天更新":`已于${s.getFullYear()}/${String(s.getMonth()+1).padStart(2,"0")}/${String(s.getDate()).padStart(2,"0")}更新`}return""},Me=e=>{const s=e.target
|
|
!we.value||s.closest(".menu-popup")||s.closest(".btn-more")||(we.value=!1,ye.value=null)}
|
|
t(()=>{Te(),me=setInterval(Te,1e3),document.addEventListener("click",Me)}),l(()=>{me&&clearInterval(me),document.removeEventListener("click",Me)})
|
|
const Te=async()=>{try{de.value=await k.getAllDownloads()}catch(e){}},$e=()=>{Te()},De=(e,s,a="warning")=>(we.value=!1,ye.value=null,new Promise(t=>{ge.value={title:e,message:s,type:a,confirmText:"确认",cancelText:"取消"},pe.value=!0,fe=t})),Se=()=>{pe.value=!1,fe&&(fe(!0),fe=null)},Be=()=>{pe.value=!1,fe&&(fe(!1),fe=null)}
|
|
return(e,s)=>(w(),o("div",S,[n("div",{class:"page-header"},[s[1]||(s[1]=n("div",{class:"header-content"},[n("h1",{class:"page-title"},"更新和下载"),n("p",{class:"page-subtitle"},' 通过单击"检查更新"、"全部更新"或"更新"下载并安装应用更新 ')],-1)),n("button",{class:"btn-check-updates",onClick:$e}," 检查更新 ")]),n("div",B,[(w(),o(i,null,r(ke,e=>n("button",{key:e.value,class:u(["filter-btn",{active:ve.value===e.value}]),onClick:s=>ve.value=e.value},[d(v(e.label)+" ",1),n("span",_,v(be(e.value)),1)],10,F)),64))]),n("div",z,[s[12]||(s[12]=n("h2",{class:"section-title"},"最近的更新",-1)),n("div",A,[0===he.value.length?(w(),o("div",E,[c(h,{icon:"fluent-color:cloud-24",class:"empty-icon"}),s[2]||(s[2]=n("p",{class:"empty-text"},"暂无下载任务",-1))])):m("",!0),(w(!0),o(i,null,r(he.value,e=>{var a,t
|
|
return w(),o("div",{key:e.id,class:"download-item"},[n("div",I,[c(h,{icon:Ce(e),class:"icon"},null,8,["icon"])]),n("div",N,[n("div",j,[n("span",q,v(e.fileName),1)]),n("div",L,[s[3]||(s[3]=n("span",{class:"item-publisher"},"下载任务",-1)),s[4]||(s[4]=n("span",{class:"item-separator"},"•",-1)),n("span",P,v((t=e.status,{pending:"等待中",downloading:"下载中",paused:"已暂停",completed:"应用",error:"失败"}[t]||"下载任务")),1)]),"downloading"===e.status?(w(),o("div",R,[n("div",G,[n("div",{class:"progress-fill",style:p({width:g(D)(100*e.progress)})},null,4)]),n("div",K,[n("span",Y,v(g(D)(100*e.progress)),1),n("span",H,v(g(M)(e.downloadedSize))+" / "+v(g(M)(e.totalSize)),1),n("span",J,v(g(T)(e.downloadSpeed)),1),n("span",O," 剩余 "+v(g($)(e.remainingTime)),1)])])):"completed"===e.status?(w(),o("div",Q,[s[6]||(s[6]=n("div",{class:"progress-bar"},[n("div",{class:"progress-fill completed",style:{width:"100%"}})],-1)),n("div",U,[s[5]||(s[5]=n("span",{class:"progress-text"},"100%",-1)),n("span",V,v(g(M)(e.totalSize)),1)])])):m("",!0),e.errorMsg?(w(),o("div",W,[c(h,{icon:"fluent-color:error-circle-24",class:"error-icon"}),d(" "+v(e.errorMsg),1)])):m("",!0)]),n("div",X,[xe(e)?(w(),o("div",Z,v(xe(e)),1)):m("",!0),n("div",ee,["completed"===e.status?(w(),o("button",{key:0,class:"btn-action btn-open",onClick:s=>(async e=>{var s,a
|
|
try{const s=await k.openDownloadFile(e)
|
|
s.success?ie(s.message||"打开文件成功",2e3):re(s.message||"打开文件失败",3e3)}catch(t){const e=(null==(a=null==(s=t.response)?void 0:s.data)?void 0:a.message)||t.message||"打开文件失败"
|
|
re(e,3e3)}})(e.id)},[c(h,{icon:"mdi:folder-open",class:"btn-icon"}),s[7]||(s[7]=d(" 打开 ",-1))],8,se)):m("",!0),n("div",ae,[n("button",{class:"btn-more",onClick:f(s=>((e,s)=>{var a
|
|
null==s||s.stopPropagation(),we.value&&(null==(a=ye.value)?void 0:a.id)===e.id?(we.value=!1,ye.value=null):(ye.value=e,we.value=!0)})(e,s),["stop"])},[c(h,{icon:"mdi:dots-vertical"})],8,te),we.value&&(null==(a=ye.value)?void 0:a.id)===e.id?(w(),o("div",{key:0,class:"menu-popup",onClick:s[0]||(s[0]=f(()=>{},["stop"]))},["downloading"===e.status?(w(),o("button",{key:0,class:"menu-item",onClick:f(s=>{(async e=>{var s,a
|
|
try{const s=await k.pauseDownload(e)
|
|
if(!s.success)return void re(s.message||"暂停下载失败",3e3)
|
|
ie(s.message||"暂停下载成功",2e3),await Te()}catch(t){const e=(null==(a=null==(s=t.response)?void 0:s.data)?void 0:a.message)||t.message||"暂停下载失败"
|
|
re(e,3e3)}})(e.id),we.value=!1},["stop"])},[c(h,{icon:"fluent-color:clock-24"}),s[8]||(s[8]=d(" 暂停 ",-1))],8,le)):m("",!0),"paused"===e.status?(w(),o("button",{key:1,class:"menu-item",onClick:f(s=>{(async e=>{var s,a
|
|
try{const s=await k.resumeDownload(e)
|
|
if(!s.success)return void re(s.message||"恢复下载失败",3e3)
|
|
ie(s.message||"恢复下载成功",2e3),await Te()}catch(t){const e=(null==(a=null==(s=t.response)?void 0:s.data)?void 0:a.message)||t.message||"恢复下载失败"
|
|
re(e,3e3)}})(e.id),we.value=!1},["stop"])},[c(h,{icon:"fluent-color:arrow-sync-24"}),s[9]||(s[9]=d(" 继续 ",-1))],8,oe)):m("",!0),"completed"===e.status||"error"===e.status?(w(),o("button",{key:2,class:"menu-item",onClick:f(s=>{(async e=>{var s,a
|
|
if(await De("重新下载",`确定要重新下载 "${e.fileName}" 吗?这将删除并重新下载该文件。`,"warning"))try{await k.deleteDownload(e.id)
|
|
const s=await k.startDownload(e.url,e.fileName)
|
|
if(!s.success)throw new Error(s.message||"重新下载失败")
|
|
await Te()}catch(t){const e=(null==(a=null==(s=t.response)?void 0:s.data)?void 0:a.message)||t.message||"重新下载失败"
|
|
re(e,3e3)}})(e),we.value=!1},["stop"])},[c(h,{icon:"fluent-color:arrow-sync-24"}),s[10]||(s[10]=d(" 重新下载 ",-1))],8,ne)):m("",!0),n("button",{class:"menu-item danger",onClick:f(s=>{(async e=>{var s,a
|
|
if(await De("删除下载任务","确定要删除这个下载任务吗?","danger"))try{const s=await k.deleteDownload(e)
|
|
if(!s.success)return void re(s.message||"删除下载任务失败",3e3)
|
|
ie(s.message||"删除下载任务成功",2e3),await Te()}catch(t){const e=(null==(a=null==(s=t.response)?void 0:s.data)?void 0:a.message)||t.message||"删除下载任务失败"
|
|
re(e,3e3)}})(e.id),we.value=!1},["stop"])},[c(h,{icon:"fluent-color:dismiss-circle-24"}),s[11]||(s[11]=d(" 删除 ",-1))],8,ce)])):m("",!0)])])])])}),128))])]),c(b,{visible:pe.value,title:ge.value.title,message:ge.value.message,type:"danger"===ge.value.type?"error":ge.value.type||"warning","confirm-text":ge.value.confirmText,"cancel-text":ge.value.cancelText,onConfirm:Se,onCancel:Be},null,8,["visible","title","message","type","confirm-text","cancel-text"]),c(C,{toasts:g(x),onRemove:g(ue)},null,8,["toasts","onRemove"])]))}}),[["__scopeId","data-v-70173d45"]])
|
|
export{ie as default}
|