mirror of
https://github.com/putyy/res-downloader.git
synced 2026-01-12 06:04:55 +08:00
x
This commit is contained in:
@@ -36,16 +36,10 @@ export class Aria2RPC {
|
||||
}
|
||||
|
||||
calculateDownloadProgress(bitfield) {
|
||||
// 将十六进制的 bitfield 转换为二进制字符串
|
||||
const totalPieces = bitfield.length * 4; // 每个十六进制字符对应 4 位
|
||||
const binaryString = bitfield.split('').map(hex => parseInt(hex, 16).toString(2).padStart(4, '0')).join('');
|
||||
|
||||
// 计算已下载的部分数
|
||||
const downloadedPieces = binaryString.split('').filter(bit => bit === '1').length;
|
||||
|
||||
// 计算进度百分比
|
||||
const progressPercentage = (downloadedPieces / totalPieces) * 100;
|
||||
|
||||
return progressPercentage.toFixed(2); // 保留两位小数
|
||||
const totalPieces = bitfield.length * 4
|
||||
const binaryString = bitfield.split('').map(hex => parseInt(hex, 16).toString(2).padStart(4, '0')).join('')
|
||||
const downloadedPieces = binaryString.split('').filter(bit => bit === '1').length
|
||||
const progressPercentage = (downloadedPieces / totalPieces) * 100
|
||||
return progressPercentage.toFixed(2)
|
||||
}
|
||||
}
|
||||
@@ -58,19 +58,6 @@ export default function initIPC() {
|
||||
});
|
||||
return false
|
||||
}
|
||||
// let upstream_proxy = ""
|
||||
// if (arg.upstream_proxy && !arg.upstream_proxy.includes(':8899')) {
|
||||
// upstream_proxy = arg.upstream_proxy
|
||||
// }
|
||||
//
|
||||
// global.isStartProxy = true
|
||||
// return startServer({
|
||||
// win: win,
|
||||
// upstreamProxy: upstream_proxy,
|
||||
// setProxyErrorCallback: err => {
|
||||
// console.log('setProxyErrorCallback', err)
|
||||
// },
|
||||
// })
|
||||
})
|
||||
|
||||
ipcMain.handle('invoke_select_down_dir', async (event, arg) => {
|
||||
@@ -107,12 +94,10 @@ export default function initIPC() {
|
||||
}
|
||||
if (quality === "0" && data.decode_key) {
|
||||
const urlInfo = urlTool.parse(down_url, true);
|
||||
console.log('urlInfo', urlInfo)
|
||||
if (urlInfo.query["token"] && urlInfo.query["encfilekey"]) {
|
||||
down_url = urlInfo.protocol + "//" + urlInfo.hostname + urlInfo.pathname.replace("251/20302", "251/20304") +
|
||||
"?encfilekey=" + urlInfo.query["encfilekey"] +
|
||||
"&token=" + urlInfo.query["token"]
|
||||
console.log("down_url:", down_url)
|
||||
}
|
||||
} else if (quality !== "-1" && data.decode_key && data.file_format) {
|
||||
const format = data.file_format.split('#');
|
||||
@@ -158,7 +143,7 @@ export default function initIPC() {
|
||||
})
|
||||
resolve(res)
|
||||
}).catch((error) => {
|
||||
console.log("err:", error)
|
||||
console.log("decodeWxFile err:", error)
|
||||
resolve(false);
|
||||
})
|
||||
} else {
|
||||
@@ -168,13 +153,13 @@ export default function initIPC() {
|
||||
}
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error(error)
|
||||
console.log("aria2RpcClient err:", error)
|
||||
clearInterval(progressIntervalId)
|
||||
resolve(false)
|
||||
});
|
||||
}, 1000)
|
||||
}).catch((error) => {
|
||||
console.log("err:", error)
|
||||
console.log("aria2RpcClient.addUri err:", error)
|
||||
resolve(false)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,7 +38,6 @@ export function startServer(win) {
|
||||
if (global.resdConfig.proxy && !global.resdConfig.proxy.includes(':' + global.resdConfig.port)) {
|
||||
upstreamProxy = global.resdConfig?.proxy
|
||||
}
|
||||
console.log("global.resdConfig.port:", global.resdConfig.port)
|
||||
const proxy = hoXy.createServer({
|
||||
upstreamProxy: upstreamProxy,
|
||||
certAuthority: {
|
||||
@@ -54,7 +53,7 @@ export function startServer(win) {
|
||||
})
|
||||
intercept(proxy, win)
|
||||
} catch (e) {
|
||||
console.error("--------------proxy catch err--------------");
|
||||
console.error("--------------proxy catch err--------------", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
"dependencies": {
|
||||
"axios": "^1.5.0",
|
||||
"hoxy": "^3.3.1",
|
||||
"http-mitm-proxy": "^1.1.0",
|
||||
"tunnel-agent": "^0.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user