From 4de876c0e96b4201d8cb64eed466c3bb3f42d501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E4=BB=99?= <615206459@qq.com> Date: Mon, 29 Jul 2024 23:24:37 +0800 Subject: [PATCH] =?UTF-8?q?[error]=20namespace.replace=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/base/store/menu.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/modules/base/store/menu.ts b/src/modules/base/store/menu.ts index d15e142..b643677 100644 --- a/src/modules/base/store/menu.ts +++ b/src/modules/base/store/menu.ts @@ -38,14 +38,18 @@ export const useMenuStore = defineStore("menu", function () { function deep(d: any) { if (typeof d == "object") { if (d.permission) { - d._permission = {}; - for (const i in d.permission) { - d._permission[i] = - list.findIndex((e: any) => - e - .replace(/:/g, "/") - .includes(`${d.namespace.replace("admin/", "")}/${i}`) - ) >= 0; + if (d.namespace) { + d._permission = {}; + for (const i in d.permission) { + d._permission[i] = + list.findIndex((e) => + e + .replace(/:/g, "/") + .includes(`${d.namespace.replace("admin/", "")}/${i}`) + ) >= 0; + } + } else { + console.error("namespace is required", d); } } else { for (const i in d) {