umi-plugin-cache-route

    2.0.0 • Public • Published

    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

    Keywords

    none

    Install

    npm i umi-plugin-cache-route

    DownloadsWeekly Downloads

    24

    Version

    2.0.0

    License

    none

    Unpacked Size

    22.8 kB

    Total Files

    8

    Last publish

    Collaborators

    • xiaohuoni