chore: 部分小更改

This commit is contained in:
Tianpao
2025-12-27 12:14:56 +08:00
parent a0a600eef7
commit 6c3fbf0ae8
10 changed files with 76 additions and 51 deletions

View File

@@ -100,7 +100,7 @@ export class Dex {
zip.forEach(async (e) => { zip.forEach(async (e) => {
if (important_name.includes(e.fileName)) { if (important_name.includes(e.fileName)) {
contain = e.fileName; contain = e.fileName;
this.in = JSON.parse(e.ReadEntrySync.toString()); this.in = JSON.parse((await e.ReadEntry).toString());
return; return;
} }
}); });

View File

@@ -1,15 +1,5 @@
import config from "./utils/config.js"; 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 { 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); const core = new Core(config);

View File

@@ -1,4 +1,4 @@
import got from "got"; import got, { Got } from "got";
import { WebSocket } from "ws"; import { WebSocket } from "ws";
import { join } from "node:path"; import { join } from "node:path";
import { Wfastdownload, Utils } from "../utils/utils.js"; import { Wfastdownload, Utils } from "../utils/utils.js";
@@ -14,8 +14,18 @@ export interface CurseForgeManifest {
export class CurseForge implements XPlatform { export class CurseForge implements XPlatform {
private utils: Utils; private utils: Utils;
private got:Got;
constructor() { constructor() {
this.utils = new Utils(); 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<modpack_info> { async getinfo(manifest: object): Promise<modpack_info> {
let result: modpack_info = Object.create({}); let result: modpack_info = Object.create({});
@@ -40,15 +50,9 @@ export class CurseForge implements XPlatform {
), ),
}); });
let tmp: [string, string] | string[][] = []; let tmp: [string, string] | string[][] = [];
await got await this.got
.post(this.utils.curseforge_url + "/v1/mods/files", { .post("v1/mods/files", {
body: FileID, body: FileID,
headers: {
"Content-Type": "application/json",
"x-api-key":
"$2a$10$ydk0TLDG/Gc6uPMdz7mad.iisj2TaMDytVcIW4gcVP231VKngLBKy",
"User-Agent": "DeEarthX",
},
}) })
.json() .json()
.then((res: any) => { .then((res: any) => {

View File

@@ -3,8 +3,6 @@ import crypto from "node:crypto"
import { yauzl_promise } from "./yauzl.promise.js" import { yauzl_promise } from "./yauzl.promise.js"
import got from "got" import got from "got"
import { Utils } from "./utils.js" import { Utils } from "./utils.js"
import pa from "node:path"
import WebSocket from "ws"
import config from "./config.js" import config from "./config.js"
interface IMixins{ interface IMixins{
name: string name: string

View File

@@ -1,7 +0,0 @@
class Debugger{
static log(msg: any){
if (process.env.DEBUG){
console.log(msg)
}
}
}

View File

@@ -0,0 +1,7 @@
const env = process.env.DEBUG;
export function debug(msg: string){
if (env === "true"){
console.info(msg);
}
}

View File

@@ -4,7 +4,6 @@ import Stream from "node:stream"
export interface IentryP extends yauzl.Entry { export interface IentryP extends yauzl.Entry {
openReadStream: Promise<Stream.Readable>; openReadStream: Promise<Stream.Readable>;
ReadEntry: Promise<Buffer>; ReadEntry: Promise<Buffer>;
ReadEntrySync: Buffer;
} }
export async function yauzl_promise(buffer: Buffer): Promise<IentryP[]>{ export async function yauzl_promise(buffer: Buffer): Promise<IentryP[]>{
@@ -29,7 +28,6 @@ export async function yauzl_promise(buffer: Buffer): Promise<IentryP[]>{
isCompressed: entry.isCompressed, isCompressed: entry.isCompressed,
openReadStream: _openReadStream(zip,entry), openReadStream: _openReadStream(zip,entry),
ReadEntry: _ReadEntry(zip,entry), ReadEntry: _ReadEntry(zip,entry),
ReadEntrySync: (await _ReadEntry(zip,entry))
} }
entries.push(_entry) entries.push(_entry)
if (zip.entryCount === entries.length){ if (zip.entryCount === entries.length){

View File

@@ -6,8 +6,8 @@ import { useRouter } from 'vue-router';
import * as shell from '@tauri-apps/plugin-shell'; import * as shell from '@tauri-apps/plugin-shell';
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
async function contant(){ async function contant() {
await invoke("open_url",{url:"https://space.bilibili.com/1728953419"}) await invoke("open_url", { url: "https://space.bilibili.com/1728953419" })
} }
//屏蔽右键菜单 //屏蔽右键菜单
@@ -29,11 +29,15 @@ document.oncontextmenu = function (event: any) {
} }
/* 启动后端 */ /* 启动后端 */
message.loading("DeEarthX.Core启动中此过程中请勿执行任何操作......").then(()=>{ message.loading("DeEarthX.Core启动中此过程中请勿执行任何操作......").then(() => {
shell.Command.create("core").spawn().then(()=>{ shell.Command.create("core").spawn().then(() => {
fetch("http://localhost:37019/", { method: "GET" }).catch((e) => {
router.push('/error')
}).then(() => {
message.success("DeEarthX.Core 启动成功") message.success("DeEarthX.Core 启动成功")
})
console.log(`DeEarthX V3 Core`) console.log(`DeEarthX V3 Core`)
}).catch((e)=>{ }).catch((e) => {
console.log(e) console.log(e)
message.error("DeEarthX.Core 启动失败请检查37019是否被占用") message.error("DeEarthX.Core 启动失败请检查37019是否被占用")
}) })
@@ -106,18 +110,21 @@ const theme = ref({
<style> <style>
/* 禁止选择文本的样式 */ /* 禁止选择文本的样式 */
h1,li,p,span { h1,
li,
p,
span {
-webkit-user-select: none; -webkit-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select:none; user-select: none;
} }
/* 禁止拖拽图片 */ /* 禁止拖拽图片 */
img { img {
-webkit-user-drag: none; -webkit-user-drag: none;
-moz-user-drag: none; -moz-user-drag: none;
-ms-user-drag: none; -ms-user-drag: none;
} }
</style> </style>

View File

@@ -0,0 +1,24 @@
<template>
<div class="tw:h-full tw:w-full tw:flex tw:flex-col tw:justify-center tw:items-center">
<div class="tw:w-32 tw:h-32 tw:mb-25">
<svg class="w-32 h-32 mb-4" viewBox="0 0 120 120">
<circle cx="60" cy="60" r="50" fill="#ef4444" />
<path d="M40,40 L80,80 M80,40 L40,80" stroke="white" stroke-width="10" stroke-linecap="round" />
</svg>
<p class="tw:text-2xl tw:font-bold tw:text-center tw:mb-20 tw:text-red-500">Error</p>
<p class="tw:text-sm tw:text-center tw:text-gray-500">
{{ errorMessage }}
</p>
</div>
</div>
</template>
<script lang="ts" setup>
import { useRoute } from 'vue-router';
const route = useRoute();
const errorReason = route.query.e as string;
const errorMessage = errorReason ? `错误原因:${errorReason}` : 'DeEarthX.Core 启动失败!';
</script>
<style lang="css" scoped></style>

View File

@@ -3,6 +3,7 @@ import { createRouter, createWebHistory } from "vue-router";
import Main from "../component/Main.vue"; import Main from "../component/Main.vue";
import Setting from "../component/Setting.vue"; import Setting from "../component/Setting.vue";
import About from "../component/About.vue"; import About from "../component/About.vue";
import Error from "../component/Error.vue";
const router = createRouter({ const router = createRouter({
history: createWebHistory(), history: createWebHistory(),
@@ -17,6 +18,9 @@ const router = createRouter({
},{ },{
path: "/about", path: "/about",
component: About component: About
},{
path: "/error",
component: Error
} }
] ]
}) })