chore: 更新低代码引擎依赖,file 增删改查完成
This commit is contained in:
parent
9e012947fb
commit
384ea1f547
1
README.md
Normal file
1
README.md
Normal file
@ -0,0 +1 @@
|
||||
低代码相关接口文档: https://developer.shiyuegame.com/showdoc/web/#/231?page_id=15660
|
@ -16,22 +16,22 @@
|
||||
"clean": "rimraf node_modules"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vtj/core": "^0.10.5",
|
||||
"@vtj/designer": "0.10.5",
|
||||
"@vtj/icons": "0.10.5",
|
||||
"@vtj/local": "^0.10.5",
|
||||
"@vtj/materials": "^0.10.5",
|
||||
"@vtj/core": "^0.10.6",
|
||||
"@vtj/designer": "0.10.6",
|
||||
"@vtj/icons": "0.10.6",
|
||||
"@vtj/local": "^0.10.6",
|
||||
"@vtj/materials": "^0.10.6",
|
||||
"@vtj/node": "0.10.1",
|
||||
"@vtj/pro": "^0.10.5",
|
||||
"@vtj/renderer": "^0.10.5",
|
||||
"@vtj/ui": "^0.10.5",
|
||||
"@vtj/utils": "0.10.5",
|
||||
"@vtj/web": "^0.10.5",
|
||||
"@vtj/pro": "^0.10.6",
|
||||
"@vtj/renderer": "^0.10.6",
|
||||
"@vtj/ui": "^0.10.6",
|
||||
"@vtj/utils": "0.10.6",
|
||||
"@vtj/web": "^0.10.6",
|
||||
"axios": "^1.8.1",
|
||||
"element-plus": "^2.9.4",
|
||||
"licia-es": "^1.46.0",
|
||||
"vue": "~3.5.13",
|
||||
"vue-router": "~4.5.0",
|
||||
"axios": "^1.8.1"
|
||||
"vue-router": "~4.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sy/vite-plugin-http2-proxy": "workspace:*",
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -12,7 +12,15 @@ import {
|
||||
} from '@vtj/core';
|
||||
import { Storage, mapToObject } from '@vtj/utils';
|
||||
import { BaseService } from '@vtj/renderer';
|
||||
import { getProject, updateProject } from '@/io';
|
||||
import {
|
||||
getProject,
|
||||
updateProject,
|
||||
createFile,
|
||||
updateFile as updateLowCodeFile,
|
||||
getFile as getLowCodeFile,
|
||||
type LowCodeFileSchema
|
||||
} from '@/io';
|
||||
import { isNumeric } from 'licia-es';
|
||||
const storage = new Storage({
|
||||
type: 'local',
|
||||
expired: 0
|
||||
@ -80,17 +88,55 @@ export class StorageService extends BaseService {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public saveFile(file: BlockSchema): Promise<boolean> {
|
||||
storage.save(`file_${file.id}`, file);
|
||||
console.log('saveFile', file);
|
||||
public async saveFile(file: BlockSchema): Promise<boolean> {
|
||||
// console.log('file', file);
|
||||
// const ACTION = {
|
||||
// CREATE: 'create',
|
||||
// UPDATE: 'update'
|
||||
// };
|
||||
// const action = isNumeric(file.id) ? ACTION.UPDATE : ACTION.CREATE;
|
||||
// console.log('action', action);
|
||||
// console.log('saveFile', file);
|
||||
// if (action === ACTION.CREATE) {
|
||||
// const newFile: LowCodeFileSchema = {
|
||||
// project_id: 2,
|
||||
// publish: false,
|
||||
// active: true,
|
||||
// dsl: file
|
||||
// };
|
||||
// Reflect.deleteProperty(newFile, 'id');
|
||||
// const res = await createFile(newFile);
|
||||
// console.log('saveFile-res', res);
|
||||
// }
|
||||
if (file.id) {
|
||||
const existFile = await getLowCodeFile(file.id);
|
||||
console.log('existFile', existFile);
|
||||
if (existFile) {
|
||||
await updateLowCodeFile(file.id, {
|
||||
...existFile,
|
||||
dsl: file
|
||||
});
|
||||
} else {
|
||||
await createFile({
|
||||
project_id: 2,
|
||||
publish: false,
|
||||
active: true,
|
||||
dsl: file
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// storage.save(`file_${file.id}`, file);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public getFile(id: string): Promise<BlockSchema> {
|
||||
public async getFile(id: string): Promise<BlockSchema> {
|
||||
const dsl = storage.get(`file_${id}`);
|
||||
console.log('getFile', id, dsl);
|
||||
if (dsl) {
|
||||
return Promise.resolve(dsl as BlockSchema);
|
||||
const lowCodeFile = await getLowCodeFile(id);
|
||||
console.log('lowCodeFile', lowCodeFile);
|
||||
if (lowCodeFile.dsl) {
|
||||
return Promise.resolve(lowCodeFile.dsl as BlockSchema);
|
||||
} else {
|
||||
return Promise.reject(null);
|
||||
}
|
||||
|
@ -16,17 +16,17 @@
|
||||
"@iframe-resizer/child": "^5.3.3",
|
||||
"@sy/low-code-shared": "workspace:*",
|
||||
"@sy/web-vitals": "workspace:*",
|
||||
"@vtj/core": "^0.10.5",
|
||||
"@vtj/icons": "0.10.5",
|
||||
"@vtj/materials": "^0.10.5",
|
||||
"@vtj/renderer": "^0.10.5",
|
||||
"@vtj/core": "^0.10.6",
|
||||
"@vtj/icons": "0.10.6",
|
||||
"@vtj/materials": "^0.10.6",
|
||||
"@vtj/renderer": "^0.10.6",
|
||||
"axios": "^1.8.1",
|
||||
"core-js": "^3.40.0",
|
||||
"element-plus": "^2.9.4",
|
||||
"licia-es": "^1.46.0",
|
||||
"postmate": "^1.5.2",
|
||||
"rrweb": "2.0.0-alpha.4",
|
||||
"vue": "^3.5.13",
|
||||
"axios": "^1.8.1"
|
||||
"vue": "^3.5.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@farmfe/cli": "^1.0.4",
|
||||
|
791
pnpm-lock.yaml
generated
791
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user