diff --git a/src/layouts/modules/global-content/index.vue b/src/layouts/modules/global-content/index.vue
index 989b6d4f..8740f404 100644
--- a/src/layouts/modules/global-content/index.vue
+++ b/src/layouts/modules/global-content/index.vue
@@ -1,6 +1,9 @@
@@ -45,7 +105,7 @@ function resetScroll() {
+
+
+
+
diff --git a/src/router/routes/index.ts b/src/router/routes/index.ts
index 5a295d8f..c5e86142 100644
--- a/src/router/routes/index.ts
+++ b/src/router/routes/index.ts
@@ -38,3 +38,22 @@ export function createStaticRoutes() {
export function getAuthVueRoutes(routes: ElegantConstRoute[]) {
return transformElegantRoutesToVueRoutes(routes, layouts, views);
}
+
+/**
+ * Get iFrame route names
+ *
+ * @param routes
+ */
+export function getIframeRouteNames(routes: ElegantConstRoute[]) {
+ const routeNames = [] as string[];
+ routes.forEach(route => {
+ if (route.component?.indexOf('view.iframe-page') !== -1 && route.props && route.name !== 'iframe-page') {
+ routeNames.push(route.name);
+ }
+ if (route.children?.length) {
+ const childNames = getIframeRouteNames(route.children);
+ routeNames.push(...childNames);
+ }
+ });
+ return routeNames;
+}
diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts
index 3230c033..011e2b05 100644
--- a/src/store/modules/route/index.ts
+++ b/src/store/modules/route/index.ts
@@ -6,7 +6,7 @@ import type { CustomRoute, ElegantConstRoute, LastLevelRouteKey, RouteKey, Route
import { router } from '@/router';
import { fetchGetConstantRoutes, fetchGetUserRoutes, fetchIsRouteExist } from '@/service/api';
import { SetupStoreId } from '@/enum';
-import { createStaticRoutes, getAuthVueRoutes } from '@/router/routes';
+import { createStaticRoutes, getAuthVueRoutes, getIframeRouteNames } from '@/router/routes';
import { ROOT_ROUTE } from '@/router/routes/builtin';
import { getRouteName, getRoutePath } from '@/router/elegant/transform';
import { useAuthStore } from '../auth';
@@ -41,6 +41,9 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
/** Home route key */
const routeHome = ref(import.meta.env.VITE_ROUTE_HOME);
+ /** iFrame Vue Routes */
+ const iFrameRoutes = shallowRef([]);
+
/**
* Set route home
*
@@ -111,6 +114,20 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
cacheRoutes.value = getCacheRouteNames(routes);
}
+ /**
+ * Get iFrame routes
+ *
+ * @param routes Vue routes
+ */
+ function getIFrameRoutes(vueRoutes: RouteRecordRaw[], routes: ElegantConstRoute[]) {
+ const iframeRouteNames = getIframeRouteNames(routes);
+ const iframe = cacheRoutes.value.indexOf('iframe-page' as RouteKey);
+ if (iframe > -1) {
+ cacheRoutes.value.splice(iframe, 1);
+ }
+ iFrameRoutes.value = filterIframeRoutesByName(vueRoutes, iframeRouteNames);
+ }
+
/**
* Reset route cache
*
@@ -244,6 +261,8 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
getGlobalMenus(sortRoutes);
getCacheRoutes(vueRoutes);
+
+ getIFrameRoutes(vueRoutes, sortRoutes);
}
/**
@@ -258,6 +277,25 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
});
}
+ /**
+ * Get iFrame routes by route names
+ *
+ * @param vueRoutes
+ * @param iframeRouteNames
+ */
+ function filterIframeRoutesByName(vueRoutes: RouteRecordRaw[], iframeRouteNames: string[]) {
+ return vueRoutes.reduce((values, route) => {
+ let result = [...values];
+ if (route.children?.length) {
+ result = result.concat(filterIframeRoutesByName(route.children, iframeRouteNames));
+ }
+ if (route.name && iframeRouteNames.includes(route.name.toString())) {
+ result.unshift(route);
+ }
+ return result;
+ }, [] as RouteRecordRaw[]);
+ }
+
/**
* Add remove route fn
*
@@ -332,6 +370,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
searchMenus,
updateGlobalMenusByLocale,
cacheRoutes,
+ iFrameRoutes,
excludeCacheRoutes,
resetRouteCache,
breadcrumbs,