chore: 容器框架升级,修复项目命令行异常问题

This commit is contained in:
wangxuefeng
2025-03-11 10:05:28 +08:00
parent de679d4289
commit 3e1a1b4a66
1187 changed files with 95352 additions and 12509 deletions

View File

@@ -0,0 +1,21 @@
import instance from './instance';
export const getApiList = async () => {
const response = await instance.get('/api/v1/api');
return response.data;
};
export const createApi = async (data: any) => {
const response = await instance.post('/api/v1/api', data);
return response.data;
};
export const updateApi = async (id: string, data: any) => {
const response = await instance.put(`/api/v1/api/${id}`, data);
return response.data;
};
export const deleteApi = async (id: string) => {
const response = await instance.delete(`/api/v1/api/${id}`);
return response.data;
};

View File

@@ -0,0 +1,21 @@
import instance from './instance';
export const getApplicationList = async () => {
const response = await instance.get('/api/v1/applications');
return response.data;
};
export const createApplication = async (data: any) => {
const response = await instance.post('/api/v1/applications', data);
return response.data;
};
export const updateApplication = async (id: string, data: any) => {
const response = await instance.put(`/api/v1/applications/${id}`, data);
return response.data;
};
export const deleteApplication = async (id: string) => {
const response = await instance.delete(`/api/v1/applications/${id}`);
return response.data;
};

View File

@@ -0,0 +1,21 @@
import instance from './instance';
export const getBlockList = async () => {
const response = await instance.get('/api/v1/blocks');
return response.data;
};
export const createBlock = async (data: any) => {
const response = await instance.post('/api/v1/blocks', data);
return response.data;
};
export const updateBlock = async (id: string, data: any) => {
const response = await instance.put(`/api/v1/blocks/${id}`, data);
return response.data;
};
export const deleteBlock = async (id: string) => {
const response = await instance.delete(`/api/v1/blocks/${id}`);
return response.data;
};

View File

@@ -0,0 +1,91 @@
import { type BlockSchema } from '@vtj/core';
import instance from './instance';
import { fi } from 'element-plus/es/locale/index.mjs';
export type LowCodeFileSchema = {
project_id: number;
publish: boolean;
active: boolean;
dsl: BlockSchema;
file_path?: string;
file_id?: 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,
file_id: file.file_id
};
}
export const getFileList = async () => {
const response = await instance.get('/api/v1/files');
return response.data;
};
export const getFile = async (id: string) => {
const response = await instance.get(`/api/v1/files/${id}`);
return response.data;
};
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: LowCodeFileSchema) => {
const response = await instance.put(
`/api/v1/files/${id}`,
transformFile(data)
);
return response.data;
};
type PublishResponse = {
code: string;
data: object;
id?: string;
message: string;
};
export const deleteFile = async (id: string) => {
const response = await instance.delete(`/api/v1/files/${id}`);
return response.data;
};
/**
* 发布指定项目的所有文件
* @param {number} projectId - 需要发布的项目ID
* @returns {Promise<any>} 包含发布操作结果的Promise对象
* @example
* // 发布项目ID为123的所有文件
* await publishAllFile(123)
*/
export const publishAllFile = async (
projectId: number
): Promise<PublishResponse> => {
const response = await instance.post('/api/v1/files/publish', {
project_id: projectId
});
return response.data;
};
/**
* 发布单个文件
* @param {string} fileId - 需要发布的文件ID
* @returns {Promise<any>} 包含发布操作结果的Promise对象
* @example
* // 发布文件ID为45tnbgeme的文件
* await publishFile('45tnbgeme')
*/
export const publishFile = async (fileId: string): Promise<PublishResponse> => {
const response = await instance.post('/api/v1/files/publish-file', {
file_id: fileId
});
return response.data;
};

View File

@@ -0,0 +1,76 @@
import instance from './instance';
import { type HistorySchema } from '@vtj/core';
export type LowCodeHistorySchema = {
project_id: number;
file_id: string;
history_id: string;
id?: string;
dsl?: HistorySchema;
};
function transformHistoryData(data: LowCodeHistorySchema) {
return {
...data,
dsl: JSON.stringify(data.dsl || {})
};
}
export type HistoriesResponse = {
code: number;
data: {
list: Array<{
id: number;
project_id: number;
file_id: string;
history_id: string;
dsl: Record<string, any>;
created_at: string;
updated_at: string;
}>;
total: number;
};
message: string;
};
export type GetHistoriesParams = {
project_id: number;
file_id: string;
page?: number;
per_page?: number;
};
export const getHistories = async (params: GetHistoriesParams) => {
const response = await instance.get<HistoriesResponse>('/api/v1/histories', {
params: {
project_id: params.project_id,
file_id: params.file_id,
...(params.page && { page: params.page }),
...(params.per_page && { per_page: params.per_page })
}
});
return response.data;
};
export const getHistory = async (id: string) => {
const response = await instance.get(`/api/v1/histories/${id}`);
return response.data;
};
export const createHistory = async (data: LowCodeHistorySchema) => {
const response = await instance.post(
'/api/v1/histories',
transformHistoryData(data)
);
return response.data;
};
export const updateHistory = async (id: string, data: any) => {
const response = await instance.put(`/api/v1/histories/${id}`, data);
return response.data;
};
export const deleteHistory = async (id: string) => {
const response = await instance.delete(`/api/v1/histories/${id}`);
return response.data;
};

