From 61673809c8229e75d8e0a60059b6049e096354dc Mon Sep 17 00:00:00 2001 From: 15736060610 <15736060610@139.com> Date: Tue, 17 Mar 2026 22:02:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/rollup.config.js | 3 ++- backend/src/core.ts | 33 +++++++++++++++------------ backend/src/dearth/ModCheckService.ts | 2 +- backend/src/modloader/index.ts | 2 +- front/src/views/TemplateView.vue | 4 +++- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/backend/rollup.config.js b/backend/rollup.config.js index fee42a5..7c865a3 100644 --- a/backend/rollup.config.js +++ b/backend/rollup.config.js @@ -27,7 +27,8 @@ export default { dedupe: ['tslib'] }), commonjs({ - transformMixedEsModules: true + transformMixedEsModules: true, + ignoreDynamicRequires: true }), json(), terser({ diff --git a/backend/src/core.ts b/backend/src/core.ts index 3a6deb4..c6cfba1 100644 --- a/backend/src/core.ts +++ b/backend/src/core.ts @@ -204,7 +204,7 @@ export class Core { return res.status(400).json({ status: 400, message: "缺少 path 参数" }); } - const { ModCheckService } = await import('./dearth/index.js'); + const { ModCheckService } = await import('./dearth/index'); const checkService = new ModCheckService(modsPath); const results = await checkService.checkMods(); @@ -238,7 +238,7 @@ export class Core { bundleName: bundleName.trim() }); - const { ModCheckService } = await import('./dearth/index.js'); + const { ModCheckService } = await import('./dearth/index'); const checkService = new ModCheckService(folderPath); const results = await checkService.checkModsWithBundle(bundleName.trim()); @@ -295,7 +295,7 @@ export class Core { // 获取模板列表 this.app.get('/templates', async (req, res) => { try { - const templateModule = await import('./template/index.js'); + const templateModule = await import('./template/index'); const TemplateManager = (templateModule as any).TemplateManager; const templateManager = new TemplateManager(); const templates = await templateManager.getTemplates(); @@ -321,7 +321,7 @@ export class Core { return; } - const templateModule = await import('./template/index.js'); + const templateModule = await import('./template/index'); const TemplateManager = (templateModule as any).TemplateManager; const templateManager = new TemplateManager(); @@ -353,7 +353,7 @@ export class Core { try { const { id } = req.params; - const templateModule = await import('./template/index.js'); + const templateModule = await import('./template/index'); const TemplateService = (templateModule as any).TemplateService; const templateService = new TemplateService(); @@ -385,7 +385,7 @@ export class Core { return; } - const templateModule = await import('./template/index.js'); + const templateModule = await import('./template/index'); const TemplateManager = (templateModule as any).TemplateManager; const templateManager = new TemplateManager(); @@ -414,7 +414,7 @@ export class Core { const { id } = req.params; const path = await import('path'); const { exec } = await import('child_process'); - const templateModule = await import('./template/index.js'); + const templateModule = await import('./template/index'); const TemplateManager = (templateModule as any).TemplateManager; const templateManager = new TemplateManager(); @@ -449,7 +449,7 @@ export class Core { this.app.get('/templates/:id/export', async (req, res) => { try { const { id } = req.params; - const templateModule = await import('./template/index.js'); + const templateModule = await import('./template/index'); const TemplateManager = (templateModule as any).TemplateManager; const templateManager = new TemplateManager(); @@ -491,7 +491,7 @@ export class Core { return res.status(400).json({ status: 400, message: "只支持 .zip 文件" }); } - const templateModule = await import('./template/index.js'); + const templateModule = await import('./template/index'); const TemplateManager = (templateModule as any).TemplateManager; const templateManager = new TemplateManager(); @@ -631,7 +631,7 @@ export class Core { unlinkSync(tempFilePath); // 导入模板 - const templateModule = await import('./template/index.js'); + const templateModule = await import('./template/index'); const TemplateManager = (templateModule as any).TemplateManager; const templateManager = new TemplateManager(); @@ -661,8 +661,8 @@ export class Core { }); } catch (err) { const error = err as Error; - const { requestId } = req.body; - logger.error("/templates/install-from-url 路由错误", error); + const { requestId, url } = req.body; + logger.error("/templates/install-from-url 路由错误", { error: error.message, stack: error.stack, url }); // 发送错误信息到SSE连接 if (sseConnections.has(requestId)) { @@ -670,7 +670,8 @@ export class Core { sseRes.write(`data: ${JSON.stringify({ type: 'error', status: 500, - message: "安装模板失败" + message: "安装模板失败", + details: error.message })}\n\n`); sseRes.end(); sseConnections.delete(requestId); @@ -679,7 +680,11 @@ export class Core { // 清理下载状态 downloadStates.delete(requestId); - res.status(500).json({ status: 500, message: "安装模板失败" }); + res.status(500).json({ + status: 500, + message: "安装模板失败", + details: error.message + }); } }); diff --git a/backend/src/dearth/ModCheckService.ts b/backend/src/dearth/ModCheckService.ts index 97369fc..1332fda 100644 --- a/backend/src/dearth/ModCheckService.ts +++ b/backend/src/dearth/ModCheckService.ts @@ -550,7 +550,7 @@ export class ModCheckService { jarData = fs.readFileSync(file.filename); } - const { yauzl_promise } = await import("../utils/ziplib.js"); + const { yauzl_promise } = await import("../utils/ziplib"); const zipEntries = await yauzl_promise(jarData); for (const entry of zipEntries) { diff --git a/backend/src/modloader/index.ts b/backend/src/modloader/index.ts index e1b3175..9e97970 100644 --- a/backend/src/modloader/index.ts +++ b/backend/src/modloader/index.ts @@ -38,7 +38,7 @@ export async function mlsetup(ml: string, mcv: string, mlv: string, path: string messageWS.serverInstallStep(`Applying Template: ${template}`, 1, totalSteps); } - const templateModule = await import('../template/index.js'); + const templateModule = await import('../template/index'); const TemplateManager = (templateModule as any).TemplateManager; const templateManager = new TemplateManager(); const templates = await templateManager.getTemplates(); diff --git a/front/src/views/TemplateView.vue b/front/src/views/TemplateView.vue index 5792c40..54e911a 100644 --- a/front/src/views/TemplateView.vue +++ b/front/src/views/TemplateView.vue @@ -558,7 +558,9 @@ async function downloadAndInstallTemplate(template: StoreTemplate) { // 关闭通知 message.destroy(notificationKey); - message.error(data.message || t('template.install_failed')); + const errorMessage = data.message || t('template.install_failed'); + const errorDetails = data.details ? ` (${data.details})` : ''; + message.error(errorMessage + errorDetails); // 重置状态 downloadLoading.value = false; showDownloadProgress.value = false;