- 当前账号:
+ 当前账号:
{{ accessStore.userRoles }}
diff --git a/packages/business/access/src/code-authority.vue b/packages/business/access/src/code-authority.vue
new file mode 100644
index 00000000..cda0d1bc
--- /dev/null
+++ b/packages/business/access/src/code-authority.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
diff --git a/packages/business/access/src/index.ts b/packages/business/access/src/index.ts
index fdb3572a..3f7e0f14 100644
--- a/packages/business/access/src/index.ts
+++ b/packages/business/access/src/index.ts
@@ -1,3 +1,4 @@
+export { default as CodeAuthority } from './code-authority.vue';
export * from './generate-menu-and-routes';
export { default as RoleAuthority } from './role-authority.vue';
export type * from './types';
diff --git a/packages/business/access/src/role-authority.vue b/packages/business/access/src/role-authority.vue
index ae6b1049..d7396903 100644
--- a/packages/business/access/src/role-authority.vue
+++ b/packages/business/access/src/role-authority.vue
@@ -2,25 +2,28 @@
Access control component for fine-grained access control.
-->
-
+
+
diff --git a/packages/business/access/src/use-access.ts b/packages/business/access/src/use-access.ts
index 5abf6336..568f59ff 100644
--- a/packages/business/access/src/use-access.ts
+++ b/packages/business/access/src/use-access.ts
@@ -1,13 +1,26 @@
import { computed } from 'vue';
import { preferences } from '@vben-core/preferences';
+import { useCoreAccessStore } from '@vben-core/stores';
function useAccess() {
+ const coreAccessStore = useCoreAccessStore();
const accessMode = computed(() => {
return preferences.app.accessMode;
});
- return { accessMode };
+ /**
+ * 基于角色判断是否有权限
+ * @description: Determine whether there is permission,The role is judged by the user's role
+ * @param roles
+ */
+ function hasAuthByRole(roles: string[]) {
+ const userRoleSet = new Set(coreAccessStore.getUserRoles);
+ const intersection = roles.filter((item) => userRoleSet.has(item));
+ return intersection.length > 0;
+ }
+
+ return { accessMode, hasAuthByRole };
}
export { useAccess };