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);
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'),

View File

@ -6,5 +6,6 @@ VITE_BASE_URL = /
# 前端可见变量(必须以 VITE_ 开头)
VITE_PORT = 10010
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

@ -28,7 +28,11 @@
name: 'low-code-renderer',
classListArray: ['responsive-iframe'],
model: {
id: route.meta?.app?.url,
name: route.meta?.app?.name,
applicationId: route.meta?.app?.applicationId,
projectId: route.meta?.app?.projectId,
fileId: route.meta?.app?.fileId,
url: route.meta?.app?.url,
},
});

View File

@ -25,6 +25,9 @@ const routes: Array<RouteRecordRaw> = [
sync: true,
alive: true,
degrade: true,
applicationId: 0,
projectId: 4,
fileId: 'b91n1y9yr',
},
},
component: () => import('@/components/renderer-adapter/index.vue'),

View File

@ -3,7 +3,8 @@
import { getApplicationList, createApplication, deleteApplication } from '@/io';
const addData = {
name: 'test',
name: '低代码平台',
alias: 'low-code-platform',
active: true,
};

View File

@ -3,9 +3,10 @@
import { getProjectList, createProject, deleteProject } from '@/io';
const addData = {
application_id: 3,
description: 'test project',
name: 'test project',
application_id: 1,
description: '低代码项目管理平台',
name: '低代码项目管理平台',
alias: 'low-code-project-management-platform',
platform: 'web',
};

View File

@ -9,6 +9,14 @@ declare global {
};
}
type LowCodeFile = {
fileId: string;
url: string;
applicationId?: number;
projectId?: number;
name?: string;
};
type WujieType = {
/** 唯一性用户必须保证 */
name: string;
@ -88,7 +96,7 @@ declare module 'vue-router' {
activeMenu?: string;
/** 菜单排序号 */
orderNo?: number;
app?: WujieType;
app?: LowCodeFile;
/** 是否外链 */
isExt?: boolean;
/**

View File

@ -6,5 +6,8 @@ VITE_BASE_URL = /
# 前端可见变量(必须以 VITE_ 开头)
VITE_PORT = 10010
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

@ -11,7 +11,7 @@ export default defineConfig(({ mode }) => {
return {
server: {
port: env.VITE_PORT,
port: Number(env.VITE_PORT),
cors: true,
},
// @ts-ignore
@ -31,6 +31,9 @@ export default defineConfig(({ mode }) => {
// path: path.resolve(process.cwd(), "../../dist/renderer"),
// clean: true,
// },
script: {
target: "es2022",
},
},
};
});

View File

@ -17,10 +17,10 @@
"@sy/low-code-shared": "workspace:*",
"@sy/web-vitals": "workspace:*",
"@tanstack/vue-query": "^5.66.9",
"@vtj/core": "^0.10.6",
"@vtj/icons": "0.10.6",
"@vtj/materials": "^0.10.6",
"@vtj/renderer": "^0.10.6",
"@vtj/core": "^0.10.7",
"@vtj/icons": "0.10.7",
"@vtj/materials": "^0.10.7",
"@vtj/renderer": "^0.10.7",
"axios": "^1.8.1",
"core-js": "^3.40.0",
"element-plus": "^2.9.4",

View File

@ -11,18 +11,25 @@ import { getFile } from './io';
const lowCodeService = new LowCodeService();
onMounted(() => {
const handshake = new Postmate.Model({});
handshake.then(parent => {
parent.emit('sync-context', 'Hello, World!');
});
});
const model = {
name: '',
applicationId: -1,
projectId: -1,
fileId: '',
url: '',
}
const { data: file, isFetching } = useQuery({
queryKey: ['getFile'],
queryFn: async () => {
return getFile('45tnbgeme');
await handshake.then(parent => {
parent.emit('sync-context', 'Hello, World!');
Object.assign(model, parent.model);
console.log('model', model);
});
return getFile(model.fileId);
},
});
@ -40,7 +47,7 @@ const { provider, onReady } = createProvider({
// runtime: 'web',
service: lowCodeService,
project: {
id: '2'
id: '4'
},
});

View File

@ -1,10 +1,8 @@
import axios from "axios";
const baseApiUrl = "https://custom-chart-pre-api.shiyue.com/";
// 创建独立实例
const instance = axios.create({
baseURL: baseApiUrl, // 基础URL直接放在实例配置中
baseURL: import.meta.env.VITE_BASE_API_URL, // 基础URL直接放在实例配置中
});
// 请求拦截器改为使用实例

View File

@ -3,10 +3,14 @@ import { type ProjectSchema, type BlockSchema, ProjectModel } from "@vtj/core";
import { BaseService } from "@vtj/renderer";
import { getProject, getFile as getLowCodeFile } from "@/io";
let initProject: ProjectModel = {};
export class LowCodeService extends BaseService {
public async init(project: ProjectSchema) {
console.log("init", project);
const remoteProject = await getProject("2");
initProject = project;
const remoteProject = await getProject(project.id);
console.log("remoteProject", remoteProject);
const model = new ProjectModel(remoteProject);
const dsl = model.toDsl();
return Promise.resolve(dsl);
@ -21,14 +25,14 @@ export class LowCodeService extends BaseService {
.map(([key, value]) => [key, JSON.stringify(value)])
),
};
updateProject("2", newProject);
const model = new ProjectModel(project);
storage.save(`project_${model.id}`, model.toDsl());
updateProject(initProject.id, newProject);
const model = new ProjectModel(newProject);
// storage.save(`project_${model.id}`, model.toDsl());
return Promise.resolve(true);
}
public async getFile(id: string): Promise<BlockSchema> {
console.log("getFile", id);
console.log("1111getFile", id);
return getLowCodeFile(id).then((lowCodeFile) => {
if (lowCodeFile.dsl) {
return Promise.resolve(lowCodeFile.dsl as BlockSchema);

View File

@ -7,7 +7,10 @@
"@/*": ["src/*"],
"$vtj/*": [".vtj/*"]
},
"lib": ["ES2015", "DOM"]
"lib": ["ES2015", "DOM"],
"module": "NodeNext",
"target": "ES2022",
"moduleResolution": "NodeNext"
},
"include": ["src"],
"exclude": [".vtj"],

View File

@ -29,7 +29,7 @@ export default defineConfig(({ mode }) => {
],
server: {
cors: true,
port: env.VITE_PORT,
port: Number(env.VITE_PORT),
},
compilation: {

1359
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,8 @@
]
},
"dev": {
"cache": true
"cache": true,
"persistent": true
},
"clean:lock": {
"cache": false,
@ -51,6 +52,17 @@
],
"cache": false
},
"preview": {
"cache": false,
"persistent": true,
"dependsOn": [
"^build"
],
"inputs": [
"$TURBO_DEFAULT$",
".env*"
]
},
"deploy": {
"cache": false,
"dependsOn": [