mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-11-10 12:48:23 +08:00
feat: support keep-alive meta config (#470)
* feat: support keepalive meta config * chore: remove console
This commit is contained in:
parent
7642c320b3
commit
2123e86991
|
@ -221,6 +221,7 @@ export default [
|
||||||
component: '/form/step/index',
|
component: '/form/step/index',
|
||||||
meta: {
|
meta: {
|
||||||
title: '分步表单页',
|
title: '分步表单页',
|
||||||
|
keepAlive: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -26,4 +26,7 @@ export interface RouteMeta {
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
hiddenBreadcrumb?: boolean;
|
hiddenBreadcrumb?: boolean;
|
||||||
single?: boolean;
|
single?: boolean;
|
||||||
|
keepAlive?: boolean;
|
||||||
|
frameSrc?: string;
|
||||||
|
frameBlank?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import isBoolean from 'lodash/isBoolean';
|
||||||
|
import isUndefined from 'lodash/isUndefined';
|
||||||
import type { ComputedRef } from 'vue';
|
import type { ComputedRef } from 'vue';
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
@ -31,8 +33,13 @@ import { useTabsRouterStore } from '@/store';
|
||||||
const aliveViews = computed(() => {
|
const aliveViews = computed(() => {
|
||||||
const tabsRouterStore = useTabsRouterStore();
|
const tabsRouterStore = useTabsRouterStore();
|
||||||
const { tabRouters } = tabsRouterStore;
|
const { tabRouters } = tabsRouterStore;
|
||||||
|
return tabRouters
|
||||||
return tabRouters.filter((route) => route.isAlive).map((route) => route.name);
|
.filter((route) => {
|
||||||
|
const keepAliveConfig = route.meta?.keepAlive;
|
||||||
|
const isRouteKeepAlive = isUndefined(keepAliveConfig) || (isBoolean(keepAliveConfig) && keepAliveConfig); // 默认开启keepalive
|
||||||
|
return route.isAlive && isRouteKeepAlive;
|
||||||
|
})
|
||||||
|
.map((route) => route.name);
|
||||||
}) as ComputedRef<string[]>;
|
}) as ComputedRef<string[]>;
|
||||||
|
|
||||||
const isRefreshing = computed(() => {
|
const isRefreshing = computed(() => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user