perf: optimize full interface loading and refresh paths

This commit is contained in:
abaishu0730 committed 2026-10-28 09:24:04 +08:00
1 parent 649a0df832
commit f317314a3c
57 files changed
+791 -136

No files matched your search

+7
View File
@@ -17,6 +17,13 @@ function validate(operation,value){
visit(value);
if(!value||typeof value!=='object'||Array.isArray(value))throw fail('存储响应无效。',502);
if(['readPdf','readPreview','readFile'].includes(operation)&&!Buffer.isBuffer(value.bytes))throw fail('存储文件响应无效。',502);
if(['readPreview','readFile'].includes(operation)&&value.total!==undefined){
const {total,start,end,status,bytes}=value,valid=Number.isSafeInteger(total)&&total>=0&&total<=MAX_FILE&&Number.isSafeInteger(start)&&Number.isSafeInteger(end);
const layout=status===416?start===0&&end===-1&&bytes.length===0:
status===200?start===0&&end===total-1&&bytes.length===total:
status===206&&total>0&&start>=0&&start<=end&&end<total&&bytes.length===end-start+1;
if(!valid||!layout)throw fail('存储分段响应无效。',502);
}
if(operation==='list'&&(!Array.isArray(value.entries)||value.entries.length>500||typeof value.path!=='string'||typeof value.truncated!=='boolean'||value.entries.some(e=>!e||typeof e.name!=='string'||!['directory','file','blocked'].includes(e.type))))throw fail('存储目录响应无效。',502);
if(operation==='check'&&(value.readable!==true||value.writable!==true))throw fail('存储检查响应无效。',502);
if(operation==='archive'&&(!Number.isSafeInteger(value.bytes)||value.bytes<0||value.bytes>MAX_FILE||!/^[a-f0-9]{64}$/.test(value.sha256)||typeof value.filename!=='string'||typeof value.relativePath!=='string'))throw fail('归档响应无效。',502);