feat:大部分功能完成

This commit is contained in:
Tianpao
2025-09-28 00:21:01 +08:00
parent b359fc881e
commit 5f16ee2bfa
22 changed files with 471 additions and 121 deletions

View File

@@ -1,5 +1,6 @@
import fs from "node:fs";
import { mr_fastdownload, Utils } from "../utils/utils.js";
import { WebSocket } from "ws";
import { Wfastdownload, Utils } from "../utils/utils.js";
import { modpack_info, XPlatform } from "./index.js";
import { join } from "node:path";
@@ -34,22 +35,22 @@ export class Modrinth implements XPlatform {
}
return result;
}
async downloadfile(manifest: object,path:string): Promise<void> {
async downloadfile(manifest: object,path:string,ws:WebSocket): Promise<void> {
const index = manifest as ModrinthManifest;
let tmp: [string, string, string][] = []
let tmp: [string, string][] = []
index.files.forEach(async (e: { path: string; downloads: string[]; fileSize: number;}) => {
if (e.path.endsWith(".zip")) {
return;
}
const url = e.downloads[0].replace("https://cdn.modrinth.com",this.utils.modrinth_Durl)
const unpath = join(path,e.path)
tmp.push([e.downloads[0],unpath,String(e.fileSize)])
tmp.push([e.downloads[0],unpath])
// if (usemirror){
// tmp.push(["https://mod.mcimirror.top"+new URL(e.downloads[0]).pathname,unpath,String(e.fileSize)])
// }else{
// tmp.push([e.downloads[0],unpath,String(e.fileSize)])
// }
});
await mr_fastdownload(tmp as unknown as [string, string, string])
await Wfastdownload(tmp as unknown as [string, string],ws)
}
}