feat: vue3渲染适配器

This commit is contained in:
wangxuefeng
2025-03-12 18:10:47 +08:00
parent bcdb4e8c95
commit 5f8609fc02
20 changed files with 398 additions and 150 deletions

View File

@@ -0,0 +1,55 @@
<script setup lang="ts">
import { onMounted } from 'vue';
import Postmate from 'postmate';
const props = defineProps<{
accessToken?: string;
applicationId: string;
fileId: string;
name: string;
projectId: string;
url: string;
}>();
Console.log('props', props);
const initPostmate = async () => {
const container = document.querySelector('#low-code-adapter');
if (!container) {
console.error('容器元素未找到');
return;
}
const connection = new Postmate({
container,
model: {
accessToken: props.accessToken,
applicationId: props.applicationId,
fileId: props.fileId,
name: props.name,
projectId: props.projectId,
url: props.url,
},
name: 'y-code-renderer',
url: props.url,
});
connection.then((child) => {
child.frame.style.height = '100%';
child.frame.style.width = '100%';
console.log(`${props.name} 连接成功`, child);
child.call('child-connected', {
name: props.name,
});
});
};
onMounted(() => {
initPostmate();
});
</script>
<template>
<div id="low-code-adapter" style="width: 100%; height: 100%"></div>
</template>

View File

@@ -0,0 +1 @@
export { default } from './adapter.vue';