umi-plugin-ssr-routes
v1.0.41
Published
A umi plugin that addresses the issue of static route configurations in UmiJS. This plugin aims to render route and menu information from an API, instead of displaying the static routes.
Readme
umi-plugin-ssr-routes
A umi plugin that addresses the issue of static route configurations in UmiJS. This plugin aims to render route and menu information from an API, instead of displaying the static routes.
Install
pnpm i umi-plugin-ssr-routes
yarn add umi-plugin-ssr-routes
npm install umi-plugin-ssr-routesUsage
Configure in .umirc.ts,
export default {
plugins: [
['umi-plugin-ssr-routes'],
],
ssrRoutes: {}
}Configure in app.ts\tsx\js,
export async function getServerSideRoutes(): Promise<ServerRouteResponse[]> {
return await getUserRoutes().then((res) => {
if (res.data) {
return res.data;
} else {
return [];
}
});
}
/** GET /api/getUserRoutes */
export async function getUserRoutes(options?: { [key: string]: any }) {
return request<{
data: ServerRouteResponse[];
}>('/api/GetUserRoutes', {
method: 'GET',
prefix: undefined,
...(options || {}),
});
}LICENSE
MIT
