Showing
1 changed file
with
26 additions
and
50 deletions
| ... | @@ -149,11 +149,10 @@ function setRoute(route, childrens) { | ... | @@ -149,11 +149,10 @@ function setRoute(route, childrens) { |
| 149 | route.forEach((val) => { | 149 | route.forEach((val) => { |
| 150 | val.id == 999999 ? (rootRoute = val) : ""; | 150 | val.id == 999999 ? (rootRoute = val) : ""; |
| 151 | if (item.parentId == val.id) { | 151 | if (item.parentId == val.id) { |
| 152 | - item.component = `${ | 152 | + item.component = `${titleCase(val.name, "low") != "" |
| 153 | - titleCase(val.name, "low") != "" | 153 | + ? "/" + titleCase(val.name, "low") |
| 154 | - ? "/" + titleCase(val.name, "low") | 154 | + : "" |
| 155 | - : "" | 155 | + }${item.component}`; |
| 156 | - }${item.component}`; | ||
| 157 | val.children.push(item); | 156 | val.children.push(item); |
| 158 | val.component = "Layout"; | 157 | val.component = "Layout"; |
| 159 | // val.meta = item.meta | 158 | // val.meta = item.meta |
| ... | @@ -169,10 +168,6 @@ function setRoute(route, childrens) { | ... | @@ -169,10 +168,6 @@ function setRoute(route, childrens) { |
| 169 | return route; | 168 | return route; |
| 170 | } | 169 | } |
| 171 | 170 | ||
| 172 | -function isValidMenuPath(p) { | ||
| 173 | - return p != null && String(p).trim() !== ""; | ||
| 174 | -} | ||
| 175 | - | ||
| 176 | function routeItemInfo(data) { | 171 | function routeItemInfo(data) { |
| 177 | const routes = [ | 172 | const routes = [ |
| 178 | { | 173 | { |
| ... | @@ -211,53 +206,34 @@ function routeItemInfo(data) { | ... | @@ -211,53 +206,34 @@ function routeItemInfo(data) { |
| 211 | ]; | 206 | ]; |
| 212 | 207 | ||
| 213 | data.forEach((item) => { | 208 | data.forEach((item) => { |
| 214 | - const rawChildren = item.children || []; | 209 | + if (item.nodeType == '1') { |
| 215 | - const isParent = item.parentId == 0 && rawChildren.length == 0; | 210 | + const isParent = item.parentId == 0 && item.children.length == 0; |
| 216 | - if (!isValidMenuPath(item.path)) { | 211 | + const route = { |
| 217 | - console.warn("[permission] skip menu item without path:", item); | 212 | + path: item.path, |
| 218 | - return; | 213 | + component: "Layout", |
| 219 | - } | 214 | + alwaysShow: true, |
| 220 | - const childRoutes = !isParent | 215 | + hidden: false, |
| 221 | - ? rawChildren | 216 | + meta: { title: item.name, icon: item.icon }, |
| 222 | - .filter((child) => { | 217 | + children: !isParent |
| 223 | - if (!isValidMenuPath(child.path)) { | 218 | + ? item.children.map((child) => ({ |
| 224 | - console.warn("[permission] skip child menu without path:", child); | ||
| 225 | - return false; | ||
| 226 | - } | ||
| 227 | - return true; | ||
| 228 | - }) | ||
| 229 | - .map((child) => ({ | ||
| 230 | path: child.path, | 219 | path: child.path, |
| 231 | component: `${child.path}`, | 220 | component: `${child.path}`, |
| 232 | - hidden: false, | 221 | + hidden: child.nodeType == '1' ? false : true, |
| 233 | name: child.name, | 222 | name: child.name, |
| 234 | meta: { title: child.name, icon: child.icon || "" }, | 223 | meta: { title: child.name, icon: child.icon || "" }, |
| 235 | })) | 224 | })) |
| 236 | - : [ | 225 | + : [ |
| 237 | - { | 226 | + { |
| 238 | - path: item.path, | 227 | + path: item.path, |
| 239 | - component: `${item.path}`, | 228 | + component: `${item.path}`, |
| 240 | - hidden: false, | 229 | + hidden: false, |
| 241 | - name: item.name, | 230 | + name: item.name, |
| 242 | - meta: { title: item.name, icon: item.icon || "" }, | 231 | + meta: { title: item.name, icon: item.icon || "" }, |
| 243 | - }, | 232 | + }, |
| 244 | - ]; | 233 | + ], |
| 245 | - if (!isParent && childRoutes.length === 0) { | 234 | + }; |
| 246 | - console.warn( | 235 | + routes.push(route); |
| 247 | - "[permission] skip menu with no valid child paths:", | ||
| 248 | - item.path | ||
| 249 | - ); | ||
| 250 | - return; | ||
| 251 | } | 236 | } |
| 252 | - const route = { | ||
| 253 | - path: item.path, | ||
| 254 | - component: "Layout", | ||
| 255 | - alwaysShow: true, | ||
| 256 | - hidden: false, | ||
| 257 | - meta: { title: item.name, icon: item.icon }, | ||
| 258 | - children: childRoutes, | ||
| 259 | - }; | ||
| 260 | - routes.push(route); | ||
| 261 | }); | 237 | }); |
| 262 | 238 | ||
| 263 | console.log(routes); | 239 | console.log(routes); | ... | ... |
-
Please register or login to post a comment