Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin
This commit is contained in:
commit
eff55a7c74
@ -41,7 +41,7 @@
|
||||
"@vben/styles": "workspace:*",
|
||||
"@vben/types": "workspace:*",
|
||||
"@vben/utils": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"ant-design-vue": "^4.2.3",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.13",
|
||||
|
@ -40,7 +40,7 @@
|
||||
"@vben/styles": "workspace:*",
|
||||
"@vben/types": "workspace:*",
|
||||
"@vben/utils": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"dayjs": "^1.11.13",
|
||||
"element-plus": "^2.8.1",
|
||||
"pinia": "2.2.2",
|
||||
|
@ -40,7 +40,7 @@
|
||||
"@vben/styles": "workspace:*",
|
||||
"@vben/types": "workspace:*",
|
||||
"@vben/utils": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"naive-ui": "^2.39.0",
|
||||
"pinia": "2.2.2",
|
||||
"vue": "^3.4.38",
|
||||
|
@ -13,7 +13,7 @@
|
||||
"devDependencies": {
|
||||
"@nolebase/vitepress-plugin-git-changelog": "^2.4.0",
|
||||
"@vite-pwa/vitepress": "^0.5.0",
|
||||
"vitepress": "^1.3.3",
|
||||
"vitepress": "^1.3.4",
|
||||
"vue": "^3.4.38"
|
||||
}
|
||||
}
|
||||
|
@ -231,10 +231,12 @@ const { hasAccessByCodes } = useAccess();
|
||||
|
||||
#### Directive Method
|
||||
|
||||
> The directive supports binding single or multiple permission codes. For a single one, you can pass a string or an array containing one permission code, and for multiple permission codes, you can pass an array.
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<Button class="mr-4" v-access:code="['AC_100100']">
|
||||
Visible to Super account ["AC_1000001"]
|
||||
<Button class="mr-4" v-access:code="'AC_100100'">
|
||||
Visible to Super account 'AC_100100'
|
||||
</Button>
|
||||
<Button class="mr-4" v-access:code="['AC_100030']">
|
||||
Visible to Admin account ["AC_100010"]
|
||||
@ -296,9 +298,11 @@ const { hasAccessByRoles } = useAccess();
|
||||
|
||||
#### Directive Method
|
||||
|
||||
> The directive supports binding single or multiple permission codes. For a single one, you can pass a string or an array containing one permission code, and for multiple permission codes, you can pass an array.
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<Button class="mr-4" v-access:role="['super']">
|
||||
<Button class="mr-4" v-access:role="'super'">
|
||||
Visible to Super account
|
||||
</Button>
|
||||
<Button class="mr-4" v-access:role="['admin']">
|
||||
|
@ -229,10 +229,12 @@ const { hasAccessByCodes } = useAccess();
|
||||
|
||||
#### 指令方式
|
||||
|
||||
> 指令支持绑定单个或多个权限码。单个时可以直接传入字符串或数组中包含一个权限码,多个权限码则传入数组。
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<Button class="mr-4" v-access:code="['AC_100100']">
|
||||
Super 账号可见 ["AC_1000001"]
|
||||
<Button class="mr-4" v-access:code="'AC_100100'">
|
||||
Super 账号可见 'AC_100100'
|
||||
</Button>
|
||||
<Button class="mr-4" v-access:code="['AC_100030']">
|
||||
Admin 账号可见 ["AC_100010"]
|
||||
@ -294,8 +296,11 @@ const { hasAccessByRoles } = useAccess();
|
||||
|
||||
#### 指令方式
|
||||
|
||||
> 指令支持绑定单个或多个权限码。单个时可以直接传入字符串或数组中包含一个权限码,多个权限码则传入数组。
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<Button class="mr-4" v-access:role="'super'"> Super 角色可见 </Button>
|
||||
<Button class="mr-4" v-access:role="['super']"> Super 角色可见 </Button>
|
||||
<Button class="mr-4" v-access:role="['admin']"> Admin 角色可见 </Button>
|
||||
<Button class="mr-4" v-access:role="['user']"> User 角色可见 </Button>
|
||||
|
@ -32,11 +32,11 @@
|
||||
"eslint-plugin-import-x": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.9.0",
|
||||
"@types/eslint": "^9.6.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.2.0",
|
||||
"@typescript-eslint/parser": "^8.2.0",
|
||||
"eslint": "^9.9.0",
|
||||
"@eslint/js": "^9.9.1",
|
||||
"@types/eslint": "^9.6.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
||||
"@typescript-eslint/parser": "^8.3.0",
|
||||
"eslint": "^9.9.1",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"eslint-plugin-jsdoc": "^50.2.2",
|
||||
|
@ -25,7 +25,7 @@
|
||||
"dependencies": {
|
||||
"@stylistic/stylelint-plugin": "^3.0.1",
|
||||
"stylelint-config-recess-order": "^5.1.0",
|
||||
"stylelint-scss": "^6.5.0"
|
||||
"stylelint-scss": "^6.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"postcss": "^8.4.41",
|
||||
|
@ -36,7 +36,7 @@
|
||||
"execa": "^9.3.1",
|
||||
"find-up": "^7.0.0",
|
||||
"nanoid": "^5.0.7",
|
||||
"ora": "^8.0.1",
|
||||
"ora": "^8.1.0",
|
||||
"pkg-types": "^1.2.0",
|
||||
"prettier": "^3.3.3",
|
||||
"rimraf": "^6.0.1"
|
||||
|
@ -46,7 +46,7 @@
|
||||
"tailwindcss": "^3.4.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@iconify/json": "^2.2.240",
|
||||
"@iconify/json": "^2.2.241",
|
||||
"@iconify/tailwind": "^1.1.3",
|
||||
"@tailwindcss/nesting": "0.0.0-insiders.565cd3e",
|
||||
"@tailwindcss/typography": "^0.5.14",
|
||||
|
@ -36,7 +36,7 @@
|
||||
"resolve.exports": "^2.0.2",
|
||||
"vite-plugin-lib-inject-css": "^2.1.1",
|
||||
"vite-plugin-pwa": "^0.20.1",
|
||||
"vite-plugin-vue-devtools": "^7.3.8"
|
||||
"vite-plugin-vue-devtools": "^7.3.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/html-minifier-terser": "^7.0.2",
|
||||
|
@ -83,7 +83,7 @@
|
||||
"cspell": "^8.14.2",
|
||||
"husky": "^9.1.5",
|
||||
"is-ci": "^3.0.1",
|
||||
"jsdom": "^24.1.1",
|
||||
"jsdom": "^25.0.0",
|
||||
"lint-staged": "^15.2.9",
|
||||
"rimraf": "^6.0.1",
|
||||
"tailwindcss": "^3.4.10",
|
||||
|
@ -35,7 +35,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@iconify/vue": "^4.1.2",
|
||||
"lucide-vue-next": "^0.435.0",
|
||||
"lucide-vue-next": "^0.436.0",
|
||||
"vue": "^3.4.38"
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@vben-core/shared": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"radix-vue": "^1.9.4",
|
||||
"sortablejs": "^1.15.2",
|
||||
"vue": "^3.4.38"
|
||||
|
@ -31,7 +31,7 @@
|
||||
"dependencies": {
|
||||
"@vben-core/shared": "workspace:*",
|
||||
"@vben-core/typings": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"vue": "^3.4.38"
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
"@vben-core/icons": "workspace:*",
|
||||
"@vben-core/shadcn-ui": "workspace:*",
|
||||
"@vben-core/typings": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"vue": "^3.4.38"
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
"@vben-core/shadcn-ui": "workspace:*",
|
||||
"@vben-core/shared": "workspace:*",
|
||||
"@vben-core/typings": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"vue": "^3.4.38"
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
"@vben-core/icons": "workspace:*",
|
||||
"@vben-core/shadcn-ui": "workspace:*",
|
||||
"@vben-core/shared": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"vue": "^3.4.38"
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,9 @@
|
||||
"@vben-core/icons": "workspace:*",
|
||||
"@vben-core/shared": "workspace:*",
|
||||
"@vben-core/typings": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"lucide-vue-next": "^0.435.0",
|
||||
"lucide-vue-next": "^0.436.0",
|
||||
"radix-vue": "^1.9.4",
|
||||
"vue": "^3.4.38"
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
"@vben-core/icons": "workspace:*",
|
||||
"@vben-core/shadcn-ui": "workspace:*",
|
||||
"@vben-core/typings": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"vue": "^3.4.38"
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,30 @@
|
||||
/**
|
||||
* Global authority directive
|
||||
* Used for fine-grained control of component permissions
|
||||
* @Example v-auth="RoleEnum.TEST"
|
||||
* @Example v-access:role="[ROLE_NAME]" or v-access:role="ROLE_NAME"
|
||||
* @Example v-access:code="[ROLE_CODE]" or v-access:code="ROLE_CODE"
|
||||
*/
|
||||
import type { App, Directive, DirectiveBinding } from 'vue';
|
||||
|
||||
import { useAccess } from './use-access';
|
||||
|
||||
function isAccessible(el: Element, binding: any) {
|
||||
function isAccessible(
|
||||
el: Element,
|
||||
binding: DirectiveBinding<string | string[]>,
|
||||
) {
|
||||
const { accessMode, hasAccessByCodes, hasAccessByRoles } = useAccess();
|
||||
|
||||
const value = binding.value;
|
||||
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
if (!value) return;
|
||||
const authMethod =
|
||||
accessMode.value === 'frontend' && binding.arg === 'role'
|
||||
? hasAccessByRoles
|
||||
: hasAccessByCodes;
|
||||
|
||||
if (!authMethod(value)) {
|
||||
const values = Array.isArray(value) ? value : [value];
|
||||
|
||||
if (!authMethod(values)) {
|
||||
el?.remove();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
"@vben/icons": "workspace:*",
|
||||
"@vben/locales": "workspace:*",
|
||||
"@vben/types": "workspace:*",
|
||||
"@vueuse/integrations": "^11.0.1",
|
||||
"@vueuse/integrations": "^11.0.3",
|
||||
"qrcode": "^1.5.4",
|
||||
"vue": "^3.4.38",
|
||||
"vue-router": "^4.4.3"
|
||||
|
@ -33,7 +33,7 @@
|
||||
"@vben/stores": "workspace:*",
|
||||
"@vben/types": "workspace:*",
|
||||
"@vben/utils": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"vue": "^3.4.38",
|
||||
"vue-router": "^4.4.3"
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@vben/preferences": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"echarts": "^5.5.1",
|
||||
"vue": "^3.4.38"
|
||||
}
|
||||
|
@ -40,7 +40,7 @@
|
||||
"@vben/styles": "workspace:*",
|
||||
"@vben/types": "workspace:*",
|
||||
"@vben/utils": "workspace:*",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"ant-design-vue": "^4.2.3",
|
||||
"dayjs": "^1.11.13",
|
||||
"pinia": "2.2.2",
|
||||
|
642
pnpm-lock.yaml
642
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user