mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-02-04 01:25:34 +08:00
前端和后端源码,合并到一个git仓库中,方便用户下载,避免前后端不匹配的问题
This commit is contained in:
70
jeecgboot-vue3/src/layouts/page/index.vue
Normal file
70
jeecgboot-vue3/src/layouts/page/index.vue
Normal file
@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<RouterView>
|
||||
<template #default="{ Component, route }">
|
||||
<!-- <transition-->
|
||||
<!-- :name="-->
|
||||
<!-- getTransitionName({-->
|
||||
<!-- route,-->
|
||||
<!-- openCache,-->
|
||||
<!-- enableTransition: getEnableTransition,-->
|
||||
<!-- cacheTabs: getCaches,-->
|
||||
<!-- def: getBasicTransition,-->
|
||||
<!-- })-->
|
||||
<!-- "-->
|
||||
<!-- mode="out-in"-->
|
||||
<!-- appear-->
|
||||
<!-- >-->
|
||||
<keep-alive v-if="openCache" :include="getCaches">
|
||||
<component :is="Component" :key="route.fullPath" />
|
||||
</keep-alive>
|
||||
<component v-else :is="Component" :key="route.fullPath" />
|
||||
<!-- </transition>-->
|
||||
</template>
|
||||
</RouterView>
|
||||
<FrameLayout v-if="getCanEmbedIFramePage" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, unref } from 'vue';
|
||||
|
||||
import FrameLayout from '/@/layouts/iframe/index.vue';
|
||||
|
||||
import { useRootSetting } from '/@/hooks/setting/useRootSetting';
|
||||
|
||||
import { useTransitionSetting } from '/@/hooks/setting/useTransitionSetting';
|
||||
import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting';
|
||||
import { getTransitionName } from './transition';
|
||||
|
||||
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PageLayout',
|
||||
components: { FrameLayout },
|
||||
setup() {
|
||||
const { getShowMultipleTab } = useMultipleTabSetting();
|
||||
const tabStore = useMultipleTabStore();
|
||||
|
||||
const { getOpenKeepAlive, getCanEmbedIFramePage } = useRootSetting();
|
||||
|
||||
const { getBasicTransition, getEnableTransition } = useTransitionSetting();
|
||||
|
||||
const openCache = computed(() => unref(getOpenKeepAlive) && unref(getShowMultipleTab));
|
||||
|
||||
const getCaches = computed((): string[] => {
|
||||
if (!unref(getOpenKeepAlive)) {
|
||||
return [];
|
||||
}
|
||||
return tabStore.getCachedTabList;
|
||||
});
|
||||
|
||||
return {
|
||||
getTransitionName,
|
||||
openCache,
|
||||
getEnableTransition,
|
||||
getBasicTransition,
|
||||
getCaches,
|
||||
getCanEmbedIFramePage,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
33
jeecgboot-vue3/src/layouts/page/transition.ts
Normal file
33
jeecgboot-vue3/src/layouts/page/transition.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import type { FunctionalComponent } from 'vue';
|
||||
import type { RouteLocation } from 'vue-router';
|
||||
|
||||
export interface DefaultContext {
|
||||
Component: FunctionalComponent & { type: Recordable };
|
||||
route: RouteLocation;
|
||||
}
|
||||
|
||||
export function getTransitionName({
|
||||
route,
|
||||
openCache,
|
||||
cacheTabs,
|
||||
enableTransition,
|
||||
def,
|
||||
}: Pick<DefaultContext, 'route'> & {
|
||||
enableTransition: boolean;
|
||||
openCache: boolean;
|
||||
def: string;
|
||||
cacheTabs: string[];
|
||||
}): string | undefined {
|
||||
if (!enableTransition) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const isInCache = cacheTabs.includes(route.name as string);
|
||||
const transitionName = 'fade-slide';
|
||||
let name: string | undefined = transitionName;
|
||||
|
||||
if (openCache) {
|
||||
name = isInCache && route.meta.loaded ? transitionName : undefined;
|
||||
}
|
||||
return name || (route.meta.transitionName as string) || def;
|
||||
}
|
||||
Reference in New Issue
Block a user