-
- {{ open ? 'Collapse code' : 'Expand code' }}
- Contributors
- -
diff --git a/docs/src/commercial/customized.md b/docs/src/commercial/customized.md
deleted file mode 100644
index 1f0bceca..00000000
--- a/docs/src/commercial/customized.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# 定制开发
-
-我们提供基于 Vben Admin 的技术支持服务及定制开发,基本需求我们都可以满足。
-
-详细需求可添加作者了解,并注明来意:
-
-- 通过邮箱联系开发者: [ann.vben@gmail.com](mailto:ann.vben@gmail.com)
-- 通过微信联系开发者:
-
-
-
-我们会在第一时间回复您,定制费用根据需求而定。
diff --git a/docs/src/commercial/technical-support.md b/docs/src/commercial/technical-support.md
deleted file mode 100644
index ded9bf2d..00000000
--- a/docs/src/commercial/technical-support.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# 技术支持
-
-## 问题反馈
-
-在使用项目的过程中,如果遇到问题,你可以先详细阅读本文档,未找到解决方案时,可以通过以下方式获取技术支持:
-
-- 通过 [GitHub Issues](https://github.com/vbenjs/vue-vben-admin/issues)
-- 通过 [GitHub Discussions](https://github.com/vbenjs/vue-vben-admin/discussions)
diff --git a/docs/src/components/common-ui/vben-alert.md b/docs/src/components/common-ui/vben-alert.md
deleted file mode 100644
index 6541b665..00000000
--- a/docs/src/components/common-ui/vben-alert.md
+++ /dev/null
@@ -1,166 +0,0 @@
----
-outline: deep
----
-
-# Vben Alert 轻量提示框
-
-框架提供的一些用于轻量提示的弹窗,仅使用js代码即可快速动态创建提示而不需要在template写任何代码。
-
-::: info 应用场景
-
-Alert提供的功能与Modal类似,但只适用于简单应用场景。例如临时性、动态地弹出模态确认框、输入框等。如果对弹窗有更复杂的需求,请使用VbenModal
-
-:::
-
-::: tip 注意
-
-Alert提供的快捷方法alert、confirm、prompt动态创建的弹窗在已打开的情况下,不支持HMR(热更新),代码变更后需要关闭这些弹窗后重新打开。
-
-:::
-
-::: tip README
-
-下方示例代码中的,存在一些主题色未适配、样式缺失的问题,这些问题只在文档内会出现,实际使用并不会有这些问题,可忽略,不必纠结。
-
-:::
-
-## 基础用法
-
-使用 `alert` 创建只有一个确认按钮的提示框。
-
-这是使用滑动动画的弹窗,从顶部向下滑动进入。
-这是使用缩放动画的弹窗,以缩放淡入淡出的方式显示。
-hello world
-This should be red
- - - -``` - -For more usage, see the [CSS Modules official documentation](https://vuejs.org/api/sfc-css-features.html#css-modules). diff --git a/docs/src/en/guide/in-depth/access.md b/docs/src/en/guide/in-depth/access.md deleted file mode 100644 index 545dddab..00000000 --- a/docs/src/en/guide/in-depth/access.md +++ /dev/null @@ -1,356 +0,0 @@ ---- -outline: deep ---- - -# Access Control - -The framework has built-in three types of access control methods: - -- Determining whether a menu or button can be accessed based on user roles -- Determining whether a menu or button can be accessed through an API -- Mixed mode: Using both frontend and backend access control simultaneously - -## Frontend Access Control - -**Implementation Principle**: The permissions for routes are hardcoded on the frontend, specifying which permissions are required to view certain routes. Only general routes are initialized, and routes that require permissions are not added to the route table. After logging in or obtaining user roles through other means, the roles are used to traverse the route table to generate a route table that the role can access. This table is then added to the router instance using `router.addRoute`, achieving permission filtering. - -**Disadvantage**: The permissions are relatively inflexible; if the backend changes roles, the frontend needs to be adjusted accordingly. This is suitable for systems with relatively fixed roles. - -### Steps - -- Ensure the current mode is set to frontend access control - -Adjust `preferences.ts` in the corresponding application directory to ensure `accessMode='frontend'`. - -```ts -import { defineOverridesPreferences } from '@vben/preferences'; - -export const overridesPreferences = defineOverridesPreferences({ - // overrides - app: { - // Default value, optional - accessMode: 'frontend', - }, -}); -``` - -- Configure route permissions - -#### If not configured, it is visible by default - -```ts {3} - { - meta: { - authority: ['super'], - }, -}, -``` - -- Ensure the roles returned by the interface match the permissions in the route table - -You can look under `src/store/auth` in the application to find the following code: - -```ts -// Set the login user information, ensuring that userInfo.roles is an array and contains permissions from the route table -// For example: userInfo.roles=['super', 'admin'] -authStore.setUserInfo(userInfo); -``` - -At this point, the configuration is complete. You need to ensure that the roles returned by the interface after login match the permissions in the route table; otherwise, access will not be possible. - -### Menu Visible but Access Forbidden - -Sometimes, we need the menu to be visible but access to it forbidden. This can be achieved by setting `menuVisibleWithForbidden` to `true`. In this case, the menu will be visible, but access will be forbidden, redirecting to a 403 page. - -```ts -{ - meta: { - menuVisibleWithForbidden: true, - }, -}, -``` - -## Backend Access Control - -**Implementation Principle**: It is achieved by dynamically generating a routing table through an API, which returns data following a certain structure. The frontend processes this data into a recognizable structure, then adds it to the routing instance using `router.addRoute`, realizing the dynamic generation of permissions. - -**Disadvantage**: The backend needs to provide a data structure that meets the standards, and the frontend needs to process this structure. This is suitable for systems with more complex permissions. - -### Steps - -- Ensure the current mode is set to backend access control - -Adjust `preferences.ts` in the corresponding application directory to ensure `accessMode='backend'`. - -```ts -import { defineOverridesPreferences } from '@vben/preferences'; - -export const overridesPreferences = defineOverridesPreferences({ - // overrides - app: { - accessMode: 'backend', - }, -}); -``` - -- Ensure the structure of the menu data returned by the interface is correct - -You can look under `src/router/access.ts` in the application to find the following code: - -```ts -async function generateAccess(options: GenerateMenuAndRoutesOptions) { - return await generateAccessible(preferences.app.accessMode, { - fetchMenuListAsync: async () => { - // This interface is for the menu data returned by the backend - return await getAllMenus(); - }, - }); -} -``` - -- Interface returns menu data, see comments for explanation - -::: details Example of Interface Returning Menu Data - -```ts -const dashboardMenus = [ - { - // Here, 'BasicLayout' is hardcoded and cannot be changed - component: 'BasicLayout', - meta: { - order: -1, - title: 'page.dashboard.title', - }, - name: 'Dashboard', - path: '/', - redirect: '/analytics', - children: [ - { - name: 'Analytics', - path: '/analytics', - // Here is the path of the page, need to remove 'views/' and '.vue' - component: '/dashboard/analytics/index', - meta: { - affixTab: true, - title: 'page.dashboard.analytics', - }, - }, - { - name: 'Workspace', - path: '/workspace', - component: '/dashboard/workspace/index', - meta: { - title: 'page.dashboard.workspace', - }, - }, - ], - }, -]; -``` - -::: - -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. - -## Mixed Access Control - -**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. - -**Advantages**: Combines the performance advantages of frontend control with the flexibility of backend control, suitable for complex business scenarios requiring permission management. - -### Steps - -- Ensure the current mode is set to mixed access control - -Adjust `preferences.ts` in the corresponding application directory to ensure `accessMode='mixed'`. - -```ts -import { defineOverridesPreferences } from '@vben/preferences'; - -export const overridesPreferences = defineOverridesPreferences({ - // overrides - app: { - accessMode: 'mixed', - }, -}); -``` - -- Configure frontend route permissions - -Same as the route permission configuration method in [Frontend Access Control](#frontend-access-control) mode. - -- Configure backend menu interface - -Same as the interface configuration method in [Backend Access Control](#backend-access-control) mode. - -- Ensure roles and permissions match - -Must satisfy both frontend route permission configuration and backend menu data return requirements, ensuring user roles match the permission configurations of both modes. - -At this point, the configuration is complete. Mixed mode will automatically merge frontend and backend routes, providing complete access control functionality. - -## Fine-grained Control of Buttons - -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. - -### Permission Code - -The permission code is the code returned by the interface. The logic to determine whether a button is displayed is located under `src/store/auth`: - -```ts -const [fetchUserInfoResult, accessCodes] = await Promise.all([ - fetchUserInfo(), - getAccessCodes(), -]); - -userInfo = fetchUserInfoResult; -authStore.setUserInfo(userInfo); -accessStore.setAccessCodes(accessCodes); -``` - -Locate the `getAccessCodes` corresponding interface, which can be adjusted according to business logic. - -The data structure returned by the permission code is an array of strings, for example: `['AC_100100', 'AC_100110', 'AC_100120', 'AC_100010']` - -With the permission codes, you can use the `AccessControl` component and API provided by `@vben/access` to show and hide buttons. - -#### Component Method - -```vue - - - - -