0.3.1 • Published 1 year ago

@versea/plugin-custom-match-route v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@versea/plugin-custom-match-route

rootFragment 类型的路由自定义匹配。

安装

npm install --save @versea/versea @versea/plugin-custom-match-route

使用

import { Versea, AppLifeCycles } from '@versea/versea';
import { IPluginCustomMatchRoute } from '@versea/plugin-custom-match-route';

async function loadScript(url): Promise<void> {
  console.log(url);
  // ...
  await Promise.resolve();
}

const versea = new Versea();
versea.use(IPluginCustomMatchRoute);

// 注册子应用
versea.registerApps([
  {
    name: 'subApp',
    routes: [
      {
        path: 'sub-app',
        isRootFragment: true,
        // 自定义路由匹配
        customMatchRoute(path) {
          return path.indexOf('test') >= 0;
        },
      },
    ],
    loadApp: async (): AppLifeCycles => {
      await loadScript('http://localhost:3000/static/js/bundle.js');
      return (window as any).microApp;
    },
  },
]);

// 在合适的时机启动 versea
void versea.start();
0.3.1

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.6

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.0

2 years ago

0.1.1

2 years ago