ss
Some checks failed
Deploy Website on push / Deploy Push Element Ftp (push) Waiting to run
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled

This commit is contained in:
Mrx
2026-01-30 16:03:46 +08:00
commit 62e532846e
1451 changed files with 127726 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
<script lang="ts" setup>
import type { RouteLocationNormalized } from 'vue-router';
import { computed, ref } from 'vue';
import { useRoute } from 'vue-router';
import { preferences } from '@vben/preferences';
import { useTabbarStore } from '@vben/stores';
import { VbenSpinner } from '@vben-core/shadcn-ui';
defineOptions({ name: 'IFrameRouterView' });
const spinningList = ref<boolean[]>([]);
const tabbarStore = useTabbarStore();
const route = useRoute();
const enableTabbar = computed(() => preferences.tabbar.enable);
const iframeRoutes = computed(() => {
if (!enableTabbar.value) {
return route.meta.iframeSrc ? [route] : [];
}
return tabbarStore.getTabs.filter((tab) => !!tab.meta?.iframeSrc);
});
const tabNames = computed(
() => new Set(iframeRoutes.value.map((item) => item.name as string)),
);
const showIframe = computed(() => iframeRoutes.value.length > 0);
function routeShow(tabItem: RouteLocationNormalized) {
return tabItem.name === route.name;
}
function canRender(tabItem: RouteLocationNormalized) {
const { meta, name } = tabItem;
if (!name || !tabbarStore.renderRouteView) {
return false;
}
if (!enableTabbar.value) {
return routeShow(tabItem);
}
// 跟随 keepAlive 状态,与其他tab页保持一致
if (
!meta?.keepAlive &&
tabNames.value.has(name as string) &&
name !== route.name
) {
return false;
}
return tabbarStore.getTabs.some((tab) => tab.name === name);
}
function hideLoading(index: number) {
spinningList.value[index] = false;
}
function showSpinning(index: number) {
const curSpinning = spinningList.value[index];
// 首次加载时显示loading
return curSpinning === undefined ? true : curSpinning;
}
</script>
<template>
<template v-if="showIframe">
<template v-for="(item, index) in iframeRoutes" :key="item.fullPath">
<div
v-if="canRender(item)"
v-show="routeShow(item)"
class="relative size-full"
>
<VbenSpinner :spinning="showSpinning(index)" />
<iframe
:src="item.meta.iframeSrc as string"
class="size-full"
@load="hideLoading(index)"
></iframe>
</div>
</template>
</template>
</template>

View File

@@ -0,0 +1,3 @@
<template>
<div></div>
</template>

View File

@@ -0,0 +1,2 @@
export { default as IFrameRouterView } from './iframe-router-view.vue';
export { default as IFrameView } from './iframe-view.vue';