diff --git a/backend/src/Dex.ts b/backend/src/Dex.ts index 596e6e5..612e7b8 100644 --- a/backend/src/Dex.ts +++ b/backend/src/Dex.ts @@ -100,7 +100,7 @@ export class Dex { zip.forEach(async (e) => { if (important_name.includes(e.fileName)) { contain = e.fileName; - this.in = JSON.parse(e.ReadEntrySync.toString()); + this.in = JSON.parse((await e.ReadEntry).toString()); return; } }); diff --git a/backend/src/main.ts b/backend/src/main.ts index 337c3c2..a1f1db6 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -1,15 +1,5 @@ import config from "./utils/config.js"; -import fsp from "node:fs/promises"; -import fs from "node:fs"; -import { pipeline } from "node:stream/promises"; -import { yauzl_promise } from "./utils/yauzl.promise.js"; import { Core } from "./core.js"; -import { DeEarth } from "./utils/DeEarth.js"; -import { version_compare } from "./utils/utils.js"; -import { Forge } from "./modloader/forge.js"; -import { Minecraft } from "./modloader/minecraft.js"; -import { Fabric } from "./modloader/fabric.js"; -import { NeoForge } from "./modloader/neoforge.js"; const core = new Core(config); diff --git a/backend/src/platform/curseforge.ts b/backend/src/platform/curseforge.ts index ef2ac12..1516938 100644 --- a/backend/src/platform/curseforge.ts +++ b/backend/src/platform/curseforge.ts @@ -1,4 +1,4 @@ -import got from "got"; +import got, { Got } from "got"; import { WebSocket } from "ws"; import { join } from "node:path"; import { Wfastdownload, Utils } from "../utils/utils.js"; @@ -14,8 +14,18 @@ export interface CurseForgeManifest { export class CurseForge implements XPlatform { private utils: Utils; + private got:Got; constructor() { this.utils = new Utils(); + this.got = got.extend({ + prefixUrl: this.utils.curseforge_url, + headers:{ + "User-Agent": "DeEarthX", + "x-api-key": + "$2a$10$ydk0TLDG/Gc6uPMdz7mad.iisj2TaMDytVcIW4gcVP231VKngLBKy", + "Content-Type": "application/json", + } + }) } async getinfo(manifest: object): Promise { let result: modpack_info = Object.create({}); @@ -40,15 +50,9 @@ export class CurseForge implements XPlatform { ), }); let tmp: [string, string] | string[][] = []; - await got - .post(this.utils.curseforge_url + "/v1/mods/files", { + await this.got + .post("v1/mods/files", { body: FileID, - headers: { - "Content-Type": "application/json", - "x-api-key": - "$2a$10$ydk0TLDG/Gc6uPMdz7mad.iisj2TaMDytVcIW4gcVP231VKngLBKy", - "User-Agent": "DeEarthX", - }, }) .json() .then((res: any) => { diff --git a/backend/src/utils/DeEarth.ts b/backend/src/utils/DeEarth.ts index 05da1f0..daa2add 100644 --- a/backend/src/utils/DeEarth.ts +++ b/backend/src/utils/DeEarth.ts @@ -3,8 +3,6 @@ import crypto from "node:crypto" import { yauzl_promise } from "./yauzl.promise.js" import got from "got" import { Utils } from "./utils.js" -import pa from "node:path" -import WebSocket from "ws" import config from "./config.js" interface IMixins{ name: string diff --git a/backend/src/utils/debugger.ts b/backend/src/utils/debugger.ts deleted file mode 100644 index beb31e8..0000000 --- a/backend/src/utils/debugger.ts +++ /dev/null @@ -1,7 +0,0 @@ -class Debugger{ - static log(msg: any){ - if (process.env.DEBUG){ - console.log(msg) - } - } -} \ No newline at end of file diff --git a/backend/src/utils/logger.ts b/backend/src/utils/logger.ts new file mode 100644 index 0000000..53b9dde --- /dev/null +++ b/backend/src/utils/logger.ts @@ -0,0 +1,7 @@ +const env = process.env.DEBUG; + +export function debug(msg: string){ + if (env === "true"){ + console.info(msg); + } +} diff --git a/backend/src/utils/yauzl.promise.ts b/backend/src/utils/yauzl.promise.ts index 1b876e7..228a571 100644 --- a/backend/src/utils/yauzl.promise.ts +++ b/backend/src/utils/yauzl.promise.ts @@ -4,7 +4,6 @@ import Stream from "node:stream" export interface IentryP extends yauzl.Entry { openReadStream: Promise; ReadEntry: Promise; - ReadEntrySync: Buffer; } export async function yauzl_promise(buffer: Buffer): Promise{ @@ -29,7 +28,6 @@ export async function yauzl_promise(buffer: Buffer): Promise{ isCompressed: entry.isCompressed, openReadStream: _openReadStream(zip,entry), ReadEntry: _ReadEntry(zip,entry), - ReadEntrySync: (await _ReadEntry(zip,entry)) } entries.push(_entry) if (zip.entryCount === entries.length){ diff --git a/front/src/App.vue b/front/src/App.vue index 6de9d0d..5a0a922 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -6,8 +6,8 @@ import { useRouter } from 'vue-router'; import * as shell from '@tauri-apps/plugin-shell'; import { invoke } from "@tauri-apps/api/core"; -async function contant(){ - await invoke("open_url",{url:"https://space.bilibili.com/1728953419"}) +async function contant() { + await invoke("open_url", { url: "https://space.bilibili.com/1728953419" }) } //屏蔽右键菜单 @@ -29,11 +29,15 @@ document.oncontextmenu = function (event: any) { } /* 启动后端 */ -message.loading("DeEarthX.Core启动中,此过程中请勿执行任何操作......").then(()=>{ - shell.Command.create("core").spawn().then(()=>{ - message.success("DeEarthX.Core 启动成功") +message.loading("DeEarthX.Core启动中,此过程中请勿执行任何操作......").then(() => { + shell.Command.create("core").spawn().then(() => { + fetch("http://localhost:37019/", { method: "GET" }).catch((e) => { + router.push('/error') + }).then(() => { + message.success("DeEarthX.Core 启动成功") + }) console.log(`DeEarthX V3 Core`) - }).catch((e)=>{ + }).catch((e) => { console.log(e) message.error("DeEarthX.Core 启动失败,请检查37019是否被占用!") }) @@ -106,18 +110,21 @@ const theme = ref({ \ No newline at end of file diff --git a/front/src/component/Error.vue b/front/src/component/Error.vue new file mode 100644 index 0000000..c85b84e --- /dev/null +++ b/front/src/component/Error.vue @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/front/src/router/index.ts b/front/src/router/index.ts index 798c0b0..441af35 100644 --- a/front/src/router/index.ts +++ b/front/src/router/index.ts @@ -3,6 +3,7 @@ import { createRouter, createWebHistory } from "vue-router"; import Main from "../component/Main.vue"; import Setting from "../component/Setting.vue"; import About from "../component/About.vue"; +import Error from "../component/Error.vue"; const router = createRouter({ history: createWebHistory(), @@ -17,6 +18,9 @@ const router = createRouter({ },{ path: "/about", component: About + },{ + path: "/error", + component: Error } ] })