This commit is contained in:
2025-12-03 16:40:46 +08:00
parent 31bc2a5576
commit 98f68fe300
6 changed files with 62 additions and 42 deletions

View File

@@ -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',
});
});

View File

@@ -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 {

View File

@@ -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: '' },
}
];

22
src/test/create-bucket.ts Normal file
View File

@@ -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)
})