fix: update deploy local app

This commit is contained in:
熊潇 2025-06-18 22:27:44 +08:00
parent 7f91070906
commit 9ac04821f5
2 changed files with 24 additions and 8 deletions

View File

@ -18,17 +18,33 @@ app
.define(async (ctx) => { .define(async (ctx) => {
const tokenUser = ctx.state.tokenUser; const tokenUser = ctx.state.tokenUser;
const data = ctx.query?.data; const data = ctx.query?.data;
const { id, key, force, install } = data; const { id, key, force, install, appKey: postAppKey, version: postVersion = '1.0.0' } = data;
if (!id) { if (!id || !postAppKey) {
ctx.throw(400, 'Invalid id'); ctx.throw(400, 'Invalid id or postAppKey');
} }
let username = tokenUser.username; let username = tokenUser.username;
if (data.username) { if (data.username && username === 'admin') {
// username = data.username; 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) { 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 { key: appKey, version } = microApp;
const check = await appPathCheck({ key: key }); const check = await appPathCheck({ key: key });

View File

@ -25,7 +25,7 @@ export const installAppFromKey = async (key: string) => {
} }
let showAppInfo = { let showAppInfo = {
key, key,
status: 'inactive', status: 'inactive' as const,
type: app?.type || 'system-app', type: app?.type || 'system-app',
description: readmeDesc || '', description: readmeDesc || '',
version, version,