Skip to content

Commit 90b3fab

Browse files
committed
feat: routes with parameters can be cached
1 parent cdf2c59 commit 90b3fab

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

CHANGELOG.zh_CN.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- 增加富文本嵌入表单的示例
77
- 表单组件 schema 增加 `required`属性。简化配置
88
- openModal 和 openDrawer 第二个参数可以代替`transferModalData`传参到内部
9+
- 带参路由可以被缓存
910

1011
### ⚡ Performance Improvements
1112

src/layouts/default/LayoutContent.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { defineComponent } from 'vue';
2-
// import { Layout } from 'ant-design-vue';
2+
import { Layout } from 'ant-design-vue';
3+
import { RouterView } from 'vue-router';
4+
35
// hooks
46

57
import { ContentEnum } from '/@/enums/appEnum';
68
import { appStore } from '/@/store/modules/app';
7-
import PageLayout from '/@/layouts/page/index';
9+
// import PageLayout from '/@/layouts/page/index';
810
export default defineComponent({
911
name: 'DefaultLayoutContent',
1012
setup() {
@@ -13,9 +15,10 @@ export default defineComponent({
1315
const { contentMode } = getProjectConfig;
1416
const wrapClass = contentMode === ContentEnum.FULL ? 'full' : 'fixed';
1517
return (
16-
// <Layout.Content class={`layout-content ${wrapClass} `}>
17-
<PageLayout class={`layout-content ${wrapClass} `} />
18-
// </Layout.Content>
18+
<Layout.Content class={`layout-content ${wrapClass} `}>
19+
{() => <RouterView />}
20+
{/* <PageLayout class={`layout-content ${wrapClass} `} /> */}
21+
</Layout.Content>
1922
);
2023
};
2124
},

src/layouts/page/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ export default defineComponent({
4444
// TODO add key?
4545
const Content = openCache ? (
4646
<KeepAlive max={max} include={cacheTabs}>
47-
<Component />
47+
<Component key={route.path} />
4848
</KeepAlive>
4949
) : (
50-
<Component />
50+
<Component key={route.path} />
5151
);
5252
return openRouterTransition ? (
5353
<Transition

src/views/demo/feat/tab-params/index.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<template>
22
<div class="p-4">
33
Current Param : {{ params }}
4-
<!-- <input /> -->
4+
<br />
5+
Keep Alive
6+
<input />
57
</div>
68
</template>
79
<script lang="ts">

0 commit comments

Comments
 (0)