2.0.0 • Published 4 years ago

umi-plugin-cache-route v2.0.0

Weekly downloads
51
License
-
Repository
github
Last release
4 years ago

umi-plugin-cache-route

NPM version NPM downloads

umi keep alive

(为了几个项目的紧急需求,通过覆盖了umi的文件的方式实现的。不是最终最优解,可用于生产) (For the urgent needs of several projects, it is achieved by overwriting UMI files. Not the ultimate optimal solution, it can be used in production.)

Usage

Configure in .umirc.js,

export default {
  plugins: [
    ['umi-plugin-cache-route', {
      keepalive:['route path','route path']
    }],
  ],
}

Init 初始化

package.json
"scripts": {
  "start": "umi dev",
  "init": "umi keepalive",
},
yarn run init

Configuration Routing 配置路由

Configure in .umirc.js,

export default {
  plugins: [
    ['umi-plugin-cache-route'],
  ],
  routes: [
    {
      path: '/',
      component: '../layouts/index',
      routes: [
        {
          path: '/list',
          component: './list',
          keepAlive: true,
        },
        {
          path: '/item',
          component: './item',
        },
      ],
    },
  ]
};

Conventional Routing 约定式路由

Configure in .umirc.js,

export default {
  plugins: [
    ['umi-plugin-cache-route', {
      keepalive:['/list']
    }],
  ],
}

Manual release 手动解除keep

import { dropByCacheKey } from 'umi';

export default () => {
  const clearCache = () => {
    dropByCacheKey('/list');
  };
  return (
    <Card>
      <Button onClick={clearCache}>clear list page cache</Button>
    </Card>
  );
};

Options

TODO

LICENSE

MIT

2.0.1-alpha.0

4 years ago

2.0.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.4

5 years ago