mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2026-01-15 02:57:09 +08:00
refactor: 路由多级缓存调整为扁平化方案
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<a-layout class="main">
|
||||
<router-view v-slot="{ Component, route }">
|
||||
<transition :name="transitionName(route)" mode="out-in" appear>
|
||||
<transition :name="appStore.transitionName" mode="out-in" appear>
|
||||
<keep-alive :include="(tabsStore.cacheList as string[])">
|
||||
<component :is="Component" :key="route.matched?.[1]?.path" />
|
||||
<component :is="Component" :key="route.path" />
|
||||
</keep-alive>
|
||||
</transition>
|
||||
</router-view>
|
||||
@@ -11,22 +11,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
||||
import { useAppStore, useTabsStore } from '@/stores'
|
||||
|
||||
defineOptions({ name: 'Main' })
|
||||
const appStore = useAppStore()
|
||||
const tabsStore = useTabsStore()
|
||||
|
||||
// 过渡动画
|
||||
const transitionName = computed(() => {
|
||||
return function (route: RouteLocationNormalizedLoaded) {
|
||||
if (route?.matched?.[1]?.meta?.animation === false) {
|
||||
return ''
|
||||
}
|
||||
return appStore.transitionName
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user