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