[](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin)    
@@ -17,7 +22,7 @@ Vue Vben Admin is a free and open source middle and back-end template. Using the
This is the latest version, 5.0, and it is not compatible with previous versions. If you are starting a new project, it is recommended to use the latest version. If you wish to view the old version, please use the [v2 branch](https://github.com/vbenjs/vue-vben-admin/tree/v2).
-## Feature
+## Features
- **Latest Technology Stack**: Developed with cutting-edge front-end technologies like Vue 3 and Vite
- **TypeScript**: A language for application-scale JavaScript
@@ -31,11 +36,11 @@ This is the latest version, 5.0, and it is not compatible with previous versions
Test Account: vben/123456
-
-
-
-
-
+
+
+
+
+
### Use Gitpod
@@ -47,31 +52,29 @@ Open the project in Gitpod (free online dev environment for GitHub) and start co
[Document](https://doc.vben.pro/)
-## Install and use
+## Install and Use
-- Get the project code
+1. Get the project code
```bash
git clone https://github.com/vbenjs/vue-vben-admin.git
```
-- Installation dependencies
+2. Install dependencies
```bash
cd vue-vben-admin
-
-corepack enable
-
+npm i -g corepack
pnpm install
```
-- run
+3. Run
```bash
pnpm dev
```
-- build
+4. Build
```bash
pnpm build
@@ -81,44 +84,43 @@ pnpm build
[CHANGELOG](https://github.com/vbenjs/vue-vben-admin/releases)
-## How to contribute
+## How to Contribute
-You are very welcome to join Or submit a Pull Request。
+You are very welcome to join! [Raise an issue](https://github.com/anncwb/vue-vben-admin/issues/new/choose) or submit a Pull Request.
-**Pull Request:**
+**Pull Request Process:**
-1. Fork code!
-2. Create your own branch: `git checkout -b feat/xxxx`
+1. Fork the code
+2. Create your branch: `git checkout -b feat/xxxx`
3. Submit your changes: `git commit -am 'feat(function): add xxxxx'`
4. Push your branch: `git push origin feat/xxxx`
-5. submit`pull request`
+5. Submit `pull request`
-## Git Contribution submission specification
+## Git Contribution Submission Specification
-- reference [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) specification ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
+Reference [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) specification ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
- - `feat` Add new features
- - `fix` Fix the problem/BUG
- - `style` The code style is related and does not affect the running result
- - `perf` Optimization/performance improvement
- - `refactor` Refactor
- - `revert` Undo edit
- - `test` Test related
- - `docs` Documentation/notes
- - `chore` Dependency update/scaffolding configuration modification etc.
- - `ci` Continuous integration
- - `types` Type definition file changes
- - `wip` In development
+- `feat` Add new features
+- `fix` Fix the problem/BUG
+- `style` The code style is related and does not affect the running result
+- `perf` Optimization/performance improvement
+- `refactor` Refactor
+- `revert` Undo edit
+- `test` Test related
+- `docs` Documentation/notes
+- `chore` Dependency update/scaffolding configuration modification etc.
+- `ci` Continuous integration
+- `types` Type definition file changes
-## Browser support
+## Browser Support
The `Chrome 80+` browser is recommended for local development
Support modern browsers, not IE
-| [](http://godban.github.io/browsers-support-badges/)IE | [](http://godban.github.io/browsers-support-badges/)Edge | [](http://godban.github.io/browsers-support-badges/)Firefox | [](http://godban.github.io/browsers-support-badges/)Chrome | [](http://godban.github.io/browsers-support-badges/)Safari |
-| :-: | :-: | :-: | :-: | :-: |
-| not support | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
+| [](http://godban.github.io/browsers-support-badges/)Edge | [](http://godban.github.io/browsers-support-badges/)Firefox | [](http://godban.github.io/browsers-support-badges/)Chrome | [](http://godban.github.io/browsers-support-badges/)Safari |
+| :-: | :-: | :-: | :-: |
+| last 2 versions | last 2 versions | last 2 versions | last 2 versions |
## Maintainer
@@ -136,11 +138,10 @@ If you think this project is helpful to you, you can help the author buy a cup o
Paypal Me
-## Contributor
+## Contributors
-
+
## Discord
diff --git a/apps/vben5/README.zh-CN.md b/apps/vben5/README.zh-CN.md
index e2f05bb98..5a6b191b8 100644
--- a/apps/vben5/README.zh-CN.md
+++ b/apps/vben5/README.zh-CN.md
@@ -1,8 +1,13 @@
-
+ Prompt
+ Prompt With slots
+ Prompt With Select
+ Prompt With Async
+
+
diff --git a/apps/vben5/docs/src/demos/vben-ellipsis-text/auto-display/index.vue b/apps/vben5/docs/src/demos/vben-ellipsis-text/auto-display/index.vue
new file mode 100644
index 000000000..fb5a32a50
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-ellipsis-text/auto-display/index.vue
@@ -0,0 +1,16 @@
+
+
+
+ {{ text }}
+
+
+
+ {{ text }}
+
+
diff --git a/apps/vben5/docs/src/en/guide/essentials/development.md b/apps/vben5/docs/src/en/guide/essentials/development.md
index da7cfd8ce..9ff832b7b 100644
--- a/apps/vben5/docs/src/en/guide/essentials/development.md
+++ b/apps/vben5/docs/src/en/guide/essentials/development.md
@@ -98,8 +98,8 @@ The execution command is: `pnpm run [script]` or `npm run [script]`.
"postinstall": "pnpm -r run stub --if-present",
// Only allow using pnpm
"preinstall": "npx only-allow pnpm",
- // Install husky
- "prepare": "is-ci || husky",
+ // Install lefthook
+ "prepare": "is-ci || lefthook install",
// Preview the application
"preview": "turbo-run preview",
// Package specification check
@@ -150,6 +150,73 @@ To run the `docs` application:
pnpm dev:docs
```
+### Distinguishing Build Environments
+
+In actual business development, multiple environments are usually distinguished during the build process, such as the test environment `test` and the production environment `build`.
+
+At this point, you can modify three files and add corresponding script configurations to distinguish between production environments.
+
+Take the addition of the test environment `test` to `@vben/web-antd` as an example:
+
+- `apps\web-antd\package.json`
+
+```json
+"scripts": {
+ "build:prod": "pnpm vite build --mode production",
+ "build:test": "pnpm vite build --mode test",
+ "build:analyze": "pnpm vite build --mode analyze",
+ "dev": "pnpm vite --mode development",
+ "preview": "vite preview",
+ "typecheck": "vue-tsc --noEmit --skipLibCheck"
+}
+```
+
+Add the command `"build:test"` and change the original `"build"` to `"build:prod"` to avoid building packages for two environments simultaneously.
+
+- `package.json`
+
+```json
+"scripts": {
+ "build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 turbo build",
+ "build:analyze": "turbo build:analyze",
+ "build:antd": "pnpm run build --filter=@vben/web-antd",
+ "build-test:antd": "pnpm run build --filter=@vben/web-antd build:test",
+
+ ······
+}
+```
+
+Add the command to build the test environment in the root directory `package.json`.
+
+- `turbo.json`
+
+```json
+"tasks": {
+ "build": {
+ "dependsOn": ["^build"],
+ "outputs": [
+ "dist/**",
+ "dist.zip",
+ ".vitepress/dist.zip",
+ ".vitepress/dist/**"
+ ]
+ },
+
+ "build-test:antd": {
+ "dependsOn": ["@vben/web-antd#build:test"],
+ "outputs": ["dist/**"]
+ },
+
+ "@vben/web-antd#build:test": {
+ "dependsOn": ["^build"],
+ "outputs": ["dist/**"]
+ },
+
+ ······
+```
+
+Add the relevant dependent commands in `turbo.json`.
+
## Public Static Resources
If you need to use public static resources in the project, such as images, static HTML, etc., and you want to directly import them in the development process through `src="/xxx.png"`.
diff --git a/apps/vben5/docs/src/en/guide/essentials/settings.md b/apps/vben5/docs/src/en/guide/essentials/settings.md
index a3cd579ec..59a6c5c01 100644
--- a/apps/vben5/docs/src/en/guide/essentials/settings.md
+++ b/apps/vben5/docs/src/en/guide/essentials/settings.md
@@ -21,7 +21,7 @@ The rules are consistent with [Vite Env Variables and Modes](https://vitejs.dev/
console.log(import.meta.env.VITE_PROT);
```
-- Variables starting with `VITE_GLOB_*` will be added to the `_app.config.js` configuration file during packaging. :::
+- Variables starting with `VITE_GLOB_*` will be added to the `_app.config.js` configuration file during packaging.
:::
@@ -60,6 +60,29 @@ VITE_INJECT_APP_LOADING=true
VITE_ARCHIVER=true
```
+```bash [.env.production]
+# Public Path for Resources, must start and end with /
+VITE_BASE=/
+
+# API URL
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+
+# Whether to enable compression, can be set to none, brotli, gzip
+VITE_COMPRESS=gzip
+
+# Whether to enable PWA
+VITE_PWA=false
+
+# vue-router mode
+VITE_ROUTER_HISTORY=hash
+
+# Whether to inject global loading
+VITE_INJECT_APP_LOADING=true
+
+# Whether to generate dist.zip after packaging
+VITE_ARCHIVER=true
+```
+
:::
## Dynamic Configuration in Production Environment
@@ -115,6 +138,27 @@ To add a new dynamically modifiable configuration item, simply follow the steps
}
```
+- In `packages/effects/hooks/src/use-app-config.ts`, add the corresponding configuration item, such as:
+
+ ```ts
+ export function useAppConfig(
+ env: Record,
+ isProduction: boolean,
+ ): ApplicationConfig {
+ // In production environment, directly use the window._VBEN_ADMIN_PRO_APP_CONF_ global variable
+ const config = isProduction
+ ? window._VBEN_ADMIN_PRO_APP_CONF_
+ : (env as VbenAdminProAppConfigRaw);
+
+ const { VITE_GLOB_API_URL, VITE_GLOB_OTHER_API_URL } = config; // [!code ++]
+
+ return {
+ apiURL: VITE_GLOB_API_URL,
+ otherApiURL: VITE_GLOB_OTHER_API_URL, // [!code ++]
+ };
+ }
+ ```
+
At this point, you can use the `useAppConfig` method within the project to access the newly added configuration item.
```ts
@@ -142,6 +186,7 @@ import { defineOverridesPreferences } from '@vben/preferences';
/**
* @description Project configuration file
* Only a part of the configuration in the project needs to be covered, and unnecessary configurations do not need to be covered. The default configuration will be automatically used
+ * !!! Please clear the cache after changing the configuration, otherwise it may not take effect
*/
export const overridesPreferences = defineOverridesPreferences({
// overrides
@@ -162,8 +207,15 @@ const defaultPreferences: Preferences = {
colorWeakMode: false,
compact: false,
contentCompact: 'wide',
+ contentCompactWidth: 1200,
+ contentPadding: 0,
+ contentPaddingBottom: 0,
+ contentPaddingLeft: 0,
+ contentPaddingRight: 0,
+ contentPaddingTop: 0,
defaultAvatar:
'https://unpkg.com/@vbenjs/static-source@0.1.7/source/avatar-v1.webp',
+ defaultHomePath: '/analytics',
dynamicTitle: true,
enableCheckUpdates: true,
enablePreferences: true,
@@ -171,10 +223,11 @@ const defaultPreferences: Preferences = {
isMobile: false,
layout: 'sidebar-nav',
locale: 'zh-CN',
- loginExpiredMode: 'modal',
+ loginExpiredMode: 'page',
name: 'Vben Admin',
preferencesButtonPosition: 'auto',
watermark: false,
+ zIndex: 200,
},
breadcrumb: {
enable: true,
@@ -190,18 +243,23 @@ const defaultPreferences: Preferences = {
enable: true,
icp: '',
icpLink: '',
+ settingShow: true,
},
footer: {
- enable: true,
+ enable: false,
fixed: false,
+ height: 32,
},
header: {
enable: true,
+ height: 50,
hidden: false,
+ menuAlign: 'start',
mode: 'fixed',
},
logo: {
enable: true,
+ fit: 'contain',
source: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp',
},
navigation: {
@@ -219,23 +277,31 @@ const defaultPreferences: Preferences = {
sidebar: {
autoActivateChild: false,
collapsed: false,
+ collapsedButton: true,
collapsedShowTitle: false,
+ collapseWidth: 60,
enable: true,
expandOnHover: true,
- extraCollapse: true,
+ extraCollapse: false,
+ extraCollapsedWidth: 60,
+ fixedButton: true,
hidden: false,
- width: 230,
+ mixedWidth: 80,
+ width: 224,
},
tabbar: {
draggable: true,
enable: true,
- height: 36,
+ height: 38,
keepAlive: true,
+ maxCount: 0,
+ middleClickToClose: false,
persist: true,
showIcon: true,
showMaximize: true,
showMore: true,
styleType: 'chrome',
+ wheelable: true,
},
theme: {
builtinType: 'default',
@@ -246,7 +312,7 @@ const defaultPreferences: Preferences = {
mode: 'dark',
radius: '0.5',
semiDarkHeader: false,
- semiDarkSidebar: true,
+ semiDarkSidebar: false,
},
transition: {
enable: true,
@@ -260,9 +326,9 @@ const defaultPreferences: Preferences = {
languageToggle: true,
lockScreen: true,
notification: true,
+ refresh: true,
sidebarToggle: true,
themeToggle: true,
- refresh: true,
},
};
```
@@ -287,8 +353,22 @@ interface AppPreferences {
compact: boolean;
/** Whether to enable content compact mode */
contentCompact: ContentCompactType;
+ /** Content compact width */
+ contentCompactWidth: number;
+ /** Content padding */
+ contentPadding: number;
+ /** Content bottom padding */
+ contentPaddingBottom: number;
+ /** Content left padding */
+ contentPaddingLeft: number;
+ /** Content right padding */
+ contentPaddingRight: number;
+ /** Content top padding */
+ contentPaddingTop: number;
// /** Default application avatar */
defaultAvatar: string;
+ /** Default homepage path */
+ defaultHomePath: string;
// /** Enable dynamic title */
dynamicTitle: boolean;
/** Whether to enable update checks */
@@ -315,6 +395,8 @@ interface AppPreferences {
* @zh_CN Whether to enable watermark
*/
watermark: boolean;
+ /** z-index */
+ zIndex: number;
}
interface BreadcrumbPreferences {
/** Whether breadcrumbs are enabled */
@@ -342,6 +424,8 @@ interface CopyrightPreferences {
icp: string;
/** Link to the ICP */
icpLink: string;
+ /** Whether to show in settings panel */
+ settingShow?: boolean;
}
interface FooterPreferences {
@@ -349,13 +433,19 @@ interface FooterPreferences {
enable: boolean;
/** Whether the footer is fixed */
fixed: boolean;
+ /** Footer height */
+ height: number;
}
interface HeaderPreferences {
/** Whether the header is enabled */
enable: boolean;
+ /** Header height */
+ height: number;
/** Whether the header is hidden, css-hidden */
hidden: boolean;
+ /** Header menu alignment */
+ menuAlign: LayoutHeaderMenuAlignType;
/** Header display mode */
mode: LayoutHeaderModeType;
}
@@ -363,6 +453,8 @@ interface HeaderPreferences {
interface LogoPreferences {
/** Whether the logo is visible */
enable: boolean;
+ /** Logo image fitting method */
+ fit: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
/** Logo URL */
source: string;
}
@@ -376,18 +468,30 @@ interface NavigationPreferences {
styleType: NavigationStyleType;
}
interface SidebarPreferences {
+ /** Automatically activate child menu when clicking on directory */
+ autoActivateChild: boolean;
/** Whether the sidebar is collapsed */
collapsed: boolean;
+ /** Whether the sidebar collapse button is visible */
+ collapsedButton: boolean;
/** Whether to show title when sidebar is collapsed */
collapsedShowTitle: boolean;
+ /** Sidebar collapse width */
+ collapseWidth: number;
/** Whether the sidebar is visible */
enable: boolean;
/** Menu auto-expand state */
expandOnHover: boolean;
/** Whether the sidebar extension area is collapsed */
extraCollapse: boolean;
+ /** Sidebar extension area collapse width */
+ extraCollapsedWidth: number;
+ /** Whether the sidebar fixed button is visible */
+ fixedButton: boolean;
/** Whether the sidebar is hidden - css */
hidden: boolean;
+ /** Mixed sidebar width */
+ mixedWidth: number;
/** Sidebar width */
width: number;
}
@@ -414,6 +518,10 @@ interface TabbarPreferences {
height: number;
/** Whether tab caching is enabled */
keepAlive: boolean;
+ /** Maximum number of tabs */
+ maxCount: number;
+ /** Whether to close tab when middle-clicked */
+ middleClickToClose: boolean;
/** Whether tabs are persistent */
persist: boolean;
/** Whether icons in multiple tabs are enabled */
@@ -424,6 +532,8 @@ interface TabbarPreferences {
showMore: boolean;
/** Tab style */
styleType: TabsStyleType;
+ /** Whether mouse wheel response is enabled */
+ wheelable: boolean;
}
interface ThemePreferences {
/** Built-in theme name */
@@ -511,5 +621,6 @@ interface Preferences {
- The `overridesPreferences` method only needs to override a part of the configurations in the project. There's no need to override configurations that are not needed; they will automatically use the default settings.
- Any configuration item can be overridden. You just need to override it within the `overridesPreferences` method. Do not modify the default configuration file.
+- Please clear the cache after changing the configuration, otherwise it may not take effect.
:::
diff --git a/apps/vben5/docs/src/en/guide/in-depth/access.md b/apps/vben5/docs/src/en/guide/in-depth/access.md
index 05997d7d5..545dddabd 100644
--- a/apps/vben5/docs/src/en/guide/in-depth/access.md
+++ b/apps/vben5/docs/src/en/guide/in-depth/access.md
@@ -4,10 +4,11 @@ outline: deep
# Access Control
-The framework has built-in two types of access control methods:
+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
@@ -151,6 +152,43 @@ const dashboardMenus = [
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.
diff --git a/apps/vben5/docs/src/en/guide/in-depth/theme.md b/apps/vben5/docs/src/en/guide/in-depth/theme.md
index 11c9c992b..164ac1797 100644
--- a/apps/vben5/docs/src/en/guide/in-depth/theme.md
+++ b/apps/vben5/docs/src/en/guide/in-depth/theme.md
@@ -28,9 +28,10 @@ You can check the list below to understand all the available variables.
```css
:root {
- --font-family: -apple-system, blinkmacsystemfont, 'Segoe UI', roboto,
- 'Helvetica Neue', arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
- 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
+ --font-family:
+ -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue',
+ arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
+ 'Segoe UI Symbol', 'Noto Color Emoji';
/* Default background color of ...etc */
--background: 0 0% 100%;
@@ -322,9 +323,10 @@ type BuiltinThemeType =
```css
:root {
- --font-family: -apple-system, blinkmacsystemfont, 'Segoe UI', roboto,
- 'Helvetica Neue', arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
- 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
+ --font-family:
+ -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue',
+ arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
+ 'Segoe UI Symbol', 'Noto Color Emoji';
/* Default background color of ...etc */
--background: 0 0% 100%;
diff --git a/apps/vben5/docs/src/en/guide/introduction/quick-start.md b/apps/vben5/docs/src/en/guide/introduction/quick-start.md
index d4829dcef..757679c39 100644
--- a/apps/vben5/docs/src/en/guide/introduction/quick-start.md
+++ b/apps/vben5/docs/src/en/guide/introduction/quick-start.md
@@ -58,7 +58,7 @@ Open a terminal in your code directory and execute the following commands:
cd vue-vben-admin
# Enable the project-specified version of pnpm
-corepack enable
+npm i -g corepack
# Install dependencies
pnpm install
diff --git a/apps/vben5/docs/src/en/guide/other/faq.md b/apps/vben5/docs/src/en/guide/other/faq.md
index da908f893..50cc13359 100644
--- a/apps/vben5/docs/src/en/guide/other/faq.md
+++ b/apps/vben5/docs/src/en/guide/other/faq.md
@@ -18,7 +18,7 @@ If you encounter a problem, you can start looking from the following aspects:
## Dependency Issues
-In a `Monorepo` project, it is necessary to develop the habit of executing `pnpm install` every time you `git pull` the code, as new dependency packages are often added. The project has already configured automatic execution of `pnpm install` in `.husky/git-merge`, but sometimes there might be issues. If it does not execute automatically, it is recommended to execute it manually once.
+In a `Monorepo` project, it's important to get into the habit of running `pnpm install` after every `git pull` because new dependencies are often added. The project has configured automatic execution of `pnpm install` in `lefthook.yml`, but sometimes there might be issues. If it does not execute automatically, it is recommended to execute it manually once.
## About Cache Update Issues
diff --git a/apps/vben5/docs/src/en/guide/project/standard.md b/apps/vben5/docs/src/en/guide/project/standard.md
index 23770c548..e5417ce7c 100644
--- a/apps/vben5/docs/src/en/guide/project/standard.md
+++ b/apps/vben5/docs/src/en/guide/project/standard.md
@@ -33,8 +33,8 @@ The project integrates the following code verification tools:
- [Prettier](https://prettier.io/) for code formatting
- [Commitlint](https://commitlint.js.org/) for checking the standard of git commit messages
- [Publint](https://publint.dev/) for checking the standard of npm packages
-- [Lint Staged](https://github.com/lint-staged/lint-staged) for running code verification before git commits
- [Cspell](https://cspell.org/) for checking spelling errors
+- [lefthook](https://github.com/evilmartians/lefthook) for managing Git hooks, automatically running code checks and formatting before commits
## ESLint
@@ -148,18 +148,66 @@ The cspell configuration file is `cspell.json`, which can be modified according
Git hooks are generally combined with various lints to check code style during git commits. If the check fails, the commit will not proceed. Developers need to modify and resubmit.
-### husky
+### lefthook
-One issue is that the check will verify all code, but we only want to check the code we are committing. This is where husky comes in.
+One issue is that the check will verify all code, but we only want to check the code we are committing. This is where lefthook comes in.
-The most effective solution is to perform Lint checks locally before committing. A common practice is to use husky or pre-commit to perform a Lint check before local submission.
+The most effective solution is to perform Lint checks locally before committing. A common practice is to use lefthook to perform a Lint check before local submission.
-The project defines corresponding hooks inside `.husky`.
+The project defines corresponding hooks inside `lefthook.yml`:
-#### How to Disable Husky
+- `pre-commit`: Runs before commit, used for code formatting and checking
-If you want to disable Husky, simply delete the .husky directory.
+ - `code-workspace`: Updates VSCode workspace configuration
+ - `lint-md`: Formats Markdown files
+ - `lint-vue`: Formats and checks Vue files
+ - `lint-js`: Formats and checks JavaScript/TypeScript files
+ - `lint-style`: Formats and checks style files
+ - `lint-package`: Formats package.json
+ - `lint-json`: Formats other JSON files
-### lint-staged
+- `post-merge`: Runs after merge, used for automatic dependency installation
-Used for automatically fixing style issues of committed files. Its configuration file is `.lintstagedrc.mjs`, which can be modified according to project needs.
+ - `install`: Runs `pnpm install` to install new dependencies
+
+- `commit-msg`: Runs during commit, used for checking commit message format
+ - `commitlint`: Uses commitlint to check commit messages
+
+#### How to Disable lefthook
+
+If you want to disable lefthook, there are two ways:
+
+::: code-group
+
+```bash [Temporary disable]
+git commit -m 'feat: add home page' --no-verify
+```
+
+```bash [Permanent disable]
+# Simply delete the lefthook.yml file
+rm lefthook.yml
+```
+
+:::
+
+#### How to Modify lefthook Configuration
+
+If you want to modify lefthook's configuration, you can edit the `lefthook.yml` file. For example:
+
+```yaml
+pre-commit:
+ parallel: true # Execute tasks in parallel
+ jobs:
+ - name: lint-js
+ run: pnpm prettier --cache --ignore-unknown --write {staged_files}
+ glob: '*.{js,jsx,ts,tsx}'
+```
+
+Where:
+
+- `parallel`: Whether to execute tasks in parallel
+- `jobs`: Defines the list of tasks to execute
+- `name`: Task name
+- `run`: Command to execute
+- `glob`: File pattern to match
+- `{staged_files}`: Represents the list of staged files
diff --git a/apps/vben5/docs/src/guide/essentials/build.md b/apps/vben5/docs/src/guide/essentials/build.md
index ab9828fd5..134a632a7 100644
--- a/apps/vben5/docs/src/guide/essentials/build.md
+++ b/apps/vben5/docs/src/guide/essentials/build.md
@@ -47,7 +47,7 @@ cd apps/web-antd/dist
# 本地预览,默认端口8080
live-server
# 指定端口
-live-server --port 9000
+live-server --port=9000
```
## 压缩
@@ -214,7 +214,7 @@ server {
使用 nginx 处理项目部署后的跨域问题
-1. 配置前端项目接口地址,在项目目录下的``.env.production`文件中配置:
+1. 配置前端项目接口地址,在项目目录下的`.env.production`文件中配置:
```bash
VITE_GLOB_API_URL=/api
diff --git a/apps/vben5/docs/src/guide/essentials/development.md b/apps/vben5/docs/src/guide/essentials/development.md
index 556e4c9dd..cb55b6b5c 100644
--- a/apps/vben5/docs/src/guide/essentials/development.md
+++ b/apps/vben5/docs/src/guide/essentials/development.md
@@ -98,8 +98,8 @@ npm 脚本是项目常见的配置,用于执行一些常见的任务,比如
"postinstall": "pnpm -r run stub --if-present",
// 只允许使用pnpm
"preinstall": "npx only-allow pnpm",
- // husky的安装
- "prepare": "is-ci || husky",
+ // lefthook的安装
+ "prepare": "is-ci || lefthook install",
// 预览应用
"preview": "turbo-run preview",
// 包规范检查
@@ -150,6 +150,73 @@ pnpm dev:ele
pnpm dev:docs
```
+## 区分构建环境
+
+在实际的业务开发中,通常会在构建时区分多种环境,如测试环境`test`、生产环境`build`等。
+
+此时可以修改三个文件,在其中增加对应的脚本配置来达到区分生产环境的效果。
+
+以`@vben/web-antd`添加测试环境`test`为例:
+
+- `apps\web-antd\package.json`
+
+```json
+"scripts": {
+ "build:prod": "pnpm vite build --mode production",
+ "build:test": "pnpm vite build --mode test",
+ "build:analyze": "pnpm vite build --mode analyze",
+ "dev": "pnpm vite --mode development",
+ "preview": "vite preview",
+ "typecheck": "vue-tsc --noEmit --skipLibCheck"
+},
+```
+
+增加命令`"build:test"`, 并将原`"build"`改为`"build:prod"`以避免同时构建两个环境的包。
+
+- `package.json`
+
+```json
+"scripts": {
+ "build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 turbo build",
+ "build:analyze": "turbo build:analyze",
+ "build:antd": "pnpm run build --filter=@vben/web-antd",
+ "build-test:antd": "pnpm run build --filter=@vben/web-antd build:test",
+
+ ······
+}
+```
+
+在根目录`package.json`中加入构建测试环境的命令
+
+- `turbo.json`
+
+```json
+"tasks": {
+ "build": {
+ "dependsOn": ["^build"],
+ "outputs": [
+ "dist/**",
+ "dist.zip",
+ ".vitepress/dist.zip",
+ ".vitepress/dist/**"
+ ]
+ },
+
+ "build-test:antd": {
+ "dependsOn": ["@vben/web-antd#build:test"],
+ "outputs": ["dist/**"]
+ },
+
+ "@vben/web-antd#build:test": {
+ "dependsOn": ["^build"],
+ "outputs": ["dist/**"]
+ },
+
+ ······
+```
+
+在`turbo.json`中加入相关依赖的命令
+
## 公共静态资源
项目中需要使用到的公共静态资源,如:图片、静态HTML等,需要在开发中通过 `src="/xxx.png"` 直接引入的。
diff --git a/apps/vben5/docs/src/guide/essentials/route.md b/apps/vben5/docs/src/guide/essentials/route.md
index d8a938dda..985c48a9b 100644
--- a/apps/vben5/docs/src/guide/essentials/route.md
+++ b/apps/vben5/docs/src/guide/essentials/route.md
@@ -339,6 +339,10 @@ interface RouteMeta {
| 'success'
| 'warning'
| string;
+ /**
+ * 路由的完整路径作为key(默认true)
+ */
+ fullPathKey?: boolean;
/**
* 当前路由的子级在菜单中不展现
* @default false
@@ -502,6 +506,13 @@ interface RouteMeta {
用于配置页面的徽标颜色。
+### fullPathKey
+
+- 类型:`boolean`
+- 默认值:`true`
+
+是否将路由的完整路径作为tab key(默认true)
+
### activePath
- 类型:`string`
@@ -602,3 +613,32 @@ const { refresh } = useRefresh();
refresh();
```
+
+## 标签页与路由控制
+
+在某些场景下,需要单个路由打开多个标签页,或者修改路由的query不打开新的标签页
+
+每个标签页Tab使用唯一的key标识,设置Tab key有三种方式,优先级由高到低:
+
+- 使用路由query参数pageKey
+
+```vue
+
@@ -280,12 +292,13 @@ function autofocus() {
v-show="isShow"
:class="{
'form-valid-error': isInValid,
+ 'form-is-required': shouldRequired,
'flex-col': isVertical,
'flex-row items-center': !isVertical,
'pb-6': !compact,
'pb-2': compact,
}"
- class="flex"
+ class="relative flex"
v-bind="$attrs"
>
- {{ label }}
- :
+
-