mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-02 07:20:38 +00:00
Link: https://code.aone.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/codereview/3678180 * refactor: rax-provider * feat: add build command * chore: compilerOptions for rax-provider
27 lines
647 B
TypeScript
27 lines
647 B
TypeScript
import { useRouter } from 'rax-use-router';
|
|
import { createHashHistory, createBrowserHistory } from 'history';
|
|
|
|
const getConfig = (config) => {
|
|
let { history } = config;
|
|
const { routes } = config;
|
|
if (typeof history === 'string') {
|
|
if (history === 'hash') {
|
|
history = createHashHistory();
|
|
} else if (history === 'browser') {
|
|
history = createBrowserHistory();
|
|
}
|
|
}
|
|
return () => ({
|
|
history,
|
|
routes,
|
|
});
|
|
};
|
|
|
|
export default function getRouter(config) {
|
|
return function Router() {
|
|
const configWrapper = getConfig(config);
|
|
const { component } = useRouter(configWrapper);
|
|
return component;
|
|
};
|
|
}
|