Skip to content

Commit 6c4513a

Browse files
authored
Merge branch 'main' into patch-2
2 parents bbdb512 + 017ed1a commit 6c4513a

File tree

57 files changed

+331
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+331
-82
lines changed

apps/web-antd/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vben/web-antd",
3-
"version": "5.5.6",
3+
"version": "5.5.7",
44
"homepage": "https://vben.pro",
55
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
66
"repository": {

apps/web-ele/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vben/web-ele",
3-
"version": "5.5.6",
3+
"version": "5.5.7",
44
"homepage": "https://vben.pro",
55
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
66
"repository": {

apps/web-naive/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vben/web-naive",
3-
"version": "5.5.6",
3+
"version": "5.5.7",
44
"homepage": "https://vben.pro",
55
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
66
"repository": {

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vben/docs",
3-
"version": "5.5.6",
3+
"version": "5.5.7",
44
"private": true,
55
"scripts": {
66
"build": "vitepress build",

docs/src/en/guide/essentials/settings.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The rules are consistent with [Vite Env Variables and Modes](https://vitejs.dev/
2121
console.log(import.meta.env.VITE_PROT);
2222
```
2323

24-
- Variables starting with `VITE_GLOB_*` will be added to the `_app.config.js` configuration file during packaging. :::
24+
- Variables starting with `VITE_GLOB_*` will be added to the `_app.config.js` configuration file during packaging.
2525

2626
:::
2727

@@ -138,6 +138,27 @@ To add a new dynamically modifiable configuration item, simply follow the steps
138138
}
139139
```
140140

141+
- In `packages/effects/hooks/src/use-app-config.ts`, add the corresponding configuration item, such as:
142+
143+
```ts
144+
export function useAppConfig(
145+
env: Record<string, any>,
146+
isProduction: boolean,
147+
): ApplicationConfig {
148+
// In production environment, directly use the window._VBEN_ADMIN_PRO_APP_CONF_ global variable
149+
const config = isProduction
150+
? window._VBEN_ADMIN_PRO_APP_CONF_
151+
: (env as VbenAdminProAppConfigRaw);
152+
153+
const { VITE_GLOB_API_URL, VITE_GLOB_OTHER_API_URL } = config; // [!code ++]
154+
155+
return {
156+
apiURL: VITE_GLOB_API_URL,
157+
otherApiURL: VITE_GLOB_OTHER_API_URL, // [!code ++]
158+
};
159+
}
160+
```
161+
141162
At this point, you can use the `useAppConfig` method within the project to access the newly added configuration item.
142163

143164
```ts

docs/src/en/guide/in-depth/access.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ outline: deep
44

55
# Access Control
66

7-
The framework has built-in two types of access control methods:
7+
The framework has built-in three types of access control methods:
88

99
- Determining whether a menu or button can be accessed based on user roles
1010
- Determining whether a menu or button can be accessed through an API
11+
- Mixed mode: Using both frontend and backend access control simultaneously
1112

1213
## Frontend Access Control
1314

@@ -151,6 +152,43 @@ const dashboardMenus = [
151152

152153
At this point, the configuration is complete. You need to ensure that after logging in, the format of the menu returned by the interface is correct; otherwise, access will not be possible.
153154

155+
## Mixed Access Control
156+
157+
**Implementation Principle**: Mixed mode combines both frontend access control and backend access control methods. The system processes frontend fixed route permissions and backend dynamic menu data in parallel, ultimately merging both parts of routes to provide a more flexible access control solution.
158+
159+
**Advantages**: Combines the performance advantages of frontend control with the flexibility of backend control, suitable for complex business scenarios requiring permission management.
160+
161+
### Steps
162+
163+
- Ensure the current mode is set to mixed access control
164+
165+
Adjust `preferences.ts` in the corresponding application directory to ensure `accessMode='mixed'`.
166+
167+
```ts
168+
import { defineOverridesPreferences } from '@vben/preferences';
169+
170+
export const overridesPreferences = defineOverridesPreferences({
171+
// overrides
172+
app: {
173+
accessMode: 'mixed',
174+
},
175+
});
176+
```
177+
178+
- Configure frontend route permissions
179+
180+
Same as the route permission configuration method in [Frontend Access Control](#frontend-access-control) mode.
181+
182+
- Configure backend menu interface
183+
184+
Same as the interface configuration method in [Backend Access Control](#backend-access-control) mode.
185+
186+
- Ensure roles and permissions match
187+
188+
Must satisfy both frontend route permission configuration and backend menu data return requirements, ensuring user roles match the permission configurations of both modes.
189+
190+
At this point, the configuration is complete. Mixed mode will automatically merge frontend and backend routes, providing complete access control functionality.
191+
154192
## Fine-grained Control of Buttons
155193

156194
In some cases, we need to control the display of buttons with fine granularity. We can control the display of buttons through interfaces or roles.

docs/src/guide/essentials/settings.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
console.log(import.meta.env.VITE_PROT);
2222
```
2323

24-
-`VITE_GLOB_*` 开头的的变量,在打包的时候,会被加入 `_app.config.js`配置文件当中. :::
24+
-`VITE_GLOB_*` 开头的的变量,在打包的时候,会被加入 `_app.config.js`配置文件当中.
2525

2626
:::
2727

@@ -137,6 +137,27 @@ const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
137137
}
138138
```
139139

140+
-`packages/effects/hooks/src/use-app-config.ts` 中,新增对应的配置项,如:
141+
142+
```ts
143+
export function useAppConfig(
144+
env: Record<string, any>,
145+
isProduction: boolean,
146+
): ApplicationConfig {
147+
// 生产环境下,直接使用 window._VBEN_ADMIN_PRO_APP_CONF_ 全局变量
148+
const config = isProduction
149+
? window._VBEN_ADMIN_PRO_APP_CONF_
150+
: (env as VbenAdminProAppConfigRaw);
151+
152+
const { VITE_GLOB_API_URL, VITE_GLOB_OTHER_API_URL } = config; // [!code ++]
153+
154+
return {
155+
apiURL: VITE_GLOB_API_URL,
156+
otherApiURL: VITE_GLOB_OTHER_API_URL, // [!code ++]
157+
};
158+
}
159+
```
160+
140161
到这里,就可以在项目内使用 `useAppConfig`方法获取到新增的配置项了。
141162

142163
```ts

docs/src/guide/in-depth/access.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ outline: deep
44

55
# 权限
66

7-
框架内置了两种权限控制方式
7+
框架内置了三种权限控制方式
88

99
- 通过用户角色来判断菜单或者按钮是否可以访问
1010
- 通过接口来判断菜单或者按钮是否可以访问
11+
- 混合模式:同时使用前端和后端权限控制
1112

1213
## 前端访问控制
1314

@@ -159,6 +160,43 @@ const dashboardMenus = [
159160

160161
到这里,就已经配置完成,你需要确保登录后,接口返回的菜单格式正确,否则无法访问。
161162

163+
## 混合访问控制
164+
165+
**实现原理**: 混合模式同时结合了前端访问控制和后端访问控制两种方式。系统会并行处理前端固定路由权限和后端动态菜单数据,最终将两部分路由合并,提供更灵活的权限控制方案。
166+
167+
**优点**: 兼具前端控制的性能优势和后端控制的灵活性,适合复杂业务场景下的权限管理。
168+
169+
### 步骤
170+
171+
- 确保当前模式为混合访问控制模式
172+
173+
调整对应应用目录下的`preferences.ts`,确保`accessMode='mixed'`
174+
175+
```ts
176+
import { defineOverridesPreferences } from '@vben/preferences';
177+
178+
export const overridesPreferences = defineOverridesPreferences({
179+
// overrides
180+
app: {
181+
accessMode: 'mixed',
182+
},
183+
});
184+
```
185+
186+
- 配置前端路由权限
187+
188+
[前端访问控制](#前端访问控制)模式的路由权限配置方式。
189+
190+
- 配置后端菜单接口
191+
192+
[后端访问控制](#后端访问控制)模式的接口配置方式。
193+
194+
- 确保角色和权限匹配
195+
196+
需要同时满足前端路由权限配置和后端菜单数据返回的要求,确保用户角色与两种模式的权限配置都匹配。
197+
198+
到这里,就已经配置完成,混合模式会自动合并前端和后端的路由,提供完整的权限控制功能。
199+
162200
## 按钮细粒度控制
163201

164202
在某些情况下,我们需要对按钮进行细粒度的控制,我们可以借助接口或者角色来控制按钮的显示。

internal/lint-configs/commitlint-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vben/commitlint-config",
3-
"version": "5.5.6",
3+
"version": "5.5.7",
44
"private": true,
55
"homepage": "https://github.com/vbenjs/vue-vben-admin",
66
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",

internal/lint-configs/stylelint-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vben/stylelint-config",
3-
"version": "5.5.6",
3+
"version": "5.5.7",
44
"private": true,
55
"homepage": "https://github.com/vbenjs/vue-vben-admin",
66
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",

0 commit comments

Comments
 (0)