From 456f676929e672adef32a02e46df4b7b2a24151d Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Sun, 13 Sep 2026 13:54:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(build):=20=E5=BD=BB=E5=BA=95=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=97=A0=E7=94=A8=E7=9A=84=E7=BD=91=E6=98=93=E4=BA=91?= =?UTF-8?q?=20API=20=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=B6=88=E9=99=A4=E7=94=B1?= =?UTF-8?q?=E4=BA=8E=E6=9C=AA=E5=AE=89=E8=A3=85=E6=A8=A1=E5=9D=97=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E5=AF=BC=E8=87=B4=E7=9A=84=20OOM=20=E5=92=8C=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nuxt.config.ts | 1 - server/api/api-enhanced/netease/[...path].ts | 67 -------------------- 2 files changed, 68 deletions(-) delete mode 100644 server/api/api-enhanced/netease/[...path].ts diff --git a/nuxt.config.ts b/nuxt.config.ts index 4f4382c..a84e9a9 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -302,7 +302,6 @@ export default defineNuxtConfig({ external: [ 'drizzle-orm', 'postgres', - '@neteasecloudmusicapienhanced/api', 'h3', 'lucide-vue-next', '@pixi/app' diff --git a/server/api/api-enhanced/netease/[...path].ts b/server/api/api-enhanced/netease/[...path].ts deleted file mode 100644 index 1e42e56..0000000 --- a/server/api/api-enhanced/netease/[...path].ts +++ /dev/null @@ -1,67 +0,0 @@ -const neteaseEnhancedApiPromise = import(/* @vite-ignore */ '@neteasecloudmusicapienhanced/api').then((mod) => { - return (mod.default || {}) as Record) => Promise> -}) - -const normalizeParams = (input: Record) => { - const output: Record = {} - for (const [key, value] of Object.entries(input || {})) { - if (value === undefined || value === null || value === '') { - continue - } - output[key] = Array.isArray(value) ? value[value.length - 1] : value - } - return output -} - -export default defineEventHandler(async (event) => { - const rawPath = getRouterParam(event, 'path') - const endpointPath = Array.isArray(rawPath) ? rawPath.join('/') : rawPath - - if (!endpointPath) { - throw createError({ - statusCode: 400, - message: '缺少网易云接口路径' - }) - } - - const action = endpointPath.replace(/\//g, '_').replace(/-/g, '_') - const api = await neteaseEnhancedApiPromise - const handler = api[action] - - if (typeof handler !== 'function') { - throw createError({ - statusCode: 404, - message: `未找到接口: ${endpointPath}` - }) - } - - const method = getMethod(event) - const queryParams = normalizeParams(getQuery(event)) - let bodyParams: Record = {} - - if (method !== 'GET') { - const body = await readBody(event).catch(() => ({})) - if (body && typeof body === 'object' && !Array.isArray(body)) { - bodyParams = normalizeParams(body as Record) - } - } - - const params = { ...queryParams, ...bodyParams } - - try { - const result = await handler(params) - if (Array.isArray(result?.cookie) && result.cookie.length > 0) { - setHeader(event, 'set-cookie', result.cookie) - } - if (typeof result?.status === 'number') { - setResponseStatus(event, result.status) - } - return result?.body ?? result - } catch (error: any) { - throw createError({ - statusCode: error?.statusCode || error?.status || 500, - message: error?.body?.message || error?.message || '网易云接口调用失败', - data: error?.body || null - }) - } -})