mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix(plugin-access): 修复getAccess的问题
This commit is contained in:
parent
463291b08a
commit
bdd63e6449
packages/fes-plugin-access
@ -26,6 +26,9 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.15"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@fesjs/fes": "^2.0.0-rc.0",
|
||||
"vue": "^3.0.5"
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { reactive, unref, computed, inject } from "vue";
|
||||
import createDirective from "./createDirective";
|
||||
import createComponent from "./createComponent";
|
||||
import isPlainObject from "lodash/isPlainObject";
|
||||
|
||||
const accessKey = Symbol("plugin-access");
|
||||
|
||||
@ -50,16 +51,21 @@ const setAccess = (accessIds) => {
|
||||
if (isPromise(accessIds)) {
|
||||
return _syncSetAccessIds(accessIds);
|
||||
}
|
||||
if(isPlainObject(accessIds)){
|
||||
if(accessIds.accessIds){
|
||||
setAccess(accessIds.accessIds);
|
||||
}
|
||||
if(accessIds.roleId){
|
||||
setRole(accessIds.roleId);
|
||||
}
|
||||
return
|
||||
}
|
||||
if (!Array.isArray(accessIds)) {
|
||||
throw new Error("[plugin-access]: argument to the setAccess() must be array or promise");
|
||||
throw new Error("[plugin-access]: argument to the setAccess() must be array or promise or object");
|
||||
}
|
||||
state.currentAccessIds = accessIds;
|
||||
};
|
||||
|
||||
const getAccess = () => {
|
||||
return state.currentAccessIds.slice(0)
|
||||
}
|
||||
|
||||
const _syncSetRoleId = (promise) => {
|
||||
rolePromiseList.push(promise);
|
||||
promise
|
||||
@ -143,7 +149,7 @@ export const access = {
|
||||
isDataReady,
|
||||
setRole,
|
||||
setAccess,
|
||||
getAccess,
|
||||
getAccess: getAllowAccessIds,
|
||||
};
|
||||
|
||||
export const useAccess = (path) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user