View File

@@ -0,0 +1,7 @@
export * from './api';
export * from './block';
export * from './file';
export * from './materials';
export * from './project';
export * from './application';
export * from './history';

View File

@@ -0,0 +1,30 @@
import axios from 'axios';
const apiBase = import.meta.env.VITE_BASE_API_URL;
// 创建独立实例
const instance = axios.create({
baseURL: apiBase // 基础URL直接放在实例配置中
});
// 请求拦截器改为使用实例
instance.interceptors.request.use(
(config) => {
// 可在此处添加统一请求头等配置
return config;
},
(error) => {
return Promise.reject(error);
}
);
instance.interceptors.response.use(
(response) => {
return response.data;
},
(error) => {
return Promise.reject(error);
}
);
// 导出实例
export default instance;

View File

@@ -0,0 +1,112 @@
import { type MaterialDescription } from '@vtj/core';
import instance from './instance';
// 定义响应类型
interface MaterialResponse {
code: number;
data: MaterialData | MaterialData[];
message: string;
}
/** 创建物料请求参数 */
interface CreateMaterialRequest {
project_id: number;
value: string;
}
/** 创建物料响应类型 */
interface CreateMaterialResponse {
code: number;
data: { id: string };
message: string;
}
/** 删除物料响应类型 */
interface DeleteMaterialResponse {
code: number;
data: { id: string };
message: string;
}
/**
* 获取物料列表
* @param params 查询参数
* @returns 物料列表
*/
export const getMaterialsList = async (
params?: Record<string, any>
): Promise<MaterialResponse> => {
const response = await instance.get('/api/v1/materials', { params });
return response.data;
};
/**
* 根据ID获取单个物料
* @param id 物料ID
* @returns 物料详情
*/
export const getMaterials = async (id: number): Promise<MaterialResponse> => {
const response = await instance.get(`/api/v1/materials/${id}`);
return response.data;
};
type MaterialData = {
project_id: number;
value: Record<string, MaterialDescription>;
// 从原interface合并的字段
id?: number;
name?: string;
created_at?: string;
updated_at?: string;
};
function transformMaterialData(data: MaterialData) {
return {
...data,
value: JSON.stringify(data.value)
};
}
/**
* 创建新物料
* @param data 物料数据(注意 value 需要是 JSON 字符串)
* @example
* postMaterials({ project_id: 1, value: '{"Authorization": "Bearer token"}' })
*/
export const postMaterials = async (
data: MaterialData
): Promise<CreateMaterialResponse> => {
const response = await instance.post(
'/api/v1/materials',
transformMaterialData(data)
);
return response.data;
};
/**
* 更新物料
* @param data 物料数据
* @returns 更新操作结果
*/
export const updateMaterials = async (data: MaterialData): Promise<any> => {
const response = await instance.put(
'/api/v1/materials',
transformMaterialData(data)
);
return response.data;
};
/**
* 删除指定物料
* @param project_id 要删除的物料所属项目ID
* @returns 删除操作结果
* @example
* deleteMaterial('123').then(() => console.log('删除成功'))
*/
export const deleteMaterials = async (
project_id: number
): Promise<DeleteMaterialResponse> => {
const response = await instance.delete(`/api/v1/materials/${project_id}`);
return response.data;
};

View File

@@ -0,0 +1,28 @@
import instance from './instance';
export const getProjectList = async (data?: Record<string, any>) => {
const response = await instance.get('/api/v1/projects', {
params: data
});
return response.data;
};
export const getProject = async (id: string) => {
const response = await instance.get(`/api/v1/projects/${id}`);
return response.data;
};
export const createProject = async (data: any) => {
const response = await instance.post('/api/v1/projects', data);
return response.data;
};
export const updateProject = async (id: string, data: any) => {
const response = await instance.put(`/api/v1/projects/${id}`, data);
return response.data;
};
export const deleteProject = async (id: string) => {
const response = await instance.delete(`/api/v1/projects/${id}`);
return response.data;
};