feat: 渲染器支持 echart 渲染

This commit is contained in:
wangxuefeng
2025-03-19 14:45:09 +08:00
parent 9b39f265d3
commit a4c5f633cf
17 changed files with 786 additions and 176 deletions

View File

@@ -581,7 +581,7 @@ const idMainContent = ELEMENT_ID_MAIN_CONTENT;
:padding-right="contentPaddingRight"
:padding-top="contentPaddingTop"
:style="contentStyle"
class="transition-[margin-top] duration-200"
class="h-[calc(100vh-7rem)] overflow-auto transition-[margin-top] duration-200"
>
<slot name="content"></slot>

View File

@@ -10,8 +10,6 @@ import { RouterView } from 'vue-router';
import { preferences, usePreferences } from '@vben/preferences';
import { storeToRefs, useTabbarStore } from '@vben/stores';
import { IFrameRouterView } from '../../iframe';
defineOptions({ name: 'LayoutContent' });
const tabbarStore = useTabbarStore();
@@ -97,6 +95,7 @@ function transformComponent(
:include="getCachedTabs"
>
<component
class="h-full w-full"
:is="transformComponent(Component, route)"
v-if="renderRouteView"
v-show="!route.meta.iframeSrc"
@@ -104,6 +103,7 @@ function transformComponent(
/>
</KeepAlive>
<component
class="h-full w-full"
:is="Component"
v-else-if="renderRouteView"
:key="route.fullPath"

View File

@@ -26,6 +26,7 @@
}
},
"dependencies": {
"licia-es": "catalog:",
"postmate": "catalog:",
"vue": "catalog:",
"wujie-vue3": "1.0.22"

View File

@@ -1,32 +1,37 @@
<script setup lang="ts">
import type { Router, RouteRecordRaw } from 'vue-router';
import { onBeforeUnmount, onMounted } from 'vue';
import { computed, onBeforeUnmount, onMounted } from 'vue';
import WujieVue from 'wujie-vue3';
import { version } from '/package.json';
const props = defineProps<{
[key: string]: any;
accessToken?: string;
applicationId: number;
degrade?: boolean;
fileId: number | string;
getRouter: () => Router;
name: string;
// 传递给子应用的参数 payload
payload?: Record<string, any>;
projectId: number;
route: RouteRecordRaw;
sync: boolean;
url: string;
}>();
console.log('props', props);
const props = withDefaults(
defineProps<{
[key: string]: any;
accessToken?: string;
applicationId: number;
degrade?: boolean;
fileId: number | string;
getRouter: () => Router;
name: string;
// 传递给子应用的参数 payload
payload?: Record<string, any>;
projectId: number;
route: RouteRecordRaw;
sync: boolean;
url: string;
}>(),
{
// 默认 wujie 降级
degrade: true,
},
);
const { bus } = WujieVue;
const isDegrade = computed(() => props.degrade ?? true);
// 生命周期钩子
const beforeLoad = (appWindow: Window) => {
console.log(`${props.name} 开始加载`, appWindow);
@@ -38,7 +43,7 @@ const afterMount = (appWindow: Window) => {
// 事件处理
const handleMessage = (data: any) => {
console.log('收到子应用消息:', data);
console.log(`${props.name} 收到子应用消息:`, data);
};
// 准备传递给子应用的数据
@@ -51,17 +56,17 @@ const subAppProps = {
// 监听子应用的事件
const handleReady = (data: any) => {
console.log('子应用就绪:', data);
console.log(`${props.name} 子应用就绪:`, data);
// 可以在这里执行一些操作
};
const handleRenderSuccess = () => {
console.log('子应用渲染成功');
console.log(`${props.name} 子应用渲染成功`);
// 通知父应用
};
const handleRenderFail = (error: any) => {
console.error('子应用渲染失败:', error);
console.error(`${props.name} 子应用渲染失败:`, error);
// 处理错误情况
};
@@ -90,7 +95,7 @@ onBeforeUnmount(() => {
:sync="sync"
width="100%"
height="100%"
:degrade="degrade"
:degrade="isDegrade"
:props="subAppProps"
:before-load="beforeLoad"
:after-mount="afterMount"