chore: 容器框架升级,修复项目命令行异常问题
This commit is contained in:
76
apps/designer/src/io/history.ts
Normal file
76
apps/designer/src/io/history.ts
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user