feat: 低代码平台增加应用列表

This commit is contained in:
wangxuefeng
2025-03-04 14:46:19 +08:00
parent 09ff94c188
commit 6fc133bb7d
24 changed files with 798 additions and 785 deletions

View File

@@ -1,9 +0,0 @@
[*.{js, jsx, ts, tsx, vue, mjs}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
ij_javascript_spaces_within_imports = true
ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot, script
ij_javascript_space_before_function_left_parenth = true
ij_javascript_use_semicolon_after_statement = true

View File

@@ -6,5 +6,6 @@ VITE_BASE_URL = /
# 前端可见变量(必须以 VITE_ 开头)
VITE_PORT = 10011
VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
# VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
VITE_BASE_API_URL = 'https://custom-chart-api.shiyuegame.com/'
VITE_DEBUG_MODE = true

View File

@@ -13,17 +13,17 @@
"clean": "rimraf node_modules"
},
"dependencies": {
"@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.6",
"@vtj/renderer": "^0.10.6",
"@vtj/ui": "^0.10.6",
"@vtj/utils": "0.10.6",
"@vtj/web": "^0.10.6",
"@vtj/core": "^0.10.7",
"@vtj/designer": "0.10.7",
"@vtj/icons": "0.10.7",
"@vtj/local": "^0.10.7",
"@vtj/materials": "^0.10.7",
"@vtj/node": "0.10.2",
"@vtj/pro": "^0.10.7",
"@vtj/renderer": "^0.10.7",
"@vtj/ui": "^0.10.7",
"@vtj/utils": "0.10.7",
"@vtj/web": "^0.10.7",
"axios": "^1.8.1",
"element-plus": "^2.9.4",
"licia-es": "^1.46.0",
@@ -35,7 +35,7 @@
},
"devDependencies": {
"@sy/vite-plugin-http2-proxy": "workspace:*",
"@vtj/cli": "^0.10.1",
"@vtj/cli": "^0.10.2",
"vite": "^6.2.0",
"vite-plugin-mkcert": "^1.17.6",
"vitest": "^3.0.7"

View File

@@ -1,21 +1,21 @@
import instance from './instance';
export const getApplicationList = async () => {
const response = await instance.get('/api/v1/application');
const response = await instance.get('/api/v1/applications');
return response.data;
};
export const createApplication = async (data: any) => {
const response = await instance.post('/api/v1/application', data);
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/application/${id}`, data);
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/application/${id}`);
const response = await instance.delete(`/api/v1/applications/${id}`);
return response.data;
};

View File

@@ -84,6 +84,19 @@ export const postMaterials = async (
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

View File

@@ -14,6 +14,7 @@ import {
} from '@vtj/core';
import { mapToObject, Storage } from '@vtj/utils';
import { BaseService } from '@vtj/renderer';
import { isEmpty } from 'licia-es';
import {
getProject,
updateProject,
@@ -29,6 +30,7 @@ import {
publishAllFile as publishLowCodeAllFile,
getMaterials as getLowCodeMaterials,
postMaterials as postLowCodeMaterials,
updateMaterials as updateLowCodeMaterials,
deleteMaterials as deleteLowCodeMaterials
} from '@/io';
const storage = new Storage({
@@ -45,10 +47,22 @@ const stringifyFields = [
'meta'
];
let initProject: ProjectSchema;
export class LowCodeService extends BaseService {
public async init(project: ProjectSchema): Promise<ProjectSchema> {
const remoteProject = await getProject('2');
console.log('init', project);
initProject = project;
const remoteProject = await getProject(initProject.id);
const arrayFields = ['pages', 'blocks', 'apis', 'meta', 'dependencies'];
arrayFields.forEach((field) => {
if (isEmpty(remoteProject[field])) {
remoteProject[field] = [];
}
});
console.log('remoteProject', remoteProject);
const model = new ProjectModel(remoteProject);
console.log('model', model || { id: initProject.id });
const dsl = model.toDsl();
return Promise.resolve(dsl);
}
@@ -68,7 +82,9 @@ export class LowCodeService extends BaseService {
.map(([key, value]) => [key, JSON.stringify(value)])
)
};
await updateProject('2', newProject);
// 剔除引擎自行添加的 id避免接口更新冲突报错
Reflect.deleteProperty(newProject, 'id');
await updateProject(initProject.id, newProject);
return Promise.resolve(true);
}
@@ -88,17 +104,27 @@ export class LowCodeService extends BaseService {
// console.log('saveMaterials', materialData);
// @ts-ignore
const existMaterials = await getLowCodeMaterials(project?.id);
console.log('existMaterials', existMaterials);
await postLowCodeMaterials({
project_id: project?.id,
value: materialData
});
if (existMaterials) {
// 更新物料
await updateLowCodeMaterials({
project_id: project?.id,
value: materialData
});
} else {
// 创建物料
await postLowCodeMaterials({
project_id: project?.id,
value: materialData
});
}
// @ts-ignore
await deleteLowCodeMaterials(project.id);
// await deleteLowCodeMaterials(project.id);
return Promise.resolve(true);
}
public async saveFile(file: BlockSchema): Promise<boolean> {
console.log('saveFile', file);
if (file.id) {
const existFile = await getLowCodeFile(file.id);
if (existFile.file_id) {
@@ -114,7 +140,7 @@ export class LowCodeService extends BaseService {
});
} else {
return createFile({
project_id: 2,
project_id: initProject.id,
publish: false,
active: true,
dsl: file,
@@ -166,7 +192,7 @@ export class LowCodeService extends BaseService {
public async getHistory(fileId: string): Promise<HistorySchema> {
const histories = await getLowCodeHistories({
project_id: 2,
project_id: initProject.id,
file_id: fileId,
per_page: 50
});
@@ -194,7 +220,7 @@ export class LowCodeService extends BaseService {
historyItem: HistoryItem
): Promise<boolean> {
await createLowCodeHistory({
project_id: 2,
project_id: initProject.id,
file_id: fileId,
history_id: historyItem.id,
dsl: historyItem.dsl as HistorySchema
@@ -217,7 +243,6 @@ export class LowCodeService extends BaseService {
file: PageFile | BlockFile
): Promise<boolean> {
return publishLowCodeFile(file.id).then((res) => {
console.log('发布页面', res);
return Promise.resolve(true);
});
}

View File

@@ -19,8 +19,9 @@ const engine = new Engine({
container,
service,
project: {
id: '2',
name: '测试'
// @ts-ignore
id: 4,
name: '低代码平台'
}
});

View File

@@ -11,7 +11,8 @@ const { provider, onReady } = createProvider({
mode: ContextMode.Runtime,
service,
project: {
id: '2'
// @ts-ignore
id: 4
},
dependencies: {
Vue: () => import('vue'),