Skip to content

Commit

Permalink
feat: plugin-access中导出hasAccessSync方法
Browse files Browse the repository at this point in the history
  • Loading branch information
wanchun committed May 30, 2024
1 parent db99bb9 commit 56f6120
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/fes-plugin-access/src/runtime/core.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand All @@ -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(() => {
Expand Down
4 changes: 4 additions & 0 deletions packages/fes-plugin-access/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import type { Ref } from 'vue';

export const access: {
hasAccess: (accessId: string | number) => Promise<boolean>;
hasAccessSync: (accessId: string | number) => boolean;
isDataReady: () => boolean;
setRole: (roleId: string | Promise<string>) => void;
getRole: () => string;
setAccess: (accessIds: Array<string | number> | Promise<Array<string | number>>) => void;
getAccess: () => string[];
match: (path: string, accessIds: string[]) => boolean;
setPresetAccess: (accessId: string | string[]) => void;
};

export function useAccess(accessId: string | number): Ref<boolean>;
Expand Down

0 comments on commit 56f6120

Please sign in to comment.