diff --git a/package.json b/package.json index 73d0c94..8392da5 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "basename": "/root/code-center", "app": { "type": "pm2-system-app", - "key": "code-center", "entry": "./app.js", "runtime": [ "client" @@ -44,6 +43,7 @@ ], "license": "UNLICENSED", "dependencies": { + "@kevisual/ai": "^0.0.12", "@types/busboy": "^1.5.4", "@types/send": "^1.2.1", "@types/ws": "^8.18.1", @@ -61,7 +61,7 @@ "@kevisual/code-center-module": "0.0.24", "@kevisual/context": "^0.0.4", "@kevisual/file-listener": "^0.0.2", - "@kevisual/local-app-manager": "0.1.27", + "@kevisual/local-app-manager": "0.1.32", "@kevisual/logger": "^0.0.4", "@kevisual/oss": "0.0.12", "@kevisual/permission": "^0.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5420017..88fb64b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,6 +12,9 @@ importers: .: dependencies: + '@kevisual/ai': + specifier: ^0.0.12 + version: 0.0.12 '@types/busboy': specifier: ^1.5.4 version: 1.5.4 @@ -59,8 +62,8 @@ importers: specifier: ^0.0.2 version: 0.0.2(dotenv@17.2.3) '@kevisual/local-app-manager': - specifier: 0.1.27 - version: 0.1.27 + specifier: 0.1.32 + version: 0.1.32 '@kevisual/logger': specifier: ^0.0.4 version: 0.0.4 @@ -152,7 +155,7 @@ importers: specifier: ^4.1.13 version: 4.1.13 - wxmsg: + wxmsg/pack-dist: dependencies: '@kevisual/context': specifier: ^0.0.4 @@ -169,13 +172,6 @@ importers: xml2js: specifier: ^0.6.2 version: 0.6.2 - devDependencies: - '@types/crypto-js': - specifier: ^4.2.2 - version: 4.2.2 - '@types/xml2js': - specifier: ^0.4.14 - version: 0.4.14 packages: @@ -190,6 +186,9 @@ packages: resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==} engines: {node: '>=18.0.0'} + '@kevisual/ai@0.0.12': + resolution: {integrity: sha512-c02ozy4B+1utJsjQee4nnQZ2vDKTMDYJxbya5CIpghm+ujs7jSiB05cyIREELAHErSOzJUQXlHC3Dr8rdb5F0A==} + '@kevisual/auth@1.0.5': resolution: {integrity: sha512-GwsLj7unKXi7lmMiIIgdig4LwwLiDJnOy15HHZR5gMbyK6s5/uJiMY5RXPB2+onGzTNDqFo/hXjsD2wkerHPVg==} @@ -208,8 +207,8 @@ packages: '@kevisual/load@0.0.6': resolution: {integrity: sha512-+3YTFehRcZ1haGel5DKYMUwmi5i6f2psyaPZlfkKU/cOXgkpwoG9/BEqPCnPjicKqqnksEpixVRkyHJ+5bjLVA==} - '@kevisual/local-app-manager@0.1.27': - resolution: {integrity: sha512-pOSqdo08ajwJuwQWOI2AHMSk/5MovEYRZro0cs0weJlc0ApB0qQYTtZnSlg0s+X3DbpTMMdXBwfB0+60wF5MzA==} + '@kevisual/local-app-manager@0.1.32': + resolution: {integrity: sha512-G1pvemOrw7BB2BQ27AIPPWM+VNOtc5/6pHB3Dx01UGJV27nCc2dpHDc+GEIM7GM1jSJ5OYyL+fbB6lVB595cog==} '@kevisual/logger@0.0.4': resolution: {integrity: sha512-+fpr92eokSxoGOW1SIRl/27lPuO+zyY+feR5o2Q4YCNlAdt2x64NwC/w8r/3NEC5QenLgd4K0azyKTI2mHbARw==} @@ -334,9 +333,6 @@ packages: '@types/ws@8.18.1': resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} - '@types/xml2js@0.4.14': - resolution: {integrity: sha512-4YnrRemBShWRO2QjvUin8ESA41rH+9nQGLUGZV/1IDhi3SL9OhdpNC/MrulTWuptXKwhx/aDxE7toV0f/ypIXQ==} - '@zxing/text-encoding@0.9.0': resolution: {integrity: sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==} @@ -1669,10 +1665,6 @@ packages: utf-8-validate: optional: true - xml2js@0.5.0: - resolution: {integrity: sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==} - engines: {node: '>=4.0.0'} - xml2js@0.6.2: resolution: {integrity: sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==} engines: {node: '>=4.0.0'} @@ -1719,6 +1711,10 @@ snapshots: dependencies: minipass: 7.1.2 + '@kevisual/ai@0.0.12': + dependencies: + '@kevisual/logger': 0.0.4 + '@kevisual/auth@1.0.5': {} '@kevisual/code-center-module@0.0.20(dotenv@17.2.3)': @@ -1803,7 +1799,7 @@ snapshots: dependencies: eventemitter3: 5.0.1 - '@kevisual/local-app-manager@0.1.27': + '@kevisual/local-app-manager@0.1.32': dependencies: pm2: 6.0.14 transitivePeerDependencies: @@ -1978,10 +1974,6 @@ snapshots: dependencies: '@types/node': 24.10.1 - '@types/xml2js@0.4.14': - dependencies: - '@types/node': 24.10.1 - '@zxing/text-encoding@0.9.0': optional: true @@ -2219,10 +2211,6 @@ snapshots: dependencies: ms: 2.1.3 - debug@4.4.3: - dependencies: - ms: 2.1.3 - debug@4.4.3(supports-color@5.5.0): dependencies: ms: 2.1.3 @@ -2666,7 +2654,7 @@ snapshots: stream-json: 1.8.0 through2: 4.0.2 web-encoding: 1.1.5 - xml2js: 0.5.0 + xml2js: 0.6.2 minipass@7.1.2: {} @@ -3027,7 +3015,7 @@ snapshots: send@1.2.0: dependencies: - debug: 4.4.3 + debug: 4.4.3(supports-color@5.5.0) encodeurl: 2.0.0 escape-html: 1.0.3 etag: 1.8.1 @@ -3334,11 +3322,6 @@ snapshots: ws@8.17.1: {} - xml2js@0.5.0: - dependencies: - sax: 1.4.1 - xmlbuilder: 11.0.1 - xml2js@0.6.2: dependencies: sax: 1.4.1 diff --git a/src/app.ts b/src/app.ts index 2873cee..0a6d572 100644 --- a/src/app.ts +++ b/src/app.ts @@ -5,6 +5,8 @@ import * as sequelizeLib from './modules/sequelize.ts'; import { useContextKey } from '@kevisual/context'; import { SimpleRouter } from '@kevisual/router/simple'; import { OssBase } from '@kevisual/oss/services'; +import { BailianProvider } from '@kevisual/ai'; + export const router = useContextKey('router', () => new SimpleRouter()); export const runtime = useContextKey('runtime', () => { return { @@ -41,3 +43,10 @@ const init = () => { }); }; export const app = useContextKey('app', init); + +export const ai = useContextKey('ai', () => { + return new BailianProvider({ + apiKey: process.env.BAILIAN_API_KEY || '', + model: 'qwen-turbo', + }); +}); \ No newline at end of file diff --git a/src/routes/config/list.ts b/src/routes/config/list.ts index d22c17d..5ea0206 100644 --- a/src/routes/config/list.ts +++ b/src/routes/config/list.ts @@ -168,11 +168,12 @@ app .define(async (ctx) => { const tokernUser = ctx.state.tokenUser; const tuid = tokernUser.id; - const { id } = ctx.query?.data || {}; - if (id) { + const { id, key } = ctx.query?.data || {}; + if (id || key) { + const search: any = id ? { id } : { key }; const config = await ConfigModel.findOne({ where: { - id, + ...search }, }); if (config && config.uid === tuid) { @@ -186,7 +187,7 @@ app if (ossConfig.isEndWithJson(key)) { try { await ossConfig.deleteObject(key); - } catch (e) {} + } catch (e) { } } await config.destroy(); } else { diff --git a/src/routes/config/models/default-keys.ts b/src/routes/config/models/default-keys.ts index 31060c3..aa70ea3 100644 --- a/src/routes/config/models/default-keys.ts +++ b/src/routes/config/models/default-keys.ts @@ -28,6 +28,11 @@ export const defaultKeys = [ { key: 'user.json', description: '用户配置', - data: { key: 'user', version: '1.0.0', redirectURL: '/root/center/' }, + data: { key: 'user', version: '1.0.0', redirectURL: '/root/home/' }, }, + { + key: 'life.json', + description: '生活配置', + data: { baseId: '', tableId: '', baseURL: '' }, + } ]; diff --git a/src/test/create-bucket.ts b/src/test/create-bucket.ts new file mode 100644 index 0000000..7607028 --- /dev/null +++ b/src/test/create-bucket.ts @@ -0,0 +1,22 @@ +import { Client } from 'minio' + +export async function createBucket(client: Client, bucketName: string) { + const exists = await client.bucketExists(bucketName) + if (!exists) { + await client.makeBucket(bucketName, '') + console.log(`Bucket "${bucketName}" created successfully.`) + } else { + console.log(`Bucket "${bucketName}" already exists.`) + } +} + +const minioClient = new Client({ + endPoint: 'minio.kevisual.cn', + port: 9000, + useSSL: false, + accessKey: 'admin', + secretKey: 'xiongxiao', +}) +createBucket(minioClient, 'nocodb').catch((err) => { + console.error('Error creating bucket:', err) +}) \ No newline at end of file