feat: 可通过配置入参来初始化编辑器

This commit is contained in:
wangxuefeng
2025-03-05 14:34:40 +08:00
parent 4f920b0ac2
commit dd69823a00
7 changed files with 94 additions and 117 deletions

View File

@@ -1,40 +1,50 @@
<template>
<div class="designer-container" ref="container"></div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import {
Engine,
widgetManager
// type ProjectModel
} from '@vtj/pro';
import Postmate from 'postmate';
import { Engine, widgetManager } from '@vtj/pro';
import { LowCodeService } from '@/service';
const container = ref();
const service = new LowCodeService();
const engine = new Engine({
container,
service,
project: {
// @ts-ignore
id: 4,
name: '低代码平台'
}
});
onMounted(async () => {
// 数据模型
const model = {
name: '',
applicationId: -1,
url: ''
};
widgetManager.set('Previewer', {
props: {
path: (block: any) => {
const pathname = location.pathname;
return `${pathname}#/preview/${block.id}`;
}
}
const handshake = new Postmate.Model({});
await handshake.then((parent) => {
parent.emit('sync-context', 'Hello, World!');
Object.assign(model, parent.model);
console.log('model', model);
const engine = new Engine({
container,
service,
project: {
id: model.applicationId,
name: model.name
}
});
widgetManager.set('Previewer', {
props: {
path: (block: any) => {
const pathname = location.pathname;
return `${pathname}#/preview/${block.id}`;
}
}
});
});
});
</script>
<template>
<div class="designer-container" ref="container"></div>
</template>
<style scoped>
.designer-container {
height: 100%;