Skip to content

Commit

Permalink
1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
xXAvoraXx committed Jul 7, 2024
1 parent c72cf46 commit 692166f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 65 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "umi-plugin-ssr-routes",
"author": "xXAvoraXx",
"version": "1.0.6",
"version": "1.0.7",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"scripts": {
Expand Down
30 changes: 0 additions & 30 deletions src/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,4 @@ interface RouteRaw extends Route {
parentKeys?: "ant-design-pro-layout" | string[];
routes?: RouteRaw[];
component?: string;
}

// Ön tarafta sunucudan gelen verilere dayalı olarak oluşturulan React.lazy gecikmeli yükleme bileşeni veya Outlet (birinci seviye rota)
type RouteComponent =
| React.LazyExoticComponent<React.ComponentType<any>>
| React.ReactElement
| null;

// patchRoutes işlevinin parametresi { routes, routeComponents } şeklinde çözümlenebilir
// Bu tür, Object.assign(routes, parsedRoutes) işlemi için kullanılır, rota verilerini birleştirir
interface ParsedRoutes {
[key: number]: Route;
}

// Bu tür, Object.assign(routeComponents, parsedRoutes) işlemi için kullanılır, rota bileşenlerini birleştirir
interface ParsedRouteComponent {
[key: number]: RouteComponent;
}

// parseRoutes işlevinin dönüş değeri
interface ParseRoutesReturnType {
routes: ParsedRoutes;
routeComponents: ParsedRouteComponent;
}

interface ComponentRaw {
key: string;
filePath: string;
fallBack: string;
children: ComponentRaw[];
}
6 changes: 3 additions & 3 deletions src/utils/getServiceContent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export default (fetchRoutes: () => Promise<RouteRaw[]>) => {
const fetchRoutesStr = fetchRoutes.toString();
return `\
export async function getRoutersInfo(): Promise<RouteRaw[]> {
return await ${fetchRoutesStr};
export async function getRoutersInfo() {
const fetchRoutes = ${fetchRoutes.toString()};
return await fetchRoutes();
}
`;
};
8 changes: 4 additions & 4 deletions src/utils/getSessionContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import LazyLoadable from './LazyLoadable';
import { createIcon } from './utils';
import { Navigate } from '@umijs/max';
import React, { lazy } from 'react';
let remoteMenu: API.RouteRaw[] = [];
let remoteMenu: RouteRaw[] = [];
export function getRemoteMenu() {
return remoteMenu;
}
export function setRemoteMenu(data: API.RouteRaw[]) {
export function setRemoteMenu(data: RouteRaw[]) {
remoteMenu = data;
}
Expand Down Expand Up @@ -49,7 +49,7 @@ function generateComponent(component: string | undefined): React.ReactNode | nul
}
// Sunucudan gelen RouteRaw dizisini Route dizisine dönüştürün
function convertRoutes(rawRoutes: API.RouteRaw[]): API.Route[] {
function convertRoutes(rawRoutes: RouteRaw[]): Route[] {
return rawRoutes.map((rawRoute) => {
const { component, routes, ...rest } = rawRoute;
Expand All @@ -70,7 +70,7 @@ function convertRoutes(rawRoutes: API.RouteRaw[]): API.Route[] {
});
}
export function parseRoutes(layout: API.RouteRaw, routesRaw: API.RouteRaw[]) {
export function parseRoutes(layout: RouteRaw, routesRaw: RouteRaw[]) {
routesRaw.forEach((route) => {
layout.routes?.push(route);
});
Expand Down
27 changes: 0 additions & 27 deletions src/utils/getTypeContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,4 @@ interface RouteRaw extends Route {
routes?: RouteRaw[];
component?: string;
}
// Ön tarafta sunucudan gelen verilere dayalı olarak oluşturulan React.lazy gecikmeli yükleme bileşeni veya Outlet (birinci seviye rota)
type RouteComponent = React.LazyExoticComponent<React.ComponentType<any>> | React.ReactElement | null;
// patchRoutes işlevinin parametresi { routes, routeComponents } şeklinde çözümlenebilir
// Bu tür, Object.assign(routes, parsedRoutes) işlemi için kullanılır, rota verilerini birleştirir
interface ParsedRoutes {
[key: number]: Route;
}
// Bu tür, Object.assign(routeComponents, parsedRoutes) işlemi için kullanılır, rota bileşenlerini birleştirir
interface ParsedRouteComponent {
[key: number]: RouteComponent;
}
// parseRoutes işlevinin dönüş değeri
interface ParseRoutesReturnType {
routes: ParsedRoutes;
routeComponents: ParsedRouteComponent;
}
interface ComponentRaw {
key: string;
filePath: string;
fallBack: string;
children: ComponentRaw[];
}
`;

0 comments on commit 692166f

Please sign in to comment.