mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	fix: 路由地址转首字母大写驼峰,作为路由名称,适配keepAlive
This commit is contained in:
		| @@ -2,6 +2,7 @@ import { constantRoutes } from '@/router' | |||||||
| import { getRouters } from '@/api/menu' | import { getRouters } from '@/api/menu' | ||||||
| import Layout from '@/layout/index' | import Layout from '@/layout/index' | ||||||
| import ParentView from '@/components/ParentView'; | import ParentView from '@/components/ParentView'; | ||||||
|  | import { toCamelCase } from "@/utils"; | ||||||
|  |  | ||||||
| const permission = { | const permission = { | ||||||
|   state: { |   state: { | ||||||
| @@ -56,6 +57,8 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { | |||||||
|       icon: route.icon, |       icon: route.icon, | ||||||
|       noCache: !route.keepAlive, |       noCache: !route.keepAlive, | ||||||
|     } |     } | ||||||
|  |     // 路由地址转首字母大写驼峰,作为路由名称,适配keepAlive | ||||||
|  |     route.name = toCamelCase(route.path, true) | ||||||
|     route.hidden = !route.visible |     route.hidden = !route.visible | ||||||
|     // 处理 component 属性 |     // 处理 component 属性 | ||||||
|     if (route.children) { // 父节点 |     if (route.children) { // 父节点 | ||||||
|   | |||||||
| @@ -427,3 +427,15 @@ export function isNumberStr(str) { | |||||||
|   return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str) |   return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // -转驼峰 | ||||||
|  | export function toCamelCase(str, upperCaseFirst) { | ||||||
|  |   str = (str || '').toLowerCase().replace(/-(.)/g, function (match, group1) { | ||||||
|  |     return group1.toUpperCase(); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   if (upperCaseFirst && str) { | ||||||
|  |     str = str.charAt(0).toUpperCase() + str.slice(1); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   return str; | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 caiti
					caiti