From 1967e8a53d3c3d3fa58a4aa3e6d6b3091c5d6055 Mon Sep 17 00:00:00 2001 From: icssoa <615206459@qq.com> Date: Thu, 7 Apr 2022 17:36:53 +0800 Subject: [PATCH] =?UTF-8?q?eps=20=E9=A6=96=E6=AC=A1=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cool/service/eps.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/cool/service/eps.ts b/src/cool/service/eps.ts index 3832779..7666bae 100644 --- a/src/cool/service/eps.ts +++ b/src/cool/service/eps.ts @@ -5,7 +5,7 @@ import { storage, toCamel } from "../utils"; // 获取标签名 function getNames(v: any) { return Object.getOwnPropertyNames(v.constructor.prototype).filter( - (e) => !["namespace", "constructor", "request"].includes(e) + (e) => !["namespace", "constructor", "request", "permission"].includes(e) ); } @@ -70,9 +70,15 @@ export function useEps(service: Service) { url: "/admin/base/open/eps" }) .then(async (res) => { + const isLoaded: boolean = storage.get("eps"); storage.set("eps", res); - set(res, true); - console.log("[Eps] 初始化成功。"); + + if (!isLoaded) { + location.reload(); + } else { + set(res, true); + console.log("[Eps] 初始化成功。"); + } }) .catch((err) => { console.error("[Eps] 获取失败!", err.message); @@ -147,12 +153,14 @@ export function useEps(service: Service) { if (!d[k].permission) { d[k].permission = {}; - for (const i in d[k]) { - d[k].permission[i] = `${d[k].namespace.replace( + const ks = Array.from(new Set([...names, ...getNames(d[k])])); + + ks.forEach((e) => { + d[k].permission[e] = `${d[k].namespace.replace( "admin/", "" - )}/${i}`.replace(/\//g, ":"); - } + )}/${e}`.replace(/\//g, ":"); + }); } list.push(e);