chore: 新增一批接口
This commit is contained in:
21
apps/designer/src/io/api.ts
Normal file
21
apps/designer/src/io/api.ts
Normal 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;
|
||||
};
|
||||
21
apps/designer/src/io/application.ts
Normal file
21
apps/designer/src/io/application.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import instance from './instance';
|
||||
|
||||
export const getApplicationList = async () => {
|
||||
const response = await instance.get('/api/v1/application');
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createApplication = async (data: any) => {
|
||||
const response = await instance.post('/api/v1/application', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const updateApplication = async (id: string, data: any) => {
|
||||
const response = await instance.put(`/api/v1/application/${id}`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const deleteApplication = async (id: string) => {
|
||||
const response = await instance.delete(`/api/v1/application/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
21
apps/designer/src/io/block.ts
Normal file
21
apps/designer/src/io/block.ts
Normal 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;
|
||||
};
|
||||
21
apps/designer/src/io/file.ts
Normal file
21
apps/designer/src/io/file.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import instance from './instance';
|
||||
|
||||
export const getFileList = async () => {
|
||||
const response = await instance.get('/api/v1/file');
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createFile = async (data: any) => {
|
||||
const response = await instance.post('/api/v1/file', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const updateFile = async (id: string, data: any) => {
|
||||
const response = await instance.put(`/api/v1/file/${id}`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const deleteFile = async (id: string) => {
|
||||
const response = await instance.delete(`/api/v1/file/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
21
apps/designer/src/io/history.ts
Normal file
21
apps/designer/src/io/history.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import instance from './instance';
|
||||
|
||||
export const getMaterialsList = async () => {
|
||||
const response = await instance.get('/api/v1/histories');
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createMaterials = async (data: any) => {
|
||||
const response = await instance.post('/api/v1/histories', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const updateMaterials = async (id: string, data: any) => {
|
||||
const response = await instance.put(`/api/v1/histories/${id}`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const deleteMaterials = async (id: string) => {
|
||||
const response = await instance.delete(`/api/v1/histories/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
6
apps/designer/src/io/index.ts
Normal file
6
apps/designer/src/io/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './api';
|
||||
export * from './block';
|
||||
export * from './file';
|
||||
export * from './materials';
|
||||
export * from './project';
|
||||
export * from './application';
|
||||
30
apps/designer/src/io/instance.ts
Normal file
30
apps/designer/src/io/instance.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const baseApiUrl = 'https://custom-chart-pre-api.shiyue.com/';
|
||||
|
||||
// 创建独立实例
|
||||
const instance = axios.create({
|
||||
baseURL: baseApiUrl // 基础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;
|
||||
23
apps/designer/src/io/materials.ts
Normal file
23
apps/designer/src/io/materials.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import instance from './instance';
|
||||
|
||||
export const getMaterialsList = async (data?: Record<string, any>) => {
|
||||
const response = await instance.get('/api/v1/materials', {
|
||||
params: data
|
||||
});
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const createMaterials = async (data: any) => {
|
||||
const response = await instance.post('/api/v1/materials', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const updateMaterials = async (id: string, data: any) => {
|
||||
const response = await instance.put(`/api/v1/materials/${id}`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const deleteMaterials = async (id: string) => {
|
||||
const response = await instance.delete(`/api/v1/materials/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
28
apps/designer/src/io/project.ts
Normal file
28
apps/designer/src/io/project.ts
Normal 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;
|
||||
};
|
||||
@@ -12,8 +12,7 @@ import {
|
||||
} from '@vtj/core';
|
||||
import { Storage, mapToObject } from '@vtj/utils';
|
||||
import { BaseService } from '@vtj/renderer';
|
||||
import { debounce } from 'licia-es';
|
||||
|
||||
import { getProject } from '@/io';
|
||||
const storage = new Storage({
|
||||
type: 'local',
|
||||
expired: 0
|
||||
@@ -21,14 +20,20 @@ const storage = new Storage({
|
||||
});
|
||||
|
||||
export class StorageService extends BaseService {
|
||||
public init(project: ProjectSchema): Promise<ProjectSchema> {
|
||||
console.log('init-project', project);
|
||||
const model = new ProjectModel(project);
|
||||
// console.log('init-project-model', model);
|
||||
const match = storage.get(`project_${model.id}`);
|
||||
console.log('init-project-match', match);
|
||||
const dsl = Object.assign(model.toDsl(), match || {});
|
||||
console.log('init-project-dsl', dsl);
|
||||
public async init(project: ProjectSchema): Promise<ProjectSchema> {
|
||||
// console.log('init-project', project);
|
||||
// const model = new ProjectModel(project);
|
||||
// // console.log('init-project-model', model);
|
||||
// const match = storage.get(`project_${model.id}`);
|
||||
// console.log('init-project-match', match);
|
||||
// const dsl = Object.assign(model.toDsl(), match || {});
|
||||
// console.log('init-project-dsl', dsl);
|
||||
// storage.save(`project_${model.id}`, dsl);
|
||||
|
||||
const remoteProject = await getProject(3);
|
||||
const model = new ProjectModel(remoteProject);
|
||||
const dsl = model.toDsl();
|
||||
console.log('dsl', dsl);
|
||||
storage.save(`project_${model.id}`, dsl);
|
||||
return Promise.resolve(dsl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user