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_ 开头)
VITE_PORT = 10011 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 VITE_DEBUG_MODE = true

View File

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

View File

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

View File

@ -84,6 +84,19 @@ export const postMaterials = async (
return response.data; 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 * @param project_id ID

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,11 @@
name: 'low-code-renderer', name: 'low-code-renderer',
classListArray: ['responsive-iframe'], classListArray: ['responsive-iframe'],
model: { 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, sync: true,
alive: true, alive: true,
degrade: true, degrade: true,
applicationId: 0,
projectId: 4,
fileId: 'b91n1y9yr',
}, },
}, },
component: () => import('@/components/renderer-adapter/index.vue'), component: () => import('@/components/renderer-adapter/index.vue'),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,18 +11,25 @@ import { getFile } from './io';
const lowCodeService = new LowCodeService(); const lowCodeService = new LowCodeService();
onMounted(() => {
const handshake = new Postmate.Model({}); const handshake = new Postmate.Model({});
handshake.then(parent => { const model = {
parent.emit('sync-context', 'Hello, World!'); name: '',
}); applicationId: -1,
}); projectId: -1,
fileId: '',
url: '',
}
const { data: file, isFetching } = useQuery({ const { data: file, isFetching } = useQuery({
queryKey: ['getFile'], queryKey: ['getFile'],
queryFn: async () => { 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', // runtime: 'web',
service: lowCodeService, service: lowCodeService,
project: { project: {
id: '2' id: '4'
}, },
}); });

View File

@ -1,10 +1,8 @@
import axios from "axios"; import axios from "axios";
const baseApiUrl = "https://custom-chart-pre-api.shiyue.com/";
// 创建独立实例 // 创建独立实例
const instance = axios.create({ 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 { BaseService } from "@vtj/renderer";
import { getProject, getFile as getLowCodeFile } from "@/io"; import { getProject, getFile as getLowCodeFile } from "@/io";
let initProject: ProjectModel = {};
export class LowCodeService extends BaseService { export class LowCodeService extends BaseService {
public async init(project: ProjectSchema) { public async init(project: ProjectSchema) {
console.log("init", project); 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 model = new ProjectModel(remoteProject);
const dsl = model.toDsl(); const dsl = model.toDsl();
return Promise.resolve(dsl); return Promise.resolve(dsl);
@ -21,14 +25,14 @@ export class LowCodeService extends BaseService {
.map(([key, value]) => [key, JSON.stringify(value)]) .map(([key, value]) => [key, JSON.stringify(value)])
), ),
}; };
updateProject("2", newProject); updateProject(initProject.id, newProject);
const model = new ProjectModel(project); const model = new ProjectModel(newProject);
storage.save(`project_${model.id}`, model.toDsl()); // storage.save(`project_${model.id}`, model.toDsl());
return Promise.resolve(true); return Promise.resolve(true);
} }
public async getFile(id: string): Promise<BlockSchema> { public async getFile(id: string): Promise<BlockSchema> {
console.log("getFile", id); console.log("1111getFile", id);
return getLowCodeFile(id).then((lowCodeFile) => { return getLowCodeFile(id).then((lowCodeFile) => {
if (lowCodeFile.dsl) { if (lowCodeFile.dsl) {
return Promise.resolve(lowCodeFile.dsl as BlockSchema); return Promise.resolve(lowCodeFile.dsl as BlockSchema);

View File

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

View File

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

1359
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

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