jinhui.wang

菜单屏蔽

...@@ -149,8 +149,7 @@ function setRoute(route, childrens) { ...@@ -149,8 +149,7 @@ 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") != ""
154 ? "/" + titleCase(val.name, "low") 153 ? "/" + titleCase(val.name, "low")
155 : "" 154 : ""
156 }${item.component}`; 155 }${item.component}`;
...@@ -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,25 +206,19 @@ function routeItemInfo(data) { ...@@ -211,25 +206,19 @@ 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 }))
...@@ -241,23 +230,10 @@ function routeItemInfo(data) { ...@@ -241,23 +230,10 @@ function routeItemInfo(data) {
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) {
246 - console.warn(
247 - "[permission] skip menu with no valid child paths:",
248 - item.path
249 - );
250 - return;
251 - }
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 }; 234 };
260 routes.push(route); 235 routes.push(route);
236 + }
261 }); 237 });
262 238
263 console.log(routes); 239 console.log(routes);
......