Skip to content

xXAvoraXx/umi-plugin-ssr-routes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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-routes

Usage

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published