From 7b25dbdf08b667d9e43c1a9fdbb6449408340aee Mon Sep 17 00:00:00 2001 From: xion Date: Sat, 8 Mar 2025 22:44:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0public=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/app.ts | 1 + src/models/user.ts | 2 +- src/routes-simple/minio/download.ts | 18 ++++++++++++++++++ src/routes/app-manager/index.ts | 2 ++ src/routes/app-manager/module/app.ts | 1 + src/routes/app-manager/public/index.ts | 1 + src/routes/app-manager/public/list.ts | 19 +++++++++++++++++++ 8 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/routes-simple/minio/download.ts create mode 100644 src/routes/app-manager/public/index.ts create mode 100644 src/routes/app-manager/public/list.ts diff --git a/package.json b/package.json index 0783f4b..3d808eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/code-center", - "version": "0.0.6-alpha.2", + "version": "0.0.6-alpha.3", "description": "code center", "type": "module", "main": "index.js", diff --git a/src/app.ts b/src/app.ts index 3a554c2..3224644 100644 --- a/src/app.ts +++ b/src/app.ts @@ -18,6 +18,7 @@ const init = () => { cors: { origin: '*', }, + // httpType: 'https', }, io: true, routerContext: { diff --git a/src/models/user.ts b/src/models/user.ts index bd38364..b72bd4b 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -291,7 +291,7 @@ import { User, UserInit, UserServices } from '@kevisual/code-center-module/model export { User, UserInit, UserServices }; UserInit(null, null, { alter: true, - logging: true, + logging: false, }).catch((e) => { console.error('User sync', e); }); diff --git a/src/routes-simple/minio/download.ts b/src/routes-simple/minio/download.ts new file mode 100644 index 0000000..f1de090 --- /dev/null +++ b/src/routes-simple/minio/download.ts @@ -0,0 +1,18 @@ +import { minioClient } from '@/app.ts'; +import { bucketName } from '@/modules/minio.ts'; + +import { router } from '../router.ts'; + +router.post('/api/minio', async (ctx) => { + let { username, appKey } = { username: '', appKey: '' }; + const path = `${username}/${appKey}`; + const res = await minioClient.listObjects(bucketName, path, true); + const file = res.filter((item) => item.isFile); + const fileList = file.map((item) => { + return { + name: item.name, + size: item.size, + }; + }); + // ctx.body = fileList; +}); diff --git a/src/routes/app-manager/index.ts b/src/routes/app-manager/index.ts index 3ba08bb..c51882c 100644 --- a/src/routes/app-manager/index.ts +++ b/src/routes/app-manager/index.ts @@ -1,4 +1,6 @@ import './list.ts'; import './user-app.ts'; +import './public/index.ts'; + export * from './module/index.ts'; diff --git a/src/routes/app-manager/module/app.ts b/src/routes/app-manager/module/app.ts index 644ca54..46beeb5 100644 --- a/src/routes/app-manager/module/app.ts +++ b/src/routes/app-manager/module/app.ts @@ -33,6 +33,7 @@ export class AppModel extends Model { declare type: string; declare uid: string; declare pid: string; + // 是否是history路由代理模式。静态的直接转minio,而不需要缓存下来。 declare proxy: boolean; declare user: string; declare status: string; diff --git a/src/routes/app-manager/public/index.ts b/src/routes/app-manager/public/index.ts new file mode 100644 index 0000000..83ec5cd --- /dev/null +++ b/src/routes/app-manager/public/index.ts @@ -0,0 +1 @@ +import './list.ts'; diff --git a/src/routes/app-manager/public/list.ts b/src/routes/app-manager/public/list.ts new file mode 100644 index 0000000..9856112 --- /dev/null +++ b/src/routes/app-manager/public/list.ts @@ -0,0 +1,19 @@ +import { app } from '@/app.ts'; +import { AppModel } from '../module/index.ts'; + +// curl http://localhost:4005/api/router?path=app&key=public-list +app + .route({ + path: 'app', + key: 'public-list', + }) + .define(async (ctx) => { + const list = await AppModel.findAll({ + where: { + status: 'running', + }, + logging: false, + }); + ctx.body = list; + }) + .addTo(app);