Finalize task visibility, selection state and active-copy uninstall protection
这个提交包含在:
1 父节点
ae3ed9c3d7
当前提交
72d678fa03
7 个文件已更改
+68
-63
没有与搜索条件相匹配的文件
+1
-1
@@ -28,6 +28,6 @@ async function browseSource(path=''){if(!device)return;try{loading=true;updateSe
|
||||
async function browseDest(path=''){try{const d=await api('destinations',{path});destPath=d.path;$('destPath').textContent=destPath||'存储空间';$('chosenDest').textContent=destPath||'请选择一个目录';folderRows($('destinations'),d.entries,false);updateSelection();error()}catch(e){error(e.message)}}
|
||||
function renderJobs(jobs){busy=jobs.some(j=>!['complete','failed','needs_attention','cleanup_failed','interrupted','cancelled'].includes(j.phase));$('tasks').replaceChildren();if(!jobs.length){const e=document.createElement('div');e.className='empty';e.textContent='暂无拷贝任务';$('tasks').append(e)}for(const job of jobs.slice(0,10)){const box=document.createElement('div');box.className='task';const title=document.createElement('div');title.className='tasktitle';const name=document.createElement('span');name.textContent=job.directories.join('、');const state=document.createElement('span');state.className='state';state.textContent=states[job.phase]||job.phase;title.append(name,state);const track=document.createElement('div');track.className='track';const bar=document.createElement('div');bar.className='bar';bar.style.width=(job.phase==='complete'?100:Math.min(100,job.total?job.bytes/job.total*100:0))+'%';track.append(bar);const metrics=document.createElement('div');metrics.className='metrics';for(const value of [bytes(job.bytes)+' / '+bytes(job.total),job.phase==='copying'?bytes(job.speed)+'/s':'',job.phase==='copying'?'预计剩余 '+duration(job.eta):job.phase==='complete'?'文件与目录核验通过':'']){if(value){const e=document.createElement('span');e.textContent=value;metrics.append(e)}}const path=document.createElement('div');path.className='taskpath';path.textContent=job.destination;box.append(title,track,metrics,path);if(job.error){const e=document.createElement('div');e.className='taskpath';e.style.color='#a74c30';e.textContent=job.error;box.append(e)}if(!job.legacy&&['failed','interrupted'].includes(job.phase))box.append(button('继续此任务',async()=>{try{await api('resume',{job:job.id},true);await refresh()}catch(e){error(e.message)}}));$('tasks').append(box)}updateSelection()}
|
||||
async function refresh(){try{const d=await api('status');$('version').textContent='大鱼硬盘拷贝 '+d.version;const signature=JSON.stringify(d.disks.map(x=>[x.id,x.filesystem]));if(signature!==lastDisks){lastDisks=signature;$('disk').replaceChildren();for(const disk of d.disks){const option=document.createElement('option');option.value=disk.id;option.textContent=disk.model+' · '+bytes(disk.size)+' · '+disk.filesystem.toUpperCase();$('disk').append(option)}if(!d.disks.length){const o=document.createElement('option');o.textContent='未发现 APFS 或 NTFS 外接硬盘';$('disk').append(o);device=''}else if(!d.disks.some(x=>x.id===device)){device=d.disks[0].id;$('disk').value=device;await browseSource()}$('fs').textContent=(d.disks.find(x=>x.id===device)?.filesystem||'USB').toUpperCase()}renderJobs(d.jobs)}catch(e){error(e.message)}}
|
||||
$('disk').onchange=()=>{device=$('disk').value;$('fs').textContent=$('disk').selectedOptions[0]?.textContent.split(' · ').at(-1)||'USB';browseSource()};$('refresh').onclick=refresh;$('sourceUp').onclick=()=>browseSource(sourcePath.split('/').slice(0,-1).join('/'));$('destUp').onclick=()=>{const up=destPath.split('/').slice(0,-1).join('/');browseDest(/^\/vol\d+\/\d+/.test(up)?up:'')};$('start').onclick=async()=>{try{loading=true;updateSelection();await api('start',{device,paths:[...selected],destination:destPath},true);selected.clear();error();await refresh()}catch(e){error(e.message)}finally{loading=false;updateSelection()}};$('release').onclick=async()=>{try{await api('eject',{device},true);error('已释放应用挂载;拔盘前仍请在飞牛系统中推出整块硬盘');await refresh()}catch(e){error(e.message)}};$('newFolder').onclick=()=>{if(!destPath)return error('请先选择一个存储空间或目录');$('folderName').value='';$('newDialog').showModal()};$('newForm').onsubmit=async e=>{if(e.submitter?.value!=='create')return;e.preventDefault();try{const d=await api('mkdir',{path:destPath,name:$('folderName').value},true);$('newDialog').close();await browseDest(d.path)}catch(err){error(err.message)}};
|
||||
$('disk').onchange=()=>{device=$('disk').value;$('fs').textContent=$('disk').selectedOptions[0]?.textContent.split(' · ').at(-1)||'USB';browseSource()};$('refresh').onclick=refresh;$('sourceUp').onclick=()=>browseSource(sourcePath.split('/').slice(0,-1).join('/'));$('destUp').onclick=()=>{const up=destPath.split('/').slice(0,-1).join('/');browseDest(/^\/vol\d+\/\d+/.test(up)?up:'')};$('start').onclick=async()=>{try{loading=true;updateSelection();await api('start',{device,paths:[...selected],destination:destPath},true);selected.clear();for(const c of document.querySelectorAll('#sources input'))c.checked=false;error();await refresh()}catch(e){error(e.message)}finally{loading=false;updateSelection()}};$('release').onclick=async()=>{try{await api('eject',{device},true);error('已释放应用挂载;拔盘前仍请在飞牛系统中推出整块硬盘');await refresh()}catch(e){error(e.message)}};$('newFolder').onclick=()=>{if(!destPath)return error('请先选择一个存储空间或目录');$('folderName').value='';$('newDialog').showModal()};$('newForm').onsubmit=async e=>{if(e.submitter?.value!=='create')return;e.preventDefault();try{const d=await api('mkdir',{path:destPath,name:$('folderName').value},true);$('newDialog').close();await browseDest(d.path)}catch(err){error(err.message)}};
|
||||
browseDest();refresh();setInterval(refresh,2500);
|
||||
</script></html>
|
||||
在新工单中引用
屏蔽一个用户