From 7bbefd8a4a933a17bbf229a41fcf0dd627a55c20 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Thu, 5 Feb 2026 01:07:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E5=BA=94=E7=94=A8=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E6=A3=80=E6=B5=8B=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/app-manager/list.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/routes/app-manager/list.ts b/src/routes/app-manager/list.ts index 55ef75d..af92b53 100644 --- a/src/routes/app-manager/list.ts +++ b/src/routes/app-manager/list.ts @@ -6,6 +6,7 @@ import { getUidByUsername, prefixFix } from './util.ts'; import { deleteFiles, getMinioListAndSetToAppList } from '../file/index.ts'; import { setExpire } from './revoke.ts'; import { User } from '@/models/user.ts'; +import { callDetectAppVersion } from './export.ts'; app .route({ path: 'app', @@ -258,7 +259,7 @@ app }) .define(async (ctx) => { const tokenUser = ctx.state.tokenUser; - const { id, username, appKey, version } = ctx.query.data; + const { id, username, appKey, version, detect } = ctx.query.data; if (!id && !appKey) { throw new CustomError('id or appKey is required'); } @@ -268,22 +269,31 @@ app if (id) { appList = await AppListModel.findByPk(id); if (appList?.uid !== uid) { - throw new CustomError('no permission'); + ctx.throw('no permission'); } } if (!appList && appKey) { if (!version) { - throw new CustomError('version is required'); + ctx.throw('version is required'); } appList = await AppListModel.findOne({ where: { key: appKey, version, uid } }); } if (!appList) { - throw new CustomError('app not found'); + ctx.throw('app 未发现'); } + if (detect) { + // 自动检测最新版本 + const res = await callDetectAppVersion({ appKey, version, username: username || tokenUser.username }, ctx.query.token); + if (res.code !== 200) { + ctx.throw(res.message || '检测版本列表失败'); + } + appList = await AppListModel.findByPk(appList.id); + } + const files = appList.data.files || []; const am = await AppModel.findOne({ where: { key: appList.key, uid: uid } }); if (!am) { - throw new CustomError('app not found'); + ctx.throw('app 未发现'); } await am.update({ data: { ...am.data, files }, version: appList.version }); setExpire(appList.key, am.user); @@ -385,7 +395,7 @@ app am = await AppModel.create({ title: appKey, key: appKey, - version: version || '0.0.0', + version: version || '0.0.1', user: checkUsername, uid, data: { files: needAddFiles },