From 56f6120f889a88b37760db029faa597597572831 Mon Sep 17 00:00:00 2001 From: harrywan Date: Thu, 30 May 2024 15:39:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20plugin-access=E4=B8=AD=E5=AF=BC?= =?UTF-8?q?=E5=87=BAhasAccessSync=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-access/src/runtime/core.tpl | 9 +++++---- packages/fes-plugin-access/types.d.ts | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/fes-plugin-access/src/runtime/core.tpl b/packages/fes-plugin-access/src/runtime/core.tpl index eac5cc69..e6204151 100644 --- a/packages/fes-plugin-access/src/runtime/core.tpl +++ b/packages/fes-plugin-access/src/runtime/core.tpl @@ -145,8 +145,13 @@ export const install = (app) => { app.component("Access", createComponent(useAccess)); }; +export const hasAccessSync = (path) => { + return match(unref(path), getAllowAccessIds()); +} + export const access = { hasAccess, + hasAccessSync, isDataReady, setRole, getRole: () => { @@ -158,10 +163,6 @@ export const access = { setPresetAccess, }; -export const hasAccessSync = (path) => { - return match(unref(path), getAllowAccessIds()); -} - export const useAccess = (path) => { const allowPageIds = computed(getAllowAccessIds); const result = computed(() => { diff --git a/packages/fes-plugin-access/types.d.ts b/packages/fes-plugin-access/types.d.ts index a1289fb7..0834e5af 100644 --- a/packages/fes-plugin-access/types.d.ts +++ b/packages/fes-plugin-access/types.d.ts @@ -3,10 +3,14 @@ import type { Ref } from 'vue'; export const access: { hasAccess: (accessId: string | number) => Promise; + hasAccessSync: (accessId: string | number) => boolean; isDataReady: () => boolean; setRole: (roleId: string | Promise) => void; + getRole: () => string; setAccess: (accessIds: Array | Promise>) => void; getAccess: () => string[]; + match: (path: string, accessIds: string[]) => boolean; + setPresetAccess: (accessId: string | string[]) => void; }; export function useAccess(accessId: string | number): Ref;