@yysports/tools 2.2.3 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@
7
7
  export declare const getModuleNameByUmi: (onRouteChangeArgs: {
8
8
  location: any;
9
9
  routes: any;
10
+ basename: string;
10
11
  }, menuNameMap?: {
11
12
  [key: string]: string;
12
13
  } | undefined) => string | undefined;
@@ -6,10 +6,15 @@
6
6
  */
7
7
  export var getModuleNameByUmi = function getModuleNameByUmi(onRouteChangeArgs, menuNameMap) {
8
8
  var location = onRouteChangeArgs.location,
9
- routes = onRouteChangeArgs.routes;
9
+ routes = onRouteChangeArgs.routes,
10
+ basename = onRouteChangeArgs.basename;
10
11
  var pathname = location.pathname;
12
+ var routePath = pathname;
13
+ if (basename !== '/') {
14
+ routePath = pathname.replace(basename, '');
15
+ }
11
16
  var currentRouteKey = Object.keys(routes).find(function (v) {
12
- return routes[v].path === pathname;
17
+ return routes[v].path === routePath;
13
18
  });
14
19
 
15
20
  // 如果路由不存在或是重定向路由,直接返回
@@ -7,6 +7,7 @@
7
7
  export declare const getModuleNameByUmi: (onRouteChangeArgs: {
8
8
  location: any;
9
9
  routes: any;
10
+ basename: string;
10
11
  }, menuNameMap?: {
11
12
  [key: string]: string;
12
13
  } | undefined) => string | undefined;
@@ -23,10 +23,14 @@ __export(route_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(route_exports);
25
25
  var getModuleNameByUmi = (onRouteChangeArgs, menuNameMap) => {
26
- const { location, routes } = onRouteChangeArgs;
26
+ const { location, routes, basename } = onRouteChangeArgs;
27
27
  const { pathname } = location;
28
+ let routePath = pathname;
29
+ if (basename !== "/") {
30
+ routePath = pathname.replace(basename, "");
31
+ }
28
32
  const currentRouteKey = Object.keys(routes).find(
29
- (v) => routes[v].path === pathname
33
+ (v) => routes[v].path === routePath
30
34
  );
31
35
  if (!currentRouteKey || routes[currentRouteKey].redirect) {
32
36
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yysports/tools",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "常用工具函数库",
5
5
  "homepage": "https://git.pousheng.com/sport-service-department/pousheng-guard/yysports_tools#readme",
6
6
  "bugs": {