Skip to content

Commit

Permalink
feat: routes with parameters can be cached
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Nov 8, 2020
1 parent cdf2c59 commit 90b3fab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- 增加富文本嵌入表单的示例
- 表单组件 schema 增加 `required`属性。简化配置
- openModal 和 openDrawer 第二个参数可以代替`transferModalData`传参到内部
- 带参路由可以被缓存

### ⚡ Performance Improvements

Expand Down
13 changes: 8 additions & 5 deletions src/layouts/default/LayoutContent.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { defineComponent } from 'vue';
// import { Layout } from 'ant-design-vue';
import { Layout } from 'ant-design-vue';
import { RouterView } from 'vue-router';

// hooks

import { ContentEnum } from '/@/enums/appEnum';
import { appStore } from '/@/store/modules/app';
import PageLayout from '/@/layouts/page/index';
// import PageLayout from '/@/layouts/page/index';
export default defineComponent({
name: 'DefaultLayoutContent',
setup() {
Expand All @@ -13,9 +15,10 @@ export default defineComponent({
const { contentMode } = getProjectConfig;
const wrapClass = contentMode === ContentEnum.FULL ? 'full' : 'fixed';
return (
// <Layout.Content class={`layout-content ${wrapClass} `}>
<PageLayout class={`layout-content ${wrapClass} `} />
// </Layout.Content>
<Layout.Content class={`layout-content ${wrapClass} `}>
{() => <RouterView />}
{/* <PageLayout class={`layout-content ${wrapClass} `} /> */}
</Layout.Content>
);
};
},
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export default defineComponent({
// TODO add key?
const Content = openCache ? (
<KeepAlive max={max} include={cacheTabs}>
<Component />
<Component key={route.path} />
</KeepAlive>
) : (
<Component />
<Component key={route.path} />
);
return openRouterTransition ? (
<Transition
Expand Down
4 changes: 3 additions & 1 deletion src/views/demo/feat/tab-params/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<div class="p-4">
Current Param : {{ params }}
<!-- <input /> -->
<br />
Keep Alive
<input />
</div>
</template>
<script lang="ts">
Expand Down

0 comments on commit 90b3fab

Please sign in to comment.