From 0b9016c32ca51af1d0e6f28d9f78c2f1bc06e8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=9F=E8=B1=86=E5=93=A5?= Date: Mon, 1 Aug 2022 00:13:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=9D=83=E9=99=90=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/www | 2 +- services/userServices.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/www b/bin/www index a799577..a2cfb54 100644 --- a/bin/www +++ b/bin/www @@ -44,7 +44,7 @@ app.use(dept); app.use(errorHandler) -const server = app.listen(3002, function () { +const server = app.listen(3102, function () { try { let host = server.address().address; host = host.replace("::", "localhost"); diff --git a/services/userServices.js b/services/userServices.js index dbb61f6..d207884 100644 --- a/services/userServices.js +++ b/services/userServices.js @@ -56,11 +56,15 @@ class UserServices { const menuIdArrNew = []; menuIdArr.forEach((menuId) => { - menuIdArrNew.push(menuId); const menu = menuList.find((x) => { return x.id === menuId; }); - const pid = menu.pid; + if(!menu){ + return + } + menuIdArrNew.push(menuId); + console.log('menu',menu); + const pid = menu?.pid; const index = menuIdArrNew.indexOf(pid); if (pid !== 0 && index === -1) { menuIdArrNew.push(pid); @@ -69,6 +73,9 @@ class UserServices { return x.id === pid; }); const pid1 = parentMenu.pid; + if(!parentMenu){ + return + } const index1 = menuIdArrNew.indexOf(pid1); if (pid1 !== 0 && index1 === -1) { menuIdArrNew.push(pid1); -- Gitee