chore: 更新低代码引擎依赖,file 增删改查完成

This commit is contained in:
wangxuefeng
2025-03-01 10:06:57 +08:00
parent 9e012947fb
commit 384ea1f547
6 changed files with 529 additions and 399 deletions

View File

@@ -1,21 +1,49 @@
import { type BlockSchema } from '@vtj/core';
import instance from './instance';
export type LowCodeFileSchema = {
project_id: number;
publish: boolean;
active: boolean;
dsl: BlockSchema;
file_path?: string;
};
function transformFile(file: LowCodeFileSchema): LowCodeFileSchema {
return {
project_id: file.project_id,
publish: file.publish,
active: file.active,
// @ts-ignore
dsl: JSON.stringify(file.dsl),
file_path: file.file_path
};
}
export const getFileList = async () => {
const response = await instance.get('/api/v1/file');
const response = await instance.get('/api/v1/files');
return response.data;
};
export const createFile = async (data: any) => {
const response = await instance.post('/api/v1/file', data);
export const getFile = async (id: string) => {
const response = await instance.get(`/api/v1/files/${id}`);
return {
...response.data,
dsl: JSON.parse(response.data.dsl)
};
};
export const createFile = async (data: LowCodeFileSchema) => {
const response = await instance.post('/api/v1/files', transformFile(data));
return response.data;
};
export const updateFile = async (id: string, data: any) => {
const response = await instance.put(`/api/v1/file/${id}`, data);
export const updateFile = async (id: string, data: LowCodeFileSchema) => {
const response = await instance.put(`/api/v1/files/${id}`, data);
return response.data;
};
export const deleteFile = async (id: string) => {
const response = await instance.delete(`/api/v1/file/${id}`);
const response = await instance.delete(`/api/v1/files/${id}`);
return response.data;
};