chore: 渲染器定时查询 wujieProps 确认是否修改了入参

This commit is contained in:
wangxuefeng
2025-03-31 10:43:18 +08:00
parent cf1fab8c58
commit 99b207ec59
3 changed files with 129 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@sy/wujie-vue3-renderer-adapter",
"version": "1.0.0",
"version": "1.0.1",
"description": "wujie-vue3 ycode renderer adapter",
"type": "module",
"scripts": {

View File

@@ -3,7 +3,7 @@ import type { AxiosInterceptorManager } from 'axios';
import type { Router, RouteRecordRaw } from 'vue-router';
import { computed, onBeforeUnmount, onMounted } from 'vue';
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import WujieVue from 'wujie-vue3';
@@ -26,6 +26,7 @@ const props = withDefaults(
projectId: number;
route?: RouteRecordRaw;
router?: Router;
searchParams?: Record<string, any>;
sync?: boolean;
url?: string;
}>(),
@@ -41,6 +42,7 @@ const props = withDefaults(
route: undefined,
// 默认不使用 router
router: undefined,
searchParams: () => ({}),
sync: true,
url: 'https://y-code-renderer.shiyue.com',
},
@@ -62,6 +64,29 @@ const { bus } = WujieVue;
// // InstanceofPlugin(),
// ];
// 使用 ref 创建响应式的 subAppProps
const subAppProps = ref({
...props,
adapterInfo: {
version,
},
});
// 监听 props 的所有变化
watch(
() => ({ ...props }),
(newProps) => {
console.log('props 发生变化', newProps);
subAppProps.value = {
...newProps,
adapterInfo: {
version,
},
};
},
{ deep: true },
);
// 生命周期钩子
const beforeLoad = (appWindow: Window) => {
console.log(`${props.name} 开始加载`, appWindow);
@@ -76,14 +101,6 @@ const handleMessage = (data: any) => {
console.log(`${props.name} 收到子应用消息:`, data);
};
// 准备传递给子应用的数据
const subAppProps = {
...props,
adapterInfo: {
version,
},
};
const finalUrl = computed(() => {
return `${props.url}?fileId=${props.fileId}&projectId=${props.projectId}&applicationId=${props.applicationId}`;
});