From 9ac04821f52c9c45de46ad35acc9d66e55916e73 Mon Sep 17 00:00:00 2001 From: xion Date: Wed, 18 Jun 2025 22:27:44 +0800 Subject: [PATCH] fix: update deploy local app --- src/routes/micro-app/list.ts | 30 ++++++++++++++++++++------ src/routes/micro-app/module/manager.ts | 2 +- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/routes/micro-app/list.ts b/src/routes/micro-app/list.ts index 0121ab6..e09ff47 100644 --- a/src/routes/micro-app/list.ts +++ b/src/routes/micro-app/list.ts @@ -18,17 +18,33 @@ app .define(async (ctx) => { const tokenUser = ctx.state.tokenUser; const data = ctx.query?.data; - const { id, key, force, install } = data; - if (!id) { - ctx.throw(400, 'Invalid id'); + const { id, key, force, install, appKey: postAppKey, version: postVersion = '1.0.0' } = data; + if (!id || !postAppKey) { + ctx.throw(400, 'Invalid id or postAppKey'); } let username = tokenUser.username; - if (data.username) { - // username = data.username; + if (data.username && username === 'admin') { + username = data.username; } - const microApp = await AppListModel.findByPk(id); + let microApp: AppListModel; + if (!microApp && id) { + microApp = await AppListModel.findByPk(id); + } + if (!microApp && postAppKey) { + microApp = await AppListModel.findOne({ + where: { + key: postAppKey, + version: postVersion, + }, + }); + } + if (!microApp) { - ctx.throw(400, 'Invalid id'); + if (id) { + ctx.throw(400, 'Invalid id'); + } else { + ctx.throw(400, `Invalid appKey , no found app with key: ${postAppKey} and version: ${postVersion}`); + } } const { key: appKey, version } = microApp; const check = await appPathCheck({ key: key }); diff --git a/src/routes/micro-app/module/manager.ts b/src/routes/micro-app/module/manager.ts index 6ea2091..3bb2c0a 100644 --- a/src/routes/micro-app/module/manager.ts +++ b/src/routes/micro-app/module/manager.ts @@ -25,7 +25,7 @@ export const installAppFromKey = async (key: string) => { } let showAppInfo = { key, - status: 'inactive', + status: 'inactive' as const, type: app?.type || 'system-app', description: readmeDesc || '', version,