diff --git a/apps/vben5/.browserslistrc b/apps/vben5/.browserslistrc
new file mode 100644
index 000000000..dc3bc09a2
--- /dev/null
+++ b/apps/vben5/.browserslistrc
@@ -0,0 +1,4 @@
+> 1%
+last 2 versions
+not dead
+not ie 11
diff --git a/apps/vben5/.changeset/README.md b/apps/vben5/.changeset/README.md
new file mode 100644
index 000000000..5654e898b
--- /dev/null
+++ b/apps/vben5/.changeset/README.md
@@ -0,0 +1,5 @@
+# Changesets
+
+Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works with multi-package repos, or single-package repos to help you version and publish your code. You can find the full documentation for it [in our repository](https://github.com/changesets/changesets)
+
+We have a quick list of common questions to get you started engaging with this project in [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
diff --git a/apps/vben5/.changeset/config.json b/apps/vben5/.changeset/config.json
new file mode 100644
index 000000000..f954fb4ba
--- /dev/null
+++ b/apps/vben5/.changeset/config.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
+ "changelog": [
+ "@changesets/changelog-github",
+ { "repo": "vbenjs/vue-vben-admin" }
+ ],
+ "commit": false,
+ "fixed": [["@vben-core/*", "@vben/*"]],
+ "snapshot": {
+ "prereleaseTemplate": "{tag}-{datetime}"
+ },
+ "privatePackages": { "version": true, "tag": true },
+ "linked": [],
+ "access": "public",
+ "baseBranch": "main",
+ "updateInternalDependencies": "patch",
+ "ignore": []
+}
diff --git a/apps/vben5/.commitlintrc.js b/apps/vben5/.commitlintrc.js
new file mode 100644
index 000000000..02e33fa62
--- /dev/null
+++ b/apps/vben5/.commitlintrc.js
@@ -0,0 +1 @@
+export { default } from '@vben/commitlint-config';
diff --git a/apps/vben5/.dockerignore b/apps/vben5/.dockerignore
new file mode 100644
index 000000000..52b833a96
--- /dev/null
+++ b/apps/vben5/.dockerignore
@@ -0,0 +1,7 @@
+node_modules
+.git
+.gitignore
+*.md
+dist
+.turbo
+dist.zip
diff --git a/apps/vben5/.editorconfig b/apps/vben5/.editorconfig
new file mode 100644
index 000000000..179aec6f1
--- /dev/null
+++ b/apps/vben5/.editorconfig
@@ -0,0 +1,18 @@
+root = true
+
+[*]
+charset=utf-8
+end_of_line=lf
+insert_final_newline=true
+indent_style=space
+indent_size=2
+max_line_length = 100
+trim_trailing_whitespace = true
+quote_type = single
+
+[*.{yml,yaml,json}]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/apps/vben5/.gitattributes b/apps/vben5/.gitattributes
new file mode 100644
index 000000000..d4e5bd3ed
--- /dev/null
+++ b/apps/vben5/.gitattributes
@@ -0,0 +1,11 @@
+# https://docs.github.com/cn/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
+
+# Automatically normalize line endings (to LF) for all text-based files.
+* text=auto eol=lf
+
+# Declare files that will always have CRLF line endings on checkout.
+*.{cmd,[cC][mM][dD]} text eol=crlf
+*.{bat,[bB][aA][tT]} text eol=crlf
+
+# Denote all files that are truly binary and should not be modified.
+*.{ico,png,jpg,jpeg,gif,webp,svg,woff,woff2} binary
\ No newline at end of file
diff --git a/apps/vben5/.gitconfig b/apps/vben5/.gitconfig
new file mode 100644
index 000000000..4b28a69cd
--- /dev/null
+++ b/apps/vben5/.gitconfig
@@ -0,0 +1,2 @@
+[core]
+ ignorecase = false
diff --git a/apps/vben5/.gitignore b/apps/vben5/.gitignore
new file mode 100644
index 000000000..c2a8a771f
--- /dev/null
+++ b/apps/vben5/.gitignore
@@ -0,0 +1,51 @@
+node_modules
+.DS_Store
+dist
+dist-ssr
+dist.zip
+dist.tar
+dist.war
+.nitro
+.output
+*-dist.zip
+*-dist.tar
+*-dist.war
+coverage
+*.local
+**/.vitepress/cache
+.cache
+.turbo
+.temp
+dev-dist
+.stylelintcache
+yarn.lock
+package-lock.json
+.VSCodeCounter
+**/backend-mock/data
+
+# local env files
+.env.local
+.env.*.local
+.eslintcache
+
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+lerna-debug.log*
+vite.config.mts.*
+vite.config.mjs.*
+vite.config.js.*
+vite.config.ts.*
+
+# Editor directories and files
+.idea
+# .vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
+.history
diff --git a/apps/vben5/.gitpod.yml b/apps/vben5/.gitpod.yml
new file mode 100644
index 000000000..fb75b433d
--- /dev/null
+++ b/apps/vben5/.gitpod.yml
@@ -0,0 +1,6 @@
+ports:
+ - port: 5555
+ onOpen: open-preview
+tasks:
+ - init: corepack enable && pnpm install
+ command: pnpm run dev:play
diff --git a/apps/vben5/.husky/commit-msg b/apps/vben5/.husky/commit-msg
new file mode 100644
index 000000000..270ebb8c1
--- /dev/null
+++ b/apps/vben5/.husky/commit-msg
@@ -0,0 +1,6 @@
+echo Start running commit-msg hook...
+
+# Check whether the git commit information is standardized
+pnpm exec commitlint --edit "$1"
+
+echo Run commit-msg hook done.
diff --git a/apps/vben5/.husky/post-merge b/apps/vben5/.husky/post-merge
new file mode 100644
index 000000000..83fa775d5
--- /dev/null
+++ b/apps/vben5/.husky/post-merge
@@ -0,0 +1,3 @@
+# 每次 git pull 之后, 安装依赖
+
+pnpm install
diff --git a/apps/vben5/.husky/pre-commit b/apps/vben5/.husky/pre-commit
new file mode 100644
index 000000000..5dccee288
--- /dev/null
+++ b/apps/vben5/.husky/pre-commit
@@ -0,0 +1,7 @@
+# update `.vscode/vben-admin.code-workspace` file
+pnpm vsh code-workspace --auto-commit
+
+# Format and submit code according to lintstagedrc.js configuration
+pnpm exec lint-staged
+
+echo Run pre-commit hook done.
diff --git a/apps/vben5/.lintstagedrc.mjs b/apps/vben5/.lintstagedrc.mjs
new file mode 100644
index 000000000..e68d8a3e0
--- /dev/null
+++ b/apps/vben5/.lintstagedrc.mjs
@@ -0,0 +1,20 @@
+export default {
+ '*.{js,jsx,ts,tsx}': [
+ 'prettier --cache --ignore-unknown --write',
+ 'eslint --cache --fix',
+ ],
+ '*.{scss,less,styl,html,vue,css}': [
+ 'prettier --cache --ignore-unknown --write',
+ 'stylelint --fix --allow-empty-input',
+ ],
+ '*.md': ['prettier --cache --ignore-unknown --write'],
+ '*.vue': [
+ 'prettier --write',
+ 'eslint --cache --fix',
+ 'stylelint --fix --allow-empty-input',
+ ],
+ '{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': [
+ 'prettier --cache --write--parser json',
+ ],
+ 'package.json': ['prettier --cache --write'],
+};
diff --git a/apps/vben5/.node-version b/apps/vben5/.node-version
new file mode 100644
index 000000000..48b14e6b2
--- /dev/null
+++ b/apps/vben5/.node-version
@@ -0,0 +1 @@
+20.14.0
diff --git a/apps/vben5/.npmrc b/apps/vben5/.npmrc
new file mode 100644
index 000000000..f4a1ad483
--- /dev/null
+++ b/apps/vben5/.npmrc
@@ -0,0 +1,13 @@
+registry = "https://registry.npmmirror.com"
+public-hoist-pattern[]=husky
+public-hoist-pattern[]=eslint
+public-hoist-pattern[]=prettier
+public-hoist-pattern[]=prettier-plugin-tailwindcss
+public-hoist-pattern[]=stylelint
+public-hoist-pattern[]=*postcss*
+public-hoist-pattern[]=@commitlint/*
+public-hoist-pattern[]=czg
+
+strict-peer-dependencies=false
+auto-install-peers=true
+dedupe-peer-dependents=true
diff --git a/apps/vben5/.prettierignore b/apps/vben5/.prettierignore
new file mode 100644
index 000000000..d0b0ca133
--- /dev/null
+++ b/apps/vben5/.prettierignore
@@ -0,0 +1,18 @@
+dist
+dev-dist
+.local
+.output.js
+node_modules
+.nvmrc
+coverage
+CODEOWNERS
+.nitro
+.output
+
+
+**/*.svg
+**/*.sh
+
+public
+.npmrc
+*-lock.yaml
diff --git a/apps/vben5/.prettierrc.mjs b/apps/vben5/.prettierrc.mjs
new file mode 100644
index 000000000..3e25d2cfa
--- /dev/null
+++ b/apps/vben5/.prettierrc.mjs
@@ -0,0 +1 @@
+export { default } from '@vben/prettier-config';
diff --git a/apps/vben5/.stylelintignore b/apps/vben5/.stylelintignore
new file mode 100644
index 000000000..f4b2db2c1
--- /dev/null
+++ b/apps/vben5/.stylelintignore
@@ -0,0 +1,4 @@
+dist
+public
+__tests__
+coverage
diff --git a/apps/vben5/LICENSE b/apps/vben5/LICENSE
new file mode 100644
index 000000000..cec5b4274
--- /dev/null
+++ b/apps/vben5/LICENSE
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) 2024-present, Vben
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/apps/vben5/README.ja-JP.md b/apps/vben5/README.ja-JP.md
new file mode 100644
index 000000000..baa4cc448
--- /dev/null
+++ b/apps/vben5/README.ja-JP.md
@@ -0,0 +1,153 @@
+
+
+[](LICENSE)
+
+
Vue Vben Admin
+
+
+[](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin)    
+
+**日本語** | [English](./README.md) | [中文](./README.zh-CN.md)
+
+## 紹介
+
+Vue Vben Adminは、最新の`vue3`、`vite`、`TypeScript`などの主流技術を使用して開発された、無料でオープンソースの中・後端テンプレートです。すぐに使える中・後端のフロントエンドソリューションとして、学習の参考にもなります。
+
+## アップグレード通知
+
+これは最新バージョン5.0であり、以前のバージョンとは互換性がありません。新しいプロジェクトを開始する場合は、最新バージョンを使用することをお勧めします。古いバージョンを表示したい場合は、[v2ブランチ](https://github.com/vbenjs/vue-vben-admin/tree/v2)を使用してください。
+
+## 特徴
+
+- **最新技術スタック**: Vue 3やViteなどの最先端フロントエンド技術で開発
+- **TypeScript**: アプリケーション規模のJavaScriptのための言語
+- **テーマ**: 複数のテーマカラーが利用可能で、カスタマイズオプションも豊富
+- **国際化**: 完全な内蔵国際化サポート
+- **権限管理**: 動的ルートベースの権限生成ソリューションを内蔵
+
+## プレビュー
+
+- [Vben Admin](https://vben.pro/) - フルバージョンの中国語サイト
+
+テストアカウント: vben/123456
+
+
+
+
+
+
+
+### Gitpodを使用
+
+Gitpod(GitHub用の無料オンライン開発環境)でプロジェクトを開き、すぐにコーディングを開始します。
+
+[](https://gitpod.io/#https://github.com/vbenjs/vue-vben-admin)
+
+## ドキュメント
+
+[ドキュメント](https://doc.vben.pro/)
+
+## インストールと使用
+
+- プロジェクトコードを取得
+
+```bash
+git clone https://github.com/vbenjs/vue-vben-admin.git
+```
+
+- 依存関係のインストール
+
+```bash
+cd vue-vben-admin
+
+corepack enable
+
+pnpm install
+
+```
+
+- 実行
+
+```bash
+pnpm dev
+```
+
+- ビルド
+
+```bash
+pnpm build
+```
+
+## 変更ログ
+
+[CHANGELOG](https://github.com/vbenjs/vue-vben-admin/releases)
+
+## 貢献方法
+
+ご参加をお待ちしておりますするか、Pull Requestを送信してください。
+
+**Pull Request:**
+
+1. コードをフォーク!
+2. 自分のブランチを作成: `git checkout -b feat/xxxx`
+3. 変更をコミット: `git commit -am 'feat(function): add xxxxx'`
+4. ブランチをプッシュ: `git push origin feat/xxxx`
+5. `pull request`を送信
+
+## Git貢献提出規則
+
+- 参考 [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) 規則 ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
+
+ - `feat` 新機能の追加
+ - `fix` 問題/バグの修正
+ - `style` コードスタイルに関連し、実行結果に影響しない
+ - `perf` 最適化/パフォーマンス向上
+ - `refactor` リファクタリング
+ - `revert` 変更の取り消し
+ - `test` テスト関連
+ - `docs` ドキュメント/注釈
+ - `chore` 依存関係の更新/スキャフォールディング設定の変更など
+ - `ci` 継続的インテグレーション
+ - `types` 型定義ファイルの変更
+ - `wip` 開発中
+
+## ブラウザサポート
+
+ローカル開発には`Chrome 80+`ブラウザを推奨します
+
+モダンブラウザをサポートし、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 |
+| :-: | :-: | :-: | :-: | :-: |
+| サポートしない | 最新2バージョン | 最新2バージョン | 最新2バージョン | 最新2バージョン |
+
+## メンテナー
+
+[@Vben](https://github.com/anncwb)
+
+## スター歴史
+
+[](https://star-history.com/#vbenjs/vue-vben-admin&Date)
+
+## 寄付
+
+このプロジェクトが役に立つと思われた場合、作者にコーヒーを一杯おごってサポートを示すことができます!
+
+
+
+Paypal Me
+
+## 貢献者
+
+
+
+
+
+## Discord
+
+- [Github Discussions](https://github.com/anncwb/vue-vben-admin/discussions)
+
+## ライセンス
+
+[MIT © Vben-2020](./LICENSE)
diff --git a/apps/vben5/README.md b/apps/vben5/README.md
new file mode 100644
index 000000000..e84c8392e
--- /dev/null
+++ b/apps/vben5/README.md
@@ -0,0 +1,152 @@
+
+
+[](LICENSE)
+
+
Vue Vben Admin
+
+
+[](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin)    
+
+**English** | [中文](./README.zh-CN.md) | [日本語](./README.ja-JP.md)
+
+## Introduction
+
+Vue Vben Admin is a free and open source middle and back-end template. Using the latest `vue3`, `vite`, `TypeScript` and other mainstream technology development, the out-of-the-box middle and back-end front-end solutions can also be used for learning reference.
+
+## Upgrade Notice
+
+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
+
+- **Latest Technology Stack**: Developed with cutting-edge front-end technologies like Vue 3 and Vite
+- **TypeScript**: A language for application-scale JavaScript
+- **Themes**: Multiple theme colors available with customizable options
+- **Internationalization**: Comprehensive built-in internationalization support
+- **Permissions**: Built-in solution for dynamic route-based permission generation
+
+## Preview
+
+- [Vben Admin](https://vben.pro/) - Full version Chinese site
+
+Test Account: vben/123456
+
+
+
+
+
+
+
+### Use Gitpod
+
+Open the project in Gitpod (free online dev environment for GitHub) and start coding immediately.
+
+[](https://gitpod.io/#https://github.com/vbenjs/vue-vben-admin)
+
+## Documentation
+
+[Document](https://doc.vben.pro/)
+
+## Install and use
+
+- Get the project code
+
+```bash
+git clone https://github.com/vbenjs/vue-vben-admin.git
+```
+
+- Installation dependencies
+
+```bash
+cd vue-vben-admin
+
+corepack enable
+
+pnpm install
+```
+
+- run
+
+```bash
+pnpm dev
+```
+
+- build
+
+```bash
+pnpm build
+```
+
+## Change Log
+
+[CHANGELOG](https://github.com/vbenjs/vue-vben-admin/releases)
+
+## How to contribute
+
+You are very welcome to join Or submit a Pull Request。
+
+**Pull Request:**
+
+1. Fork code!
+2. Create your own 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`
+
+## 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))
+
+ - `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
+
+## 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 |
+
+## Maintainer
+
+[@Vben](https://github.com/anncwb)
+
+## Star History
+
+[](https://star-history.com/#vbenjs/vue-vben-admin&Date)
+
+## Donate
+
+If you think this project is helpful to you, you can help the author buy a cup of coffee to show your support!
+
+
+
+Paypal Me
+
+## Contributor
+
+
+
+
+
+## Discord
+
+- [Github Discussions](https://github.com/anncwb/vue-vben-admin/discussions)
+
+## License
+
+[MIT © Vben-2020](./LICENSE)
diff --git a/apps/vben5/README.zh-CN.md b/apps/vben5/README.zh-CN.md
new file mode 100644
index 000000000..e2f05bb98
--- /dev/null
+++ b/apps/vben5/README.zh-CN.md
@@ -0,0 +1,152 @@
+
+
+[](LICENSE)
+
+
Vue Vben Admin
+
+
+[](https://sonarcloud.io/summary/new_code?id=vbenjs_vue-vben-admin)    
+
+**中文** | [English](./README.md) | [日本語](./README.ja-JP.md)
+
+## 简介
+
+Vue Vben Admin 是 Vue Vben Admin 的升级版本。作为一个免费开源的中后台模板,它采用了最新的 Vue 3、Vite、TypeScript 等主流技术开发,开箱即用,可用于中后台前端开发,也适合学习参考。
+
+## 升级提示
+
+该版本为最新版本`5.0`, 与其他版本不兼容,如果你是新项目,建议使用最新版本。如果你想查看旧版本,请使用 [v2 分支](https://github.com/vbenjs/vue-vben-admin/tree/v2)
+
+## 特性
+
+- **最新技术栈**:使用 Vue3/vite 等前端前沿技术开发
+- **TypeScript**: 应用程序级 JavaScript 的语言
+- **主题**:提供多套主题色彩,可配置自定义主题
+- **国际化**:内置完善的国际化方案
+- **权限** 内置完善的动态路由权限生成方案
+
+## 预览
+
+- [Vben Admin](https://vben.pro/) - 完整版中文站点
+
+测试账号: vben/123456
+
+
+
+
+
+
+
+### 使用 Gitpod
+
+在 Gitpod(适用于 GitHub 的免费在线开发环境)中打开项目,并立即开始编码.
+
+[](https://gitpod.io/#https://github.com/vbenjs/vue-vben-admin)
+
+## 文档
+
+[文档地址](https://doc.vben.pro/)
+
+## 安装使用
+
+- 获取项目代码
+
+```bash
+git clone https://github.com/vbenjs/vue-vben-admin.git
+```
+
+- 安装依赖
+
+```bash
+cd vue-vben-admin
+
+corepack enable
+
+pnpm install
+```
+
+- 运行
+
+```bash
+pnpm dev
+```
+
+- 打包
+
+```bash
+pnpm build
+```
+
+## 更新日志
+
+[CHANGELOG](https://github.com/vbenjs/vue-vben-admin/releases)
+
+## 如何贡献
+
+非常欢迎你的加入 或者提交一个 Pull Request。
+
+**Pull Request:**
+
+1. Fork 代码!
+2. 创建自己的分支: `git checkout -b feature/xxxx`
+3. 提交你的修改: `git commit -am 'feat(function): add xxxxx'`
+4. 推送您的分支: `git push origin feature/xxxx`
+5. 提交`pull request`
+
+## Git 贡献提交规范
+
+- 参考 [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) 规范 ([Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular))
+
+ - `feat` 增加新功能
+ - `fix` 修复问题/BUG
+ - `style` 代码风格相关无影响运行结果的
+ - `perf` 优化/性能提升
+ - `refactor` 重构
+ - `revert` 撤销修改
+ - `test` 测试相关
+ - `docs` 文档/注释
+ - `chore` 依赖更新/脚手架配置修改等
+ - `ci` 持续集成
+ - `types` 类型定义文件更改
+ - `wip` 开发中
+
+## 浏览器支持
+
+本地开发推荐使用`Chrome 80+` 浏览器
+
+支持现代浏览器, 不支持 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 |
+
+## 维护者
+
+[@Vben](https://github.com/anncwb)
+
+## Star History
+
+[](https://star-history.com/#vbenjs/vue-vben-admin&Date)
+
+## 捐赠
+
+如果你觉得这个项目对你有帮助,你可以帮作者买一杯咖啡表示支持!
+
+
+
+Paypal Me
+
+## Contributor
+
+
+
+
+
+## Discord
+
+- [Github Discussions](https://github.com/anncwb/vue-vben-admin/discussions)
+
+## License
+
+[MIT © Vben-2020](./LICENSE)
diff --git a/apps/vben5/apps/app-antd/.env b/apps/vben5/apps/app-antd/.env
new file mode 100644
index 000000000..c14a467fb
--- /dev/null
+++ b/apps/vben5/apps/app-antd/.env
@@ -0,0 +1,5 @@
+# 应用标题
+VITE_APP_TITLE=Vben Admin Antd
+
+# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
+VITE_APP_NAMESPACE=vben-web-antd
diff --git a/apps/vben5/apps/app-antd/.env.analyze b/apps/vben5/apps/app-antd/.env.analyze
new file mode 100644
index 000000000..ffafa8dd5
--- /dev/null
+++ b/apps/vben5/apps/app-antd/.env.analyze
@@ -0,0 +1,7 @@
+# public path
+VITE_BASE=/
+
+# Basic interface address SPA
+VITE_GLOB_API_URL=/api
+
+VITE_VISUALIZER=true
diff --git a/apps/vben5/apps/app-antd/.env.development b/apps/vben5/apps/app-antd/.env.development
new file mode 100644
index 000000000..0692ed288
--- /dev/null
+++ b/apps/vben5/apps/app-antd/.env.development
@@ -0,0 +1,19 @@
+# 端口号
+VITE_PORT=5666
+
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=/
+
+# 是否开启 Nitro Mock服务,true 为开启,false 为关闭
+VITE_NITRO_MOCK=true
+
+# 是否打开 devtools,true 为打开,false 为关闭
+VITE_DEVTOOLS=false
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
+
+VITE_GLOB_CLIENT_ID=vue-admin-client
+VITE_GLOB_CLIENT_SECRET=1q2w3e*
diff --git a/apps/vben5/apps/app-antd/.env.production b/apps/vben5/apps/app-antd/.env.production
new file mode 100644
index 000000000..5375847a6
--- /dev/null
+++ b/apps/vben5/apps/app-antd/.env.production
@@ -0,0 +1,19 @@
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+
+# 是否开启压缩,可以设置为 none, brotli, gzip
+VITE_COMPRESS=none
+
+# 是否开启 PWA
+VITE_PWA=false
+
+# vue-router 的模式
+VITE_ROUTER_HISTORY=hash
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
+
+# 打包后是否生成dist.zip
+VITE_ARCHIVER=true
diff --git a/apps/vben5/apps/app-antd/index.html b/apps/vben5/apps/app-antd/index.html
new file mode 100644
index 000000000..480eb84de
--- /dev/null
+++ b/apps/vben5/apps/app-antd/index.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+ <%= VITE_APP_TITLE %>
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/package.json b/apps/vben5/apps/app-antd/package.json
new file mode 100644
index 000000000..a4bc65408
--- /dev/null
+++ b/apps/vben5/apps/app-antd/package.json
@@ -0,0 +1,54 @@
+{
+ "name": "@vben/app-antd",
+ "version": "5.4.8",
+ "homepage": "https://vben.pro",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "apps/app-antd"
+ },
+ "license": "MIT",
+ "author": {
+ "name": "vben",
+ "email": "ann.vben@gmail.com",
+ "url": "https://github.com/anncwb"
+ },
+ "type": "module",
+ "scripts": {
+ "build": "pnpm vite build --mode production",
+ "build:analyze": "pnpm vite build --mode analyze",
+ "dev": "pnpm vite --mode development",
+ "preview": "vite preview",
+ "typecheck": "vue-tsc --noEmit --skipLibCheck"
+ },
+ "imports": {
+ "#/*": "./src/*"
+ },
+ "dependencies": {
+ "@abp/account": "workspace:*",
+ "@abp/core": "workspace:*",
+ "@abp/identity": "workspace:*",
+ "@abp/request": "workspace:*",
+ "@vben/access": "workspace:*",
+ "@vben/common-ui": "workspace:*",
+ "@vben/constants": "workspace:*",
+ "@vben/hooks": "workspace:*",
+ "@vben/icons": "workspace:*",
+ "@vben/layouts": "workspace:*",
+ "@vben/locales": "workspace:*",
+ "@vben/plugins": "workspace:*",
+ "@vben/preferences": "workspace:*",
+ "@vben/request": "workspace:*",
+ "@vben/stores": "workspace:*",
+ "@vben/styles": "workspace:*",
+ "@vben/types": "workspace:*",
+ "@vben/utils": "workspace:*",
+ "@vueuse/core": "catalog:",
+ "ant-design-vue": "catalog:",
+ "dayjs": "catalog:",
+ "pinia": "catalog:",
+ "vue": "catalog:",
+ "vue-router": "catalog:"
+ }
+}
diff --git a/apps/vben5/apps/app-antd/postcss.config.mjs b/apps/vben5/apps/app-antd/postcss.config.mjs
new file mode 100644
index 000000000..3d8070455
--- /dev/null
+++ b/apps/vben5/apps/app-antd/postcss.config.mjs
@@ -0,0 +1 @@
+export { default } from '@vben/tailwind-config/postcss';
diff --git a/apps/vben5/apps/app-antd/public/favicon.ico b/apps/vben5/apps/app-antd/public/favicon.ico
new file mode 100644
index 000000000..fcf9818e2
Binary files /dev/null and b/apps/vben5/apps/app-antd/public/favicon.ico differ
diff --git a/apps/vben5/apps/app-antd/src/adapter/component/index.ts b/apps/vben5/apps/app-antd/src/adapter/component/index.ts
new file mode 100644
index 000000000..1afa62174
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/adapter/component/index.ts
@@ -0,0 +1,127 @@
+/**
+ * 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
+ * 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
+ */
+
+import type { BaseFormComponentType } from '@vben/common-ui';
+
+import type { Component, SetupContext } from 'vue';
+import { h } from 'vue';
+
+import { globalShareState } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+import {
+ AutoComplete,
+ Button,
+ Checkbox,
+ CheckboxGroup,
+ DatePicker,
+ Divider,
+ Input,
+ InputNumber,
+ InputPassword,
+ Mentions,
+ notification,
+ Radio,
+ RadioGroup,
+ RangePicker,
+ Rate,
+ Select,
+ Space,
+ Switch,
+ Textarea,
+ TimePicker,
+ TreeSelect,
+ Upload,
+} from 'ant-design-vue';
+
+const withDefaultPlaceholder = (
+ component: T,
+ type: 'input' | 'select',
+) => {
+ return (props: any, { attrs, slots }: Omit) => {
+ const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
+ return h(component, { ...props, ...attrs, placeholder }, slots);
+ };
+};
+
+// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
+export type ComponentType =
+ | 'AutoComplete'
+ | 'Checkbox'
+ | 'CheckboxGroup'
+ | 'DatePicker'
+ | 'DefaultButton'
+ | 'Divider'
+ | 'Input'
+ | 'InputNumber'
+ | 'InputPassword'
+ | 'Mentions'
+ | 'PrimaryButton'
+ | 'Radio'
+ | 'RadioGroup'
+ | 'RangePicker'
+ | 'Rate'
+ | 'Select'
+ | 'Space'
+ | 'Switch'
+ | 'Textarea'
+ | 'TimePicker'
+ | 'TreeSelect'
+ | 'Upload'
+ | BaseFormComponentType;
+
+async function initComponentAdapter() {
+ const components: Partial> = {
+ // 如果你的组件体积比较大,可以使用异步加载
+ // Button: () =>
+ // import('xxx').then((res) => res.Button),
+
+ AutoComplete,
+ Checkbox,
+ CheckboxGroup,
+ DatePicker,
+ // 自定义默认按钮
+ DefaultButton: (props, { attrs, slots }) => {
+ return h(Button, { ...props, attrs, type: 'default' }, slots);
+ },
+ Divider,
+ Input: withDefaultPlaceholder(Input, 'input'),
+ InputNumber: withDefaultPlaceholder(InputNumber, 'input'),
+ InputPassword: withDefaultPlaceholder(InputPassword, 'input'),
+ Mentions: withDefaultPlaceholder(Mentions, 'input'),
+ // 自定义主要按钮
+ PrimaryButton: (props, { attrs, slots }) => {
+ return h(Button, { ...props, attrs, type: 'primary' }, slots);
+ },
+ Radio,
+ RadioGroup,
+ RangePicker,
+ Rate,
+ Select: withDefaultPlaceholder(Select, 'select'),
+ Space,
+ Switch,
+ Textarea: withDefaultPlaceholder(Textarea, 'input'),
+ TimePicker,
+ TreeSelect: withDefaultPlaceholder(TreeSelect, 'select'),
+ Upload,
+ };
+
+ // 将组件注册到全局共享状态中
+ globalShareState.setComponents(components);
+
+ // 定义全局共享状态中的消息提示
+ globalShareState.defineMessage({
+ // 复制成功消息提示
+ copyPreferencesSuccess: (title, content) => {
+ notification.success({
+ description: content,
+ message: title,
+ placement: 'bottomRight',
+ });
+ },
+ });
+}
+
+export { initComponentAdapter };
diff --git a/apps/vben5/apps/app-antd/src/adapter/form.ts b/apps/vben5/apps/app-antd/src/adapter/form.ts
new file mode 100644
index 000000000..65ff793b6
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/adapter/form.ts
@@ -0,0 +1,47 @@
+import type {
+ VbenFormSchema as FormSchema,
+ VbenFormProps,
+} from '@vben/common-ui';
+
+import type { ComponentType } from './component';
+
+import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+setupVbenForm({
+ config: {
+ // ant design vue组件库默认都是 v-model:value
+ baseModelPropName: 'value',
+
+ // 一些组件是 v-model:checked 或者 v-model:fileList
+ modelPropNameMap: {
+ Checkbox: 'checked',
+ Radio: 'checked',
+ Switch: 'checked',
+ Upload: 'fileList',
+ },
+ },
+ defineRules: {
+ // 输入项目必填国际化适配
+ required: (value, _params, ctx) => {
+ if (value === undefined || value === null || value.length === 0) {
+ return $t('ui.formRules.required', [ctx.label]);
+ }
+ return true;
+ },
+ // 选择项目必填国际化适配
+ selectRequired: (value, _params, ctx) => {
+ if (value === undefined || value === null) {
+ return $t('ui.formRules.selectRequired', [ctx.label]);
+ }
+ return true;
+ },
+ },
+});
+
+const useVbenForm = useForm;
+
+export { useVbenForm, z };
+
+export type VbenFormSchema = FormSchema;
+export type { VbenFormProps };
diff --git a/apps/vben5/apps/app-antd/src/adapter/request/index.ts b/apps/vben5/apps/app-antd/src/adapter/request/index.ts
new file mode 100644
index 000000000..06284043b
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/adapter/request/index.ts
@@ -0,0 +1,100 @@
+import { preferences } from '@vben/preferences';
+import {
+ authenticateResponseInterceptor,
+ errorMessageResponseInterceptor,
+} from '@vben/request';
+import { useAccessStore } from '@vben/stores';
+
+import { requestClient } from '@abp/request';
+import { message } from 'ant-design-vue';
+
+import { useAuthStore } from '#/store';
+
+export function initRequestClient() {
+ /**
+ * 重新认证逻辑
+ */
+ async function doReAuthenticate() {
+ console.warn('Access token or refresh token is invalid or expired. ');
+ const accessStore = useAccessStore();
+ const authStore = useAuthStore();
+ accessStore.setAccessToken(null);
+ if (
+ preferences.app.loginExpiredMode === 'modal' &&
+ accessStore.isAccessChecked
+ ) {
+ accessStore.setLoginExpired(true);
+ } else {
+ await authStore.logout();
+ }
+ }
+
+ /**
+ * 刷新token逻辑
+ */
+ async function doRefreshToken() {
+ return '';
+ }
+
+ function formatToken(token: null | string) {
+ return token ? `Bearer ${token}` : null;
+ }
+ // 请求头处理
+ requestClient.addRequestInterceptor({
+ fulfilled: async (config) => {
+ const accessStore = useAccessStore();
+ if (accessStore.accessToken) {
+ config.headers.Authorization = `${accessStore.accessToken}`;
+ }
+ config.headers['Accept-Language'] = preferences.app.locale;
+ return config;
+ },
+ });
+
+ // response数据解构
+ requestClient.addResponseInterceptor({
+ fulfilled: (response) => {
+ const { data, status, headers } = response;
+
+ if (headers._abpwrapresult === 'true') {
+ const { code, result, message, details } = data;
+ const hasSuccess = data && Reflect.has(data, 'code') && code === '0';
+ if (hasSuccess) {
+ return result;
+ }
+ const content = details || message;
+
+ throw Object.assign({}, response, { response, message: content });
+ }
+
+ if (status >= 200 && status < 400) {
+ return data;
+ }
+
+ throw Object.assign({}, response, { response });
+ },
+ });
+
+ // token过期的处理
+ requestClient.addResponseInterceptor(
+ authenticateResponseInterceptor({
+ client: requestClient,
+ doReAuthenticate,
+ doRefreshToken,
+ enableRefreshToken: preferences.app.enableRefreshToken,
+ formatToken,
+ }),
+ );
+
+ // 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
+ requestClient.addResponseInterceptor(
+ errorMessageResponseInterceptor((msg: string, error) => {
+ // 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
+ // 当前mock接口返回的错误字段是 error 或者 message
+ const responseData = error?.response?.data ?? {};
+ const errorMessage = responseData?.error ?? responseData?.message ?? '';
+ // 如果没有错误信息,则会根据状态码进行提示
+ message.error(errorMessage || msg);
+ }),
+ );
+}
diff --git a/apps/vben5/apps/app-antd/src/adapter/vxe-table.ts b/apps/vben5/apps/app-antd/src/adapter/vxe-table.ts
new file mode 100644
index 000000000..d296b2050
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/adapter/vxe-table.ts
@@ -0,0 +1,67 @@
+import { h } from 'vue';
+
+import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
+
+import { Button, Image } from 'ant-design-vue';
+
+import { useVbenForm } from './form';
+
+setupVbenVxeTable({
+ configVxeTable: (vxeUI) => {
+ vxeUI.setConfig({
+ grid: {
+ align: 'center',
+ border: false,
+ columnConfig: {
+ resizable: true,
+ },
+ minHeight: 180,
+ formConfig: {
+ // 全局禁用vxe-table的表单配置,使用formOptions
+ enabled: false,
+ },
+ proxyConfig: {
+ autoLoad: true,
+ response: {
+ result: 'items',
+ total: 'total',
+ list: 'items',
+ },
+ showActiveMsg: true,
+ showResponseMsg: false,
+ },
+ round: true,
+ showOverflow: true,
+ size: 'small',
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellImage' },
+ vxeUI.renderer.add('CellImage', {
+ renderTableDefault(_renderOpts, params) {
+ const { column, row } = params;
+ return h(Image, { src: row[column.field] });
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellLink' },
+ vxeUI.renderer.add('CellLink', {
+ renderTableDefault(renderOpts) {
+ const { props } = renderOpts;
+ return h(
+ Button,
+ { size: 'small', type: 'link' },
+ { default: () => props?.text },
+ );
+ },
+ });
+
+ // 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
+ // vxeUI.formats.add
+ },
+ useVbenForm,
+});
+
+export { useVbenVxeGrid };
+
+export type * from '@vben/plugins/vxe-table';
diff --git a/apps/vben5/apps/app-antd/src/api/core/abp.ts b/apps/vben5/apps/app-antd/src/api/core/abp.ts
new file mode 100644
index 000000000..e5fba68f5
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/api/core/abp.ts
@@ -0,0 +1,36 @@
+import type {
+ ApplicationConfigurationDto,
+ ApplicationLocalizationDto,
+} from '@abp/core';
+
+import { requestClient } from '@abp/request';
+
+/**
+ * 获取应用程序配置信息
+ */
+export function getConfigApi(options?: {
+ includeLocalizationResources?: boolean;
+}): Promise {
+ return requestClient.get(
+ '/api/abp/application-configuration',
+ {
+ params: options,
+ },
+ );
+}
+
+/**
+ * 获取应用程序语言
+ * @returns 本地化配置
+ */
+export function getLocalizationApi(options: {
+ cultureName: string;
+ onlyDynamics?: boolean;
+}): Promise {
+ return requestClient.get(
+ '/api/abp/application-localization',
+ {
+ params: options,
+ },
+ );
+}
diff --git a/apps/vben5/apps/app-antd/src/api/core/index.ts b/apps/vben5/apps/app-antd/src/api/core/index.ts
new file mode 100644
index 000000000..5fe53ee1e
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/api/core/index.ts
@@ -0,0 +1,2 @@
+export * from './abp';
+export * from './menu';
diff --git a/apps/vben5/apps/app-antd/src/api/core/menu.ts b/apps/vben5/apps/app-antd/src/api/core/menu.ts
new file mode 100644
index 000000000..9ef60b11c
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/api/core/menu.ts
@@ -0,0 +1,10 @@
+import type { RouteRecordStringComponent } from '@vben/types';
+
+import { requestClient } from '#/api/request';
+
+/**
+ * 获取用户所有菜单
+ */
+export async function getAllMenusApi() {
+ return requestClient.get('/menu/all');
+}
diff --git a/apps/vben5/apps/app-antd/src/api/index.ts b/apps/vben5/apps/app-antd/src/api/index.ts
new file mode 100644
index 000000000..4b0e04137
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/api/index.ts
@@ -0,0 +1 @@
+export * from './core';
diff --git a/apps/vben5/apps/app-antd/src/api/request.ts b/apps/vben5/apps/app-antd/src/api/request.ts
new file mode 100644
index 000000000..c607daf6e
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/api/request.ts
@@ -0,0 +1,114 @@
+/**
+ * 该文件可自行根据业务逻辑进行调整
+ */
+import type { HttpResponse } from '@vben/request';
+
+import { useAppConfig } from '@vben/hooks';
+import { preferences } from '@vben/preferences';
+import {
+ authenticateResponseInterceptor,
+ errorMessageResponseInterceptor,
+ RequestClient,
+} from '@vben/request';
+import { useAccessStore } from '@vben/stores';
+
+import { message } from 'ant-design-vue';
+
+import { useAuthStore } from '#/store';
+
+// import { refreshTokenApi } from './core';
+
+const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+
+function createRequestClient(baseURL: string) {
+ const client = new RequestClient({
+ baseURL,
+ });
+
+ /**
+ * 重新认证逻辑
+ */
+ async function doReAuthenticate() {
+ console.warn('Access token or refresh token is invalid or expired. ');
+ const accessStore = useAccessStore();
+ const authStore = useAuthStore();
+ accessStore.setAccessToken(null);
+ if (
+ preferences.app.loginExpiredMode === 'modal' &&
+ accessStore.isAccessChecked
+ ) {
+ accessStore.setLoginExpired(true);
+ } else {
+ await authStore.logout();
+ }
+ }
+
+ /**
+ * 刷新token逻辑
+ */
+ async function doRefreshToken() {
+ const accessStore = useAccessStore();
+ // const resp = await refreshTokenApi();
+ // const newToken = resp.data;
+ // accessStore.setAccessToken(newToken);
+ return String(accessStore.accessToken);
+ }
+
+ function formatToken(token: null | string) {
+ return token ? `Bearer ${token}` : null;
+ }
+
+ // 请求头处理
+ client.addRequestInterceptor({
+ fulfilled: async (config) => {
+ const accessStore = useAccessStore();
+
+ config.headers.Authorization = formatToken(accessStore.accessToken);
+ config.headers['Accept-Language'] = preferences.app.locale;
+ return config;
+ },
+ });
+
+ // response数据解构
+ client.addResponseInterceptor({
+ fulfilled: (response) => {
+ const { data: responseData, status } = response;
+
+ const { code, data } = responseData;
+ if (status >= 200 && status < 400 && code === 0) {
+ return data;
+ }
+
+ throw Object.assign({}, response, { response });
+ },
+ });
+
+ // token过期的处理
+ client.addResponseInterceptor(
+ authenticateResponseInterceptor({
+ client,
+ doReAuthenticate,
+ doRefreshToken,
+ enableRefreshToken: preferences.app.enableRefreshToken,
+ formatToken,
+ }),
+ );
+
+ // 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
+ client.addResponseInterceptor(
+ errorMessageResponseInterceptor((msg: string, error) => {
+ // 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
+ // 当前mock接口返回的错误字段是 error 或者 message
+ const responseData = error?.response?.data ?? {};
+ const errorMessage = responseData?.error ?? responseData?.message ?? '';
+ // 如果没有错误信息,则会根据状态码进行提示
+ message.error(errorMessage || msg);
+ }),
+ );
+
+ return client;
+}
+
+export const requestClient = createRequestClient(apiURL);
+
+export const baseRequestClient = new RequestClient({ baseURL: apiURL });
diff --git a/apps/vben5/apps/app-antd/src/app.vue b/apps/vben5/apps/app-antd/src/app.vue
new file mode 100644
index 000000000..bbaccce13
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/app.vue
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/bootstrap.ts b/apps/vben5/apps/app-antd/src/bootstrap.ts
new file mode 100644
index 000000000..a0af6fcfe
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/bootstrap.ts
@@ -0,0 +1,50 @@
+import { createApp, watchEffect } from 'vue';
+
+import { registerAccessDirective } from '@vben/access';
+import { preferences } from '@vben/preferences';
+import { initStores } from '@vben/stores';
+import '@vben/styles';
+import '@vben/styles/antd';
+
+import { useTitle } from '@vueuse/core';
+
+import { $t, setupI18n } from '#/locales';
+
+import { initComponentAdapter } from './adapter/component';
+import { initRequestClient } from './adapter/request';
+import App from './app.vue';
+import { router } from './router';
+
+async function bootstrap(namespace: string) {
+ // 初始化组件适配器
+ await initComponentAdapter();
+ initRequestClient();
+
+ const app = createApp(App);
+
+ // 配置 pinia-tore
+ await initStores(app, { namespace });
+
+ // 国际化 i18n 配置
+ await setupI18n(app);
+
+ // 安装权限指令
+ registerAccessDirective(app);
+
+ // 配置路由及路由守卫
+ app.use(router);
+
+ // 动态更新标题
+ watchEffect(() => {
+ if (preferences.app.dynamicTitle) {
+ const routeTitle = router.currentRoute.value.meta?.title;
+ const pageTitle =
+ (routeTitle ? `${$t(routeTitle)} - ` : '') + preferences.app.name;
+ useTitle(pageTitle);
+ }
+ });
+
+ app.mount('#app');
+}
+
+export { bootstrap };
diff --git a/apps/vben5/apps/app-antd/src/layouts/auth.vue b/apps/vben5/apps/app-antd/src/layouts/auth.vue
new file mode 100644
index 000000000..18d415bc7
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/layouts/auth.vue
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/layouts/basic.vue b/apps/vben5/apps/app-antd/src/layouts/basic.vue
new file mode 100644
index 000000000..51412956a
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/layouts/basic.vue
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/layouts/index.ts b/apps/vben5/apps/app-antd/src/layouts/index.ts
new file mode 100644
index 000000000..a43207805
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/layouts/index.ts
@@ -0,0 +1,6 @@
+const BasicLayout = () => import('./basic.vue');
+const AuthPageLayout = () => import('./auth.vue');
+
+const IFrameView = () => import('@vben/layouts').then((m) => m.IFrameView);
+
+export { AuthPageLayout, BasicLayout, IFrameView };
diff --git a/apps/vben5/apps/app-antd/src/locales/README.md b/apps/vben5/apps/app-antd/src/locales/README.md
new file mode 100644
index 000000000..7b451032e
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/locales/README.md
@@ -0,0 +1,3 @@
+# locale
+
+每个app使用的国际化可能不同,这里用于扩展国际化的功能,例如扩展 dayjs、antd组件库的多语言切换,以及app本身的国际化文件。
diff --git a/apps/vben5/apps/app-antd/src/locales/index.ts b/apps/vben5/apps/app-antd/src/locales/index.ts
new file mode 100644
index 000000000..c71aba29e
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/locales/index.ts
@@ -0,0 +1,127 @@
+import type { LocaleSetupOptions, SupportedLanguagesType } from '@vben/locales';
+import type { Locale } from 'ant-design-vue/es/locale';
+
+import type { App } from 'vue';
+import { ref } from 'vue';
+
+import {
+ $t,
+ setupI18n as coreSetup,
+ loadLocalesMapFromDir,
+} from '@vben/locales';
+import { preferences } from '@vben/preferences';
+
+import { useAbpStore } from '@abp/core';
+import antdEnLocale from 'ant-design-vue/es/locale/en_US';
+import antdDefaultLocale from 'ant-design-vue/es/locale/zh_CN';
+import dayjs from 'dayjs';
+
+import { getLocalizationApi } from '#/api/core';
+
+const antdLocale = ref(antdDefaultLocale);
+
+const modules = import.meta.glob('./langs/**/*.json');
+
+const localesMap = loadLocalesMapFromDir(
+ /\.\/langs\/([^/]+)\/(.*)\.json$/,
+ modules,
+);
+/**
+ * 加载应用特有的语言包
+ * 这里也可以改造为从服务端获取翻译数据
+ * @param lang
+ */
+async function loadMessages(lang: SupportedLanguagesType) {
+ const [appLocaleMessages, _, abpLocales] = await Promise.all([
+ localesMap[lang]?.(),
+ loadThirdPartyMessage(lang),
+ loadAbpLocale(lang),
+ ]);
+ return {
+ ...appLocaleMessages?.default,
+ ...abpLocales,
+ };
+}
+
+/**
+ * 加载第三方组件库的语言包
+ * @param lang
+ */
+async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
+ await Promise.all([loadAntdLocale(lang), loadDayjsLocale(lang)]);
+}
+
+/**
+ * 加载dayjs的语言包
+ * @param lang
+ */
+async function loadDayjsLocale(lang: SupportedLanguagesType) {
+ let locale;
+ switch (lang) {
+ case 'en-US': {
+ locale = await import('dayjs/locale/en');
+ break;
+ }
+ case 'zh-CN': {
+ locale = await import('dayjs/locale/zh-cn');
+ break;
+ }
+ // 默认使用英语
+ default: {
+ locale = await import('dayjs/locale/en');
+ }
+ }
+ if (locale) {
+ dayjs.locale(locale);
+ } else {
+ console.error(`Failed to load dayjs locale for ${lang}`);
+ }
+}
+
+/**
+ * 加载antd的语言包
+ * @param lang
+ */
+async function loadAntdLocale(lang: SupportedLanguagesType) {
+ switch (lang) {
+ case 'en-US': {
+ antdLocale.value = antdEnLocale;
+ break;
+ }
+ case 'zh-CN': {
+ antdLocale.value = antdDefaultLocale;
+ break;
+ }
+ }
+}
+
+/**
+ * 加载abp的语言包
+ * @param lang
+ */
+async function loadAbpLocale(lang: SupportedLanguagesType) {
+ const abpStore = useAbpStore();
+ let localization = abpStore.localization;
+
+ if (lang !== localization?.currentCulture.cultureName) {
+ localization = await getLocalizationApi({
+ cultureName: lang,
+ onlyDynamics: false,
+ });
+ }
+ abpStore.setLocalization(localization);
+ const locales = abpStore.getI18nLocales();
+ return locales;
+}
+
+async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
+ await coreSetup(app, {
+ defaultLocale: preferences.app.locale,
+ loadMessages,
+ // missingWarn: !import.meta.env.PROD,
+ missingWarn: false,
+ ...options,
+ });
+}
+
+export { $t, antdLocale, setupI18n };
diff --git a/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json b/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json
new file mode 100644
index 000000000..a7a462088
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json
@@ -0,0 +1,13 @@
+{
+ "title": "Abp Framework",
+ "manage": {
+ "title": "Manage",
+ "identity": {
+ "title": "Identity",
+ "user": "User",
+ "role": "Role",
+ "claimTypes": "Claim Types",
+ "securityLogs": "Security Logs"
+ }
+ }
+}
diff --git a/apps/vben5/apps/app-antd/src/locales/langs/en-US/demos.json b/apps/vben5/apps/app-antd/src/locales/langs/en-US/demos.json
new file mode 100644
index 000000000..071564349
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/locales/langs/en-US/demos.json
@@ -0,0 +1,12 @@
+{
+ "title": "Demos",
+ "antd": "Ant Design Vue",
+ "vben": {
+ "title": "Project",
+ "about": "About",
+ "document": "Document",
+ "antdv": "Ant Design Vue Version",
+ "naive-ui": "Naive UI Version",
+ "element-plus": "Element Plus Version"
+ }
+}
diff --git a/apps/vben5/apps/app-antd/src/locales/langs/en-US/page.json b/apps/vben5/apps/app-antd/src/locales/langs/en-US/page.json
new file mode 100644
index 000000000..618a258c0
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/locales/langs/en-US/page.json
@@ -0,0 +1,14 @@
+{
+ "auth": {
+ "login": "Login",
+ "register": "Register",
+ "codeLogin": "Code Login",
+ "qrcodeLogin": "Qr Code Login",
+ "forgetPassword": "Forget Password"
+ },
+ "dashboard": {
+ "title": "Dashboard",
+ "analytics": "Analytics",
+ "workspace": "Workspace"
+ }
+}
diff --git a/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json
new file mode 100644
index 000000000..ef6be38c5
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json
@@ -0,0 +1,13 @@
+{
+ "title": "Abp框架",
+ "manage": {
+ "title": "管理",
+ "identity": {
+ "title": "身份认证管理",
+ "user": "用户",
+ "role": "角色",
+ "claimTypes": "身份标识",
+ "securityLogs": "安全日志"
+ }
+ }
+}
diff --git a/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/demos.json b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/demos.json
new file mode 100644
index 000000000..93ee722f5
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/demos.json
@@ -0,0 +1,12 @@
+{
+ "title": "演示",
+ "antd": "Ant Design Vue",
+ "vben": {
+ "title": "项目",
+ "about": "关于",
+ "document": "文档",
+ "antdv": "Ant Design Vue 版本",
+ "naive-ui": "Naive UI 版本",
+ "element-plus": "Element Plus 版本"
+ }
+}
diff --git a/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/page.json b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/page.json
new file mode 100644
index 000000000..4cb67081c
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/page.json
@@ -0,0 +1,14 @@
+{
+ "auth": {
+ "login": "登录",
+ "register": "注册",
+ "codeLogin": "验证码登录",
+ "qrcodeLogin": "二维码登录",
+ "forgetPassword": "忘记密码"
+ },
+ "dashboard": {
+ "title": "概览",
+ "analytics": "分析页",
+ "workspace": "工作台"
+ }
+}
diff --git a/apps/vben5/apps/app-antd/src/main.ts b/apps/vben5/apps/app-antd/src/main.ts
new file mode 100644
index 000000000..5d728a02a
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/main.ts
@@ -0,0 +1,31 @@
+import { initPreferences } from '@vben/preferences';
+import { unmountGlobalLoading } from '@vben/utils';
+
+import { overridesPreferences } from './preferences';
+
+/**
+ * 应用初始化完成之后再进行页面加载渲染
+ */
+async function initApplication() {
+ // name用于指定项目唯一标识
+ // 用于区分不同项目的偏好设置以及存储数据的key前缀以及其他一些需要隔离的数据
+ const env = import.meta.env.PROD ? 'prod' : 'dev';
+ const appVersion = import.meta.env.VITE_APP_VERSION;
+ const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${appVersion}-${env}`;
+
+ // app偏好设置初始化
+ await initPreferences({
+ namespace,
+ overrides: overridesPreferences,
+ });
+
+ // 启动应用并挂载
+ // vue应用主要逻辑及视图
+ const { bootstrap } = await import('./bootstrap');
+ await bootstrap(namespace);
+
+ // 移除并销毁loading
+ unmountGlobalLoading();
+}
+
+initApplication();
diff --git a/apps/vben5/apps/app-antd/src/preferences.ts b/apps/vben5/apps/app-antd/src/preferences.ts
new file mode 100644
index 000000000..b2e9ace43
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/preferences.ts
@@ -0,0 +1,13 @@
+import { defineOverridesPreferences } from '@vben/preferences';
+
+/**
+ * @description 项目配置文件
+ * 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置
+ * !!! 更改配置后请清空缓存,否则可能不生效
+ */
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ name: import.meta.env.VITE_APP_TITLE,
+ },
+});
diff --git a/apps/vben5/apps/app-antd/src/router/access.ts b/apps/vben5/apps/app-antd/src/router/access.ts
new file mode 100644
index 000000000..3a48be237
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/router/access.ts
@@ -0,0 +1,42 @@
+import type {
+ ComponentRecordType,
+ GenerateMenuAndRoutesOptions,
+} from '@vben/types';
+
+import { generateAccessible } from '@vben/access';
+import { preferences } from '@vben/preferences';
+
+import { message } from 'ant-design-vue';
+
+import { getAllMenusApi } from '#/api';
+import { BasicLayout, IFrameView } from '#/layouts';
+import { $t } from '#/locales';
+
+const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
+
+async function generateAccess(options: GenerateMenuAndRoutesOptions) {
+ const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue');
+
+ const layoutMap: ComponentRecordType = {
+ BasicLayout,
+ IFrameView,
+ };
+
+ return await generateAccessible(preferences.app.accessMode, {
+ ...options,
+ fetchMenuListAsync: async () => {
+ message.loading({
+ content: `${$t('common.loadingMenu')}...`,
+ duration: 1.5,
+ });
+ return await getAllMenusApi();
+ },
+ // 可以指定没有权限跳转403页面
+ forbiddenComponent,
+ // 如果 route.meta.menuVisibleWithForbidden = true
+ layoutMap,
+ pageMap,
+ });
+}
+
+export { generateAccess };
diff --git a/apps/vben5/apps/app-antd/src/router/guard.ts b/apps/vben5/apps/app-antd/src/router/guard.ts
new file mode 100644
index 000000000..fce5a892c
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/router/guard.ts
@@ -0,0 +1,125 @@
+import type { Router } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+import { preferences } from '@vben/preferences';
+import { useAccessStore, useUserStore } from '@vben/stores';
+import { startProgress, stopProgress } from '@vben/utils';
+
+import { accessRoutes, coreRouteNames } from '#/router/routes';
+import { useAuthStore } from '#/store';
+
+import { generateAccess } from './access';
+
+/**
+ * 通用守卫配置
+ * @param router
+ */
+function setupCommonGuard(router: Router) {
+ // 记录已经加载的页面
+ const loadedPaths = new Set();
+
+ router.beforeEach(async (to) => {
+ to.meta.loaded = loadedPaths.has(to.path);
+
+ // 页面加载进度条
+ if (!to.meta.loaded && preferences.transition.progress) {
+ startProgress();
+ }
+ return true;
+ });
+
+ router.afterEach((to) => {
+ // 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
+
+ loadedPaths.add(to.path);
+
+ // 关闭页面加载进度条
+ if (preferences.transition.progress) {
+ stopProgress();
+ }
+ });
+}
+
+/**
+ * 权限访问守卫配置
+ * @param router
+ */
+function setupAccessGuard(router: Router) {
+ router.beforeEach(async (to, from) => {
+ const accessStore = useAccessStore();
+ const userStore = useUserStore();
+ const authStore = useAuthStore();
+
+ // 基本路由,这些路由不需要进入权限拦截
+ if (coreRouteNames.includes(to.name as string)) {
+ if (to.path === LOGIN_PATH && accessStore.accessToken) {
+ return decodeURIComponent(
+ (to.query?.redirect as string) || DEFAULT_HOME_PATH,
+ );
+ }
+ return true;
+ }
+
+ // accessToken 检查
+ if (!accessStore.accessToken) {
+ // 明确声明忽略权限访问权限,则可以访问
+ if (to.meta.ignoreAccess) {
+ return true;
+ }
+
+ // 没有访问权限,跳转登录页面
+ if (to.fullPath !== LOGIN_PATH) {
+ return {
+ path: LOGIN_PATH,
+ // 如不需要,直接删除 query
+ query: { redirect: encodeURIComponent(to.fullPath) },
+ // 携带当前跳转的页面,登录后重新跳转该页面
+ replace: true,
+ };
+ }
+ return to;
+ }
+
+ // 是否已经生成过动态路由
+ if (accessStore.isAccessChecked) {
+ return true;
+ }
+
+ // 生成路由表
+ // 当前登录用户拥有的角色标识列表
+ const userInfo = userStore.userInfo || (await authStore.fetchUserInfo());
+ const userRoles = userInfo.roles ?? [];
+
+ // 生成菜单和路由
+ const { accessibleMenus, accessibleRoutes } = await generateAccess({
+ roles: userRoles,
+ router,
+ // 则会在菜单中显示,但是访问会被重定向到403
+ routes: accessRoutes,
+ });
+
+ // 保存菜单信息和路由信息
+ accessStore.setAccessMenus(accessibleMenus);
+ accessStore.setAccessRoutes(accessibleRoutes);
+ accessStore.setIsAccessChecked(true);
+ const redirectPath = (from.query.redirect ?? to.fullPath) as string;
+
+ return {
+ ...router.resolve(decodeURIComponent(redirectPath)),
+ replace: true,
+ };
+ });
+}
+
+/**
+ * 项目守卫配置
+ * @param router
+ */
+function createRouterGuard(router: Router) {
+ /** 通用 */
+ setupCommonGuard(router);
+ /** 权限访问 */
+ setupAccessGuard(router);
+}
+
+export { createRouterGuard };
diff --git a/apps/vben5/apps/app-antd/src/router/index.ts b/apps/vben5/apps/app-antd/src/router/index.ts
new file mode 100644
index 000000000..484023034
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/router/index.ts
@@ -0,0 +1,37 @@
+import {
+ createRouter,
+ createWebHashHistory,
+ createWebHistory,
+} from 'vue-router';
+
+import { resetStaticRoutes } from '@vben/utils';
+
+import { createRouterGuard } from './guard';
+import { routes } from './routes';
+
+/**
+ * @zh_CN 创建vue-router实例
+ */
+const router = createRouter({
+ history:
+ import.meta.env.VITE_ROUTER_HISTORY === 'hash'
+ ? createWebHashHistory(import.meta.env.VITE_BASE)
+ : createWebHistory(import.meta.env.VITE_BASE),
+ // 应该添加到路由的初始路由列表。
+ routes,
+ scrollBehavior: (to, _from, savedPosition) => {
+ if (savedPosition) {
+ return savedPosition;
+ }
+ return to.hash ? { behavior: 'smooth', el: to.hash } : { left: 0, top: 0 };
+ },
+ // 是否应该禁止尾部斜杠。
+ // strict: true,
+});
+
+const resetRoutes = () => resetStaticRoutes(router, routes);
+
+// 创建路由守卫
+createRouterGuard(router);
+
+export { resetRoutes, router };
diff --git a/apps/vben5/apps/app-antd/src/router/routes/core.ts b/apps/vben5/apps/app-antd/src/router/routes/core.ts
new file mode 100644
index 000000000..fe030a9a2
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/router/routes/core.ts
@@ -0,0 +1,88 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+
+import { AuthPageLayout } from '#/layouts';
+import { $t } from '#/locales';
+import Login from '#/views/_core/authentication/login.vue';
+
+/** 全局404页面 */
+const fallbackNotFoundRoute: RouteRecordRaw = {
+ component: () => import('#/views/_core/fallback/not-found.vue'),
+ meta: {
+ hideInBreadcrumb: true,
+ hideInMenu: true,
+ hideInTab: true,
+ title: '404',
+ },
+ name: 'FallbackNotFound',
+ path: '/:path(.*)*',
+};
+
+/** 基本路由,这些路由是必须存在的 */
+const coreRoutes: RouteRecordRaw[] = [
+ {
+ meta: {
+ title: 'Root',
+ },
+ name: 'Root',
+ path: '/',
+ redirect: DEFAULT_HOME_PATH,
+ },
+ {
+ component: AuthPageLayout,
+ meta: {
+ hideInTab: true,
+ title: 'Authentication',
+ },
+ name: 'Authentication',
+ path: '/auth',
+ redirect: LOGIN_PATH,
+ children: [
+ {
+ name: 'Login',
+ path: 'login',
+ component: Login,
+ meta: {
+ title: $t('page.auth.login'),
+ },
+ },
+ {
+ name: 'CodeLogin',
+ path: 'code-login',
+ component: () => import('#/views/_core/authentication/code-login.vue'),
+ meta: {
+ title: $t('page.auth.codeLogin'),
+ },
+ },
+ {
+ name: 'QrCodeLogin',
+ path: 'qrcode-login',
+ component: () =>
+ import('#/views/_core/authentication/qrcode-login.vue'),
+ meta: {
+ title: $t('page.auth.qrcodeLogin'),
+ },
+ },
+ {
+ name: 'ForgetPassword',
+ path: 'forget-password',
+ component: () =>
+ import('#/views/_core/authentication/forget-password.vue'),
+ meta: {
+ title: $t('page.auth.forgetPassword'),
+ },
+ },
+ {
+ name: 'Register',
+ path: 'register',
+ component: () => import('#/views/_core/authentication/register.vue'),
+ meta: {
+ title: $t('page.auth.register'),
+ },
+ },
+ ],
+ },
+];
+
+export { coreRoutes, fallbackNotFoundRoute };
diff --git a/apps/vben5/apps/app-antd/src/router/routes/index.ts b/apps/vben5/apps/app-antd/src/router/routes/index.ts
new file mode 100644
index 000000000..e6fb14402
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/router/routes/index.ts
@@ -0,0 +1,37 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { mergeRouteModules, traverseTreeValues } from '@vben/utils';
+
+import { coreRoutes, fallbackNotFoundRoute } from './core';
+
+const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
+ eager: true,
+});
+
+// 有需要可以自行打开注释,并创建文件夹
+// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
+// const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true });
+
+/** 动态路由 */
+const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
+
+/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
+// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
+// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
+const staticRoutes: RouteRecordRaw[] = [];
+const externalRoutes: RouteRecordRaw[] = [];
+
+/** 路由列表,由基本路由、外部路由和404兜底路由组成
+ * 无需走权限验证(会一直显示在菜单中) */
+const routes: RouteRecordRaw[] = [
+ ...coreRoutes,
+ ...externalRoutes,
+ fallbackNotFoundRoute,
+];
+
+/** 基本路由列表,这些路由不需要进入权限拦截 */
+const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
+
+/** 有权限校验的路由列表,包含动态路由和静态路由 */
+const accessRoutes = [...dynamicRoutes, ...staticRoutes];
+export { accessRoutes, coreRouteNames, routes };
diff --git a/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts b/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts
new file mode 100644
index 000000000..acae5784f
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts
@@ -0,0 +1,80 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'https://abp.io/assets/favicon.ico/favicon-16x16.png',
+ keepAlive: true,
+ order: 1000,
+ title: $t('abp.title'),
+ },
+ name: 'AbpFramework',
+ path: '/abp',
+ children: [
+ {
+ meta: {
+ title: $t('abp.manage.title'),
+ icon: 'arcticons:activity-manager',
+ },
+ name: 'Manage',
+ path: '/manage',
+ children: [
+ {
+ meta: {
+ title: $t('abp.manage.identity.title'),
+ icon: 'teenyicons:id-outline',
+ },
+ name: 'Identity',
+ path: '/manage/identity',
+ children: [
+ {
+ component: () => import('#/views/identity/user/index.vue'),
+ name: 'Users',
+ path: '/manage/identity/users',
+ meta: {
+ title: $t('abp.manage.identity.user'),
+ icon: 'mdi:user-outline',
+ },
+ },
+ {
+ component: () => import('#/views/identity/role/index.vue'),
+ name: 'Roles',
+ path: '/manage/identity/roles',
+ meta: {
+ title: $t('abp.manage.identity.role'),
+ icon: 'carbon:user-role',
+ },
+ },
+ {
+ component: () =>
+ import('#/views/identity/claim-types/index.vue'),
+ name: 'ClaimTypes',
+ path: '/manage/identity/claim-types',
+ meta: {
+ title: $t('abp.manage.identity.claimTypes'),
+ icon: 'la:id-card-solid',
+ },
+ },
+ {
+ component: () =>
+ import('#/views/identity/security-logs/index.vue'),
+ name: 'SecurityLogs',
+ path: '/manage/identity/security-logs',
+ meta: {
+ title: $t('abp.manage.identity.securityLogs'),
+ icon: 'carbon:security',
+ },
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/app-antd/src/router/routes/modules/dashboard.ts b/apps/vben5/apps/app-antd/src/router/routes/modules/dashboard.ts
new file mode 100644
index 000000000..1bddab9db
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/router/routes/modules/dashboard.ts
@@ -0,0 +1,40 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'lucide:layout-dashboard',
+ order: -1,
+ title: $t('page.dashboard.title'),
+ },
+ name: 'Dashboard',
+ path: '/',
+ children: [
+ {
+ name: 'Analytics',
+ path: '/analytics',
+ component: () => import('#/views/dashboard/analytics/index.vue'),
+ meta: {
+ affixTab: true,
+ icon: 'lucide:area-chart',
+ title: $t('page.dashboard.analytics'),
+ },
+ },
+ {
+ name: 'Workspace',
+ path: '/workspace',
+ component: () => import('#/views/dashboard/workspace/index.vue'),
+ meta: {
+ icon: 'carbon:workspace',
+ title: $t('page.dashboard.workspace'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/app-antd/src/router/routes/modules/demos.ts b/apps/vben5/apps/app-antd/src/router/routes/modules/demos.ts
new file mode 100644
index 000000000..32bb338e0
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/router/routes/modules/demos.ts
@@ -0,0 +1,30 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'ic:baseline-view-in-ar',
+ keepAlive: true,
+ order: 1000,
+ title: $t('demos.title'),
+ },
+ name: 'Demos',
+ path: '/demos',
+ children: [
+ {
+ meta: {
+ title: $t('demos.antd'),
+ },
+ name: 'AntDesignDemos',
+ path: '/demos/ant-design',
+ component: () => import('#/views/demos/antd/index.vue'),
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/app-antd/src/router/routes/modules/vben.ts b/apps/vben5/apps/app-antd/src/router/routes/modules/vben.ts
new file mode 100644
index 000000000..210e8610f
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/router/routes/modules/vben.ts
@@ -0,0 +1,81 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import {
+ VBEN_DOC_URL,
+ VBEN_ELE_PREVIEW_URL,
+ VBEN_GITHUB_URL,
+ VBEN_LOGO_URL,
+ VBEN_NAIVE_PREVIEW_URL,
+} from '@vben/constants';
+
+import { BasicLayout, IFrameView } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ badgeType: 'dot',
+ icon: VBEN_LOGO_URL,
+ order: 9999,
+ title: $t('demos.vben.title'),
+ },
+ name: 'VbenProject',
+ path: '/vben-admin',
+ children: [
+ {
+ name: 'VbenAbout',
+ path: '/vben-admin/about',
+ component: () => import('#/views/_core/about/index.vue'),
+ meta: {
+ icon: 'lucide:copyright',
+ title: $t('demos.vben.about'),
+ },
+ },
+ {
+ name: 'VbenDocument',
+ path: '/vben-admin/document',
+ component: IFrameView,
+ meta: {
+ icon: 'lucide:book-open-text',
+ link: VBEN_DOC_URL,
+ title: $t('demos.vben.document'),
+ },
+ },
+ {
+ name: 'VbenGithub',
+ path: '/vben-admin/github',
+ component: IFrameView,
+ meta: {
+ icon: 'mdi:github',
+ link: VBEN_GITHUB_URL,
+ title: 'Github',
+ },
+ },
+ {
+ name: 'VbenNaive',
+ path: '/vben-admin/naive',
+ component: IFrameView,
+ meta: {
+ badgeType: 'dot',
+ icon: 'logos:naiveui',
+ link: VBEN_NAIVE_PREVIEW_URL,
+ title: $t('demos.vben.naive-ui'),
+ },
+ },
+ {
+ name: 'VbenElementPlus',
+ path: '/vben-admin/ele',
+ component: IFrameView,
+ meta: {
+ badgeType: 'dot',
+ icon: 'logos:element',
+ link: VBEN_ELE_PREVIEW_URL,
+ title: $t('demos.vben.element-plus'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/app-antd/src/store/auth.ts b/apps/vben5/apps/app-antd/src/store/auth.ts
new file mode 100644
index 000000000..c4a8670fa
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/store/auth.ts
@@ -0,0 +1,126 @@
+import type { Recordable, UserInfo } from '@vben/types';
+
+import { ref } from 'vue';
+import { useRouter } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
+
+import { getUserInfoApi, loginApi } from '@abp/account';
+import { useAbpStore } from '@abp/core';
+import { notification } from 'ant-design-vue';
+import { defineStore } from 'pinia';
+
+import { getConfigApi } from '#/api/core/abp';
+import { $t } from '#/locales';
+
+export const useAuthStore = defineStore('auth', () => {
+ const accessStore = useAccessStore();
+ const userStore = useUserStore();
+ const abpStore = useAbpStore();
+ const router = useRouter();
+
+ const loginLoading = ref(false);
+
+ /**
+ * 异步处理登录操作
+ * Asynchronously handle the login process
+ * @param params 登录表单数据
+ */
+ async function authLogin(
+ params: Recordable,
+ onSuccess?: () => Promise | void,
+ ) {
+ // 异步处理用户登录操作并获取 accessToken
+ let userInfo: null | UserInfo = null;
+ try {
+ loginLoading.value = true;
+ const loginResult = await loginApi(params as any);
+ const { accessToken, tokenType, refreshToken } = loginResult;
+ // 如果成功获取到 accessToken
+ if (accessToken) {
+ accessStore.setAccessToken(`${tokenType} ${accessToken}`);
+ accessStore.setRefreshToken(refreshToken);
+
+ userInfo = await fetchUserInfo();
+
+ userStore.setUserInfo(userInfo);
+
+ if (accessStore.loginExpired) {
+ accessStore.setLoginExpired(false);
+ } else {
+ onSuccess
+ ? await onSuccess?.()
+ : await router.push(userInfo.homePath || DEFAULT_HOME_PATH);
+ }
+
+ if (userInfo?.realName) {
+ notification.success({
+ description: `${$t('authentication.loginSuccessDesc')}:${userInfo?.realName}`,
+ duration: 3,
+ message: $t('authentication.loginSuccess'),
+ });
+ }
+ }
+ } finally {
+ loginLoading.value = false;
+ }
+
+ return {
+ userInfo,
+ };
+ }
+
+ async function logout(redirect: boolean = true) {
+ try {
+ // await logoutApi();
+ } catch {
+ // 不做任何处理
+ }
+ resetAllStores();
+ accessStore.setLoginExpired(false);
+
+ // 回登录页带上当前路由地址
+ await router.replace({
+ path: LOGIN_PATH,
+ query: redirect
+ ? {
+ redirect: encodeURIComponent(router.currentRoute.value.fullPath),
+ }
+ : {},
+ });
+ }
+
+ async function fetchUserInfo() {
+ let userInfo: ({ [key: string]: any } & UserInfo) | null = null;
+ const userInfoRes = await getUserInfoApi();
+ const abpConfig = await getConfigApi();
+ userInfo = {
+ userId: userInfoRes.sub,
+ username: userInfoRes.uniqueName,
+ realName: userInfoRes.name,
+ avatar: userInfoRes.avatarUrl ?? userInfoRes.picture,
+ desc: userInfoRes.uniqueName ?? userInfoRes.name,
+ email: userInfoRes.email ?? userInfoRes.email,
+ token: '',
+ roles: abpConfig.currentUser.roles,
+ homePath: '/',
+ };
+ userStore.setUserInfo(userInfo);
+ abpStore.setApplication(abpConfig);
+ accessStore.setAccessCodes(Object.keys(abpConfig.auth.grantedPolicies));
+ return userInfo;
+ }
+
+ function $reset() {
+ loginLoading.value = false;
+ }
+
+ return {
+ $reset,
+ authLogin,
+ fetchUserInfo,
+ loginLoading,
+ logout,
+ };
+});
diff --git a/apps/vben5/apps/app-antd/src/store/index.ts b/apps/vben5/apps/app-antd/src/store/index.ts
new file mode 100644
index 000000000..269586ee8
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/store/index.ts
@@ -0,0 +1 @@
+export * from './auth';
diff --git a/apps/vben5/apps/app-antd/src/views/_core/README.md b/apps/vben5/apps/app-antd/src/views/_core/README.md
new file mode 100644
index 000000000..8248afe6c
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/README.md
@@ -0,0 +1,3 @@
+# \_core
+
+此目录包含应用程序正常运行所需的基本视图。这些视图是应用程序布局中使用的视图。
diff --git a/apps/vben5/apps/app-antd/src/views/_core/about/index.vue b/apps/vben5/apps/app-antd/src/views/_core/about/index.vue
new file mode 100644
index 000000000..0ee524335
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/about/index.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/authentication/code-login.vue b/apps/vben5/apps/app-antd/src/views/_core/authentication/code-login.vue
new file mode 100644
index 000000000..556b273af
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/authentication/code-login.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/authentication/forget-password.vue b/apps/vben5/apps/app-antd/src/views/_core/authentication/forget-password.vue
new file mode 100644
index 000000000..fef0d4279
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/authentication/forget-password.vue
@@ -0,0 +1,43 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/authentication/login.vue b/apps/vben5/apps/app-antd/src/views/_core/authentication/login.vue
new file mode 100644
index 000000000..7fee812fd
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/authentication/login.vue
@@ -0,0 +1,45 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/authentication/qrcode-login.vue b/apps/vben5/apps/app-antd/src/views/_core/authentication/qrcode-login.vue
new file mode 100644
index 000000000..23f5f2dad
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/authentication/qrcode-login.vue
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/authentication/register.vue b/apps/vben5/apps/app-antd/src/views/_core/authentication/register.vue
new file mode 100644
index 000000000..b1a5de726
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/authentication/register.vue
@@ -0,0 +1,96 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/fallback/coming-soon.vue b/apps/vben5/apps/app-antd/src/views/_core/fallback/coming-soon.vue
new file mode 100644
index 000000000..f394930f2
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/fallback/coming-soon.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/fallback/forbidden.vue b/apps/vben5/apps/app-antd/src/views/_core/fallback/forbidden.vue
new file mode 100644
index 000000000..8ea65fedb
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/fallback/forbidden.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/fallback/internal-error.vue b/apps/vben5/apps/app-antd/src/views/_core/fallback/internal-error.vue
new file mode 100644
index 000000000..819a47d5e
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/fallback/internal-error.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/fallback/not-found.vue b/apps/vben5/apps/app-antd/src/views/_core/fallback/not-found.vue
new file mode 100644
index 000000000..4d178e9cb
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/fallback/not-found.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/_core/fallback/offline.vue b/apps/vben5/apps/app-antd/src/views/_core/fallback/offline.vue
new file mode 100644
index 000000000..5de4a88de
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/_core/fallback/offline.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-trends.vue b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-trends.vue
new file mode 100644
index 000000000..fadfc917c
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-trends.vue
@@ -0,0 +1,100 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits-data.vue b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits-data.vue
new file mode 100644
index 000000000..30c4265df
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits-data.vue
@@ -0,0 +1,84 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits-sales.vue b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits-sales.vue
new file mode 100644
index 000000000..260520b84
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits-sales.vue
@@ -0,0 +1,48 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits-source.vue b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits-source.vue
new file mode 100644
index 000000000..e0d0aab5e
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits-source.vue
@@ -0,0 +1,67 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits.vue b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits.vue
new file mode 100644
index 000000000..7e1f14ee6
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/analytics-visits.vue
@@ -0,0 +1,57 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/dashboard/analytics/index.vue b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/index.vue
new file mode 100644
index 000000000..00b34df1e
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/dashboard/analytics/index.vue
@@ -0,0 +1,90 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/dashboard/workspace/index.vue b/apps/vben5/apps/app-antd/src/views/dashboard/workspace/index.vue
new file mode 100644
index 000000000..b95d61381
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/dashboard/workspace/index.vue
@@ -0,0 +1,266 @@
+
+
+
+
+
+
+ 早安, {{ userStore.userInfo?.realName }}, 开始您一天的工作吧!
+
+ 今日晴,20℃ - 32℃!
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/demos/antd/index.vue b/apps/vben5/apps/app-antd/src/views/demos/antd/index.vue
new file mode 100644
index 000000000..b3b05cc15
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/demos/antd/index.vue
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+ Default
+ Primary
+ Info
+ Error
+
+
+
+
+ 信息
+ 错误
+ 警告
+ 成功
+
+
+
+
+
+ 信息
+ 错误
+ 警告
+ 成功
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/identity/claim-types/index.vue b/apps/vben5/apps/app-antd/src/views/identity/claim-types/index.vue
new file mode 100644
index 000000000..7d36dd612
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/identity/claim-types/index.vue
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/identity/role/index.vue b/apps/vben5/apps/app-antd/src/views/identity/role/index.vue
new file mode 100644
index 000000000..725a355e4
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/identity/role/index.vue
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/identity/security-logs/index.vue b/apps/vben5/apps/app-antd/src/views/identity/security-logs/index.vue
new file mode 100644
index 000000000..23476a2a0
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/identity/security-logs/index.vue
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/src/views/identity/user/index.vue b/apps/vben5/apps/app-antd/src/views/identity/user/index.vue
new file mode 100644
index 000000000..4c15e5f00
--- /dev/null
+++ b/apps/vben5/apps/app-antd/src/views/identity/user/index.vue
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/app-antd/tailwind.config.mjs b/apps/vben5/apps/app-antd/tailwind.config.mjs
new file mode 100644
index 000000000..f17f556fa
--- /dev/null
+++ b/apps/vben5/apps/app-antd/tailwind.config.mjs
@@ -0,0 +1 @@
+export { default } from '@vben/tailwind-config';
diff --git a/apps/vben5/apps/app-antd/tsconfig.json b/apps/vben5/apps/app-antd/tsconfig.json
new file mode 100644
index 000000000..02c287fe6
--- /dev/null
+++ b/apps/vben5/apps/app-antd/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/web-app.json",
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "#/*": ["./src/*"]
+ }
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
+}
diff --git a/apps/vben5/apps/app-antd/tsconfig.node.json b/apps/vben5/apps/app-antd/tsconfig.node.json
new file mode 100644
index 000000000..c2f0d86cc
--- /dev/null
+++ b/apps/vben5/apps/app-antd/tsconfig.node.json
@@ -0,0 +1,10 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/node.json",
+ "compilerOptions": {
+ "composite": true,
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
+ "noEmit": false
+ },
+ "include": ["vite.config.mts"]
+}
diff --git a/apps/vben5/apps/app-antd/vite.config.mts b/apps/vben5/apps/app-antd/vite.config.mts
new file mode 100644
index 000000000..cc4b2bef1
--- /dev/null
+++ b/apps/vben5/apps/app-antd/vite.config.mts
@@ -0,0 +1,27 @@
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ application: {},
+ vite: {
+ server: {
+ proxy: {
+ '/api': {
+ changeOrigin: true,
+ // rewrite: (path) => path.replace(/^\/api/, ''),
+ // mock代理目标地址
+ target: 'http://81.68.64.105:30001/',
+ ws: true,
+ },
+ '/connect': {
+ changeOrigin: true,
+ // rewrite: (path) => path.replace(/^\/api/, ''),
+ // mock代理目标地址
+ target: 'http://81.68.64.105:30001/',
+ ws: true,
+ },
+ },
+ },
+ },
+ };
+});
diff --git a/apps/vben5/apps/backend-mock/.env b/apps/vben5/apps/backend-mock/.env
new file mode 100644
index 000000000..b20c4a65f
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/.env
@@ -0,0 +1,3 @@
+PORT=5320
+ACCESS_TOKEN_SECRET=access_token_secret
+REFRESH_TOKEN_SECRET=refresh_token_secret
diff --git a/apps/vben5/apps/backend-mock/README.md b/apps/vben5/apps/backend-mock/README.md
new file mode 100644
index 000000000..401bda76f
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/README.md
@@ -0,0 +1,15 @@
+# @vben/backend-mock
+
+## Description
+
+Vben Admin 数据 mock 服务,没有对接任何的数据库,所有数据都是模拟的,用于前端开发时提供数据支持。线上环境不再提供 mock 集成,可自行部署服务或者对接真实数据,由于 `mock.js` 等工具有一些限制,比如上传文件不行、无法模拟复杂的逻辑等,所以这里使用了真实的后端服务来实现。唯一麻烦的是本地需要同时启动后端服务和前端服务,但是这样可以更好的模拟真实环境。该服务不需要手动启动,已经集成在 vite 插件内,随应用一起启用。
+
+## Running the app
+
+```bash
+# development
+$ pnpm run start
+
+# production mode
+$ pnpm run build
+```
diff --git a/apps/vben5/apps/backend-mock/api/auth/codes.ts b/apps/vben5/apps/backend-mock/api/auth/codes.ts
new file mode 100644
index 000000000..7ba012705
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/auth/codes.ts
@@ -0,0 +1,14 @@
+import { verifyAccessToken } from '~/utils/jwt-utils';
+import { unAuthorizedResponse } from '~/utils/response';
+
+export default eventHandler((event) => {
+ const userinfo = verifyAccessToken(event);
+ if (!userinfo) {
+ return unAuthorizedResponse(event);
+ }
+
+ const codes =
+ MOCK_CODES.find((item) => item.username === userinfo.username)?.codes ?? [];
+
+ return useResponseSuccess(codes);
+});
diff --git a/apps/vben5/apps/backend-mock/api/auth/login.post.ts b/apps/vben5/apps/backend-mock/api/auth/login.post.ts
new file mode 100644
index 000000000..df5737a25
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/auth/login.post.ts
@@ -0,0 +1,36 @@
+import {
+ clearRefreshTokenCookie,
+ setRefreshTokenCookie,
+} from '~/utils/cookie-utils';
+import { generateAccessToken, generateRefreshToken } from '~/utils/jwt-utils';
+import { forbiddenResponse } from '~/utils/response';
+
+export default defineEventHandler(async (event) => {
+ const { password, username } = await readBody(event);
+ if (!password || !username) {
+ setResponseStatus(event, 400);
+ return useResponseError(
+ 'BadRequestException',
+ 'Username and password are required',
+ );
+ }
+
+ const findUser = MOCK_USERS.find(
+ (item) => item.username === username && item.password === password,
+ );
+
+ if (!findUser) {
+ clearRefreshTokenCookie(event);
+ return forbiddenResponse(event, 'Username or password is incorrect.');
+ }
+
+ const accessToken = generateAccessToken(findUser);
+ const refreshToken = generateRefreshToken(findUser);
+
+ setRefreshTokenCookie(event, refreshToken);
+
+ return useResponseSuccess({
+ ...findUser,
+ accessToken,
+ });
+});
diff --git a/apps/vben5/apps/backend-mock/api/auth/logout.post.ts b/apps/vben5/apps/backend-mock/api/auth/logout.post.ts
new file mode 100644
index 000000000..ac6afe940
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/auth/logout.post.ts
@@ -0,0 +1,15 @@
+import {
+ clearRefreshTokenCookie,
+ getRefreshTokenFromCookie,
+} from '~/utils/cookie-utils';
+
+export default defineEventHandler(async (event) => {
+ const refreshToken = getRefreshTokenFromCookie(event);
+ if (!refreshToken) {
+ return useResponseSuccess('');
+ }
+
+ clearRefreshTokenCookie(event);
+
+ return useResponseSuccess('');
+});
diff --git a/apps/vben5/apps/backend-mock/api/auth/refresh.post.ts b/apps/vben5/apps/backend-mock/api/auth/refresh.post.ts
new file mode 100644
index 000000000..7df4d34f5
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/auth/refresh.post.ts
@@ -0,0 +1,33 @@
+import {
+ clearRefreshTokenCookie,
+ getRefreshTokenFromCookie,
+ setRefreshTokenCookie,
+} from '~/utils/cookie-utils';
+import { verifyRefreshToken } from '~/utils/jwt-utils';
+import { forbiddenResponse } from '~/utils/response';
+
+export default defineEventHandler(async (event) => {
+ const refreshToken = getRefreshTokenFromCookie(event);
+ if (!refreshToken) {
+ return forbiddenResponse(event);
+ }
+
+ clearRefreshTokenCookie(event);
+
+ const userinfo = verifyRefreshToken(refreshToken);
+ if (!userinfo) {
+ return forbiddenResponse(event);
+ }
+
+ const findUser = MOCK_USERS.find(
+ (item) => item.username === userinfo.username,
+ );
+ if (!findUser) {
+ return forbiddenResponse(event);
+ }
+ const accessToken = generateAccessToken(findUser);
+
+ setRefreshTokenCookie(event, refreshToken);
+
+ return accessToken;
+});
diff --git a/apps/vben5/apps/backend-mock/api/menu/all.ts b/apps/vben5/apps/backend-mock/api/menu/all.ts
new file mode 100644
index 000000000..580cee4f9
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/menu/all.ts
@@ -0,0 +1,13 @@
+import { verifyAccessToken } from '~/utils/jwt-utils';
+import { unAuthorizedResponse } from '~/utils/response';
+
+export default eventHandler(async (event) => {
+ const userinfo = verifyAccessToken(event);
+ if (!userinfo) {
+ return unAuthorizedResponse(event);
+ }
+
+ const menus =
+ MOCK_MENUS.find((item) => item.username === userinfo.username)?.menus ?? [];
+ return useResponseSuccess(menus);
+});
diff --git a/apps/vben5/apps/backend-mock/api/status.ts b/apps/vben5/apps/backend-mock/api/status.ts
new file mode 100644
index 000000000..41773e1d5
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/status.ts
@@ -0,0 +1,5 @@
+export default eventHandler((event) => {
+ const { status } = getQuery(event);
+ setResponseStatus(event, Number(status));
+ return useResponseError(`${status}`);
+});
diff --git a/apps/vben5/apps/backend-mock/api/table/list.ts b/apps/vben5/apps/backend-mock/api/table/list.ts
new file mode 100644
index 000000000..4a0db94ec
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/table/list.ts
@@ -0,0 +1,48 @@
+import { faker } from '@faker-js/faker';
+import { verifyAccessToken } from '~/utils/jwt-utils';
+import { unAuthorizedResponse } from '~/utils/response';
+
+function generateMockDataList(count: number) {
+ const dataList = [];
+
+ for (let i = 0; i < count; i++) {
+ const dataItem = {
+ id: faker.string.uuid(),
+ imageUrl: faker.image.avatar(),
+ imageUrl2: faker.image.avatar(),
+ open: faker.datatype.boolean(),
+ status: faker.helpers.arrayElement(['success', 'error', 'warning']),
+ productName: faker.commerce.productName(),
+ price: faker.commerce.price(),
+ currency: faker.finance.currencyCode(),
+ quantity: faker.number.int({ min: 1, max: 100 }),
+ available: faker.datatype.boolean(),
+ category: faker.commerce.department(),
+ releaseDate: faker.date.past(),
+ rating: faker.number.float({ min: 1, max: 5 }),
+ description: faker.commerce.productDescription(),
+ weight: faker.number.float({ min: 0.1, max: 10 }),
+ color: faker.color.human(),
+ inProduction: faker.datatype.boolean(),
+ tags: Array.from({ length: 3 }, () => faker.commerce.productAdjective()),
+ };
+
+ dataList.push(dataItem);
+ }
+
+ return dataList;
+}
+
+const mockData = generateMockDataList(100);
+
+export default eventHandler(async (event) => {
+ const userinfo = verifyAccessToken(event);
+ if (!userinfo) {
+ return unAuthorizedResponse(event);
+ }
+
+ await sleep(600);
+
+ const { page, pageSize } = getQuery(event);
+ return usePageResponseSuccess(page as string, pageSize as string, mockData);
+});
diff --git a/apps/vben5/apps/backend-mock/api/test.get.ts b/apps/vben5/apps/backend-mock/api/test.get.ts
new file mode 100644
index 000000000..ca4a500be
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/test.get.ts
@@ -0,0 +1 @@
+export default defineEventHandler(() => 'Test get handler');
diff --git a/apps/vben5/apps/backend-mock/api/test.post.ts b/apps/vben5/apps/backend-mock/api/test.post.ts
new file mode 100644
index 000000000..698cf211e
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/test.post.ts
@@ -0,0 +1 @@
+export default defineEventHandler(() => 'Test post handler');
diff --git a/apps/vben5/apps/backend-mock/api/user/info.ts b/apps/vben5/apps/backend-mock/api/user/info.ts
new file mode 100644
index 000000000..cfa2346cb
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/api/user/info.ts
@@ -0,0 +1,10 @@
+import { verifyAccessToken } from '~/utils/jwt-utils';
+import { unAuthorizedResponse } from '~/utils/response';
+
+export default eventHandler((event) => {
+ const userinfo = verifyAccessToken(event);
+ if (!userinfo) {
+ return unAuthorizedResponse(event);
+ }
+ return useResponseSuccess(userinfo);
+});
diff --git a/apps/vben5/apps/backend-mock/error.ts b/apps/vben5/apps/backend-mock/error.ts
new file mode 100644
index 000000000..e20beac4e
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/error.ts
@@ -0,0 +1,7 @@
+import type { NitroErrorHandler } from 'nitropack';
+
+const errorHandler: NitroErrorHandler = function (error, event) {
+ event.node.res.end(`[Error Handler] ${error.stack}`);
+};
+
+export default errorHandler;
diff --git a/apps/vben5/apps/backend-mock/middleware/1.api.ts b/apps/vben5/apps/backend-mock/middleware/1.api.ts
new file mode 100644
index 000000000..84e2ce0e0
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/middleware/1.api.ts
@@ -0,0 +1,7 @@
+export default defineEventHandler((event) => {
+ if (event.method === 'OPTIONS') {
+ event.node.res.statusCode = 204;
+ event.node.res.statusMessage = 'No Content.';
+ return 'OK';
+ }
+});
diff --git a/apps/vben5/apps/backend-mock/nitro.config.ts b/apps/vben5/apps/backend-mock/nitro.config.ts
new file mode 100644
index 000000000..c2d7297fb
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/nitro.config.ts
@@ -0,0 +1,19 @@
+import errorHandler from './error';
+
+process.env.COMPATIBILITY_DATE = new Date().toISOString();
+export default defineNitroConfig({
+ devErrorHandler: errorHandler,
+ errorHandler: '~/error',
+ routeRules: {
+ '/api/**': {
+ cors: true,
+ headers: {
+ 'Access-Control-Allow-Credentials': 'true',
+ 'Access-Control-Allow-Headers': '*',
+ 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
+ 'Access-Control-Allow-Origin': '*',
+ 'Access-Control-Expose-Headers': '*',
+ },
+ },
+ },
+});
diff --git a/apps/vben5/apps/backend-mock/package.json b/apps/vben5/apps/backend-mock/package.json
new file mode 100644
index 000000000..cc0b8d533
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "@vben/backend-mock",
+ "version": "0.0.1",
+ "description": "",
+ "private": true,
+ "license": "MIT",
+ "author": "",
+ "scripts": {
+ "build": "nitro build",
+ "start": "nitro dev"
+ },
+ "dependencies": {
+ "@faker-js/faker": "catalog:",
+ "jsonwebtoken": "catalog:",
+ "nitropack": "catalog:"
+ },
+ "devDependencies": {
+ "@types/jsonwebtoken": "catalog:",
+ "h3": "catalog:"
+ }
+}
diff --git a/apps/vben5/apps/backend-mock/routes/[...].ts b/apps/vben5/apps/backend-mock/routes/[...].ts
new file mode 100644
index 000000000..70c5f7c74
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/routes/[...].ts
@@ -0,0 +1,12 @@
+export default defineEventHandler(() => {
+ return `
+Hello Vben Admin
+Mock service is starting
+
+`;
+});
diff --git a/apps/vben5/apps/backend-mock/tsconfig.build.json b/apps/vben5/apps/backend-mock/tsconfig.build.json
new file mode 100644
index 000000000..64f86c6bd
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/tsconfig.build.json
@@ -0,0 +1,4 @@
+{
+ "extends": "./tsconfig.json",
+ "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
+}
diff --git a/apps/vben5/apps/backend-mock/tsconfig.json b/apps/vben5/apps/backend-mock/tsconfig.json
new file mode 100644
index 000000000..43008af1c
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/tsconfig.json
@@ -0,0 +1,3 @@
+{
+ "extends": "./.nitro/types/tsconfig.json"
+}
diff --git a/apps/vben5/apps/backend-mock/utils/cookie-utils.ts b/apps/vben5/apps/backend-mock/utils/cookie-utils.ts
new file mode 100644
index 000000000..0d92f577d
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/utils/cookie-utils.ts
@@ -0,0 +1,26 @@
+import type { EventHandlerRequest, H3Event } from 'h3';
+
+export function clearRefreshTokenCookie(event: H3Event) {
+ deleteCookie(event, 'jwt', {
+ httpOnly: true,
+ sameSite: 'none',
+ secure: true,
+ });
+}
+
+export function setRefreshTokenCookie(
+ event: H3Event,
+ refreshToken: string,
+) {
+ setCookie(event, 'jwt', refreshToken, {
+ httpOnly: true,
+ maxAge: 24 * 60 * 60 * 1000,
+ sameSite: 'none',
+ secure: true,
+ });
+}
+
+export function getRefreshTokenFromCookie(event: H3Event) {
+ const refreshToken = getCookie(event, 'jwt');
+ return refreshToken;
+}
diff --git a/apps/vben5/apps/backend-mock/utils/jwt-utils.ts b/apps/vben5/apps/backend-mock/utils/jwt-utils.ts
new file mode 100644
index 000000000..8cfc68436
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/utils/jwt-utils.ts
@@ -0,0 +1,59 @@
+import type { EventHandlerRequest, H3Event } from 'h3';
+
+import jwt from 'jsonwebtoken';
+
+import { UserInfo } from './mock-data';
+
+// TODO: Replace with your own secret key
+const ACCESS_TOKEN_SECRET = 'access_token_secret';
+const REFRESH_TOKEN_SECRET = 'refresh_token_secret';
+
+export interface UserPayload extends UserInfo {
+ iat: number;
+ exp: number;
+}
+
+export function generateAccessToken(user: UserInfo) {
+ return jwt.sign(user, ACCESS_TOKEN_SECRET, { expiresIn: '7d' });
+}
+
+export function generateRefreshToken(user: UserInfo) {
+ return jwt.sign(user, REFRESH_TOKEN_SECRET, {
+ expiresIn: '30d',
+ });
+}
+
+export function verifyAccessToken(
+ event: H3Event,
+): null | Omit {
+ const authHeader = getHeader(event, 'Authorization');
+ if (!authHeader?.startsWith('Bearer')) {
+ return null;
+ }
+
+ const token = authHeader.split(' ')[1];
+ try {
+ const decoded = jwt.verify(token, ACCESS_TOKEN_SECRET) as UserPayload;
+
+ const username = decoded.username;
+ const user = MOCK_USERS.find((item) => item.username === username);
+ const { password: _pwd, ...userinfo } = user;
+ return userinfo;
+ } catch {
+ return null;
+ }
+}
+
+export function verifyRefreshToken(
+ token: string,
+): null | Omit {
+ try {
+ const decoded = jwt.verify(token, REFRESH_TOKEN_SECRET) as UserPayload;
+ const username = decoded.username;
+ const user = MOCK_USERS.find((item) => item.username === username);
+ const { password: _pwd, ...userinfo } = user;
+ return userinfo;
+ } catch {
+ return null;
+ }
+}
diff --git a/apps/vben5/apps/backend-mock/utils/mock-data.ts b/apps/vben5/apps/backend-mock/utils/mock-data.ts
new file mode 100644
index 000000000..71970a285
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/utils/mock-data.ts
@@ -0,0 +1,186 @@
+export interface UserInfo {
+ id: number;
+ password: string;
+ realName: string;
+ roles: string[];
+ username: string;
+}
+
+export const MOCK_USERS: UserInfo[] = [
+ {
+ id: 0,
+ password: '123456',
+ realName: 'Vben',
+ roles: ['super'],
+ username: 'vben',
+ },
+ {
+ id: 1,
+ password: '123456',
+ realName: 'Admin',
+ roles: ['admin'],
+ username: 'admin',
+ },
+ {
+ id: 2,
+ password: '123456',
+ realName: 'Jack',
+ roles: ['user'],
+ username: 'jack',
+ },
+];
+
+export const MOCK_CODES = [
+ // super
+ {
+ codes: ['AC_100100', 'AC_100110', 'AC_100120', 'AC_100010'],
+ username: 'vben',
+ },
+ {
+ // admin
+ codes: ['AC_100010', 'AC_100020', 'AC_100030'],
+ username: 'admin',
+ },
+ {
+ // user
+ codes: ['AC_1000001', 'AC_1000002'],
+ username: 'jack',
+ },
+];
+
+const dashboardMenus = [
+ {
+ component: 'BasicLayout',
+ meta: {
+ order: -1,
+ title: 'page.dashboard.title',
+ },
+ name: 'Dashboard',
+ path: '/',
+ redirect: '/analytics',
+ children: [
+ {
+ name: 'Analytics',
+ path: '/analytics',
+ component: '/dashboard/analytics/index',
+ meta: {
+ affixTab: true,
+ title: 'page.dashboard.analytics',
+ },
+ },
+ {
+ name: 'Workspace',
+ path: '/workspace',
+ component: '/dashboard/workspace/index',
+ meta: {
+ title: 'page.dashboard.workspace',
+ },
+ },
+ ],
+ },
+];
+
+const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
+ const roleWithMenus = {
+ admin: {
+ component: '/demos/access/admin-visible',
+ meta: {
+ icon: 'mdi:button-cursor',
+ title: 'demos.access.adminVisible',
+ },
+ name: 'AccessAdminVisibleDemo',
+ path: '/demos/access/admin-visible',
+ },
+ super: {
+ component: '/demos/access/super-visible',
+ meta: {
+ icon: 'mdi:button-cursor',
+ title: 'demos.access.superVisible',
+ },
+ name: 'AccessSuperVisibleDemo',
+ path: '/demos/access/super-visible',
+ },
+ user: {
+ component: '/demos/access/user-visible',
+ meta: {
+ icon: 'mdi:button-cursor',
+ title: 'demos.access.userVisible',
+ },
+ name: 'AccessUserVisibleDemo',
+ path: '/demos/access/user-visible',
+ },
+ };
+
+ return [
+ {
+ component: 'BasicLayout',
+ meta: {
+ icon: 'ic:baseline-view-in-ar',
+ keepAlive: true,
+ order: 1000,
+ title: 'demos.title',
+ },
+ name: 'Demos',
+ path: '/demos',
+ redirect: '/demos/access',
+ children: [
+ {
+ name: 'AccessDemos',
+ path: '/demosaccess',
+ meta: {
+ icon: 'mdi:cloud-key-outline',
+ title: 'demos.access.backendPermissions',
+ },
+ redirect: '/demos/access/page-control',
+ children: [
+ {
+ name: 'AccessPageControlDemo',
+ path: '/demos/access/page-control',
+ component: '/demos/access/index',
+ meta: {
+ icon: 'mdi:page-previous-outline',
+ title: 'demos.access.pageAccess',
+ },
+ },
+ {
+ name: 'AccessButtonControlDemo',
+ path: '/demos/access/button-control',
+ component: '/demos/access/button-control',
+ meta: {
+ icon: 'mdi:button-cursor',
+ title: 'demos.access.buttonControl',
+ },
+ },
+ {
+ name: 'AccessMenuVisible403Demo',
+ path: '/demos/access/menu-visible-403',
+ component: '/demos/access/menu-visible-403',
+ meta: {
+ authority: ['no-body'],
+ icon: 'mdi:button-cursor',
+ menuVisibleWithForbidden: true,
+ title: 'demos.access.menuVisible403',
+ },
+ },
+ roleWithMenus[role],
+ ],
+ },
+ ],
+ },
+ ];
+};
+
+export const MOCK_MENUS = [
+ {
+ menus: [...dashboardMenus, ...createDemosMenus('super')],
+ username: 'vben',
+ },
+ {
+ menus: [...dashboardMenus, ...createDemosMenus('admin')],
+ username: 'admin',
+ },
+ {
+ menus: [...dashboardMenus, ...createDemosMenus('user')],
+ username: 'jack',
+ },
+];
diff --git a/apps/vben5/apps/backend-mock/utils/response.ts b/apps/vben5/apps/backend-mock/utils/response.ts
new file mode 100644
index 000000000..2a5a908f2
--- /dev/null
+++ b/apps/vben5/apps/backend-mock/utils/response.ts
@@ -0,0 +1,68 @@
+import type { EventHandlerRequest, H3Event } from 'h3';
+
+export function useResponseSuccess(data: T) {
+ return {
+ code: 0,
+ data,
+ error: null,
+ message: 'ok',
+ };
+}
+
+export function usePageResponseSuccess(
+ page: number | string,
+ pageSize: number | string,
+ list: T[],
+ { message = 'ok' } = {},
+) {
+ const pageData = pagination(
+ Number.parseInt(`${page}`),
+ Number.parseInt(`${pageSize}`),
+ list,
+ );
+
+ return {
+ ...useResponseSuccess({
+ items: pageData,
+ total: list.length,
+ }),
+ message,
+ };
+}
+
+export function useResponseError(message: string, error: any = null) {
+ return {
+ code: -1,
+ data: null,
+ error,
+ message,
+ };
+}
+
+export function forbiddenResponse(
+ event: H3Event,
+ message = 'Forbidden Exception',
+) {
+ setResponseStatus(event, 403);
+ return useResponseError(message, message);
+}
+
+export function unAuthorizedResponse(event: H3Event) {
+ setResponseStatus(event, 401);
+ return useResponseError('Unauthorized Exception', 'Unauthorized Exception');
+}
+
+export function sleep(ms: number) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+}
+
+export function pagination(
+ pageNo: number,
+ pageSize: number,
+ array: T[],
+): T[] {
+ const offset = (pageNo - 1) * Number(pageSize);
+ return offset + Number(pageSize) >= array.length
+ ? array.slice(offset)
+ : array.slice(offset, offset + Number(pageSize));
+}
diff --git a/apps/vben5/apps/web-antd/.env b/apps/vben5/apps/web-antd/.env
new file mode 100644
index 000000000..c14a467fb
--- /dev/null
+++ b/apps/vben5/apps/web-antd/.env
@@ -0,0 +1,5 @@
+# 应用标题
+VITE_APP_TITLE=Vben Admin Antd
+
+# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
+VITE_APP_NAMESPACE=vben-web-antd
diff --git a/apps/vben5/apps/web-antd/.env.analyze b/apps/vben5/apps/web-antd/.env.analyze
new file mode 100644
index 000000000..ffafa8dd5
--- /dev/null
+++ b/apps/vben5/apps/web-antd/.env.analyze
@@ -0,0 +1,7 @@
+# public path
+VITE_BASE=/
+
+# Basic interface address SPA
+VITE_GLOB_API_URL=/api
+
+VITE_VISUALIZER=true
diff --git a/apps/vben5/apps/web-antd/.env.development b/apps/vben5/apps/web-antd/.env.development
new file mode 100644
index 000000000..c138f4829
--- /dev/null
+++ b/apps/vben5/apps/web-antd/.env.development
@@ -0,0 +1,16 @@
+# 端口号
+VITE_PORT=5666
+
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=/api
+
+# 是否开启 Nitro Mock服务,true 为开启,false 为关闭
+VITE_NITRO_MOCK=true
+
+# 是否打开 devtools,true 为打开,false 为关闭
+VITE_DEVTOOLS=false
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
diff --git a/apps/vben5/apps/web-antd/.env.production b/apps/vben5/apps/web-antd/.env.production
new file mode 100644
index 000000000..5375847a6
--- /dev/null
+++ b/apps/vben5/apps/web-antd/.env.production
@@ -0,0 +1,19 @@
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+
+# 是否开启压缩,可以设置为 none, brotli, gzip
+VITE_COMPRESS=none
+
+# 是否开启 PWA
+VITE_PWA=false
+
+# vue-router 的模式
+VITE_ROUTER_HISTORY=hash
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
+
+# 打包后是否生成dist.zip
+VITE_ARCHIVER=true
diff --git a/apps/vben5/apps/web-antd/index.html b/apps/vben5/apps/web-antd/index.html
new file mode 100644
index 000000000..480eb84de
--- /dev/null
+++ b/apps/vben5/apps/web-antd/index.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+ <%= VITE_APP_TITLE %>
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/package.json b/apps/vben5/apps/web-antd/package.json
new file mode 100644
index 000000000..42afa3c69
--- /dev/null
+++ b/apps/vben5/apps/web-antd/package.json
@@ -0,0 +1,50 @@
+{
+ "name": "@vben/web-antd",
+ "version": "5.4.8",
+ "homepage": "https://vben.pro",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "apps/web-antd"
+ },
+ "license": "MIT",
+ "author": {
+ "name": "vben",
+ "email": "ann.vben@gmail.com",
+ "url": "https://github.com/anncwb"
+ },
+ "type": "module",
+ "scripts": {
+ "build": "pnpm vite build --mode production",
+ "build:analyze": "pnpm vite build --mode analyze",
+ "dev": "pnpm vite --mode development",
+ "preview": "vite preview",
+ "typecheck": "vue-tsc --noEmit --skipLibCheck"
+ },
+ "imports": {
+ "#/*": "./src/*"
+ },
+ "dependencies": {
+ "@vben/access": "workspace:*",
+ "@vben/common-ui": "workspace:*",
+ "@vben/constants": "workspace:*",
+ "@vben/hooks": "workspace:*",
+ "@vben/icons": "workspace:*",
+ "@vben/layouts": "workspace:*",
+ "@vben/locales": "workspace:*",
+ "@vben/plugins": "workspace:*",
+ "@vben/preferences": "workspace:*",
+ "@vben/request": "workspace:*",
+ "@vben/stores": "workspace:*",
+ "@vben/styles": "workspace:*",
+ "@vben/types": "workspace:*",
+ "@vben/utils": "workspace:*",
+ "@vueuse/core": "catalog:",
+ "ant-design-vue": "catalog:",
+ "dayjs": "catalog:",
+ "pinia": "catalog:",
+ "vue": "catalog:",
+ "vue-router": "catalog:"
+ }
+}
diff --git a/apps/vben5/apps/web-antd/postcss.config.mjs b/apps/vben5/apps/web-antd/postcss.config.mjs
new file mode 100644
index 000000000..3d8070455
--- /dev/null
+++ b/apps/vben5/apps/web-antd/postcss.config.mjs
@@ -0,0 +1 @@
+export { default } from '@vben/tailwind-config/postcss';
diff --git a/apps/vben5/apps/web-antd/public/favicon.ico b/apps/vben5/apps/web-antd/public/favicon.ico
new file mode 100644
index 000000000..fcf9818e2
Binary files /dev/null and b/apps/vben5/apps/web-antd/public/favicon.ico differ
diff --git a/apps/vben5/apps/web-antd/src/adapter/component/index.ts b/apps/vben5/apps/web-antd/src/adapter/component/index.ts
new file mode 100644
index 000000000..1afa62174
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/adapter/component/index.ts
@@ -0,0 +1,127 @@
+/**
+ * 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
+ * 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
+ */
+
+import type { BaseFormComponentType } from '@vben/common-ui';
+
+import type { Component, SetupContext } from 'vue';
+import { h } from 'vue';
+
+import { globalShareState } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+import {
+ AutoComplete,
+ Button,
+ Checkbox,
+ CheckboxGroup,
+ DatePicker,
+ Divider,
+ Input,
+ InputNumber,
+ InputPassword,
+ Mentions,
+ notification,
+ Radio,
+ RadioGroup,
+ RangePicker,
+ Rate,
+ Select,
+ Space,
+ Switch,
+ Textarea,
+ TimePicker,
+ TreeSelect,
+ Upload,
+} from 'ant-design-vue';
+
+const withDefaultPlaceholder = (
+ component: T,
+ type: 'input' | 'select',
+) => {
+ return (props: any, { attrs, slots }: Omit) => {
+ const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
+ return h(component, { ...props, ...attrs, placeholder }, slots);
+ };
+};
+
+// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
+export type ComponentType =
+ | 'AutoComplete'
+ | 'Checkbox'
+ | 'CheckboxGroup'
+ | 'DatePicker'
+ | 'DefaultButton'
+ | 'Divider'
+ | 'Input'
+ | 'InputNumber'
+ | 'InputPassword'
+ | 'Mentions'
+ | 'PrimaryButton'
+ | 'Radio'
+ | 'RadioGroup'
+ | 'RangePicker'
+ | 'Rate'
+ | 'Select'
+ | 'Space'
+ | 'Switch'
+ | 'Textarea'
+ | 'TimePicker'
+ | 'TreeSelect'
+ | 'Upload'
+ | BaseFormComponentType;
+
+async function initComponentAdapter() {
+ const components: Partial> = {
+ // 如果你的组件体积比较大,可以使用异步加载
+ // Button: () =>
+ // import('xxx').then((res) => res.Button),
+
+ AutoComplete,
+ Checkbox,
+ CheckboxGroup,
+ DatePicker,
+ // 自定义默认按钮
+ DefaultButton: (props, { attrs, slots }) => {
+ return h(Button, { ...props, attrs, type: 'default' }, slots);
+ },
+ Divider,
+ Input: withDefaultPlaceholder(Input, 'input'),
+ InputNumber: withDefaultPlaceholder(InputNumber, 'input'),
+ InputPassword: withDefaultPlaceholder(InputPassword, 'input'),
+ Mentions: withDefaultPlaceholder(Mentions, 'input'),
+ // 自定义主要按钮
+ PrimaryButton: (props, { attrs, slots }) => {
+ return h(Button, { ...props, attrs, type: 'primary' }, slots);
+ },
+ Radio,
+ RadioGroup,
+ RangePicker,
+ Rate,
+ Select: withDefaultPlaceholder(Select, 'select'),
+ Space,
+ Switch,
+ Textarea: withDefaultPlaceholder(Textarea, 'input'),
+ TimePicker,
+ TreeSelect: withDefaultPlaceholder(TreeSelect, 'select'),
+ Upload,
+ };
+
+ // 将组件注册到全局共享状态中
+ globalShareState.setComponents(components);
+
+ // 定义全局共享状态中的消息提示
+ globalShareState.defineMessage({
+ // 复制成功消息提示
+ copyPreferencesSuccess: (title, content) => {
+ notification.success({
+ description: content,
+ message: title,
+ placement: 'bottomRight',
+ });
+ },
+ });
+}
+
+export { initComponentAdapter };
diff --git a/apps/vben5/apps/web-antd/src/adapter/form.ts b/apps/vben5/apps/web-antd/src/adapter/form.ts
new file mode 100644
index 000000000..65ff793b6
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/adapter/form.ts
@@ -0,0 +1,47 @@
+import type {
+ VbenFormSchema as FormSchema,
+ VbenFormProps,
+} from '@vben/common-ui';
+
+import type { ComponentType } from './component';
+
+import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+setupVbenForm({
+ config: {
+ // ant design vue组件库默认都是 v-model:value
+ baseModelPropName: 'value',
+
+ // 一些组件是 v-model:checked 或者 v-model:fileList
+ modelPropNameMap: {
+ Checkbox: 'checked',
+ Radio: 'checked',
+ Switch: 'checked',
+ Upload: 'fileList',
+ },
+ },
+ defineRules: {
+ // 输入项目必填国际化适配
+ required: (value, _params, ctx) => {
+ if (value === undefined || value === null || value.length === 0) {
+ return $t('ui.formRules.required', [ctx.label]);
+ }
+ return true;
+ },
+ // 选择项目必填国际化适配
+ selectRequired: (value, _params, ctx) => {
+ if (value === undefined || value === null) {
+ return $t('ui.formRules.selectRequired', [ctx.label]);
+ }
+ return true;
+ },
+ },
+});
+
+const useVbenForm = useForm;
+
+export { useVbenForm, z };
+
+export type VbenFormSchema = FormSchema;
+export type { VbenFormProps };
diff --git a/apps/vben5/apps/web-antd/src/adapter/vxe-table.ts b/apps/vben5/apps/web-antd/src/adapter/vxe-table.ts
new file mode 100644
index 000000000..d296b2050
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/adapter/vxe-table.ts
@@ -0,0 +1,67 @@
+import { h } from 'vue';
+
+import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
+
+import { Button, Image } from 'ant-design-vue';
+
+import { useVbenForm } from './form';
+
+setupVbenVxeTable({
+ configVxeTable: (vxeUI) => {
+ vxeUI.setConfig({
+ grid: {
+ align: 'center',
+ border: false,
+ columnConfig: {
+ resizable: true,
+ },
+ minHeight: 180,
+ formConfig: {
+ // 全局禁用vxe-table的表单配置,使用formOptions
+ enabled: false,
+ },
+ proxyConfig: {
+ autoLoad: true,
+ response: {
+ result: 'items',
+ total: 'total',
+ list: 'items',
+ },
+ showActiveMsg: true,
+ showResponseMsg: false,
+ },
+ round: true,
+ showOverflow: true,
+ size: 'small',
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellImage' },
+ vxeUI.renderer.add('CellImage', {
+ renderTableDefault(_renderOpts, params) {
+ const { column, row } = params;
+ return h(Image, { src: row[column.field] });
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellLink' },
+ vxeUI.renderer.add('CellLink', {
+ renderTableDefault(renderOpts) {
+ const { props } = renderOpts;
+ return h(
+ Button,
+ { size: 'small', type: 'link' },
+ { default: () => props?.text },
+ );
+ },
+ });
+
+ // 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
+ // vxeUI.formats.add
+ },
+ useVbenForm,
+});
+
+export { useVbenVxeGrid };
+
+export type * from '@vben/plugins/vxe-table';
diff --git a/apps/vben5/apps/web-antd/src/api/core/auth.ts b/apps/vben5/apps/web-antd/src/api/core/auth.ts
new file mode 100644
index 000000000..71d9f9943
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/api/core/auth.ts
@@ -0,0 +1,51 @@
+import { baseRequestClient, requestClient } from '#/api/request';
+
+export namespace AuthApi {
+ /** 登录接口参数 */
+ export interface LoginParams {
+ password?: string;
+ username?: string;
+ }
+
+ /** 登录接口返回值 */
+ export interface LoginResult {
+ accessToken: string;
+ }
+
+ export interface RefreshTokenResult {
+ data: string;
+ status: number;
+ }
+}
+
+/**
+ * 登录
+ */
+export async function loginApi(data: AuthApi.LoginParams) {
+ return requestClient.post('/auth/login', data);
+}
+
+/**
+ * 刷新accessToken
+ */
+export async function refreshTokenApi() {
+ return baseRequestClient.post('/auth/refresh', {
+ withCredentials: true,
+ });
+}
+
+/**
+ * 退出登录
+ */
+export async function logoutApi() {
+ return baseRequestClient.post('/auth/logout', {
+ withCredentials: true,
+ });
+}
+
+/**
+ * 获取用户权限码
+ */
+export async function getAccessCodesApi() {
+ return requestClient.get('/auth/codes');
+}
diff --git a/apps/vben5/apps/web-antd/src/api/core/index.ts b/apps/vben5/apps/web-antd/src/api/core/index.ts
new file mode 100644
index 000000000..28a5aef47
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/api/core/index.ts
@@ -0,0 +1,3 @@
+export * from './auth';
+export * from './menu';
+export * from './user';
diff --git a/apps/vben5/apps/web-antd/src/api/core/menu.ts b/apps/vben5/apps/web-antd/src/api/core/menu.ts
new file mode 100644
index 000000000..9ef60b11c
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/api/core/menu.ts
@@ -0,0 +1,10 @@
+import type { RouteRecordStringComponent } from '@vben/types';
+
+import { requestClient } from '#/api/request';
+
+/**
+ * 获取用户所有菜单
+ */
+export async function getAllMenusApi() {
+ return requestClient.get('/menu/all');
+}
diff --git a/apps/vben5/apps/web-antd/src/api/core/user.ts b/apps/vben5/apps/web-antd/src/api/core/user.ts
new file mode 100644
index 000000000..7e28ea848
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/api/core/user.ts
@@ -0,0 +1,10 @@
+import type { UserInfo } from '@vben/types';
+
+import { requestClient } from '#/api/request';
+
+/**
+ * 获取用户信息
+ */
+export async function getUserInfoApi() {
+ return requestClient.get('/user/info');
+}
diff --git a/apps/vben5/apps/web-antd/src/api/index.ts b/apps/vben5/apps/web-antd/src/api/index.ts
new file mode 100644
index 000000000..4b0e04137
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/api/index.ts
@@ -0,0 +1 @@
+export * from './core';
diff --git a/apps/vben5/apps/web-antd/src/api/request.ts b/apps/vben5/apps/web-antd/src/api/request.ts
new file mode 100644
index 000000000..67ef35e44
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/api/request.ts
@@ -0,0 +1,114 @@
+/**
+ * 该文件可自行根据业务逻辑进行调整
+ */
+import type { HttpResponse } from '@vben/request';
+
+import { useAppConfig } from '@vben/hooks';
+import { preferences } from '@vben/preferences';
+import {
+ authenticateResponseInterceptor,
+ errorMessageResponseInterceptor,
+ RequestClient,
+} from '@vben/request';
+import { useAccessStore } from '@vben/stores';
+
+import { message } from 'ant-design-vue';
+
+import { useAuthStore } from '#/store';
+
+import { refreshTokenApi } from './core';
+
+const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+
+function createRequestClient(baseURL: string) {
+ const client = new RequestClient({
+ baseURL,
+ });
+
+ /**
+ * 重新认证逻辑
+ */
+ async function doReAuthenticate() {
+ console.warn('Access token or refresh token is invalid or expired. ');
+ const accessStore = useAccessStore();
+ const authStore = useAuthStore();
+ accessStore.setAccessToken(null);
+ if (
+ preferences.app.loginExpiredMode === 'modal' &&
+ accessStore.isAccessChecked
+ ) {
+ accessStore.setLoginExpired(true);
+ } else {
+ await authStore.logout();
+ }
+ }
+
+ /**
+ * 刷新token逻辑
+ */
+ async function doRefreshToken() {
+ const accessStore = useAccessStore();
+ const resp = await refreshTokenApi();
+ const newToken = resp.data;
+ accessStore.setAccessToken(newToken);
+ return newToken;
+ }
+
+ function formatToken(token: null | string) {
+ return token ? `Bearer ${token}` : null;
+ }
+
+ // 请求头处理
+ client.addRequestInterceptor({
+ fulfilled: async (config) => {
+ const accessStore = useAccessStore();
+
+ config.headers.Authorization = formatToken(accessStore.accessToken);
+ config.headers['Accept-Language'] = preferences.app.locale;
+ return config;
+ },
+ });
+
+ // response数据解构
+ client.addResponseInterceptor({
+ fulfilled: (response) => {
+ const { data: responseData, status } = response;
+
+ const { code, data } = responseData;
+ if (status >= 200 && status < 400 && code === 0) {
+ return data;
+ }
+
+ throw Object.assign({}, response, { response });
+ },
+ });
+
+ // token过期的处理
+ client.addResponseInterceptor(
+ authenticateResponseInterceptor({
+ client,
+ doReAuthenticate,
+ doRefreshToken,
+ enableRefreshToken: preferences.app.enableRefreshToken,
+ formatToken,
+ }),
+ );
+
+ // 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
+ client.addResponseInterceptor(
+ errorMessageResponseInterceptor((msg: string, error) => {
+ // 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
+ // 当前mock接口返回的错误字段是 error 或者 message
+ const responseData = error?.response?.data ?? {};
+ const errorMessage = responseData?.error ?? responseData?.message ?? '';
+ // 如果没有错误信息,则会根据状态码进行提示
+ message.error(errorMessage || msg);
+ }),
+ );
+
+ return client;
+}
+
+export const requestClient = createRequestClient(apiURL);
+
+export const baseRequestClient = new RequestClient({ baseURL: apiURL });
diff --git a/apps/vben5/apps/web-antd/src/app.vue b/apps/vben5/apps/web-antd/src/app.vue
new file mode 100644
index 000000000..bbaccce13
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/app.vue
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/bootstrap.ts b/apps/vben5/apps/web-antd/src/bootstrap.ts
new file mode 100644
index 000000000..963d1c7f7
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/bootstrap.ts
@@ -0,0 +1,48 @@
+import { createApp, watchEffect } from 'vue';
+
+import { registerAccessDirective } from '@vben/access';
+import { preferences } from '@vben/preferences';
+import { initStores } from '@vben/stores';
+import '@vben/styles';
+import '@vben/styles/antd';
+
+import { useTitle } from '@vueuse/core';
+
+import { $t, setupI18n } from '#/locales';
+
+import { initComponentAdapter } from './adapter/component';
+import App from './app.vue';
+import { router } from './router';
+
+async function bootstrap(namespace: string) {
+ // 初始化组件适配器
+ await initComponentAdapter();
+
+ const app = createApp(App);
+
+ // 国际化 i18n 配置
+ await setupI18n(app);
+
+ // 配置 pinia-tore
+ await initStores(app, { namespace });
+
+ // 安装权限指令
+ registerAccessDirective(app);
+
+ // 配置路由及路由守卫
+ app.use(router);
+
+ // 动态更新标题
+ watchEffect(() => {
+ if (preferences.app.dynamicTitle) {
+ const routeTitle = router.currentRoute.value.meta?.title;
+ const pageTitle =
+ (routeTitle ? `${$t(routeTitle)} - ` : '') + preferences.app.name;
+ useTitle(pageTitle);
+ }
+ });
+
+ app.mount('#app');
+}
+
+export { bootstrap };
diff --git a/apps/vben5/apps/web-antd/src/layouts/auth.vue b/apps/vben5/apps/web-antd/src/layouts/auth.vue
new file mode 100644
index 000000000..18d415bc7
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/layouts/auth.vue
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/layouts/basic.vue b/apps/vben5/apps/web-antd/src/layouts/basic.vue
new file mode 100644
index 000000000..51412956a
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/layouts/basic.vue
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/layouts/index.ts b/apps/vben5/apps/web-antd/src/layouts/index.ts
new file mode 100644
index 000000000..a43207805
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/layouts/index.ts
@@ -0,0 +1,6 @@
+const BasicLayout = () => import('./basic.vue');
+const AuthPageLayout = () => import('./auth.vue');
+
+const IFrameView = () => import('@vben/layouts').then((m) => m.IFrameView);
+
+export { AuthPageLayout, BasicLayout, IFrameView };
diff --git a/apps/vben5/apps/web-antd/src/locales/README.md b/apps/vben5/apps/web-antd/src/locales/README.md
new file mode 100644
index 000000000..7b451032e
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/locales/README.md
@@ -0,0 +1,3 @@
+# locale
+
+每个app使用的国际化可能不同,这里用于扩展国际化的功能,例如扩展 dayjs、antd组件库的多语言切换,以及app本身的国际化文件。
diff --git a/apps/vben5/apps/web-antd/src/locales/index.ts b/apps/vben5/apps/web-antd/src/locales/index.ts
new file mode 100644
index 000000000..1972e06ee
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/locales/index.ts
@@ -0,0 +1,100 @@
+import type { LocaleSetupOptions, SupportedLanguagesType } from '@vben/locales';
+import type { Locale } from 'ant-design-vue/es/locale';
+
+import type { App } from 'vue';
+import { ref } from 'vue';
+
+import {
+ $t,
+ setupI18n as coreSetup,
+ loadLocalesMapFromDir,
+} from '@vben/locales';
+import { preferences } from '@vben/preferences';
+
+import antdEnLocale from 'ant-design-vue/es/locale/en_US';
+import antdDefaultLocale from 'ant-design-vue/es/locale/zh_CN';
+import dayjs from 'dayjs';
+
+const antdLocale = ref(antdDefaultLocale);
+
+const modules = import.meta.glob('./langs/**/*.json');
+
+const localesMap = loadLocalesMapFromDir(
+ /\.\/langs\/([^/]+)\/(.*)\.json$/,
+ modules,
+);
+/**
+ * 加载应用特有的语言包
+ * 这里也可以改造为从服务端获取翻译数据
+ * @param lang
+ */
+async function loadMessages(lang: SupportedLanguagesType) {
+ const [appLocaleMessages] = await Promise.all([
+ localesMap[lang]?.(),
+ loadThirdPartyMessage(lang),
+ ]);
+ return appLocaleMessages?.default;
+}
+
+/**
+ * 加载第三方组件库的语言包
+ * @param lang
+ */
+async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
+ await Promise.all([loadAntdLocale(lang), loadDayjsLocale(lang)]);
+}
+
+/**
+ * 加载dayjs的语言包
+ * @param lang
+ */
+async function loadDayjsLocale(lang: SupportedLanguagesType) {
+ let locale;
+ switch (lang) {
+ case 'en-US': {
+ locale = await import('dayjs/locale/en');
+ break;
+ }
+ case 'zh-CN': {
+ locale = await import('dayjs/locale/zh-cn');
+ break;
+ }
+ // 默认使用英语
+ default: {
+ locale = await import('dayjs/locale/en');
+ }
+ }
+ if (locale) {
+ dayjs.locale(locale);
+ } else {
+ console.error(`Failed to load dayjs locale for ${lang}`);
+ }
+}
+
+/**
+ * 加载antd的语言包
+ * @param lang
+ */
+async function loadAntdLocale(lang: SupportedLanguagesType) {
+ switch (lang) {
+ case 'en-US': {
+ antdLocale.value = antdEnLocale;
+ break;
+ }
+ case 'zh-CN': {
+ antdLocale.value = antdDefaultLocale;
+ break;
+ }
+ }
+}
+
+async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
+ await coreSetup(app, {
+ defaultLocale: preferences.app.locale,
+ loadMessages,
+ missingWarn: !import.meta.env.PROD,
+ ...options,
+ });
+}
+
+export { $t, antdLocale, setupI18n };
diff --git a/apps/vben5/apps/web-antd/src/locales/langs/en-US/demos.json b/apps/vben5/apps/web-antd/src/locales/langs/en-US/demos.json
new file mode 100644
index 000000000..071564349
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/locales/langs/en-US/demos.json
@@ -0,0 +1,12 @@
+{
+ "title": "Demos",
+ "antd": "Ant Design Vue",
+ "vben": {
+ "title": "Project",
+ "about": "About",
+ "document": "Document",
+ "antdv": "Ant Design Vue Version",
+ "naive-ui": "Naive UI Version",
+ "element-plus": "Element Plus Version"
+ }
+}
diff --git a/apps/vben5/apps/web-antd/src/locales/langs/en-US/page.json b/apps/vben5/apps/web-antd/src/locales/langs/en-US/page.json
new file mode 100644
index 000000000..618a258c0
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/locales/langs/en-US/page.json
@@ -0,0 +1,14 @@
+{
+ "auth": {
+ "login": "Login",
+ "register": "Register",
+ "codeLogin": "Code Login",
+ "qrcodeLogin": "Qr Code Login",
+ "forgetPassword": "Forget Password"
+ },
+ "dashboard": {
+ "title": "Dashboard",
+ "analytics": "Analytics",
+ "workspace": "Workspace"
+ }
+}
diff --git a/apps/vben5/apps/web-antd/src/locales/langs/zh-CN/demos.json b/apps/vben5/apps/web-antd/src/locales/langs/zh-CN/demos.json
new file mode 100644
index 000000000..93ee722f5
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/locales/langs/zh-CN/demos.json
@@ -0,0 +1,12 @@
+{
+ "title": "演示",
+ "antd": "Ant Design Vue",
+ "vben": {
+ "title": "项目",
+ "about": "关于",
+ "document": "文档",
+ "antdv": "Ant Design Vue 版本",
+ "naive-ui": "Naive UI 版本",
+ "element-plus": "Element Plus 版本"
+ }
+}
diff --git a/apps/vben5/apps/web-antd/src/locales/langs/zh-CN/page.json b/apps/vben5/apps/web-antd/src/locales/langs/zh-CN/page.json
new file mode 100644
index 000000000..4cb67081c
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/locales/langs/zh-CN/page.json
@@ -0,0 +1,14 @@
+{
+ "auth": {
+ "login": "登录",
+ "register": "注册",
+ "codeLogin": "验证码登录",
+ "qrcodeLogin": "二维码登录",
+ "forgetPassword": "忘记密码"
+ },
+ "dashboard": {
+ "title": "概览",
+ "analytics": "分析页",
+ "workspace": "工作台"
+ }
+}
diff --git a/apps/vben5/apps/web-antd/src/main.ts b/apps/vben5/apps/web-antd/src/main.ts
new file mode 100644
index 000000000..5d728a02a
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/main.ts
@@ -0,0 +1,31 @@
+import { initPreferences } from '@vben/preferences';
+import { unmountGlobalLoading } from '@vben/utils';
+
+import { overridesPreferences } from './preferences';
+
+/**
+ * 应用初始化完成之后再进行页面加载渲染
+ */
+async function initApplication() {
+ // name用于指定项目唯一标识
+ // 用于区分不同项目的偏好设置以及存储数据的key前缀以及其他一些需要隔离的数据
+ const env = import.meta.env.PROD ? 'prod' : 'dev';
+ const appVersion = import.meta.env.VITE_APP_VERSION;
+ const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${appVersion}-${env}`;
+
+ // app偏好设置初始化
+ await initPreferences({
+ namespace,
+ overrides: overridesPreferences,
+ });
+
+ // 启动应用并挂载
+ // vue应用主要逻辑及视图
+ const { bootstrap } = await import('./bootstrap');
+ await bootstrap(namespace);
+
+ // 移除并销毁loading
+ unmountGlobalLoading();
+}
+
+initApplication();
diff --git a/apps/vben5/apps/web-antd/src/preferences.ts b/apps/vben5/apps/web-antd/src/preferences.ts
new file mode 100644
index 000000000..b2e9ace43
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/preferences.ts
@@ -0,0 +1,13 @@
+import { defineOverridesPreferences } from '@vben/preferences';
+
+/**
+ * @description 项目配置文件
+ * 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置
+ * !!! 更改配置后请清空缓存,否则可能不生效
+ */
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ name: import.meta.env.VITE_APP_TITLE,
+ },
+});
diff --git a/apps/vben5/apps/web-antd/src/router/access.ts b/apps/vben5/apps/web-antd/src/router/access.ts
new file mode 100644
index 000000000..3a48be237
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/router/access.ts
@@ -0,0 +1,42 @@
+import type {
+ ComponentRecordType,
+ GenerateMenuAndRoutesOptions,
+} from '@vben/types';
+
+import { generateAccessible } from '@vben/access';
+import { preferences } from '@vben/preferences';
+
+import { message } from 'ant-design-vue';
+
+import { getAllMenusApi } from '#/api';
+import { BasicLayout, IFrameView } from '#/layouts';
+import { $t } from '#/locales';
+
+const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
+
+async function generateAccess(options: GenerateMenuAndRoutesOptions) {
+ const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue');
+
+ const layoutMap: ComponentRecordType = {
+ BasicLayout,
+ IFrameView,
+ };
+
+ return await generateAccessible(preferences.app.accessMode, {
+ ...options,
+ fetchMenuListAsync: async () => {
+ message.loading({
+ content: `${$t('common.loadingMenu')}...`,
+ duration: 1.5,
+ });
+ return await getAllMenusApi();
+ },
+ // 可以指定没有权限跳转403页面
+ forbiddenComponent,
+ // 如果 route.meta.menuVisibleWithForbidden = true
+ layoutMap,
+ pageMap,
+ });
+}
+
+export { generateAccess };
diff --git a/apps/vben5/apps/web-antd/src/router/guard.ts b/apps/vben5/apps/web-antd/src/router/guard.ts
new file mode 100644
index 000000000..fce5a892c
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/router/guard.ts
@@ -0,0 +1,125 @@
+import type { Router } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+import { preferences } from '@vben/preferences';
+import { useAccessStore, useUserStore } from '@vben/stores';
+import { startProgress, stopProgress } from '@vben/utils';
+
+import { accessRoutes, coreRouteNames } from '#/router/routes';
+import { useAuthStore } from '#/store';
+
+import { generateAccess } from './access';
+
+/**
+ * 通用守卫配置
+ * @param router
+ */
+function setupCommonGuard(router: Router) {
+ // 记录已经加载的页面
+ const loadedPaths = new Set();
+
+ router.beforeEach(async (to) => {
+ to.meta.loaded = loadedPaths.has(to.path);
+
+ // 页面加载进度条
+ if (!to.meta.loaded && preferences.transition.progress) {
+ startProgress();
+ }
+ return true;
+ });
+
+ router.afterEach((to) => {
+ // 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
+
+ loadedPaths.add(to.path);
+
+ // 关闭页面加载进度条
+ if (preferences.transition.progress) {
+ stopProgress();
+ }
+ });
+}
+
+/**
+ * 权限访问守卫配置
+ * @param router
+ */
+function setupAccessGuard(router: Router) {
+ router.beforeEach(async (to, from) => {
+ const accessStore = useAccessStore();
+ const userStore = useUserStore();
+ const authStore = useAuthStore();
+
+ // 基本路由,这些路由不需要进入权限拦截
+ if (coreRouteNames.includes(to.name as string)) {
+ if (to.path === LOGIN_PATH && accessStore.accessToken) {
+ return decodeURIComponent(
+ (to.query?.redirect as string) || DEFAULT_HOME_PATH,
+ );
+ }
+ return true;
+ }
+
+ // accessToken 检查
+ if (!accessStore.accessToken) {
+ // 明确声明忽略权限访问权限,则可以访问
+ if (to.meta.ignoreAccess) {
+ return true;
+ }
+
+ // 没有访问权限,跳转登录页面
+ if (to.fullPath !== LOGIN_PATH) {
+ return {
+ path: LOGIN_PATH,
+ // 如不需要,直接删除 query
+ query: { redirect: encodeURIComponent(to.fullPath) },
+ // 携带当前跳转的页面,登录后重新跳转该页面
+ replace: true,
+ };
+ }
+ return to;
+ }
+
+ // 是否已经生成过动态路由
+ if (accessStore.isAccessChecked) {
+ return true;
+ }
+
+ // 生成路由表
+ // 当前登录用户拥有的角色标识列表
+ const userInfo = userStore.userInfo || (await authStore.fetchUserInfo());
+ const userRoles = userInfo.roles ?? [];
+
+ // 生成菜单和路由
+ const { accessibleMenus, accessibleRoutes } = await generateAccess({
+ roles: userRoles,
+ router,
+ // 则会在菜单中显示,但是访问会被重定向到403
+ routes: accessRoutes,
+ });
+
+ // 保存菜单信息和路由信息
+ accessStore.setAccessMenus(accessibleMenus);
+ accessStore.setAccessRoutes(accessibleRoutes);
+ accessStore.setIsAccessChecked(true);
+ const redirectPath = (from.query.redirect ?? to.fullPath) as string;
+
+ return {
+ ...router.resolve(decodeURIComponent(redirectPath)),
+ replace: true,
+ };
+ });
+}
+
+/**
+ * 项目守卫配置
+ * @param router
+ */
+function createRouterGuard(router: Router) {
+ /** 通用 */
+ setupCommonGuard(router);
+ /** 权限访问 */
+ setupAccessGuard(router);
+}
+
+export { createRouterGuard };
diff --git a/apps/vben5/apps/web-antd/src/router/index.ts b/apps/vben5/apps/web-antd/src/router/index.ts
new file mode 100644
index 000000000..484023034
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/router/index.ts
@@ -0,0 +1,37 @@
+import {
+ createRouter,
+ createWebHashHistory,
+ createWebHistory,
+} from 'vue-router';
+
+import { resetStaticRoutes } from '@vben/utils';
+
+import { createRouterGuard } from './guard';
+import { routes } from './routes';
+
+/**
+ * @zh_CN 创建vue-router实例
+ */
+const router = createRouter({
+ history:
+ import.meta.env.VITE_ROUTER_HISTORY === 'hash'
+ ? createWebHashHistory(import.meta.env.VITE_BASE)
+ : createWebHistory(import.meta.env.VITE_BASE),
+ // 应该添加到路由的初始路由列表。
+ routes,
+ scrollBehavior: (to, _from, savedPosition) => {
+ if (savedPosition) {
+ return savedPosition;
+ }
+ return to.hash ? { behavior: 'smooth', el: to.hash } : { left: 0, top: 0 };
+ },
+ // 是否应该禁止尾部斜杠。
+ // strict: true,
+});
+
+const resetRoutes = () => resetStaticRoutes(router, routes);
+
+// 创建路由守卫
+createRouterGuard(router);
+
+export { resetRoutes, router };
diff --git a/apps/vben5/apps/web-antd/src/router/routes/core.ts b/apps/vben5/apps/web-antd/src/router/routes/core.ts
new file mode 100644
index 000000000..fe030a9a2
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/router/routes/core.ts
@@ -0,0 +1,88 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+
+import { AuthPageLayout } from '#/layouts';
+import { $t } from '#/locales';
+import Login from '#/views/_core/authentication/login.vue';
+
+/** 全局404页面 */
+const fallbackNotFoundRoute: RouteRecordRaw = {
+ component: () => import('#/views/_core/fallback/not-found.vue'),
+ meta: {
+ hideInBreadcrumb: true,
+ hideInMenu: true,
+ hideInTab: true,
+ title: '404',
+ },
+ name: 'FallbackNotFound',
+ path: '/:path(.*)*',
+};
+
+/** 基本路由,这些路由是必须存在的 */
+const coreRoutes: RouteRecordRaw[] = [
+ {
+ meta: {
+ title: 'Root',
+ },
+ name: 'Root',
+ path: '/',
+ redirect: DEFAULT_HOME_PATH,
+ },
+ {
+ component: AuthPageLayout,
+ meta: {
+ hideInTab: true,
+ title: 'Authentication',
+ },
+ name: 'Authentication',
+ path: '/auth',
+ redirect: LOGIN_PATH,
+ children: [
+ {
+ name: 'Login',
+ path: 'login',
+ component: Login,
+ meta: {
+ title: $t('page.auth.login'),
+ },
+ },
+ {
+ name: 'CodeLogin',
+ path: 'code-login',
+ component: () => import('#/views/_core/authentication/code-login.vue'),
+ meta: {
+ title: $t('page.auth.codeLogin'),
+ },
+ },
+ {
+ name: 'QrCodeLogin',
+ path: 'qrcode-login',
+ component: () =>
+ import('#/views/_core/authentication/qrcode-login.vue'),
+ meta: {
+ title: $t('page.auth.qrcodeLogin'),
+ },
+ },
+ {
+ name: 'ForgetPassword',
+ path: 'forget-password',
+ component: () =>
+ import('#/views/_core/authentication/forget-password.vue'),
+ meta: {
+ title: $t('page.auth.forgetPassword'),
+ },
+ },
+ {
+ name: 'Register',
+ path: 'register',
+ component: () => import('#/views/_core/authentication/register.vue'),
+ meta: {
+ title: $t('page.auth.register'),
+ },
+ },
+ ],
+ },
+];
+
+export { coreRoutes, fallbackNotFoundRoute };
diff --git a/apps/vben5/apps/web-antd/src/router/routes/index.ts b/apps/vben5/apps/web-antd/src/router/routes/index.ts
new file mode 100644
index 000000000..e6fb14402
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/router/routes/index.ts
@@ -0,0 +1,37 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { mergeRouteModules, traverseTreeValues } from '@vben/utils';
+
+import { coreRoutes, fallbackNotFoundRoute } from './core';
+
+const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
+ eager: true,
+});
+
+// 有需要可以自行打开注释,并创建文件夹
+// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
+// const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true });
+
+/** 动态路由 */
+const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
+
+/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
+// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
+// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
+const staticRoutes: RouteRecordRaw[] = [];
+const externalRoutes: RouteRecordRaw[] = [];
+
+/** 路由列表,由基本路由、外部路由和404兜底路由组成
+ * 无需走权限验证(会一直显示在菜单中) */
+const routes: RouteRecordRaw[] = [
+ ...coreRoutes,
+ ...externalRoutes,
+ fallbackNotFoundRoute,
+];
+
+/** 基本路由列表,这些路由不需要进入权限拦截 */
+const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
+
+/** 有权限校验的路由列表,包含动态路由和静态路由 */
+const accessRoutes = [...dynamicRoutes, ...staticRoutes];
+export { accessRoutes, coreRouteNames, routes };
diff --git a/apps/vben5/apps/web-antd/src/router/routes/modules/dashboard.ts b/apps/vben5/apps/web-antd/src/router/routes/modules/dashboard.ts
new file mode 100644
index 000000000..1bddab9db
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/router/routes/modules/dashboard.ts
@@ -0,0 +1,40 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'lucide:layout-dashboard',
+ order: -1,
+ title: $t('page.dashboard.title'),
+ },
+ name: 'Dashboard',
+ path: '/',
+ children: [
+ {
+ name: 'Analytics',
+ path: '/analytics',
+ component: () => import('#/views/dashboard/analytics/index.vue'),
+ meta: {
+ affixTab: true,
+ icon: 'lucide:area-chart',
+ title: $t('page.dashboard.analytics'),
+ },
+ },
+ {
+ name: 'Workspace',
+ path: '/workspace',
+ component: () => import('#/views/dashboard/workspace/index.vue'),
+ meta: {
+ icon: 'carbon:workspace',
+ title: $t('page.dashboard.workspace'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/web-antd/src/router/routes/modules/demos.ts b/apps/vben5/apps/web-antd/src/router/routes/modules/demos.ts
new file mode 100644
index 000000000..32bb338e0
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/router/routes/modules/demos.ts
@@ -0,0 +1,30 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'ic:baseline-view-in-ar',
+ keepAlive: true,
+ order: 1000,
+ title: $t('demos.title'),
+ },
+ name: 'Demos',
+ path: '/demos',
+ children: [
+ {
+ meta: {
+ title: $t('demos.antd'),
+ },
+ name: 'AntDesignDemos',
+ path: '/demos/ant-design',
+ component: () => import('#/views/demos/antd/index.vue'),
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/web-antd/src/router/routes/modules/vben.ts b/apps/vben5/apps/web-antd/src/router/routes/modules/vben.ts
new file mode 100644
index 000000000..210e8610f
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/router/routes/modules/vben.ts
@@ -0,0 +1,81 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import {
+ VBEN_DOC_URL,
+ VBEN_ELE_PREVIEW_URL,
+ VBEN_GITHUB_URL,
+ VBEN_LOGO_URL,
+ VBEN_NAIVE_PREVIEW_URL,
+} from '@vben/constants';
+
+import { BasicLayout, IFrameView } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ badgeType: 'dot',
+ icon: VBEN_LOGO_URL,
+ order: 9999,
+ title: $t('demos.vben.title'),
+ },
+ name: 'VbenProject',
+ path: '/vben-admin',
+ children: [
+ {
+ name: 'VbenAbout',
+ path: '/vben-admin/about',
+ component: () => import('#/views/_core/about/index.vue'),
+ meta: {
+ icon: 'lucide:copyright',
+ title: $t('demos.vben.about'),
+ },
+ },
+ {
+ name: 'VbenDocument',
+ path: '/vben-admin/document',
+ component: IFrameView,
+ meta: {
+ icon: 'lucide:book-open-text',
+ link: VBEN_DOC_URL,
+ title: $t('demos.vben.document'),
+ },
+ },
+ {
+ name: 'VbenGithub',
+ path: '/vben-admin/github',
+ component: IFrameView,
+ meta: {
+ icon: 'mdi:github',
+ link: VBEN_GITHUB_URL,
+ title: 'Github',
+ },
+ },
+ {
+ name: 'VbenNaive',
+ path: '/vben-admin/naive',
+ component: IFrameView,
+ meta: {
+ badgeType: 'dot',
+ icon: 'logos:naiveui',
+ link: VBEN_NAIVE_PREVIEW_URL,
+ title: $t('demos.vben.naive-ui'),
+ },
+ },
+ {
+ name: 'VbenElementPlus',
+ path: '/vben-admin/ele',
+ component: IFrameView,
+ meta: {
+ badgeType: 'dot',
+ icon: 'logos:element',
+ link: VBEN_ELE_PREVIEW_URL,
+ title: $t('demos.vben.element-plus'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/web-antd/src/store/auth.ts b/apps/vben5/apps/web-antd/src/store/auth.ts
new file mode 100644
index 000000000..9d64d2058
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/store/auth.ts
@@ -0,0 +1,115 @@
+import type { Recordable, UserInfo } from '@vben/types';
+
+import { ref } from 'vue';
+import { useRouter } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
+
+import { notification } from 'ant-design-vue';
+import { defineStore } from 'pinia';
+
+import { getAccessCodesApi, getUserInfoApi, loginApi, logoutApi } from '#/api';
+import { $t } from '#/locales';
+
+export const useAuthStore = defineStore('auth', () => {
+ const accessStore = useAccessStore();
+ const userStore = useUserStore();
+ const router = useRouter();
+
+ const loginLoading = ref(false);
+
+ /**
+ * 异步处理登录操作
+ * Asynchronously handle the login process
+ * @param params 登录表单数据
+ */
+ async function authLogin(
+ params: Recordable,
+ onSuccess?: () => Promise | void,
+ ) {
+ // 异步处理用户登录操作并获取 accessToken
+ let userInfo: null | UserInfo = null;
+ try {
+ loginLoading.value = true;
+ const { accessToken } = await loginApi(params);
+
+ // 如果成功获取到 accessToken
+ if (accessToken) {
+ accessStore.setAccessToken(accessToken);
+
+ // 获取用户信息并存储到 accessStore 中
+ const [fetchUserInfoResult, accessCodes] = await Promise.all([
+ fetchUserInfo(),
+ getAccessCodesApi(),
+ ]);
+
+ userInfo = fetchUserInfoResult;
+
+ userStore.setUserInfo(userInfo);
+ accessStore.setAccessCodes(accessCodes);
+
+ if (accessStore.loginExpired) {
+ accessStore.setLoginExpired(false);
+ } else {
+ onSuccess
+ ? await onSuccess?.()
+ : await router.push(userInfo.homePath || DEFAULT_HOME_PATH);
+ }
+
+ if (userInfo?.realName) {
+ notification.success({
+ description: `${$t('authentication.loginSuccessDesc')}:${userInfo?.realName}`,
+ duration: 3,
+ message: $t('authentication.loginSuccess'),
+ });
+ }
+ }
+ } finally {
+ loginLoading.value = false;
+ }
+
+ return {
+ userInfo,
+ };
+ }
+
+ async function logout(redirect: boolean = true) {
+ try {
+ await logoutApi();
+ } catch {
+ // 不做任何处理
+ }
+ resetAllStores();
+ accessStore.setLoginExpired(false);
+
+ // 回登录页带上当前路由地址
+ await router.replace({
+ path: LOGIN_PATH,
+ query: redirect
+ ? {
+ redirect: encodeURIComponent(router.currentRoute.value.fullPath),
+ }
+ : {},
+ });
+ }
+
+ async function fetchUserInfo() {
+ let userInfo: null | UserInfo = null;
+ userInfo = await getUserInfoApi();
+ userStore.setUserInfo(userInfo);
+ return userInfo;
+ }
+
+ function $reset() {
+ loginLoading.value = false;
+ }
+
+ return {
+ $reset,
+ authLogin,
+ fetchUserInfo,
+ loginLoading,
+ logout,
+ };
+});
diff --git a/apps/vben5/apps/web-antd/src/store/index.ts b/apps/vben5/apps/web-antd/src/store/index.ts
new file mode 100644
index 000000000..269586ee8
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/store/index.ts
@@ -0,0 +1 @@
+export * from './auth';
diff --git a/apps/vben5/apps/web-antd/src/views/_core/README.md b/apps/vben5/apps/web-antd/src/views/_core/README.md
new file mode 100644
index 000000000..8248afe6c
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/README.md
@@ -0,0 +1,3 @@
+# \_core
+
+此目录包含应用程序正常运行所需的基本视图。这些视图是应用程序布局中使用的视图。
diff --git a/apps/vben5/apps/web-antd/src/views/_core/about/index.vue b/apps/vben5/apps/web-antd/src/views/_core/about/index.vue
new file mode 100644
index 000000000..0ee524335
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/about/index.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/authentication/code-login.vue b/apps/vben5/apps/web-antd/src/views/_core/authentication/code-login.vue
new file mode 100644
index 000000000..556b273af
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/authentication/code-login.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/authentication/forget-password.vue b/apps/vben5/apps/web-antd/src/views/_core/authentication/forget-password.vue
new file mode 100644
index 000000000..fef0d4279
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/authentication/forget-password.vue
@@ -0,0 +1,43 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/authentication/login.vue b/apps/vben5/apps/web-antd/src/views/_core/authentication/login.vue
new file mode 100644
index 000000000..099e4c8c0
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/authentication/login.vue
@@ -0,0 +1,98 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/authentication/qrcode-login.vue b/apps/vben5/apps/web-antd/src/views/_core/authentication/qrcode-login.vue
new file mode 100644
index 000000000..23f5f2dad
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/authentication/qrcode-login.vue
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/authentication/register.vue b/apps/vben5/apps/web-antd/src/views/_core/authentication/register.vue
new file mode 100644
index 000000000..b1a5de726
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/authentication/register.vue
@@ -0,0 +1,96 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/fallback/coming-soon.vue b/apps/vben5/apps/web-antd/src/views/_core/fallback/coming-soon.vue
new file mode 100644
index 000000000..f394930f2
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/fallback/coming-soon.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/fallback/forbidden.vue b/apps/vben5/apps/web-antd/src/views/_core/fallback/forbidden.vue
new file mode 100644
index 000000000..8ea65fedb
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/fallback/forbidden.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/fallback/internal-error.vue b/apps/vben5/apps/web-antd/src/views/_core/fallback/internal-error.vue
new file mode 100644
index 000000000..819a47d5e
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/fallback/internal-error.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/fallback/not-found.vue b/apps/vben5/apps/web-antd/src/views/_core/fallback/not-found.vue
new file mode 100644
index 000000000..4d178e9cb
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/fallback/not-found.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/_core/fallback/offline.vue b/apps/vben5/apps/web-antd/src/views/_core/fallback/offline.vue
new file mode 100644
index 000000000..5de4a88de
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/_core/fallback/offline.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-trends.vue b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-trends.vue
new file mode 100644
index 000000000..fadfc917c
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-trends.vue
@@ -0,0 +1,100 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits-data.vue b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits-data.vue
new file mode 100644
index 000000000..30c4265df
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits-data.vue
@@ -0,0 +1,84 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits-sales.vue b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits-sales.vue
new file mode 100644
index 000000000..260520b84
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits-sales.vue
@@ -0,0 +1,48 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits-source.vue b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits-source.vue
new file mode 100644
index 000000000..e0d0aab5e
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits-source.vue
@@ -0,0 +1,67 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits.vue b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits.vue
new file mode 100644
index 000000000..7e1f14ee6
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/analytics-visits.vue
@@ -0,0 +1,57 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/dashboard/analytics/index.vue b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/index.vue
new file mode 100644
index 000000000..00b34df1e
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/dashboard/analytics/index.vue
@@ -0,0 +1,90 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/dashboard/workspace/index.vue b/apps/vben5/apps/web-antd/src/views/dashboard/workspace/index.vue
new file mode 100644
index 000000000..b95d61381
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/dashboard/workspace/index.vue
@@ -0,0 +1,266 @@
+
+
+
+
+
+
+ 早安, {{ userStore.userInfo?.realName }}, 开始您一天的工作吧!
+
+ 今日晴,20℃ - 32℃!
+
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/src/views/demos/antd/index.vue b/apps/vben5/apps/web-antd/src/views/demos/antd/index.vue
new file mode 100644
index 000000000..b3b05cc15
--- /dev/null
+++ b/apps/vben5/apps/web-antd/src/views/demos/antd/index.vue
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+ Default
+ Primary
+ Info
+ Error
+
+
+
+
+ 信息
+ 错误
+ 警告
+ 成功
+
+
+
+
+
+ 信息
+ 错误
+ 警告
+ 成功
+
+
+
+
diff --git a/apps/vben5/apps/web-antd/tailwind.config.mjs b/apps/vben5/apps/web-antd/tailwind.config.mjs
new file mode 100644
index 000000000..f17f556fa
--- /dev/null
+++ b/apps/vben5/apps/web-antd/tailwind.config.mjs
@@ -0,0 +1 @@
+export { default } from '@vben/tailwind-config';
diff --git a/apps/vben5/apps/web-antd/tsconfig.json b/apps/vben5/apps/web-antd/tsconfig.json
new file mode 100644
index 000000000..02c287fe6
--- /dev/null
+++ b/apps/vben5/apps/web-antd/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/web-app.json",
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "#/*": ["./src/*"]
+ }
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
+}
diff --git a/apps/vben5/apps/web-antd/tsconfig.node.json b/apps/vben5/apps/web-antd/tsconfig.node.json
new file mode 100644
index 000000000..c2f0d86cc
--- /dev/null
+++ b/apps/vben5/apps/web-antd/tsconfig.node.json
@@ -0,0 +1,10 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/node.json",
+ "compilerOptions": {
+ "composite": true,
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
+ "noEmit": false
+ },
+ "include": ["vite.config.mts"]
+}
diff --git a/apps/vben5/apps/web-antd/vite.config.mts b/apps/vben5/apps/web-antd/vite.config.mts
new file mode 100644
index 000000000..b6360f1d4
--- /dev/null
+++ b/apps/vben5/apps/web-antd/vite.config.mts
@@ -0,0 +1,20 @@
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ application: {},
+ vite: {
+ server: {
+ proxy: {
+ '/api': {
+ changeOrigin: true,
+ rewrite: (path) => path.replace(/^\/api/, ''),
+ // mock代理目标地址
+ target: 'http://localhost:5320/api',
+ ws: true,
+ },
+ },
+ },
+ },
+ };
+});
diff --git a/apps/vben5/apps/web-ele/.env b/apps/vben5/apps/web-ele/.env
new file mode 100644
index 000000000..87cb3df14
--- /dev/null
+++ b/apps/vben5/apps/web-ele/.env
@@ -0,0 +1,5 @@
+# 应用标题
+VITE_APP_TITLE=Vben Admin Ele
+
+# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
+VITE_APP_NAMESPACE=vben-web-ele
diff --git a/apps/vben5/apps/web-ele/.env.analyze b/apps/vben5/apps/web-ele/.env.analyze
new file mode 100644
index 000000000..ffafa8dd5
--- /dev/null
+++ b/apps/vben5/apps/web-ele/.env.analyze
@@ -0,0 +1,7 @@
+# public path
+VITE_BASE=/
+
+# Basic interface address SPA
+VITE_GLOB_API_URL=/api
+
+VITE_VISUALIZER=true
diff --git a/apps/vben5/apps/web-ele/.env.development b/apps/vben5/apps/web-ele/.env.development
new file mode 100644
index 000000000..8bcb432e6
--- /dev/null
+++ b/apps/vben5/apps/web-ele/.env.development
@@ -0,0 +1,16 @@
+# 端口号
+VITE_PORT=5777
+
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=/api
+
+# 是否开启 Nitro Mock服务,true 为开启,false 为关闭
+VITE_NITRO_MOCK=true
+
+# 是否打开 devtools,true 为打开,false 为关闭
+VITE_DEVTOOLS=false
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
diff --git a/apps/vben5/apps/web-ele/.env.production b/apps/vben5/apps/web-ele/.env.production
new file mode 100644
index 000000000..5375847a6
--- /dev/null
+++ b/apps/vben5/apps/web-ele/.env.production
@@ -0,0 +1,19 @@
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+
+# 是否开启压缩,可以设置为 none, brotli, gzip
+VITE_COMPRESS=none
+
+# 是否开启 PWA
+VITE_PWA=false
+
+# vue-router 的模式
+VITE_ROUTER_HISTORY=hash
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
+
+# 打包后是否生成dist.zip
+VITE_ARCHIVER=true
diff --git a/apps/vben5/apps/web-ele/index.html b/apps/vben5/apps/web-ele/index.html
new file mode 100644
index 000000000..2b59b8d75
--- /dev/null
+++ b/apps/vben5/apps/web-ele/index.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+ <%= VITE_APP_TITLE %>
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/package.json b/apps/vben5/apps/web-ele/package.json
new file mode 100644
index 000000000..430156951
--- /dev/null
+++ b/apps/vben5/apps/web-ele/package.json
@@ -0,0 +1,53 @@
+{
+ "name": "@vben/web-ele",
+ "version": "5.4.8",
+ "homepage": "https://vben.pro",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "apps/web-ele"
+ },
+ "license": "MIT",
+ "author": {
+ "name": "vben",
+ "email": "ann.vben@gmail.com",
+ "url": "https://github.com/anncwb"
+ },
+ "type": "module",
+ "scripts": {
+ "build": "pnpm vite build --mode production",
+ "build:analyze": "pnpm vite build --mode analyze",
+ "dev": "pnpm vite --mode development",
+ "preview": "vite preview",
+ "typecheck": "vue-tsc --noEmit --skipLibCheck"
+ },
+ "imports": {
+ "#/*": "./src/*"
+ },
+ "dependencies": {
+ "@vben/access": "workspace:*",
+ "@vben/common-ui": "workspace:*",
+ "@vben/constants": "workspace:*",
+ "@vben/hooks": "workspace:*",
+ "@vben/icons": "workspace:*",
+ "@vben/layouts": "workspace:*",
+ "@vben/locales": "workspace:*",
+ "@vben/plugins": "workspace:*",
+ "@vben/preferences": "workspace:*",
+ "@vben/request": "workspace:*",
+ "@vben/stores": "workspace:*",
+ "@vben/styles": "workspace:*",
+ "@vben/types": "workspace:*",
+ "@vben/utils": "workspace:*",
+ "@vueuse/core": "catalog:",
+ "dayjs": "catalog:",
+ "element-plus": "catalog:",
+ "pinia": "catalog:",
+ "vue": "catalog:",
+ "vue-router": "catalog:"
+ },
+ "devDependencies": {
+ "unplugin-element-plus": "catalog:"
+ }
+}
diff --git a/apps/vben5/apps/web-ele/postcss.config.mjs b/apps/vben5/apps/web-ele/postcss.config.mjs
new file mode 100644
index 000000000..3d8070455
--- /dev/null
+++ b/apps/vben5/apps/web-ele/postcss.config.mjs
@@ -0,0 +1 @@
+export { default } from '@vben/tailwind-config/postcss';
diff --git a/apps/vben5/apps/web-ele/public/favicon.ico b/apps/vben5/apps/web-ele/public/favicon.ico
new file mode 100644
index 000000000..fcf9818e2
Binary files /dev/null and b/apps/vben5/apps/web-ele/public/favicon.ico differ
diff --git a/apps/vben5/apps/web-ele/src/adapter/component/index.ts b/apps/vben5/apps/web-ele/src/adapter/component/index.ts
new file mode 100644
index 000000000..ebf9dd3e1
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/adapter/component/index.ts
@@ -0,0 +1,106 @@
+/**
+ * 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
+ * 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
+ */
+
+import type { BaseFormComponentType } from '@vben/common-ui';
+
+import type { Component, SetupContext } from 'vue';
+import { h } from 'vue';
+
+import { globalShareState } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+import {
+ ElButton,
+ ElCheckbox,
+ ElCheckboxGroup,
+ ElDatePicker,
+ ElDivider,
+ ElInput,
+ ElInputNumber,
+ ElNotification,
+ ElRadioGroup,
+ ElSelect,
+ ElSpace,
+ ElSwitch,
+ ElTimePicker,
+ ElTreeSelect,
+ ElUpload,
+} from 'element-plus';
+
+const withDefaultPlaceholder = (
+ component: T,
+ type: 'input' | 'select',
+) => {
+ return (props: any, { attrs, slots }: Omit) => {
+ const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
+ return h(component, { ...props, ...attrs, placeholder }, slots);
+ };
+};
+
+// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
+export type ComponentType =
+ | 'Checkbox'
+ | 'CheckboxGroup'
+ | 'DatePicker'
+ | 'Divider'
+ | 'Input'
+ | 'InputNumber'
+ | 'RadioGroup'
+ | 'Select'
+ | 'Space'
+ | 'Switch'
+ | 'TimePicker'
+ | 'TreeSelect'
+ | 'Upload'
+ | BaseFormComponentType;
+
+async function initComponentAdapter() {
+ const components: Partial> = {
+ // 如果你的组件体积比较大,可以使用异步加载
+ // Button: () =>
+ // import('xxx').then((res) => res.Button),
+
+ Checkbox: ElCheckbox,
+ CheckboxGroup: ElCheckboxGroup,
+ // 自定义默认按钮
+ DefaultButton: (props, { attrs, slots }) => {
+ return h(ElButton, { ...props, attrs, type: 'info' }, slots);
+ },
+ // 自定义主要按钮
+ PrimaryButton: (props, { attrs, slots }) => {
+ return h(ElButton, { ...props, attrs, type: 'primary' }, slots);
+ },
+ Divider: ElDivider,
+ Input: withDefaultPlaceholder(ElInput, 'input'),
+ InputNumber: withDefaultPlaceholder(ElInputNumber, 'input'),
+ RadioGroup: ElRadioGroup,
+ Select: withDefaultPlaceholder(ElSelect, 'select'),
+ Space: ElSpace,
+ Switch: ElSwitch,
+ TimePicker: ElTimePicker,
+ DatePicker: ElDatePicker,
+ TreeSelect: withDefaultPlaceholder(ElTreeSelect, 'select'),
+ Upload: ElUpload,
+ };
+
+ // 将组件注册到全局共享状态中
+ globalShareState.setComponents(components);
+
+ // 定义全局共享状态中的消息提示
+ globalShareState.defineMessage({
+ // 复制成功消息提示
+ copyPreferencesSuccess: (title, content) => {
+ ElNotification({
+ title,
+ message: content,
+ position: 'bottom-right',
+ duration: 0,
+ type: 'success',
+ });
+ },
+ });
+}
+
+export { initComponentAdapter };
diff --git a/apps/vben5/apps/web-ele/src/adapter/form.ts b/apps/vben5/apps/web-ele/src/adapter/form.ts
new file mode 100644
index 000000000..1b6e04719
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/adapter/form.ts
@@ -0,0 +1,38 @@
+import type {
+ VbenFormSchema as FormSchema,
+ VbenFormProps,
+} from '@vben/common-ui';
+
+import type { ComponentType } from './component';
+
+import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+setupVbenForm({
+ config: {
+ modelPropNameMap: {
+ Upload: 'fileList',
+ },
+ },
+ defineRules: {
+ required: (value, _params, ctx) => {
+ if (value === undefined || value === null || value.length === 0) {
+ return $t('ui.formRules.required', [ctx.label]);
+ }
+ return true;
+ },
+ selectRequired: (value, _params, ctx) => {
+ if (value === undefined || value === null) {
+ return $t('ui.formRules.selectRequired', [ctx.label]);
+ }
+ return true;
+ },
+ },
+});
+
+const useVbenForm = useForm;
+
+export { useVbenForm, z };
+
+export type VbenFormSchema = FormSchema;
+export type { VbenFormProps };
diff --git a/apps/vben5/apps/web-ele/src/adapter/vxe-table.ts b/apps/vben5/apps/web-ele/src/adapter/vxe-table.ts
new file mode 100644
index 000000000..44b31eaed
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/adapter/vxe-table.ts
@@ -0,0 +1,68 @@
+import { h } from 'vue';
+
+import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
+
+import { ElButton, ElImage } from 'element-plus';
+
+import { useVbenForm } from './form';
+
+setupVbenVxeTable({
+ configVxeTable: (vxeUI) => {
+ vxeUI.setConfig({
+ grid: {
+ align: 'center',
+ border: false,
+ columnConfig: {
+ resizable: true,
+ },
+ minHeight: 180,
+ formConfig: {
+ // 全局禁用vxe-table的表单配置,使用formOptions
+ enabled: false,
+ },
+ proxyConfig: {
+ autoLoad: true,
+ response: {
+ result: 'items',
+ total: 'total',
+ list: 'items',
+ },
+ showActiveMsg: true,
+ showResponseMsg: false,
+ },
+ round: true,
+ showOverflow: true,
+ size: 'small',
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellImage' },
+ vxeUI.renderer.add('CellImage', {
+ renderTableDefault(_renderOpts, params) {
+ const { column, row } = params;
+ const src = row[column.field];
+ return h(ElImage, { src, previewSrcList: [src] });
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellLink' },
+ vxeUI.renderer.add('CellLink', {
+ renderTableDefault(renderOpts) {
+ const { props } = renderOpts;
+ return h(
+ ElButton,
+ { size: 'small', link: true },
+ { default: () => props?.text },
+ );
+ },
+ });
+
+ // 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
+ // vxeUI.formats.add
+ },
+ useVbenForm,
+});
+
+export { useVbenVxeGrid };
+
+export type * from '@vben/plugins/vxe-table';
diff --git a/apps/vben5/apps/web-ele/src/api/core/auth.ts b/apps/vben5/apps/web-ele/src/api/core/auth.ts
new file mode 100644
index 000000000..71d9f9943
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/api/core/auth.ts
@@ -0,0 +1,51 @@
+import { baseRequestClient, requestClient } from '#/api/request';
+
+export namespace AuthApi {
+ /** 登录接口参数 */
+ export interface LoginParams {
+ password?: string;
+ username?: string;
+ }
+
+ /** 登录接口返回值 */
+ export interface LoginResult {
+ accessToken: string;
+ }
+
+ export interface RefreshTokenResult {
+ data: string;
+ status: number;
+ }
+}
+
+/**
+ * 登录
+ */
+export async function loginApi(data: AuthApi.LoginParams) {
+ return requestClient.post('/auth/login', data);
+}
+
+/**
+ * 刷新accessToken
+ */
+export async function refreshTokenApi() {
+ return baseRequestClient.post('/auth/refresh', {
+ withCredentials: true,
+ });
+}
+
+/**
+ * 退出登录
+ */
+export async function logoutApi() {
+ return baseRequestClient.post('/auth/logout', {
+ withCredentials: true,
+ });
+}
+
+/**
+ * 获取用户权限码
+ */
+export async function getAccessCodesApi() {
+ return requestClient.get('/auth/codes');
+}
diff --git a/apps/vben5/apps/web-ele/src/api/core/index.ts b/apps/vben5/apps/web-ele/src/api/core/index.ts
new file mode 100644
index 000000000..28a5aef47
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/api/core/index.ts
@@ -0,0 +1,3 @@
+export * from './auth';
+export * from './menu';
+export * from './user';
diff --git a/apps/vben5/apps/web-ele/src/api/core/menu.ts b/apps/vben5/apps/web-ele/src/api/core/menu.ts
new file mode 100644
index 000000000..9ef60b11c
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/api/core/menu.ts
@@ -0,0 +1,10 @@
+import type { RouteRecordStringComponent } from '@vben/types';
+
+import { requestClient } from '#/api/request';
+
+/**
+ * 获取用户所有菜单
+ */
+export async function getAllMenusApi() {
+ return requestClient.get('/menu/all');
+}
diff --git a/apps/vben5/apps/web-ele/src/api/core/user.ts b/apps/vben5/apps/web-ele/src/api/core/user.ts
new file mode 100644
index 000000000..7e28ea848
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/api/core/user.ts
@@ -0,0 +1,10 @@
+import type { UserInfo } from '@vben/types';
+
+import { requestClient } from '#/api/request';
+
+/**
+ * 获取用户信息
+ */
+export async function getUserInfoApi() {
+ return requestClient.get('/user/info');
+}
diff --git a/apps/vben5/apps/web-ele/src/api/index.ts b/apps/vben5/apps/web-ele/src/api/index.ts
new file mode 100644
index 000000000..4b0e04137
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/api/index.ts
@@ -0,0 +1 @@
+export * from './core';
diff --git a/apps/vben5/apps/web-ele/src/api/request.ts b/apps/vben5/apps/web-ele/src/api/request.ts
new file mode 100644
index 000000000..a9514c817
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/api/request.ts
@@ -0,0 +1,113 @@
+/**
+ * 该文件可自行根据业务逻辑进行调整
+ */
+import type { HttpResponse } from '@vben/request';
+
+import { useAppConfig } from '@vben/hooks';
+import { preferences } from '@vben/preferences';
+import {
+ authenticateResponseInterceptor,
+ errorMessageResponseInterceptor,
+ RequestClient,
+} from '@vben/request';
+import { useAccessStore } from '@vben/stores';
+
+import { ElMessage } from 'element-plus';
+
+import { useAuthStore } from '#/store';
+
+import { refreshTokenApi } from './core';
+
+const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+
+function createRequestClient(baseURL: string) {
+ const client = new RequestClient({
+ baseURL,
+ });
+
+ /**
+ * 重新认证逻辑
+ */
+ async function doReAuthenticate() {
+ console.warn('Access token or refresh token is invalid or expired. ');
+ const accessStore = useAccessStore();
+ const authStore = useAuthStore();
+ accessStore.setAccessToken(null);
+ if (
+ preferences.app.loginExpiredMode === 'modal' &&
+ accessStore.isAccessChecked
+ ) {
+ accessStore.setLoginExpired(true);
+ } else {
+ await authStore.logout();
+ }
+ }
+
+ /**
+ * 刷新token逻辑
+ */
+ async function doRefreshToken() {
+ const accessStore = useAccessStore();
+ const resp = await refreshTokenApi();
+ const newToken = resp.data;
+ accessStore.setAccessToken(newToken);
+ return newToken;
+ }
+
+ function formatToken(token: null | string) {
+ return token ? `Bearer ${token}` : null;
+ }
+
+ // 请求头处理
+ client.addRequestInterceptor({
+ fulfilled: async (config) => {
+ const accessStore = useAccessStore();
+
+ config.headers.Authorization = formatToken(accessStore.accessToken);
+ config.headers['Accept-Language'] = preferences.app.locale;
+ return config;
+ },
+ });
+
+ // response数据解构
+ client.addResponseInterceptor({
+ fulfilled: (response) => {
+ const { data: responseData, status } = response;
+
+ const { code, data } = responseData;
+ if (status >= 200 && status < 400 && code === 0) {
+ return data;
+ }
+ throw Object.assign({}, response, { response });
+ },
+ });
+
+ // token过期的处理
+ client.addResponseInterceptor(
+ authenticateResponseInterceptor({
+ client,
+ doReAuthenticate,
+ doRefreshToken,
+ enableRefreshToken: preferences.app.enableRefreshToken,
+ formatToken,
+ }),
+ );
+
+ // 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
+ client.addResponseInterceptor(
+ errorMessageResponseInterceptor((msg: string, error) => {
+ // 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
+ // 当前mock接口返回的错误字段是 error 或者 message
+ const responseData = error?.response?.data ?? {};
+ const errorMessage = responseData?.error ?? responseData?.message ?? '';
+ // 如果没有错误信息,则会根据状态码进行提示
+ ElMessage.error(errorMessage || msg);
+ }),
+ );
+
+ return client;
+}
+
+export const requestClient = createRequestClient(apiURL);
+
+export const baseRequestClient = new RequestClient({ baseURL: apiURL });
diff --git a/apps/vben5/apps/web-ele/src/app.vue b/apps/vben5/apps/web-ele/src/app.vue
new file mode 100644
index 000000000..1217658da
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/app.vue
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/bootstrap.ts b/apps/vben5/apps/web-ele/src/bootstrap.ts
new file mode 100644
index 000000000..de1884730
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/bootstrap.ts
@@ -0,0 +1,47 @@
+import { createApp, watchEffect } from 'vue';
+
+import { registerAccessDirective } from '@vben/access';
+import { preferences } from '@vben/preferences';
+import { initStores } from '@vben/stores';
+import '@vben/styles';
+import '@vben/styles/ele';
+
+import { useTitle } from '@vueuse/core';
+
+import { $t, setupI18n } from '#/locales';
+
+import { initComponentAdapter } from './adapter/component';
+import App from './app.vue';
+import { router } from './router';
+
+async function bootstrap(namespace: string) {
+ // 初始化组件适配器
+ await initComponentAdapter();
+ const app = createApp(App);
+
+ // 国际化 i18n 配置
+ await setupI18n(app);
+
+ // 配置 pinia-tore
+ await initStores(app, { namespace });
+
+ // 安装权限指令
+ registerAccessDirective(app);
+
+ // 配置路由及路由守卫
+ app.use(router);
+
+ // 动态更新标题
+ watchEffect(() => {
+ if (preferences.app.dynamicTitle) {
+ const routeTitle = router.currentRoute.value.meta?.title;
+ const pageTitle =
+ (routeTitle ? `${$t(routeTitle)} - ` : '') + preferences.app.name;
+ useTitle(pageTitle);
+ }
+ });
+
+ app.mount('#app');
+}
+
+export { bootstrap };
diff --git a/apps/vben5/apps/web-ele/src/layouts/auth.vue b/apps/vben5/apps/web-ele/src/layouts/auth.vue
new file mode 100644
index 000000000..18d415bc7
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/layouts/auth.vue
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/layouts/basic.vue b/apps/vben5/apps/web-ele/src/layouts/basic.vue
new file mode 100644
index 000000000..51412956a
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/layouts/basic.vue
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/layouts/index.ts b/apps/vben5/apps/web-ele/src/layouts/index.ts
new file mode 100644
index 000000000..a43207805
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/layouts/index.ts
@@ -0,0 +1,6 @@
+const BasicLayout = () => import('./basic.vue');
+const AuthPageLayout = () => import('./auth.vue');
+
+const IFrameView = () => import('@vben/layouts').then((m) => m.IFrameView);
+
+export { AuthPageLayout, BasicLayout, IFrameView };
diff --git a/apps/vben5/apps/web-ele/src/locales/README.md b/apps/vben5/apps/web-ele/src/locales/README.md
new file mode 100644
index 000000000..7b451032e
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/locales/README.md
@@ -0,0 +1,3 @@
+# locale
+
+每个app使用的国际化可能不同,这里用于扩展国际化的功能,例如扩展 dayjs、antd组件库的多语言切换,以及app本身的国际化文件。
diff --git a/apps/vben5/apps/web-ele/src/locales/index.ts b/apps/vben5/apps/web-ele/src/locales/index.ts
new file mode 100644
index 000000000..1f3e22c91
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/locales/index.ts
@@ -0,0 +1,100 @@
+import type { LocaleSetupOptions, SupportedLanguagesType } from '@vben/locales';
+import type { Language } from 'element-plus/es/locale';
+
+import type { App } from 'vue';
+import { ref } from 'vue';
+
+import {
+ $t,
+ setupI18n as coreSetup,
+ loadLocalesMapFromDir,
+} from '@vben/locales';
+import { preferences } from '@vben/preferences';
+
+import dayjs from 'dayjs';
+import enLocale from 'element-plus/es/locale/lang/en';
+import defaultLocale from 'element-plus/es/locale/lang/zh-cn';
+
+const elementLocale = ref(defaultLocale);
+
+const modules = import.meta.glob('./langs/**/*.json');
+
+const localesMap = loadLocalesMapFromDir(
+ /\.\/langs\/([^/]+)\/(.*)\.json$/,
+ modules,
+);
+/**
+ * 加载应用特有的语言包
+ * 这里也可以改造为从服务端获取翻译数据
+ * @param lang
+ */
+async function loadMessages(lang: SupportedLanguagesType) {
+ const [appLocaleMessages] = await Promise.all([
+ localesMap[lang]?.(),
+ loadThirdPartyMessage(lang),
+ ]);
+ return appLocaleMessages?.default;
+}
+
+/**
+ * 加载第三方组件库的语言包
+ * @param lang
+ */
+async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
+ await Promise.all([loadElementLocale(lang), loadDayjsLocale(lang)]);
+}
+
+/**
+ * 加载dayjs的语言包
+ * @param lang
+ */
+async function loadDayjsLocale(lang: SupportedLanguagesType) {
+ let locale;
+ switch (lang) {
+ case 'en-US': {
+ locale = await import('dayjs/locale/en');
+ break;
+ }
+ case 'zh-CN': {
+ locale = await import('dayjs/locale/zh-cn');
+ break;
+ }
+ // 默认使用英语
+ default: {
+ locale = await import('dayjs/locale/en');
+ }
+ }
+ if (locale) {
+ dayjs.locale(locale);
+ } else {
+ console.error(`Failed to load dayjs locale for ${lang}`);
+ }
+}
+
+/**
+ * 加载element-plus的语言包
+ * @param lang
+ */
+async function loadElementLocale(lang: SupportedLanguagesType) {
+ switch (lang) {
+ case 'en-US': {
+ elementLocale.value = enLocale;
+ break;
+ }
+ case 'zh-CN': {
+ elementLocale.value = defaultLocale;
+ break;
+ }
+ }
+}
+
+async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
+ await coreSetup(app, {
+ defaultLocale: preferences.app.locale,
+ loadMessages,
+ missingWarn: !import.meta.env.PROD,
+ ...options,
+ });
+}
+
+export { $t, elementLocale, setupI18n };
diff --git a/apps/vben5/apps/web-ele/src/locales/langs/en-US/demos.json b/apps/vben5/apps/web-ele/src/locales/langs/en-US/demos.json
new file mode 100644
index 000000000..056da0dae
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/locales/langs/en-US/demos.json
@@ -0,0 +1,12 @@
+{
+ "title": "Demos",
+ "elementPlus": "Element Plus",
+ "vben": {
+ "title": "Project",
+ "about": "About",
+ "document": "Document",
+ "antdv": "Ant Design Vue Version",
+ "naive-ui": "Naive UI Version",
+ "element-plus": "Element Plus Version"
+ }
+}
diff --git a/apps/vben5/apps/web-ele/src/locales/langs/en-US/page.json b/apps/vben5/apps/web-ele/src/locales/langs/en-US/page.json
new file mode 100644
index 000000000..618a258c0
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/locales/langs/en-US/page.json
@@ -0,0 +1,14 @@
+{
+ "auth": {
+ "login": "Login",
+ "register": "Register",
+ "codeLogin": "Code Login",
+ "qrcodeLogin": "Qr Code Login",
+ "forgetPassword": "Forget Password"
+ },
+ "dashboard": {
+ "title": "Dashboard",
+ "analytics": "Analytics",
+ "workspace": "Workspace"
+ }
+}
diff --git a/apps/vben5/apps/web-ele/src/locales/langs/zh-CN/demos.json b/apps/vben5/apps/web-ele/src/locales/langs/zh-CN/demos.json
new file mode 100644
index 000000000..0620e16a1
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/locales/langs/zh-CN/demos.json
@@ -0,0 +1,12 @@
+{
+ "title": "演示",
+ "elementPlus": "Element Plus",
+ "vben": {
+ "title": "项目",
+ "about": "关于",
+ "document": "文档",
+ "antdv": "Ant Design Vue 版本",
+ "naive-ui": "Naive UI 版本",
+ "element-plus": "Element Plus 版本"
+ }
+}
diff --git a/apps/vben5/apps/web-ele/src/locales/langs/zh-CN/page.json b/apps/vben5/apps/web-ele/src/locales/langs/zh-CN/page.json
new file mode 100644
index 000000000..4cb67081c
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/locales/langs/zh-CN/page.json
@@ -0,0 +1,14 @@
+{
+ "auth": {
+ "login": "登录",
+ "register": "注册",
+ "codeLogin": "验证码登录",
+ "qrcodeLogin": "二维码登录",
+ "forgetPassword": "忘记密码"
+ },
+ "dashboard": {
+ "title": "概览",
+ "analytics": "分析页",
+ "workspace": "工作台"
+ }
+}
diff --git a/apps/vben5/apps/web-ele/src/main.ts b/apps/vben5/apps/web-ele/src/main.ts
new file mode 100644
index 000000000..5d728a02a
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/main.ts
@@ -0,0 +1,31 @@
+import { initPreferences } from '@vben/preferences';
+import { unmountGlobalLoading } from '@vben/utils';
+
+import { overridesPreferences } from './preferences';
+
+/**
+ * 应用初始化完成之后再进行页面加载渲染
+ */
+async function initApplication() {
+ // name用于指定项目唯一标识
+ // 用于区分不同项目的偏好设置以及存储数据的key前缀以及其他一些需要隔离的数据
+ const env = import.meta.env.PROD ? 'prod' : 'dev';
+ const appVersion = import.meta.env.VITE_APP_VERSION;
+ const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${appVersion}-${env}`;
+
+ // app偏好设置初始化
+ await initPreferences({
+ namespace,
+ overrides: overridesPreferences,
+ });
+
+ // 启动应用并挂载
+ // vue应用主要逻辑及视图
+ const { bootstrap } = await import('./bootstrap');
+ await bootstrap(namespace);
+
+ // 移除并销毁loading
+ unmountGlobalLoading();
+}
+
+initApplication();
diff --git a/apps/vben5/apps/web-ele/src/preferences.ts b/apps/vben5/apps/web-ele/src/preferences.ts
new file mode 100644
index 000000000..b2e9ace43
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/preferences.ts
@@ -0,0 +1,13 @@
+import { defineOverridesPreferences } from '@vben/preferences';
+
+/**
+ * @description 项目配置文件
+ * 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置
+ * !!! 更改配置后请清空缓存,否则可能不生效
+ */
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ name: import.meta.env.VITE_APP_TITLE,
+ },
+});
diff --git a/apps/vben5/apps/web-ele/src/router/access.ts b/apps/vben5/apps/web-ele/src/router/access.ts
new file mode 100644
index 000000000..2d07c892b
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/router/access.ts
@@ -0,0 +1,42 @@
+import type {
+ ComponentRecordType,
+ GenerateMenuAndRoutesOptions,
+} from '@vben/types';
+
+import { generateAccessible } from '@vben/access';
+import { preferences } from '@vben/preferences';
+
+import { ElMessage } from 'element-plus';
+
+import { getAllMenusApi } from '#/api';
+import { BasicLayout, IFrameView } from '#/layouts';
+import { $t } from '#/locales';
+
+const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
+
+async function generateAccess(options: GenerateMenuAndRoutesOptions) {
+ const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue');
+
+ const layoutMap: ComponentRecordType = {
+ BasicLayout,
+ IFrameView,
+ };
+
+ return await generateAccessible(preferences.app.accessMode, {
+ ...options,
+ fetchMenuListAsync: async () => {
+ ElMessage({
+ duration: 1500,
+ message: `${$t('common.loadingMenu')}...`,
+ });
+ return await getAllMenusApi();
+ },
+ // 可以指定没有权限跳转403页面
+ forbiddenComponent,
+ // 如果 route.meta.menuVisibleWithForbidden = true
+ layoutMap,
+ pageMap,
+ });
+}
+
+export { generateAccess };
diff --git a/apps/vben5/apps/web-ele/src/router/guard.ts b/apps/vben5/apps/web-ele/src/router/guard.ts
new file mode 100644
index 000000000..fce5a892c
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/router/guard.ts
@@ -0,0 +1,125 @@
+import type { Router } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+import { preferences } from '@vben/preferences';
+import { useAccessStore, useUserStore } from '@vben/stores';
+import { startProgress, stopProgress } from '@vben/utils';
+
+import { accessRoutes, coreRouteNames } from '#/router/routes';
+import { useAuthStore } from '#/store';
+
+import { generateAccess } from './access';
+
+/**
+ * 通用守卫配置
+ * @param router
+ */
+function setupCommonGuard(router: Router) {
+ // 记录已经加载的页面
+ const loadedPaths = new Set();
+
+ router.beforeEach(async (to) => {
+ to.meta.loaded = loadedPaths.has(to.path);
+
+ // 页面加载进度条
+ if (!to.meta.loaded && preferences.transition.progress) {
+ startProgress();
+ }
+ return true;
+ });
+
+ router.afterEach((to) => {
+ // 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
+
+ loadedPaths.add(to.path);
+
+ // 关闭页面加载进度条
+ if (preferences.transition.progress) {
+ stopProgress();
+ }
+ });
+}
+
+/**
+ * 权限访问守卫配置
+ * @param router
+ */
+function setupAccessGuard(router: Router) {
+ router.beforeEach(async (to, from) => {
+ const accessStore = useAccessStore();
+ const userStore = useUserStore();
+ const authStore = useAuthStore();
+
+ // 基本路由,这些路由不需要进入权限拦截
+ if (coreRouteNames.includes(to.name as string)) {
+ if (to.path === LOGIN_PATH && accessStore.accessToken) {
+ return decodeURIComponent(
+ (to.query?.redirect as string) || DEFAULT_HOME_PATH,
+ );
+ }
+ return true;
+ }
+
+ // accessToken 检查
+ if (!accessStore.accessToken) {
+ // 明确声明忽略权限访问权限,则可以访问
+ if (to.meta.ignoreAccess) {
+ return true;
+ }
+
+ // 没有访问权限,跳转登录页面
+ if (to.fullPath !== LOGIN_PATH) {
+ return {
+ path: LOGIN_PATH,
+ // 如不需要,直接删除 query
+ query: { redirect: encodeURIComponent(to.fullPath) },
+ // 携带当前跳转的页面,登录后重新跳转该页面
+ replace: true,
+ };
+ }
+ return to;
+ }
+
+ // 是否已经生成过动态路由
+ if (accessStore.isAccessChecked) {
+ return true;
+ }
+
+ // 生成路由表
+ // 当前登录用户拥有的角色标识列表
+ const userInfo = userStore.userInfo || (await authStore.fetchUserInfo());
+ const userRoles = userInfo.roles ?? [];
+
+ // 生成菜单和路由
+ const { accessibleMenus, accessibleRoutes } = await generateAccess({
+ roles: userRoles,
+ router,
+ // 则会在菜单中显示,但是访问会被重定向到403
+ routes: accessRoutes,
+ });
+
+ // 保存菜单信息和路由信息
+ accessStore.setAccessMenus(accessibleMenus);
+ accessStore.setAccessRoutes(accessibleRoutes);
+ accessStore.setIsAccessChecked(true);
+ const redirectPath = (from.query.redirect ?? to.fullPath) as string;
+
+ return {
+ ...router.resolve(decodeURIComponent(redirectPath)),
+ replace: true,
+ };
+ });
+}
+
+/**
+ * 项目守卫配置
+ * @param router
+ */
+function createRouterGuard(router: Router) {
+ /** 通用 */
+ setupCommonGuard(router);
+ /** 权限访问 */
+ setupAccessGuard(router);
+}
+
+export { createRouterGuard };
diff --git a/apps/vben5/apps/web-ele/src/router/index.ts b/apps/vben5/apps/web-ele/src/router/index.ts
new file mode 100644
index 000000000..484023034
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/router/index.ts
@@ -0,0 +1,37 @@
+import {
+ createRouter,
+ createWebHashHistory,
+ createWebHistory,
+} from 'vue-router';
+
+import { resetStaticRoutes } from '@vben/utils';
+
+import { createRouterGuard } from './guard';
+import { routes } from './routes';
+
+/**
+ * @zh_CN 创建vue-router实例
+ */
+const router = createRouter({
+ history:
+ import.meta.env.VITE_ROUTER_HISTORY === 'hash'
+ ? createWebHashHistory(import.meta.env.VITE_BASE)
+ : createWebHistory(import.meta.env.VITE_BASE),
+ // 应该添加到路由的初始路由列表。
+ routes,
+ scrollBehavior: (to, _from, savedPosition) => {
+ if (savedPosition) {
+ return savedPosition;
+ }
+ return to.hash ? { behavior: 'smooth', el: to.hash } : { left: 0, top: 0 };
+ },
+ // 是否应该禁止尾部斜杠。
+ // strict: true,
+});
+
+const resetRoutes = () => resetStaticRoutes(router, routes);
+
+// 创建路由守卫
+createRouterGuard(router);
+
+export { resetRoutes, router };
diff --git a/apps/vben5/apps/web-ele/src/router/routes/core.ts b/apps/vben5/apps/web-ele/src/router/routes/core.ts
new file mode 100644
index 000000000..fe030a9a2
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/router/routes/core.ts
@@ -0,0 +1,88 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+
+import { AuthPageLayout } from '#/layouts';
+import { $t } from '#/locales';
+import Login from '#/views/_core/authentication/login.vue';
+
+/** 全局404页面 */
+const fallbackNotFoundRoute: RouteRecordRaw = {
+ component: () => import('#/views/_core/fallback/not-found.vue'),
+ meta: {
+ hideInBreadcrumb: true,
+ hideInMenu: true,
+ hideInTab: true,
+ title: '404',
+ },
+ name: 'FallbackNotFound',
+ path: '/:path(.*)*',
+};
+
+/** 基本路由,这些路由是必须存在的 */
+const coreRoutes: RouteRecordRaw[] = [
+ {
+ meta: {
+ title: 'Root',
+ },
+ name: 'Root',
+ path: '/',
+ redirect: DEFAULT_HOME_PATH,
+ },
+ {
+ component: AuthPageLayout,
+ meta: {
+ hideInTab: true,
+ title: 'Authentication',
+ },
+ name: 'Authentication',
+ path: '/auth',
+ redirect: LOGIN_PATH,
+ children: [
+ {
+ name: 'Login',
+ path: 'login',
+ component: Login,
+ meta: {
+ title: $t('page.auth.login'),
+ },
+ },
+ {
+ name: 'CodeLogin',
+ path: 'code-login',
+ component: () => import('#/views/_core/authentication/code-login.vue'),
+ meta: {
+ title: $t('page.auth.codeLogin'),
+ },
+ },
+ {
+ name: 'QrCodeLogin',
+ path: 'qrcode-login',
+ component: () =>
+ import('#/views/_core/authentication/qrcode-login.vue'),
+ meta: {
+ title: $t('page.auth.qrcodeLogin'),
+ },
+ },
+ {
+ name: 'ForgetPassword',
+ path: 'forget-password',
+ component: () =>
+ import('#/views/_core/authentication/forget-password.vue'),
+ meta: {
+ title: $t('page.auth.forgetPassword'),
+ },
+ },
+ {
+ name: 'Register',
+ path: 'register',
+ component: () => import('#/views/_core/authentication/register.vue'),
+ meta: {
+ title: $t('page.auth.register'),
+ },
+ },
+ ],
+ },
+];
+
+export { coreRoutes, fallbackNotFoundRoute };
diff --git a/apps/vben5/apps/web-ele/src/router/routes/index.ts b/apps/vben5/apps/web-ele/src/router/routes/index.ts
new file mode 100644
index 000000000..e6fb14402
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/router/routes/index.ts
@@ -0,0 +1,37 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { mergeRouteModules, traverseTreeValues } from '@vben/utils';
+
+import { coreRoutes, fallbackNotFoundRoute } from './core';
+
+const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
+ eager: true,
+});
+
+// 有需要可以自行打开注释,并创建文件夹
+// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
+// const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true });
+
+/** 动态路由 */
+const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
+
+/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
+// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
+// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
+const staticRoutes: RouteRecordRaw[] = [];
+const externalRoutes: RouteRecordRaw[] = [];
+
+/** 路由列表,由基本路由、外部路由和404兜底路由组成
+ * 无需走权限验证(会一直显示在菜单中) */
+const routes: RouteRecordRaw[] = [
+ ...coreRoutes,
+ ...externalRoutes,
+ fallbackNotFoundRoute,
+];
+
+/** 基本路由列表,这些路由不需要进入权限拦截 */
+const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
+
+/** 有权限校验的路由列表,包含动态路由和静态路由 */
+const accessRoutes = [...dynamicRoutes, ...staticRoutes];
+export { accessRoutes, coreRouteNames, routes };
diff --git a/apps/vben5/apps/web-ele/src/router/routes/modules/dashboard.ts b/apps/vben5/apps/web-ele/src/router/routes/modules/dashboard.ts
new file mode 100644
index 000000000..1bddab9db
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/router/routes/modules/dashboard.ts
@@ -0,0 +1,40 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'lucide:layout-dashboard',
+ order: -1,
+ title: $t('page.dashboard.title'),
+ },
+ name: 'Dashboard',
+ path: '/',
+ children: [
+ {
+ name: 'Analytics',
+ path: '/analytics',
+ component: () => import('#/views/dashboard/analytics/index.vue'),
+ meta: {
+ affixTab: true,
+ icon: 'lucide:area-chart',
+ title: $t('page.dashboard.analytics'),
+ },
+ },
+ {
+ name: 'Workspace',
+ path: '/workspace',
+ component: () => import('#/views/dashboard/workspace/index.vue'),
+ meta: {
+ icon: 'carbon:workspace',
+ title: $t('page.dashboard.workspace'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/web-ele/src/router/routes/modules/demos.ts b/apps/vben5/apps/web-ele/src/router/routes/modules/demos.ts
new file mode 100644
index 000000000..223efcf9d
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/router/routes/modules/demos.ts
@@ -0,0 +1,30 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'ic:baseline-view-in-ar',
+ keepAlive: true,
+ order: 1000,
+ title: $t('demos.title'),
+ },
+ name: 'Demos',
+ path: '/demos',
+ children: [
+ {
+ meta: {
+ title: $t('demos.elementPlus'),
+ },
+ name: 'NaiveDemos',
+ path: '/demos/element',
+ component: () => import('#/views/demos/element/index.vue'),
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/web-ele/src/router/routes/modules/vben.ts b/apps/vben5/apps/web-ele/src/router/routes/modules/vben.ts
new file mode 100644
index 000000000..2cfef5498
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/router/routes/modules/vben.ts
@@ -0,0 +1,82 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import {
+ VBEN_ANT_PREVIEW_URL,
+ VBEN_DOC_URL,
+ VBEN_GITHUB_URL,
+ VBEN_LOGO_URL,
+ VBEN_NAIVE_PREVIEW_URL,
+} from '@vben/constants';
+import { SvgAntdvLogoIcon } from '@vben/icons';
+
+import { BasicLayout, IFrameView } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ badgeType: 'dot',
+ icon: VBEN_LOGO_URL,
+ order: 9999,
+ title: $t('demos.vben.title'),
+ },
+ name: 'VbenProject',
+ path: '/vben-admin',
+ children: [
+ {
+ name: 'VbenAbout',
+ path: '/vben-admin/about',
+ component: () => import('#/views/_core/about/index.vue'),
+ meta: {
+ icon: 'lucide:copyright',
+ title: $t('demos.vben.about'),
+ },
+ },
+ {
+ name: 'VbenDocument',
+ path: '/vben-admin/document',
+ component: IFrameView,
+ meta: {
+ icon: 'lucide:book-open-text',
+ link: VBEN_DOC_URL,
+ title: $t('demos.vben.document'),
+ },
+ },
+ {
+ name: 'VbenGithub',
+ path: '/vben-admin/github',
+ component: IFrameView,
+ meta: {
+ icon: 'mdi:github',
+ link: VBEN_GITHUB_URL,
+ title: 'Github',
+ },
+ },
+ {
+ name: 'VbenNaive',
+ path: '/vben-admin/naive',
+ component: IFrameView,
+ meta: {
+ badgeType: 'dot',
+ icon: 'logos:naiveui',
+ link: VBEN_NAIVE_PREVIEW_URL,
+ title: $t('demos.vben.naive-ui'),
+ },
+ },
+ {
+ name: 'VbenAntd',
+ path: '/vben-admin/antd',
+ component: IFrameView,
+ meta: {
+ badgeType: 'dot',
+ icon: SvgAntdvLogoIcon,
+ link: VBEN_ANT_PREVIEW_URL,
+ title: $t('demos.vben.antdv'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/web-ele/src/store/auth.ts b/apps/vben5/apps/web-ele/src/store/auth.ts
new file mode 100644
index 000000000..639fb0372
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/store/auth.ts
@@ -0,0 +1,116 @@
+import type { Recordable, UserInfo } from '@vben/types';
+
+import { ref } from 'vue';
+import { useRouter } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
+
+import { ElNotification } from 'element-plus';
+import { defineStore } from 'pinia';
+
+import { getAccessCodesApi, getUserInfoApi, loginApi, logoutApi } from '#/api';
+import { $t } from '#/locales';
+
+export const useAuthStore = defineStore('auth', () => {
+ const accessStore = useAccessStore();
+ const userStore = useUserStore();
+ const router = useRouter();
+
+ const loginLoading = ref(false);
+
+ /**
+ * 异步处理登录操作
+ * Asynchronously handle the login process
+ * @param params 登录表单数据
+ */
+ async function authLogin(
+ params: Recordable,
+ onSuccess?: () => Promise | void,
+ ) {
+ // 异步处理用户登录操作并获取 accessToken
+ let userInfo: null | UserInfo = null;
+ try {
+ loginLoading.value = true;
+ const { accessToken } = await loginApi(params);
+
+ // 如果成功获取到 accessToken
+ if (accessToken) {
+ // 将 accessToken 存储到 accessStore 中
+ accessStore.setAccessToken(accessToken);
+
+ // 获取用户信息并存储到 accessStore 中
+ const [fetchUserInfoResult, accessCodes] = await Promise.all([
+ fetchUserInfo(),
+ getAccessCodesApi(),
+ ]);
+
+ userInfo = fetchUserInfoResult;
+
+ userStore.setUserInfo(userInfo);
+ accessStore.setAccessCodes(accessCodes);
+
+ if (accessStore.loginExpired) {
+ accessStore.setLoginExpired(false);
+ } else {
+ onSuccess
+ ? await onSuccess?.()
+ : await router.push(userInfo.homePath || DEFAULT_HOME_PATH);
+ }
+
+ if (userInfo?.realName) {
+ ElNotification({
+ message: `${$t('authentication.loginSuccessDesc')}:${userInfo?.realName}`,
+ title: $t('authentication.loginSuccess'),
+ type: 'success',
+ });
+ }
+ }
+ } finally {
+ loginLoading.value = false;
+ }
+
+ return {
+ userInfo,
+ };
+ }
+
+ async function logout(redirect: boolean = true) {
+ try {
+ await logoutApi();
+ } catch {
+ // 不做任何处理
+ }
+ resetAllStores();
+ accessStore.setLoginExpired(false);
+
+ // 回登录页带上当前路由地址
+ await router.replace({
+ path: LOGIN_PATH,
+ query: redirect
+ ? {
+ redirect: encodeURIComponent(router.currentRoute.value.fullPath),
+ }
+ : {},
+ });
+ }
+
+ async function fetchUserInfo() {
+ let userInfo: null | UserInfo = null;
+ userInfo = await getUserInfoApi();
+ userStore.setUserInfo(userInfo);
+ return userInfo;
+ }
+
+ function $reset() {
+ loginLoading.value = false;
+ }
+
+ return {
+ $reset,
+ authLogin,
+ fetchUserInfo,
+ loginLoading,
+ logout,
+ };
+});
diff --git a/apps/vben5/apps/web-ele/src/store/index.ts b/apps/vben5/apps/web-ele/src/store/index.ts
new file mode 100644
index 000000000..269586ee8
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/store/index.ts
@@ -0,0 +1 @@
+export * from './auth';
diff --git a/apps/vben5/apps/web-ele/src/views/_core/README.md b/apps/vben5/apps/web-ele/src/views/_core/README.md
new file mode 100644
index 000000000..8248afe6c
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/README.md
@@ -0,0 +1,3 @@
+# \_core
+
+此目录包含应用程序正常运行所需的基本视图。这些视图是应用程序布局中使用的视图。
diff --git a/apps/vben5/apps/web-ele/src/views/_core/about/index.vue b/apps/vben5/apps/web-ele/src/views/_core/about/index.vue
new file mode 100644
index 000000000..0ee524335
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/about/index.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/authentication/code-login.vue b/apps/vben5/apps/web-ele/src/views/_core/authentication/code-login.vue
new file mode 100644
index 000000000..556b273af
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/authentication/code-login.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/authentication/forget-password.vue b/apps/vben5/apps/web-ele/src/views/_core/authentication/forget-password.vue
new file mode 100644
index 000000000..fef0d4279
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/authentication/forget-password.vue
@@ -0,0 +1,43 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/authentication/login.vue b/apps/vben5/apps/web-ele/src/views/_core/authentication/login.vue
new file mode 100644
index 000000000..099e4c8c0
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/authentication/login.vue
@@ -0,0 +1,98 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/authentication/qrcode-login.vue b/apps/vben5/apps/web-ele/src/views/_core/authentication/qrcode-login.vue
new file mode 100644
index 000000000..23f5f2dad
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/authentication/qrcode-login.vue
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/authentication/register.vue b/apps/vben5/apps/web-ele/src/views/_core/authentication/register.vue
new file mode 100644
index 000000000..b1a5de726
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/authentication/register.vue
@@ -0,0 +1,96 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/fallback/coming-soon.vue b/apps/vben5/apps/web-ele/src/views/_core/fallback/coming-soon.vue
new file mode 100644
index 000000000..f394930f2
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/fallback/coming-soon.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/fallback/forbidden.vue b/apps/vben5/apps/web-ele/src/views/_core/fallback/forbidden.vue
new file mode 100644
index 000000000..8ea65fedb
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/fallback/forbidden.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/fallback/internal-error.vue b/apps/vben5/apps/web-ele/src/views/_core/fallback/internal-error.vue
new file mode 100644
index 000000000..819a47d5e
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/fallback/internal-error.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/fallback/not-found.vue b/apps/vben5/apps/web-ele/src/views/_core/fallback/not-found.vue
new file mode 100644
index 000000000..4d178e9cb
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/fallback/not-found.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/_core/fallback/offline.vue b/apps/vben5/apps/web-ele/src/views/_core/fallback/offline.vue
new file mode 100644
index 000000000..5de4a88de
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/_core/fallback/offline.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-trends.vue b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-trends.vue
new file mode 100644
index 000000000..fadfc917c
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-trends.vue
@@ -0,0 +1,100 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits-data.vue b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits-data.vue
new file mode 100644
index 000000000..30c4265df
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits-data.vue
@@ -0,0 +1,84 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits-sales.vue b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits-sales.vue
new file mode 100644
index 000000000..260520b84
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits-sales.vue
@@ -0,0 +1,48 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits-source.vue b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits-source.vue
new file mode 100644
index 000000000..e0d0aab5e
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits-source.vue
@@ -0,0 +1,67 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits.vue b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits.vue
new file mode 100644
index 000000000..7e1f14ee6
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/analytics-visits.vue
@@ -0,0 +1,57 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/dashboard/analytics/index.vue b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/index.vue
new file mode 100644
index 000000000..00b34df1e
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/dashboard/analytics/index.vue
@@ -0,0 +1,90 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/dashboard/workspace/index.vue b/apps/vben5/apps/web-ele/src/views/dashboard/workspace/index.vue
new file mode 100644
index 000000000..b95d61381
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/dashboard/workspace/index.vue
@@ -0,0 +1,266 @@
+
+
+
+
+
+
+ 早安, {{ userStore.userInfo?.realName }}, 开始您一天的工作吧!
+
+ 今日晴,20℃ - 32℃!
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/src/views/demos/element/index.vue b/apps/vben5/apps/web-ele/src/views/demos/element/index.vue
new file mode 100644
index 000000000..55bc25713
--- /dev/null
+++ b/apps/vben5/apps/web-ele/src/views/demos/element/index.vue
@@ -0,0 +1,109 @@
+
+
+
+
+
+ 按钮
+
+ Text
+ Default
+ Primary
+ Info
+ Success
+ Warning
+ Error
+
+
+
+ Message
+
+ 信息
+ 错误
+ 警告
+ 成功
+
+
+
+ Notification
+
+ 信息
+ 错误
+ 警告
+ 成功
+
+
+
+ Segmented
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-ele/tailwind.config.mjs b/apps/vben5/apps/web-ele/tailwind.config.mjs
new file mode 100644
index 000000000..f17f556fa
--- /dev/null
+++ b/apps/vben5/apps/web-ele/tailwind.config.mjs
@@ -0,0 +1 @@
+export { default } from '@vben/tailwind-config';
diff --git a/apps/vben5/apps/web-ele/tsconfig.json b/apps/vben5/apps/web-ele/tsconfig.json
new file mode 100644
index 000000000..02c287fe6
--- /dev/null
+++ b/apps/vben5/apps/web-ele/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/web-app.json",
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "#/*": ["./src/*"]
+ }
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
+}
diff --git a/apps/vben5/apps/web-ele/tsconfig.node.json b/apps/vben5/apps/web-ele/tsconfig.node.json
new file mode 100644
index 000000000..c2f0d86cc
--- /dev/null
+++ b/apps/vben5/apps/web-ele/tsconfig.node.json
@@ -0,0 +1,10 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/node.json",
+ "compilerOptions": {
+ "composite": true,
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
+ "noEmit": false
+ },
+ "include": ["vite.config.mts"]
+}
diff --git a/apps/vben5/apps/web-ele/vite.config.mts b/apps/vben5/apps/web-ele/vite.config.mts
new file mode 100644
index 000000000..9f1e72353
--- /dev/null
+++ b/apps/vben5/apps/web-ele/vite.config.mts
@@ -0,0 +1,27 @@
+import { defineConfig } from '@vben/vite-config';
+
+import ElementPlus from 'unplugin-element-plus/vite';
+
+export default defineConfig(async () => {
+ return {
+ application: {},
+ vite: {
+ plugins: [
+ ElementPlus({
+ format: 'esm',
+ }),
+ ],
+ server: {
+ proxy: {
+ '/api': {
+ changeOrigin: true,
+ rewrite: (path) => path.replace(/^\/api/, ''),
+ // mock代理目标地址
+ target: 'http://localhost:5320/api',
+ ws: true,
+ },
+ },
+ },
+ },
+ };
+});
diff --git a/apps/vben5/apps/web-naive/.env b/apps/vben5/apps/web-naive/.env
new file mode 100644
index 000000000..350660c0e
--- /dev/null
+++ b/apps/vben5/apps/web-naive/.env
@@ -0,0 +1,5 @@
+# 应用标题
+VITE_APP_TITLE=Vben Admin Naive
+
+# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
+VITE_APP_NAMESPACE=vben-web-naive
diff --git a/apps/vben5/apps/web-naive/.env.analyze b/apps/vben5/apps/web-naive/.env.analyze
new file mode 100644
index 000000000..ffafa8dd5
--- /dev/null
+++ b/apps/vben5/apps/web-naive/.env.analyze
@@ -0,0 +1,7 @@
+# public path
+VITE_BASE=/
+
+# Basic interface address SPA
+VITE_GLOB_API_URL=/api
+
+VITE_VISUALIZER=true
diff --git a/apps/vben5/apps/web-naive/.env.development b/apps/vben5/apps/web-naive/.env.development
new file mode 100644
index 000000000..11c5254ae
--- /dev/null
+++ b/apps/vben5/apps/web-naive/.env.development
@@ -0,0 +1,16 @@
+# 端口号
+VITE_PORT=5888
+
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=/api
+
+# 是否开启 Nitro Mock服务,true 为开启,false 为关闭
+VITE_NITRO_MOCK=true
+
+# 是否打开 devtools,true 为打开,false 为关闭
+VITE_DEVTOOLS=false
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
diff --git a/apps/vben5/apps/web-naive/.env.production b/apps/vben5/apps/web-naive/.env.production
new file mode 100644
index 000000000..5375847a6
--- /dev/null
+++ b/apps/vben5/apps/web-naive/.env.production
@@ -0,0 +1,19 @@
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+
+# 是否开启压缩,可以设置为 none, brotli, gzip
+VITE_COMPRESS=none
+
+# 是否开启 PWA
+VITE_PWA=false
+
+# vue-router 的模式
+VITE_ROUTER_HISTORY=hash
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
+
+# 打包后是否生成dist.zip
+VITE_ARCHIVER=true
diff --git a/apps/vben5/apps/web-naive/index.html b/apps/vben5/apps/web-naive/index.html
new file mode 100644
index 000000000..7ea638418
--- /dev/null
+++ b/apps/vben5/apps/web-naive/index.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+ <%= VITE_APP_TITLE %>
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/package.json b/apps/vben5/apps/web-naive/package.json
new file mode 100644
index 000000000..0710c3415
--- /dev/null
+++ b/apps/vben5/apps/web-naive/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "@vben/web-naive",
+ "version": "5.4.8",
+ "homepage": "https://vben.pro",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "apps/web-naive"
+ },
+ "license": "MIT",
+ "author": {
+ "name": "vben",
+ "email": "ann.vben@gmail.com",
+ "url": "https://github.com/anncwb"
+ },
+ "type": "module",
+ "scripts": {
+ "build": "pnpm vite build --mode production",
+ "build:analyze": "pnpm vite build --mode analyze",
+ "dev": "pnpm vite --mode development",
+ "preview": "vite preview",
+ "typecheck": "vue-tsc --noEmit --skipLibCheck"
+ },
+ "imports": {
+ "#/*": "./src/*"
+ },
+ "dependencies": {
+ "@vben/access": "workspace:*",
+ "@vben/common-ui": "workspace:*",
+ "@vben/constants": "workspace:*",
+ "@vben/hooks": "workspace:*",
+ "@vben/icons": "workspace:*",
+ "@vben/layouts": "workspace:*",
+ "@vben/locales": "workspace:*",
+ "@vben/plugins": "workspace:*",
+ "@vben/preferences": "workspace:*",
+ "@vben/request": "workspace:*",
+ "@vben/stores": "workspace:*",
+ "@vben/styles": "workspace:*",
+ "@vben/types": "workspace:*",
+ "@vben/utils": "workspace:*",
+ "@vueuse/core": "catalog:",
+ "naive-ui": "catalog:",
+ "pinia": "catalog:",
+ "vue": "catalog:",
+ "vue-router": "catalog:"
+ }
+}
diff --git a/apps/vben5/apps/web-naive/postcss.config.mjs b/apps/vben5/apps/web-naive/postcss.config.mjs
new file mode 100644
index 000000000..3d8070455
--- /dev/null
+++ b/apps/vben5/apps/web-naive/postcss.config.mjs
@@ -0,0 +1 @@
+export { default } from '@vben/tailwind-config/postcss';
diff --git a/apps/vben5/apps/web-naive/public/favicon.ico b/apps/vben5/apps/web-naive/public/favicon.ico
new file mode 100644
index 000000000..fcf9818e2
Binary files /dev/null and b/apps/vben5/apps/web-naive/public/favicon.ico differ
diff --git a/apps/vben5/apps/web-naive/src/adapter/component/index.ts b/apps/vben5/apps/web-naive/src/adapter/component/index.ts
new file mode 100644
index 000000000..c5dffddb8
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/adapter/component/index.ts
@@ -0,0 +1,103 @@
+/**
+ * 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
+ * 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
+ */
+
+import type { BaseFormComponentType } from '@vben/common-ui';
+
+import type { Component, SetupContext } from 'vue';
+import { h } from 'vue';
+
+import { globalShareState } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+import {
+ NButton,
+ NCheckbox,
+ NCheckboxGroup,
+ NDatePicker,
+ NDivider,
+ NInput,
+ NInputNumber,
+ NRadioGroup,
+ NSelect,
+ NSpace,
+ NSwitch,
+ NTimePicker,
+ NTreeSelect,
+ NUpload,
+} from 'naive-ui';
+
+import { message } from '#/adapter/naive';
+
+const withDefaultPlaceholder = (
+ component: T,
+ type: 'input' | 'select',
+) => {
+ return (props: any, { attrs, slots }: Omit) => {
+ const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
+ return h(component, { ...props, ...attrs, placeholder }, slots);
+ };
+};
+
+// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
+export type ComponentType =
+ | 'Checkbox'
+ | 'CheckboxGroup'
+ | 'DatePicker'
+ | 'Divider'
+ | 'Input'
+ | 'InputNumber'
+ | 'RadioGroup'
+ | 'Select'
+ | 'Space'
+ | 'Switch'
+ | 'TimePicker'
+ | 'TreeSelect'
+ | 'Upload'
+ | BaseFormComponentType;
+
+async function initComponentAdapter() {
+ const components: Partial> = {
+ // 如果你的组件体积比较大,可以使用异步加载
+ // Button: () =>
+ // import('xxx').then((res) => res.Button),
+
+ Checkbox: NCheckbox,
+ CheckboxGroup: NCheckboxGroup,
+ DatePicker: NDatePicker,
+ // 自定义默认按钮
+ DefaultButton: (props, { attrs, slots }) => {
+ return h(NButton, { ...props, attrs, type: 'default' }, slots);
+ },
+ // 自定义主要按钮
+ PrimaryButton: (props, { attrs, slots }) => {
+ return h(NButton, { ...props, attrs, type: 'primary' }, slots);
+ },
+ Divider: NDivider,
+ Input: withDefaultPlaceholder(NInput, 'input'),
+ InputNumber: withDefaultPlaceholder(NInputNumber, 'input'),
+ RadioGroup: NRadioGroup,
+ Select: withDefaultPlaceholder(NSelect, 'select'),
+ Space: NSpace,
+ Switch: NSwitch,
+ TimePicker: NTimePicker,
+ TreeSelect: withDefaultPlaceholder(NTreeSelect, 'select'),
+ Upload: NUpload,
+ };
+
+ // 将组件注册到全局共享状态中
+ globalShareState.setComponents(components);
+
+ // 定义全局共享状态中的消息提示
+ globalShareState.defineMessage({
+ // 复制成功消息提示
+ copyPreferencesSuccess: (title, content) => {
+ message.success(content || title, {
+ duration: 0,
+ });
+ },
+ });
+}
+
+export { initComponentAdapter };
diff --git a/apps/vben5/apps/web-naive/src/adapter/form.ts b/apps/vben5/apps/web-naive/src/adapter/form.ts
new file mode 100644
index 000000000..2c3cee875
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/adapter/form.ts
@@ -0,0 +1,45 @@
+import type {
+ VbenFormSchema as FormSchema,
+ VbenFormProps,
+} from '@vben/common-ui';
+
+import type { ComponentType } from './component';
+
+import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+setupVbenForm({
+ config: {
+ // naive-ui组件不接受onChang事件,所以需要禁用
+ disabledOnChangeListener: true,
+ // naive-ui组件的空值为null,不能是undefined,否则重置表单时不生效
+ emptyStateValue: null,
+ baseModelPropName: 'value',
+ modelPropNameMap: {
+ Checkbox: 'checked',
+ Radio: 'checked',
+ Upload: 'fileList',
+ },
+ },
+ defineRules: {
+ required: (value, _params, ctx) => {
+ if (value === undefined || value === null || value.length === 0) {
+ return $t('ui.formRules.required', [ctx.label]);
+ }
+ return true;
+ },
+ selectRequired: (value, _params, ctx) => {
+ if (value === undefined || value === null) {
+ return $t('ui.formRules.selectRequired', [ctx.label]);
+ }
+ return true;
+ },
+ },
+});
+
+const useVbenForm = useForm;
+
+export { useVbenForm, z };
+
+export type VbenFormSchema = FormSchema;
+export type { VbenFormProps };
diff --git a/apps/vben5/apps/web-naive/src/adapter/naive.ts b/apps/vben5/apps/web-naive/src/adapter/naive.ts
new file mode 100644
index 000000000..1eb7b7b6e
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/adapter/naive.ts
@@ -0,0 +1,25 @@
+import { computed } from 'vue';
+
+import { preferences } from '@vben/preferences';
+import '@vben/styles';
+
+import { createDiscreteApi, darkTheme, lightTheme } from 'naive-ui';
+
+const themeOverridesProviderProps = computed(() => ({
+ themeOverrides: preferences.theme.mode === 'light' ? lightTheme : darkTheme,
+}));
+
+const themeProviderProps = computed(() => ({
+ theme: preferences.theme.mode === 'light' ? lightTheme : darkTheme,
+}));
+
+export const { dialog, loadingBar, message, modal, notification } =
+ createDiscreteApi(
+ ['message', 'dialog', 'notification', 'loadingBar', 'modal'],
+ {
+ configProviderProps: themeProviderProps,
+ loadingBarProviderProps: themeOverridesProviderProps,
+ messageProviderProps: themeOverridesProviderProps,
+ notificationProviderProps: themeOverridesProviderProps,
+ },
+ );
diff --git a/apps/vben5/apps/web-naive/src/adapter/vxe-table.ts b/apps/vben5/apps/web-naive/src/adapter/vxe-table.ts
new file mode 100644
index 000000000..081cfb29e
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/adapter/vxe-table.ts
@@ -0,0 +1,67 @@
+import { h } from 'vue';
+
+import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
+
+import { NButton, NImage } from 'naive-ui';
+
+import { useVbenForm } from './form';
+
+setupVbenVxeTable({
+ configVxeTable: (vxeUI) => {
+ vxeUI.setConfig({
+ grid: {
+ align: 'center',
+ border: false,
+ columnConfig: {
+ resizable: true,
+ },
+ minHeight: 180,
+ formConfig: {
+ // 全局禁用vxe-table的表单配置,使用formOptions
+ enabled: false,
+ },
+ proxyConfig: {
+ autoLoad: true,
+ response: {
+ result: 'items',
+ total: 'total',
+ list: 'items',
+ },
+ showActiveMsg: true,
+ showResponseMsg: false,
+ },
+ round: true,
+ showOverflow: true,
+ size: 'small',
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellImage' },
+ vxeUI.renderer.add('CellImage', {
+ renderTableDefault(_renderOpts, params) {
+ const { column, row } = params;
+ return h(NImage, { src: row[column.field] });
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellLink' },
+ vxeUI.renderer.add('CellLink', {
+ renderTableDefault(renderOpts) {
+ const { props } = renderOpts;
+ return h(
+ NButton,
+ { size: 'small', type: 'primary', quaternary: true },
+ { default: () => props?.text },
+ );
+ },
+ });
+
+ // 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
+ // vxeUI.formats.add
+ },
+ useVbenForm,
+});
+
+export { useVbenVxeGrid };
+
+export type * from '@vben/plugins/vxe-table';
diff --git a/apps/vben5/apps/web-naive/src/api/core/auth.ts b/apps/vben5/apps/web-naive/src/api/core/auth.ts
new file mode 100644
index 000000000..71d9f9943
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/api/core/auth.ts
@@ -0,0 +1,51 @@
+import { baseRequestClient, requestClient } from '#/api/request';
+
+export namespace AuthApi {
+ /** 登录接口参数 */
+ export interface LoginParams {
+ password?: string;
+ username?: string;
+ }
+
+ /** 登录接口返回值 */
+ export interface LoginResult {
+ accessToken: string;
+ }
+
+ export interface RefreshTokenResult {
+ data: string;
+ status: number;
+ }
+}
+
+/**
+ * 登录
+ */
+export async function loginApi(data: AuthApi.LoginParams) {
+ return requestClient.post('/auth/login', data);
+}
+
+/**
+ * 刷新accessToken
+ */
+export async function refreshTokenApi() {
+ return baseRequestClient.post('/auth/refresh', {
+ withCredentials: true,
+ });
+}
+
+/**
+ * 退出登录
+ */
+export async function logoutApi() {
+ return baseRequestClient.post('/auth/logout', {
+ withCredentials: true,
+ });
+}
+
+/**
+ * 获取用户权限码
+ */
+export async function getAccessCodesApi() {
+ return requestClient.get('/auth/codes');
+}
diff --git a/apps/vben5/apps/web-naive/src/api/core/index.ts b/apps/vben5/apps/web-naive/src/api/core/index.ts
new file mode 100644
index 000000000..28a5aef47
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/api/core/index.ts
@@ -0,0 +1,3 @@
+export * from './auth';
+export * from './menu';
+export * from './user';
diff --git a/apps/vben5/apps/web-naive/src/api/core/menu.ts b/apps/vben5/apps/web-naive/src/api/core/menu.ts
new file mode 100644
index 000000000..9ef60b11c
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/api/core/menu.ts
@@ -0,0 +1,10 @@
+import type { RouteRecordStringComponent } from '@vben/types';
+
+import { requestClient } from '#/api/request';
+
+/**
+ * 获取用户所有菜单
+ */
+export async function getAllMenusApi() {
+ return requestClient.get('/menu/all');
+}
diff --git a/apps/vben5/apps/web-naive/src/api/core/user.ts b/apps/vben5/apps/web-naive/src/api/core/user.ts
new file mode 100644
index 000000000..7e28ea848
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/api/core/user.ts
@@ -0,0 +1,10 @@
+import type { UserInfo } from '@vben/types';
+
+import { requestClient } from '#/api/request';
+
+/**
+ * 获取用户信息
+ */
+export async function getUserInfoApi() {
+ return requestClient.get('/user/info');
+}
diff --git a/apps/vben5/apps/web-naive/src/api/index.ts b/apps/vben5/apps/web-naive/src/api/index.ts
new file mode 100644
index 000000000..4b0e04137
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/api/index.ts
@@ -0,0 +1 @@
+export * from './core';
diff --git a/apps/vben5/apps/web-naive/src/api/request.ts b/apps/vben5/apps/web-naive/src/api/request.ts
new file mode 100644
index 000000000..72056e198
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/api/request.ts
@@ -0,0 +1,112 @@
+/**
+ * 该文件可自行根据业务逻辑进行调整
+ */
+import type { HttpResponse } from '@vben/request';
+
+import { useAppConfig } from '@vben/hooks';
+import { preferences } from '@vben/preferences';
+import {
+ authenticateResponseInterceptor,
+ errorMessageResponseInterceptor,
+ RequestClient,
+} from '@vben/request';
+import { useAccessStore } from '@vben/stores';
+
+import { message } from '#/adapter/naive';
+import { useAuthStore } from '#/store';
+
+import { refreshTokenApi } from './core';
+
+const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+
+function createRequestClient(baseURL: string) {
+ const client = new RequestClient({
+ baseURL,
+ });
+
+ /**
+ * 重新认证逻辑
+ */
+ async function doReAuthenticate() {
+ console.warn('Access token or refresh token is invalid or expired. ');
+ const accessStore = useAccessStore();
+ const authStore = useAuthStore();
+ accessStore.setAccessToken(null);
+ if (
+ preferences.app.loginExpiredMode === 'modal' &&
+ accessStore.isAccessChecked
+ ) {
+ accessStore.setLoginExpired(true);
+ } else {
+ await authStore.logout();
+ }
+ }
+
+ /**
+ * 刷新token逻辑
+ */
+ async function doRefreshToken() {
+ const accessStore = useAccessStore();
+ const resp = await refreshTokenApi();
+ const newToken = resp.data;
+ accessStore.setAccessToken(newToken);
+ return newToken;
+ }
+
+ function formatToken(token: null | string) {
+ return token ? `Bearer ${token}` : null;
+ }
+
+ // 请求头处理
+ client.addRequestInterceptor({
+ fulfilled: async (config) => {
+ const accessStore = useAccessStore();
+
+ config.headers.Authorization = formatToken(accessStore.accessToken);
+ config.headers['Accept-Language'] = preferences.app.locale;
+ return config;
+ },
+ });
+
+ // response数据解构
+ client.addResponseInterceptor({
+ fulfilled: (response) => {
+ const { data: responseData, status } = response;
+
+ const { code, data } = responseData;
+ if (status >= 200 && status < 400 && code === 0) {
+ return data;
+ }
+ throw Object.assign({}, response, { response });
+ },
+ });
+
+ // token过期的处理
+ client.addResponseInterceptor(
+ authenticateResponseInterceptor({
+ client,
+ doReAuthenticate,
+ doRefreshToken,
+ enableRefreshToken: preferences.app.enableRefreshToken,
+ formatToken,
+ }),
+ );
+
+ // 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
+ client.addResponseInterceptor(
+ errorMessageResponseInterceptor((msg: string, error) => {
+ // 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
+ // 当前mock接口返回的错误字段是 error 或者 message
+ const responseData = error?.response?.data ?? {};
+ const errorMessage = responseData?.error ?? responseData?.message ?? '';
+ // 如果没有错误信息,则会根据状态码进行提示
+ message.error(errorMessage || msg);
+ }),
+ );
+
+ return client;
+}
+
+export const requestClient = createRequestClient(apiURL);
+
+export const baseRequestClient = new RequestClient({ baseURL: apiURL });
diff --git a/apps/vben5/apps/web-naive/src/app.vue b/apps/vben5/apps/web-naive/src/app.vue
new file mode 100644
index 000000000..23983c55c
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/app.vue
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/bootstrap.ts b/apps/vben5/apps/web-naive/src/bootstrap.ts
new file mode 100644
index 000000000..fc7f961d6
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/bootstrap.ts
@@ -0,0 +1,46 @@
+import { createApp, watchEffect } from 'vue';
+
+import { registerAccessDirective } from '@vben/access';
+import { preferences } from '@vben/preferences';
+import { initStores } from '@vben/stores';
+import '@vben/styles';
+
+import { useTitle } from '@vueuse/core';
+
+import { $t, setupI18n } from '#/locales';
+
+import { initComponentAdapter } from './adapter/component';
+import App from './app.vue';
+import { router } from './router';
+
+async function bootstrap(namespace: string) {
+ // 初始化组件适配器
+ initComponentAdapter();
+ const app = createApp(App);
+
+ // 国际化 i18n 配置
+ await setupI18n(app);
+
+ // 配置 pinia-tore
+ await initStores(app, { namespace });
+
+ // 安装权限指令
+ registerAccessDirective(app);
+
+ // 配置路由及路由守卫
+ app.use(router);
+
+ // 动态更新标题
+ watchEffect(() => {
+ if (preferences.app.dynamicTitle) {
+ const routeTitle = router.currentRoute.value.meta?.title;
+ const pageTitle =
+ (routeTitle ? `${$t(routeTitle)} - ` : '') + preferences.app.name;
+ useTitle(pageTitle);
+ }
+ });
+
+ app.mount('#app');
+}
+
+export { bootstrap };
diff --git a/apps/vben5/apps/web-naive/src/layouts/auth.vue b/apps/vben5/apps/web-naive/src/layouts/auth.vue
new file mode 100644
index 000000000..18d415bc7
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/layouts/auth.vue
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/layouts/basic.vue b/apps/vben5/apps/web-naive/src/layouts/basic.vue
new file mode 100644
index 000000000..f75b3ddc6
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/layouts/basic.vue
@@ -0,0 +1,158 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/layouts/index.ts b/apps/vben5/apps/web-naive/src/layouts/index.ts
new file mode 100644
index 000000000..a43207805
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/layouts/index.ts
@@ -0,0 +1,6 @@
+const BasicLayout = () => import('./basic.vue');
+const AuthPageLayout = () => import('./auth.vue');
+
+const IFrameView = () => import('@vben/layouts').then((m) => m.IFrameView);
+
+export { AuthPageLayout, BasicLayout, IFrameView };
diff --git a/apps/vben5/apps/web-naive/src/locales/README.md b/apps/vben5/apps/web-naive/src/locales/README.md
new file mode 100644
index 000000000..7b451032e
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/locales/README.md
@@ -0,0 +1,3 @@
+# locale
+
+每个app使用的国际化可能不同,这里用于扩展国际化的功能,例如扩展 dayjs、antd组件库的多语言切换,以及app本身的国际化文件。
diff --git a/apps/vben5/apps/web-naive/src/locales/index.ts b/apps/vben5/apps/web-naive/src/locales/index.ts
new file mode 100644
index 000000000..3d77913ad
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/locales/index.ts
@@ -0,0 +1,38 @@
+import type { LocaleSetupOptions, SupportedLanguagesType } from '@vben/locales';
+
+import type { App } from 'vue';
+
+import {
+ $t,
+ setupI18n as coreSetup,
+ loadLocalesMapFromDir,
+} from '@vben/locales';
+import { preferences } from '@vben/preferences';
+
+const modules = import.meta.glob('./langs/**/*.json');
+
+const localesMap = loadLocalesMapFromDir(
+ /\.\/langs\/([^/]+)\/(.*)\.json$/,
+ modules,
+);
+
+/**
+ * 加载应用特有的语言包
+ * 这里也可以改造为从服务端获取翻译数据
+ * @param lang
+ */
+async function loadMessages(lang: SupportedLanguagesType) {
+ const appLocaleMessages = await localesMap[lang]?.();
+ return appLocaleMessages?.default;
+}
+
+async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
+ await coreSetup(app, {
+ defaultLocale: preferences.app.locale,
+ loadMessages,
+ missingWarn: !import.meta.env.PROD,
+ ...options,
+ });
+}
+
+export { $t, setupI18n };
diff --git a/apps/vben5/apps/web-naive/src/locales/langs/en-US/demos.json b/apps/vben5/apps/web-naive/src/locales/langs/en-US/demos.json
new file mode 100644
index 000000000..9fdffc765
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/locales/langs/en-US/demos.json
@@ -0,0 +1,13 @@
+{
+ "title": "Demos",
+ "naive": "Naive UI",
+ "table": "Table",
+ "vben": {
+ "title": "Project",
+ "about": "About",
+ "document": "Document",
+ "antdv": "Ant Design Vue Version",
+ "naive-ui": "Naive UI Version",
+ "element-plus": "Element Plus Version"
+ }
+}
diff --git a/apps/vben5/apps/web-naive/src/locales/langs/en-US/page.json b/apps/vben5/apps/web-naive/src/locales/langs/en-US/page.json
new file mode 100644
index 000000000..618a258c0
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/locales/langs/en-US/page.json
@@ -0,0 +1,14 @@
+{
+ "auth": {
+ "login": "Login",
+ "register": "Register",
+ "codeLogin": "Code Login",
+ "qrcodeLogin": "Qr Code Login",
+ "forgetPassword": "Forget Password"
+ },
+ "dashboard": {
+ "title": "Dashboard",
+ "analytics": "Analytics",
+ "workspace": "Workspace"
+ }
+}
diff --git a/apps/vben5/apps/web-naive/src/locales/langs/zh-CN/demos.json b/apps/vben5/apps/web-naive/src/locales/langs/zh-CN/demos.json
new file mode 100644
index 000000000..79b54fa21
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/locales/langs/zh-CN/demos.json
@@ -0,0 +1,13 @@
+{
+ "title": "演示",
+ "naive": "Naive UI",
+ "table": "Table",
+ "vben": {
+ "title": "项目",
+ "about": "关于",
+ "document": "文档",
+ "antdv": "Ant Design Vue 版本",
+ "naive-ui": "Naive UI 版本",
+ "element-plus": "Element Plus 版本"
+ }
+}
diff --git a/apps/vben5/apps/web-naive/src/locales/langs/zh-CN/page.json b/apps/vben5/apps/web-naive/src/locales/langs/zh-CN/page.json
new file mode 100644
index 000000000..4cb67081c
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/locales/langs/zh-CN/page.json
@@ -0,0 +1,14 @@
+{
+ "auth": {
+ "login": "登录",
+ "register": "注册",
+ "codeLogin": "验证码登录",
+ "qrcodeLogin": "二维码登录",
+ "forgetPassword": "忘记密码"
+ },
+ "dashboard": {
+ "title": "概览",
+ "analytics": "分析页",
+ "workspace": "工作台"
+ }
+}
diff --git a/apps/vben5/apps/web-naive/src/main.ts b/apps/vben5/apps/web-naive/src/main.ts
new file mode 100644
index 000000000..5d728a02a
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/main.ts
@@ -0,0 +1,31 @@
+import { initPreferences } from '@vben/preferences';
+import { unmountGlobalLoading } from '@vben/utils';
+
+import { overridesPreferences } from './preferences';
+
+/**
+ * 应用初始化完成之后再进行页面加载渲染
+ */
+async function initApplication() {
+ // name用于指定项目唯一标识
+ // 用于区分不同项目的偏好设置以及存储数据的key前缀以及其他一些需要隔离的数据
+ const env = import.meta.env.PROD ? 'prod' : 'dev';
+ const appVersion = import.meta.env.VITE_APP_VERSION;
+ const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${appVersion}-${env}`;
+
+ // app偏好设置初始化
+ await initPreferences({
+ namespace,
+ overrides: overridesPreferences,
+ });
+
+ // 启动应用并挂载
+ // vue应用主要逻辑及视图
+ const { bootstrap } = await import('./bootstrap');
+ await bootstrap(namespace);
+
+ // 移除并销毁loading
+ unmountGlobalLoading();
+}
+
+initApplication();
diff --git a/apps/vben5/apps/web-naive/src/preferences.ts b/apps/vben5/apps/web-naive/src/preferences.ts
new file mode 100644
index 000000000..b2e9ace43
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/preferences.ts
@@ -0,0 +1,13 @@
+import { defineOverridesPreferences } from '@vben/preferences';
+
+/**
+ * @description 项目配置文件
+ * 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置
+ * !!! 更改配置后请清空缓存,否则可能不生效
+ */
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ name: import.meta.env.VITE_APP_TITLE,
+ },
+});
diff --git a/apps/vben5/apps/web-naive/src/router/access.ts b/apps/vben5/apps/web-naive/src/router/access.ts
new file mode 100644
index 000000000..7a80bac09
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/router/access.ts
@@ -0,0 +1,40 @@
+import type {
+ ComponentRecordType,
+ GenerateMenuAndRoutesOptions,
+} from '@vben/types';
+
+import { generateAccessible } from '@vben/access';
+import { preferences } from '@vben/preferences';
+
+import { message } from '#/adapter/naive';
+import { getAllMenusApi } from '#/api';
+import { BasicLayout, IFrameView } from '#/layouts';
+import { $t } from '#/locales';
+
+const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
+
+async function generateAccess(options: GenerateMenuAndRoutesOptions) {
+ const pageMap: ComponentRecordType = import.meta.glob('../views/**/*.vue');
+
+ const layoutMap: ComponentRecordType = {
+ BasicLayout,
+ IFrameView,
+ };
+
+ return await generateAccessible(preferences.app.accessMode, {
+ ...options,
+ fetchMenuListAsync: async () => {
+ message.loading(`${$t('common.loadingMenu')}...`, {
+ duration: 1.5,
+ });
+ return await getAllMenusApi();
+ },
+ // 可以指定没有权限跳转403页面
+ forbiddenComponent,
+ // 如果 route.meta.menuVisibleWithForbidden = true
+ layoutMap,
+ pageMap,
+ });
+}
+
+export { generateAccess };
diff --git a/apps/vben5/apps/web-naive/src/router/guard.ts b/apps/vben5/apps/web-naive/src/router/guard.ts
new file mode 100644
index 000000000..c95d994ec
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/router/guard.ts
@@ -0,0 +1,124 @@
+import type { Router } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+import { preferences } from '@vben/preferences';
+import { useAccessStore, useUserStore } from '@vben/stores';
+import { startProgress, stopProgress } from '@vben/utils';
+
+import { accessRoutes, coreRouteNames } from '#/router/routes';
+import { useAuthStore } from '#/store';
+
+import { generateAccess } from './access';
+
+/**
+ * 通用守卫配置
+ * @param router
+ */
+function setupCommonGuard(router: Router) {
+ // 记录已经加载的页面
+ const loadedPaths = new Set();
+
+ router.beforeEach(async (to) => {
+ to.meta.loaded = loadedPaths.has(to.path);
+
+ // 页面加载进度条
+ if (!to.meta.loaded && preferences.transition.progress) {
+ startProgress();
+ }
+ return true;
+ });
+
+ router.afterEach((to) => {
+ // 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
+
+ loadedPaths.add(to.path);
+
+ // 关闭页面加载进度条
+ if (preferences.transition.progress) {
+ stopProgress();
+ }
+ });
+}
+
+/**
+ * 权限访问守卫配置
+ * @param router
+ */
+function setupAccessGuard(router: Router) {
+ router.beforeEach(async (to, from) => {
+ const accessStore = useAccessStore();
+ const userStore = useUserStore();
+ const authStore = useAuthStore();
+
+ // 基本路由,这些路由不需要进入权限拦截
+ if (coreRouteNames.includes(to.name as string)) {
+ if (to.path === LOGIN_PATH && accessStore.accessToken) {
+ return decodeURIComponent(
+ (to.query?.redirect as string) || DEFAULT_HOME_PATH,
+ );
+ }
+ return true;
+ }
+
+ // accessToken 检查
+ if (!accessStore.accessToken) {
+ // 明确声明忽略权限访问权限,则可以访问
+ if (to.meta.ignoreAccess) {
+ return true;
+ }
+
+ // 没有访问权限,跳转登录页面
+ if (to.fullPath !== LOGIN_PATH) {
+ return {
+ path: LOGIN_PATH,
+ // 如不需要,直接删除 query
+ query: { redirect: encodeURIComponent(to.fullPath) },
+ // 携带当前跳转的页面,登录后重新跳转该页面
+ replace: true,
+ };
+ }
+ return to;
+ }
+
+ // 是否已经生成过动态路由
+ if (accessStore.isAccessChecked) {
+ return true;
+ }
+ // 生成路由表
+ // 当前登录用户拥有的角色标识列表
+ const userInfo = userStore.userInfo || (await authStore.fetchUserInfo());
+ const userRoles = userInfo.roles ?? [];
+
+ // 生成菜单和路由
+ const { accessibleMenus, accessibleRoutes } = await generateAccess({
+ roles: userRoles,
+ router,
+ // 则会在菜单中显示,但是访问会被重定向到403
+ routes: accessRoutes,
+ });
+
+ // 保存菜单信息和路由信息
+ accessStore.setAccessMenus(accessibleMenus);
+ accessStore.setAccessRoutes(accessibleRoutes);
+ accessStore.setIsAccessChecked(true);
+ const redirectPath = (from.query.redirect ?? to.fullPath) as string;
+
+ return {
+ ...router.resolve(decodeURIComponent(redirectPath)),
+ replace: true,
+ };
+ });
+}
+
+/**
+ * 项目守卫配置
+ * @param router
+ */
+function createRouterGuard(router: Router) {
+ /** 通用 */
+ setupCommonGuard(router);
+ /** 权限访问 */
+ setupAccessGuard(router);
+}
+
+export { createRouterGuard };
diff --git a/apps/vben5/apps/web-naive/src/router/index.ts b/apps/vben5/apps/web-naive/src/router/index.ts
new file mode 100644
index 000000000..484023034
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/router/index.ts
@@ -0,0 +1,37 @@
+import {
+ createRouter,
+ createWebHashHistory,
+ createWebHistory,
+} from 'vue-router';
+
+import { resetStaticRoutes } from '@vben/utils';
+
+import { createRouterGuard } from './guard';
+import { routes } from './routes';
+
+/**
+ * @zh_CN 创建vue-router实例
+ */
+const router = createRouter({
+ history:
+ import.meta.env.VITE_ROUTER_HISTORY === 'hash'
+ ? createWebHashHistory(import.meta.env.VITE_BASE)
+ : createWebHistory(import.meta.env.VITE_BASE),
+ // 应该添加到路由的初始路由列表。
+ routes,
+ scrollBehavior: (to, _from, savedPosition) => {
+ if (savedPosition) {
+ return savedPosition;
+ }
+ return to.hash ? { behavior: 'smooth', el: to.hash } : { left: 0, top: 0 };
+ },
+ // 是否应该禁止尾部斜杠。
+ // strict: true,
+});
+
+const resetRoutes = () => resetStaticRoutes(router, routes);
+
+// 创建路由守卫
+createRouterGuard(router);
+
+export { resetRoutes, router };
diff --git a/apps/vben5/apps/web-naive/src/router/routes/core.ts b/apps/vben5/apps/web-naive/src/router/routes/core.ts
new file mode 100644
index 000000000..fe030a9a2
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/router/routes/core.ts
@@ -0,0 +1,88 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+
+import { AuthPageLayout } from '#/layouts';
+import { $t } from '#/locales';
+import Login from '#/views/_core/authentication/login.vue';
+
+/** 全局404页面 */
+const fallbackNotFoundRoute: RouteRecordRaw = {
+ component: () => import('#/views/_core/fallback/not-found.vue'),
+ meta: {
+ hideInBreadcrumb: true,
+ hideInMenu: true,
+ hideInTab: true,
+ title: '404',
+ },
+ name: 'FallbackNotFound',
+ path: '/:path(.*)*',
+};
+
+/** 基本路由,这些路由是必须存在的 */
+const coreRoutes: RouteRecordRaw[] = [
+ {
+ meta: {
+ title: 'Root',
+ },
+ name: 'Root',
+ path: '/',
+ redirect: DEFAULT_HOME_PATH,
+ },
+ {
+ component: AuthPageLayout,
+ meta: {
+ hideInTab: true,
+ title: 'Authentication',
+ },
+ name: 'Authentication',
+ path: '/auth',
+ redirect: LOGIN_PATH,
+ children: [
+ {
+ name: 'Login',
+ path: 'login',
+ component: Login,
+ meta: {
+ title: $t('page.auth.login'),
+ },
+ },
+ {
+ name: 'CodeLogin',
+ path: 'code-login',
+ component: () => import('#/views/_core/authentication/code-login.vue'),
+ meta: {
+ title: $t('page.auth.codeLogin'),
+ },
+ },
+ {
+ name: 'QrCodeLogin',
+ path: 'qrcode-login',
+ component: () =>
+ import('#/views/_core/authentication/qrcode-login.vue'),
+ meta: {
+ title: $t('page.auth.qrcodeLogin'),
+ },
+ },
+ {
+ name: 'ForgetPassword',
+ path: 'forget-password',
+ component: () =>
+ import('#/views/_core/authentication/forget-password.vue'),
+ meta: {
+ title: $t('page.auth.forgetPassword'),
+ },
+ },
+ {
+ name: 'Register',
+ path: 'register',
+ component: () => import('#/views/_core/authentication/register.vue'),
+ meta: {
+ title: $t('page.auth.register'),
+ },
+ },
+ ],
+ },
+];
+
+export { coreRoutes, fallbackNotFoundRoute };
diff --git a/apps/vben5/apps/web-naive/src/router/routes/index.ts b/apps/vben5/apps/web-naive/src/router/routes/index.ts
new file mode 100644
index 000000000..e6fb14402
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/router/routes/index.ts
@@ -0,0 +1,37 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { mergeRouteModules, traverseTreeValues } from '@vben/utils';
+
+import { coreRoutes, fallbackNotFoundRoute } from './core';
+
+const dynamicRouteFiles = import.meta.glob('./modules/**/*.ts', {
+ eager: true,
+});
+
+// 有需要可以自行打开注释,并创建文件夹
+// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true });
+// const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true });
+
+/** 动态路由 */
+const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
+
+/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
+// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
+// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
+const staticRoutes: RouteRecordRaw[] = [];
+const externalRoutes: RouteRecordRaw[] = [];
+
+/** 路由列表,由基本路由、外部路由和404兜底路由组成
+ * 无需走权限验证(会一直显示在菜单中) */
+const routes: RouteRecordRaw[] = [
+ ...coreRoutes,
+ ...externalRoutes,
+ fallbackNotFoundRoute,
+];
+
+/** 基本路由列表,这些路由不需要进入权限拦截 */
+const coreRouteNames = traverseTreeValues(coreRoutes, (route) => route.name);
+
+/** 有权限校验的路由列表,包含动态路由和静态路由 */
+const accessRoutes = [...dynamicRoutes, ...staticRoutes];
+export { accessRoutes, coreRouteNames, routes };
diff --git a/apps/vben5/apps/web-naive/src/router/routes/modules/dashboard.ts b/apps/vben5/apps/web-naive/src/router/routes/modules/dashboard.ts
new file mode 100644
index 000000000..1bddab9db
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/router/routes/modules/dashboard.ts
@@ -0,0 +1,40 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'lucide:layout-dashboard',
+ order: -1,
+ title: $t('page.dashboard.title'),
+ },
+ name: 'Dashboard',
+ path: '/',
+ children: [
+ {
+ name: 'Analytics',
+ path: '/analytics',
+ component: () => import('#/views/dashboard/analytics/index.vue'),
+ meta: {
+ affixTab: true,
+ icon: 'lucide:area-chart',
+ title: $t('page.dashboard.analytics'),
+ },
+ },
+ {
+ name: 'Workspace',
+ path: '/workspace',
+ component: () => import('#/views/dashboard/workspace/index.vue'),
+ meta: {
+ icon: 'carbon:workspace',
+ title: $t('page.dashboard.workspace'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/web-naive/src/router/routes/modules/demos.ts b/apps/vben5/apps/web-naive/src/router/routes/modules/demos.ts
new file mode 100644
index 000000000..cf5658800
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/router/routes/modules/demos.ts
@@ -0,0 +1,38 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'ic:baseline-view-in-ar',
+ keepAlive: true,
+ order: 1000,
+ title: $t('demos.title'),
+ },
+ name: 'Demos',
+ path: '/demos',
+ children: [
+ {
+ meta: {
+ title: $t('demos.naive'),
+ },
+ name: 'NaiveDemos',
+ path: '/demos/naive',
+ component: () => import('#/views/demos/naive/index.vue'),
+ },
+ {
+ meta: {
+ title: $t('demos.table'),
+ },
+ name: 'Table',
+ path: '/demos/table',
+ component: () => import('#/views/demos/table/index.vue'),
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/web-naive/src/router/routes/modules/vben.ts b/apps/vben5/apps/web-naive/src/router/routes/modules/vben.ts
new file mode 100644
index 000000000..44461a7fd
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/router/routes/modules/vben.ts
@@ -0,0 +1,82 @@
+import type { RouteRecordRaw } from 'vue-router';
+
+import {
+ VBEN_ANT_PREVIEW_URL,
+ VBEN_DOC_URL,
+ VBEN_ELE_PREVIEW_URL,
+ VBEN_GITHUB_URL,
+ VBEN_LOGO_URL,
+} from '@vben/constants';
+import { SvgAntdvLogoIcon } from '@vben/icons';
+
+import { BasicLayout, IFrameView } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ badgeType: 'dot',
+ icon: VBEN_LOGO_URL,
+ order: 9999,
+ title: $t('demos.vben.title'),
+ },
+ name: 'VbenProject',
+ path: '/vben-admin',
+ children: [
+ {
+ name: 'VbenAbout',
+ path: '/vben-admin/about',
+ component: () => import('#/views/_core/about/index.vue'),
+ meta: {
+ icon: 'lucide:copyright',
+ title: $t('demos.vben.about'),
+ },
+ },
+ {
+ name: 'VbenDocument',
+ path: '/vben-admin/document',
+ component: IFrameView,
+ meta: {
+ icon: 'lucide:book-open-text',
+ link: VBEN_DOC_URL,
+ title: $t('demos.vben.document'),
+ },
+ },
+ {
+ name: 'VbenGithub',
+ path: '/vben-admin/github',
+ component: IFrameView,
+ meta: {
+ icon: 'mdi:github',
+ link: VBEN_GITHUB_URL,
+ title: 'Github',
+ },
+ },
+ {
+ name: 'VbenAntd',
+ path: '/vben-admin/antd',
+ component: IFrameView,
+ meta: {
+ badgeType: 'dot',
+ icon: SvgAntdvLogoIcon,
+ link: VBEN_ANT_PREVIEW_URL,
+ title: $t('demos.vben.antdv'),
+ },
+ },
+ {
+ name: 'VbenElementPlus',
+ path: '/vben-admin/ele',
+ component: IFrameView,
+ meta: {
+ badgeType: 'dot',
+ icon: 'logos:element',
+ link: VBEN_ELE_PREVIEW_URL,
+ title: $t('demos.vben.element-plus'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
diff --git a/apps/vben5/apps/web-naive/src/store/auth.ts b/apps/vben5/apps/web-naive/src/store/auth.ts
new file mode 100644
index 000000000..20aac5622
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/store/auth.ts
@@ -0,0 +1,116 @@
+import type { Recordable, UserInfo } from '@vben/types';
+
+import { ref } from 'vue';
+import { useRouter } from 'vue-router';
+
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
+import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
+
+import { defineStore } from 'pinia';
+
+import { notification } from '#/adapter/naive';
+import { getAccessCodesApi, getUserInfoApi, loginApi, logoutApi } from '#/api';
+import { $t } from '#/locales';
+
+export const useAuthStore = defineStore('auth', () => {
+ const accessStore = useAccessStore();
+ const userStore = useUserStore();
+ const router = useRouter();
+
+ const loginLoading = ref(false);
+
+ /**
+ * 异步处理登录操作
+ * Asynchronously handle the login process
+ * @param params 登录表单数据
+ */
+ async function authLogin(
+ params: Recordable,
+ onSuccess?: () => Promise | void,
+ ) {
+ // 异步处理用户登录操作并获取 accessToken
+ let userInfo: null | UserInfo = null;
+ try {
+ loginLoading.value = true;
+ const { accessToken } = await loginApi(params);
+
+ // 如果成功获取到 accessToken
+ if (accessToken) {
+ // 将 accessToken 存储到 accessStore 中
+ accessStore.setAccessToken(accessToken);
+
+ // 获取用户信息并存储到 accessStore 中
+ const [fetchUserInfoResult, accessCodes] = await Promise.all([
+ fetchUserInfo(),
+ getAccessCodesApi(),
+ ]);
+
+ userInfo = fetchUserInfoResult;
+
+ userStore.setUserInfo(userInfo);
+ accessStore.setAccessCodes(accessCodes);
+
+ if (accessStore.loginExpired) {
+ accessStore.setLoginExpired(false);
+ } else {
+ onSuccess
+ ? await onSuccess?.()
+ : await router.push(userInfo.homePath || DEFAULT_HOME_PATH);
+ }
+
+ if (userInfo?.realName) {
+ notification.success({
+ content: $t('authentication.loginSuccess'),
+ description: `${$t('authentication.loginSuccessDesc')}:${userInfo?.realName}`,
+ duration: 3000,
+ });
+ }
+ }
+ } finally {
+ loginLoading.value = false;
+ }
+
+ return {
+ userInfo,
+ };
+ }
+
+ async function logout(redirect: boolean = true) {
+ try {
+ await logoutApi();
+ } catch {
+ // 不做任何处理
+ }
+ resetAllStores();
+ accessStore.setLoginExpired(false);
+
+ // 回登录页带上当前路由地址
+ await router.replace({
+ path: LOGIN_PATH,
+ query: redirect
+ ? {
+ redirect: encodeURIComponent(router.currentRoute.value.fullPath),
+ }
+ : {},
+ });
+ }
+
+ async function fetchUserInfo() {
+ let userInfo: null | UserInfo = null;
+ userInfo = await getUserInfoApi();
+ userStore.setUserInfo(userInfo);
+ return userInfo;
+ }
+
+ function $reset() {
+ loginLoading.value = false;
+ }
+
+ return {
+ $reset,
+ authLogin,
+ fetchUserInfo,
+ loginLoading,
+ logout,
+ };
+});
diff --git a/apps/vben5/apps/web-naive/src/store/index.ts b/apps/vben5/apps/web-naive/src/store/index.ts
new file mode 100644
index 000000000..269586ee8
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/store/index.ts
@@ -0,0 +1 @@
+export * from './auth';
diff --git a/apps/vben5/apps/web-naive/src/views/_core/README.md b/apps/vben5/apps/web-naive/src/views/_core/README.md
new file mode 100644
index 000000000..8248afe6c
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/README.md
@@ -0,0 +1,3 @@
+# \_core
+
+此目录包含应用程序正常运行所需的基本视图。这些视图是应用程序布局中使用的视图。
diff --git a/apps/vben5/apps/web-naive/src/views/_core/about/index.vue b/apps/vben5/apps/web-naive/src/views/_core/about/index.vue
new file mode 100644
index 000000000..0ee524335
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/about/index.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/authentication/code-login.vue b/apps/vben5/apps/web-naive/src/views/_core/authentication/code-login.vue
new file mode 100644
index 000000000..556b273af
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/authentication/code-login.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/authentication/forget-password.vue b/apps/vben5/apps/web-naive/src/views/_core/authentication/forget-password.vue
new file mode 100644
index 000000000..fef0d4279
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/authentication/forget-password.vue
@@ -0,0 +1,43 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/authentication/login.vue b/apps/vben5/apps/web-naive/src/views/_core/authentication/login.vue
new file mode 100644
index 000000000..099e4c8c0
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/authentication/login.vue
@@ -0,0 +1,98 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/authentication/qrcode-login.vue b/apps/vben5/apps/web-naive/src/views/_core/authentication/qrcode-login.vue
new file mode 100644
index 000000000..23f5f2dad
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/authentication/qrcode-login.vue
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/authentication/register.vue b/apps/vben5/apps/web-naive/src/views/_core/authentication/register.vue
new file mode 100644
index 000000000..daf89c447
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/authentication/register.vue
@@ -0,0 +1,96 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/fallback/coming-soon.vue b/apps/vben5/apps/web-naive/src/views/_core/fallback/coming-soon.vue
new file mode 100644
index 000000000..f394930f2
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/fallback/coming-soon.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/fallback/forbidden.vue b/apps/vben5/apps/web-naive/src/views/_core/fallback/forbidden.vue
new file mode 100644
index 000000000..8ea65fedb
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/fallback/forbidden.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/fallback/internal-error.vue b/apps/vben5/apps/web-naive/src/views/_core/fallback/internal-error.vue
new file mode 100644
index 000000000..819a47d5e
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/fallback/internal-error.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/fallback/not-found.vue b/apps/vben5/apps/web-naive/src/views/_core/fallback/not-found.vue
new file mode 100644
index 000000000..4d178e9cb
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/fallback/not-found.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/_core/fallback/offline.vue b/apps/vben5/apps/web-naive/src/views/_core/fallback/offline.vue
new file mode 100644
index 000000000..5de4a88de
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/_core/fallback/offline.vue
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-trends.vue b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-trends.vue
new file mode 100644
index 000000000..fadfc917c
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-trends.vue
@@ -0,0 +1,100 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits-data.vue b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits-data.vue
new file mode 100644
index 000000000..30c4265df
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits-data.vue
@@ -0,0 +1,84 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits-sales.vue b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits-sales.vue
new file mode 100644
index 000000000..260520b84
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits-sales.vue
@@ -0,0 +1,48 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits-source.vue b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits-source.vue
new file mode 100644
index 000000000..e0d0aab5e
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits-source.vue
@@ -0,0 +1,67 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits.vue b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits.vue
new file mode 100644
index 000000000..7e1f14ee6
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/analytics-visits.vue
@@ -0,0 +1,57 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/dashboard/analytics/index.vue b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/index.vue
new file mode 100644
index 000000000..00b34df1e
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/dashboard/analytics/index.vue
@@ -0,0 +1,90 @@
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/dashboard/workspace/index.vue b/apps/vben5/apps/web-naive/src/views/dashboard/workspace/index.vue
new file mode 100644
index 000000000..b95d61381
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/dashboard/workspace/index.vue
@@ -0,0 +1,266 @@
+
+
+
+
+
+
+ 早安, {{ userStore.userInfo?.realName }}, 开始您一天的工作吧!
+
+ 今日晴,20℃ - 32℃!
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/demos/naive/index.vue b/apps/vben5/apps/web-naive/src/views/demos/naive/index.vue
new file mode 100644
index 000000000..41d55109e
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/demos/naive/index.vue
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+ Default
+ Tertiary
+ Primary
+ Info
+ Success
+ Warning
+ Error
+
+
+
+
+
+ 错误
+ 警告
+ 成功
+ 加载中
+
+
+
+
+
+ 错误
+ 警告
+ 成功
+ 加载中
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/src/views/demos/table/index.vue b/apps/vben5/apps/web-naive/src/views/demos/table/index.vue
new file mode 100644
index 000000000..ddc958bc3
--- /dev/null
+++ b/apps/vben5/apps/web-naive/src/views/demos/table/index.vue
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/apps/web-naive/tailwind.config.mjs b/apps/vben5/apps/web-naive/tailwind.config.mjs
new file mode 100644
index 000000000..f17f556fa
--- /dev/null
+++ b/apps/vben5/apps/web-naive/tailwind.config.mjs
@@ -0,0 +1 @@
+export { default } from '@vben/tailwind-config';
diff --git a/apps/vben5/apps/web-naive/tsconfig.json b/apps/vben5/apps/web-naive/tsconfig.json
new file mode 100644
index 000000000..02c287fe6
--- /dev/null
+++ b/apps/vben5/apps/web-naive/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/web-app.json",
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "#/*": ["./src/*"]
+ }
+ },
+ "references": [{ "path": "./tsconfig.node.json" }],
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
+}
diff --git a/apps/vben5/apps/web-naive/tsconfig.node.json b/apps/vben5/apps/web-naive/tsconfig.node.json
new file mode 100644
index 000000000..c2f0d86cc
--- /dev/null
+++ b/apps/vben5/apps/web-naive/tsconfig.node.json
@@ -0,0 +1,10 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/node.json",
+ "compilerOptions": {
+ "composite": true,
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
+ "noEmit": false
+ },
+ "include": ["vite.config.mts"]
+}
diff --git a/apps/vben5/apps/web-naive/vite.config.mts b/apps/vben5/apps/web-naive/vite.config.mts
new file mode 100644
index 000000000..b6360f1d4
--- /dev/null
+++ b/apps/vben5/apps/web-naive/vite.config.mts
@@ -0,0 +1,20 @@
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ application: {},
+ vite: {
+ server: {
+ proxy: {
+ '/api': {
+ changeOrigin: true,
+ rewrite: (path) => path.replace(/^\/api/, ''),
+ // mock代理目标地址
+ target: 'http://localhost:5320/api',
+ ws: true,
+ },
+ },
+ },
+ },
+ };
+});
diff --git a/apps/vben5/cspell.json b/apps/vben5/cspell.json
new file mode 100644
index 000000000..89545b432
--- /dev/null
+++ b/apps/vben5/cspell.json
@@ -0,0 +1,68 @@
+{
+ "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
+ "version": "0.2",
+ "language": "en,en-US",
+ "allowCompoundWords": true,
+ "words": [
+ "acmr",
+ "antd",
+ "antdv",
+ "astro",
+ "brotli",
+ "clsx",
+ "defu",
+ "demi",
+ "echarts",
+ "ependencies",
+ "esno",
+ "etag",
+ "execa",
+ "iconify",
+ "iconoir",
+ "intlify",
+ "lockb",
+ "lucide",
+ "minh",
+ "minw",
+ "mkdist",
+ "mockjs",
+ "naiveui",
+ "nocheck",
+ "noopener",
+ "noreferrer",
+ "nprogress",
+ "nuxt",
+ "pinia",
+ "prefixs",
+ "publint",
+ "qrcode",
+ "shadcn",
+ "sonner",
+ "sortablejs",
+ "styl",
+ "taze",
+ "ui-kit",
+ "uicons",
+ "unplugin",
+ "unref",
+ "vben",
+ "vbenjs",
+ "vite",
+ "vitejs",
+ "vitepress",
+ "vnode",
+ "vueuse",
+ "yxxx"
+ ],
+ "ignorePaths": [
+ "**/node_modules/**",
+ "**/dist/**",
+ "**/*-dist/**",
+ "**/icons/**",
+ "pnpm-lock.yaml",
+ "**/*.log",
+ "**/*.test.ts",
+ "**/*.spec.ts",
+ "**/__tests__/**"
+ ]
+}
diff --git a/apps/vben5/docs/.vitepress/components/demo-preview.vue b/apps/vben5/docs/.vitepress/components/demo-preview.vue
new file mode 100644
index 000000000..4c8829f88
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/components/demo-preview.vue
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+ ERROR:
+
+ The preview directory does not exist. Please check the 'dir'
+ parameter.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/.vitepress/components/index.ts b/apps/vben5/docs/.vitepress/components/index.ts
new file mode 100644
index 000000000..9430871e6
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/components/index.ts
@@ -0,0 +1 @@
+export { default as DemoPreview } from './demo-preview.vue';
diff --git a/apps/vben5/docs/.vitepress/components/preview-group.vue b/apps/vben5/docs/.vitepress/components/preview-group.vue
new file mode 100644
index 000000000..c8c6e83c7
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/components/preview-group.vue
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ tab.label }}
+
+
+
+
+
+
+
+
+
+ {{ open ? 'Collapse code' : 'Expand code' }}
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/.vitepress/config/en.mts b/apps/vben5/docs/.vitepress/config/en.mts
new file mode 100644
index 000000000..3f7dd4fa8
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/config/en.mts
@@ -0,0 +1,229 @@
+import { type DefaultTheme, defineConfig } from 'vitepress';
+
+import { version } from '../../../package.json';
+
+export const en = defineConfig({
+ description: 'Vben Admin & Enterprise level management system framework',
+ lang: 'en-US',
+ themeConfig: {
+ darkModeSwitchLabel: 'Theme',
+ darkModeSwitchTitle: 'Switch to Dark Mode',
+ docFooter: {
+ next: 'Next Page',
+ prev: 'Previous Page',
+ },
+ editLink: {
+ pattern:
+ 'https://github.com/vbenjs/vue-vben-admin/edit/main/docs/src/:path',
+ text: 'Edit this page on GitHub',
+ },
+ footer: {
+ copyright: `Copyright © 2020-${new Date().getFullYear()} Vben`,
+ message: 'Released under the MIT License.',
+ },
+ langMenuLabel: 'Language',
+ lastUpdated: {
+ formatOptions: {
+ dateStyle: 'short',
+ timeStyle: 'medium',
+ },
+ text: 'Last updated on',
+ },
+ lightModeSwitchTitle: 'Switch to Light Mode',
+ nav: nav(),
+ outline: {
+ label: 'Navigate',
+ },
+ returnToTopLabel: 'Back to top',
+ sidebar: {
+ '/en/commercial/': {
+ base: '/en/commercial/',
+ items: sidebarCommercial(),
+ },
+ '/en/guide/': { base: '/en/guide/', items: sidebarGuide() },
+ },
+ },
+});
+
+function sidebarGuide(): DefaultTheme.SidebarItem[] {
+ return [
+ {
+ collapsed: false,
+ text: 'Introduction',
+ items: [
+ {
+ link: 'introduction/vben',
+ text: 'About Vben Admin',
+ },
+ {
+ link: 'introduction/why',
+ text: 'Why Choose Us?',
+ },
+ { link: 'introduction/quick-start', text: 'Quick Start' },
+ { link: 'introduction/thin', text: 'Lite Version' },
+ ],
+ },
+ {
+ text: 'Basics',
+ items: [
+ { link: 'essentials/concept', text: 'Basic Concepts' },
+ { link: 'essentials/development', text: 'Local Development' },
+ { link: 'essentials/route', text: 'Routing and Menu' },
+ { link: 'essentials/settings', text: 'Configuration' },
+ { link: 'essentials/icons', text: 'Icons' },
+ { link: 'essentials/styles', text: 'Styles' },
+ { link: 'essentials/external-module', text: 'External Modules' },
+ { link: 'essentials/build', text: 'Build and Deployment' },
+ { link: 'essentials/server', text: 'Server Interaction and Data Mock' },
+ ],
+ },
+ {
+ text: 'Advanced',
+ items: [
+ { link: 'in-depth/login', text: 'Login' },
+ { link: 'in-depth/theme', text: 'Theme' },
+ { link: 'in-depth/access', text: 'Access Control' },
+ { link: 'in-depth/locale', text: 'Internationalization' },
+ { link: 'in-depth/features', text: 'Common Features' },
+ { link: 'in-depth/check-updates', text: 'Check Updates' },
+ { link: 'in-depth/loading', text: 'Global Loading' },
+ { link: 'in-depth/ui-framework', text: 'UI Framework Switching' },
+ ],
+ },
+ {
+ text: 'Engineering',
+ items: [
+ { link: 'project/standard', text: 'Standards' },
+ { link: 'project/cli', text: 'CLI' },
+ { link: 'project/dir', text: 'Directory Explanation' },
+ { link: 'project/test', text: 'Unit Testing' },
+ { link: 'project/tailwindcss', text: 'Tailwind CSS' },
+ { link: 'project/changeset', text: 'Changeset' },
+ { link: 'project/vite', text: 'Vite Config' },
+ ],
+ },
+ {
+ text: 'Others',
+ items: [
+ { link: 'other/project-update', text: 'Project Update' },
+ { link: 'other/remove-code', text: 'Remove Code' },
+ { link: 'other/faq', text: 'FAQ' },
+ ],
+ },
+ ];
+}
+
+function sidebarCommercial(): DefaultTheme.SidebarItem[] {
+ return [
+ {
+ link: 'community',
+ text: 'Community',
+ },
+ {
+ link: 'technical-support',
+ text: 'Technical-support',
+ },
+ {
+ link: 'customized',
+ text: 'Customized',
+ },
+ ];
+}
+
+function nav(): DefaultTheme.NavItem[] {
+ return [
+ {
+ activeMatch: '^/en/(guide|components)/',
+ text: 'Doc',
+ items: [
+ {
+ activeMatch: '^/en/guide/',
+ link: '/en/guide/introduction/vben',
+ text: 'Guide',
+ },
+ // {
+ // activeMatch: '^/en/components/',
+ // link: '/en/components/introduction',
+ // text: 'Components',
+ // },
+ {
+ text: 'Historical Versions',
+ items: [
+ {
+ link: 'https://doc.vvbin.cn',
+ text: '2.x Version Documentation',
+ },
+ ],
+ },
+ ],
+ },
+ {
+ text: 'Demo',
+ items: [
+ {
+ text: 'Vben Admin',
+ items: [
+ {
+ link: 'https://www.vben.pro',
+ text: 'Demo Version',
+ },
+ {
+ link: 'https://ant.vben.pro',
+ text: 'Ant Design Vue Version',
+ },
+ {
+ link: 'https://naive.vben.pro',
+ text: 'Naive Version',
+ },
+ {
+ link: 'https://ele.vben.pro',
+ text: 'Element Plus Version',
+ },
+ ],
+ },
+ {
+ text: 'Others',
+ items: [
+ {
+ link: 'https://vben.vvbin.cn',
+ text: 'Vben Admin 2.x',
+ },
+ ],
+ },
+ ],
+ },
+ {
+ text: version,
+ items: [
+ {
+ link: 'https://github.com/vbenjs/vue-vben-admin/releases',
+ text: 'Changelog',
+ },
+ {
+ link: 'https://github.com/orgs/vbenjs/projects/5',
+ text: 'Roadmap',
+ },
+ {
+ link: 'https://github.com/vbenjs/vue-vben-admin/blob/main/.github/contributing.md',
+ text: 'Contribution',
+ },
+ ],
+ },
+ {
+ link: '/commercial/technical-support',
+ text: '🦄 Tech Support',
+ },
+ {
+ link: '/sponsor/personal',
+ text: '✨ Sponsor',
+ },
+ {
+ link: '/commercial/community',
+ text: '👨👦👦 Community',
+ },
+ // {
+ // link: '/friend-links/',
+ // text: '🤝 Friend Links',
+ // },
+ ];
+}
diff --git a/apps/vben5/docs/.vitepress/config/index.mts b/apps/vben5/docs/.vitepress/config/index.mts
new file mode 100644
index 000000000..6b8cb81d8
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/config/index.mts
@@ -0,0 +1,25 @@
+import { withPwa } from '@vite-pwa/vitepress';
+import { defineConfigWithTheme } from 'vitepress';
+
+import { en } from './en.mts';
+import { shared } from './shared.mts';
+import { zh } from './zh.mts';
+
+export default withPwa(
+ defineConfigWithTheme({
+ ...shared,
+ locales: {
+ en: {
+ label: 'English',
+ lang: 'en',
+ link: '/en/',
+ ...en,
+ },
+ root: {
+ label: '简体中文',
+ lang: 'zh-CN',
+ ...zh,
+ },
+ },
+ }),
+);
diff --git a/apps/vben5/docs/.vitepress/config/plugins/demo-preview.ts b/apps/vben5/docs/.vitepress/config/plugins/demo-preview.ts
new file mode 100644
index 000000000..03b1698ca
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/config/plugins/demo-preview.ts
@@ -0,0 +1,143 @@
+import type { MarkdownEnv, MarkdownRenderer } from 'vitepress';
+
+import crypto from 'node:crypto';
+import { readdirSync } from 'node:fs';
+import { join } from 'node:path';
+
+export const rawPathRegexp =
+ // eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/strict
+ /^(.+?(?:\.([\da-z]+))?)(#[\w-]+)?(?: ?{(\d+(?:[,-]\d+)*)? ?(\S+)?})? ?(?:\[(.+)])?$/;
+
+function rawPathToToken(rawPath: string) {
+ const [
+ filepath = '',
+ extension = '',
+ region = '',
+ lines = '',
+ lang = '',
+ rawTitle = '',
+ ] = (rawPathRegexp.exec(rawPath) || []).slice(1);
+
+ const title = rawTitle || filepath.split('/').pop() || '';
+
+ return { extension, filepath, lang, lines, region, title };
+}
+
+export const demoPreviewPlugin = (md: MarkdownRenderer) => {
+ md.core.ruler.after('inline', 'demo-preview', (state) => {
+ const insertComponentImport = (importString: string) => {
+ const index = state.tokens.findIndex(
+ (i) => i.type === 'html_block' && i.content.match(/\n`;
+ state.tokens.splice(0, 0, importComponent);
+ } else {
+ if (state.tokens[index]) {
+ const content = state.tokens[index].content;
+ state.tokens[index].content = content.replace(
+ '',
+ `${importString}\n`,
+ );
+ }
+ }
+ };
+ // Define the regular expression to match the desired pattern
+ const regex = /]*\sdir="([^"]*)"/g;
+ // Iterate through the Markdown content and replace the pattern
+ state.src = state.src.replaceAll(regex, (_match, dir) => {
+ const componentDir = join(process.cwd(), 'src', dir).replaceAll(
+ '\\',
+ '/',
+ );
+
+ let childFiles: string[] = [];
+ let dirExists = true;
+
+ try {
+ childFiles =
+ readdirSync(componentDir, {
+ encoding: 'utf8',
+ recursive: false,
+ withFileTypes: false,
+ }) || [];
+ } catch {
+ dirExists = false;
+ }
+
+ if (!dirExists) {
+ return '';
+ }
+
+ const uniqueWord = generateContentHash(componentDir);
+
+ const ComponentName = `DemoComponent_${uniqueWord}`;
+ insertComponentImport(
+ `import ${ComponentName} from '${componentDir}/index.vue'`,
+ );
+ const { path: _path } = state.env as MarkdownEnv;
+
+ const index = state.tokens.findIndex((i) => i.content.match(regex));
+
+ if (!state.tokens[index]) {
+ return '';
+ }
+ const firstString = 'index.vue';
+ childFiles = childFiles.sort((a, b) => {
+ if (a === firstString) return -1;
+ if (b === firstString) return 1;
+ return a.localeCompare(b, 'en', { sensitivity: 'base' });
+ });
+ state.tokens[index].content =
+ `<${ComponentName}/>
+ `;
+
+ const _dummyToken = new state.Token('', '', 0);
+ const tokenArray: Array = [];
+ childFiles.forEach((filename) => {
+ // const slotName = filename.replace(extname(filename), '');
+
+ const templateStart = new state.Token('html_inline', '', 0);
+ templateStart.content = ``;
+ tokenArray.push(templateStart);
+
+ const resolvedPath = join(componentDir, filename);
+
+ const { extension, filepath, lang, lines, title } =
+ rawPathToToken(resolvedPath);
+ // Add code tokens for each line
+ const token = new state.Token('fence', 'code', 0);
+ token.info = `${lang || extension}${lines ? `{${lines}}` : ''}${
+ title ? `[${title}]` : ''
+ }`;
+
+ token.content = `<<< ${filepath}`;
+ (token as any).src = [resolvedPath];
+ tokenArray.push(token);
+
+ const templateEnd = new state.Token('html_inline', '', 0);
+ templateEnd.content = ' ';
+ tokenArray.push(templateEnd);
+ });
+ const endTag = new state.Token('html_inline', '', 0);
+ endTag.content = ' ';
+ tokenArray.push(endTag);
+
+ state.tokens.splice(index + 1, 0, ...tokenArray);
+
+ // console.log(
+ // state.md.renderer.render(state.tokens, state?.options ?? [], state.env),
+ // );
+ return '';
+ });
+ });
+};
+
+function generateContentHash(input: string, length: number = 10): string {
+ // 使用 SHA-256 生成哈希值
+ const hash = crypto.createHash('sha256').update(input).digest('hex');
+
+ // 将哈希值转换为 Base36 编码,并取指定长度的字符作为结果
+ return Number.parseInt(hash, 16).toString(36).slice(0, length);
+}
diff --git a/apps/vben5/docs/.vitepress/config/shared.mts b/apps/vben5/docs/.vitepress/config/shared.mts
new file mode 100644
index 000000000..c48cc6097
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/config/shared.mts
@@ -0,0 +1,172 @@
+import type { PwaOptions } from '@vite-pwa/vitepress';
+import type { HeadConfig } from 'vitepress';
+
+import { resolve } from 'node:path';
+
+import {
+ viteArchiverPlugin,
+ viteVxeTableImportsPlugin,
+} from '@vben/vite-config';
+
+import {
+ GitChangelog,
+ GitChangelogMarkdownSection,
+} from '@nolebase/vitepress-plugin-git-changelog/vite';
+import tailwind from 'tailwindcss';
+import { defineConfig, postcssIsolateStyles } from 'vitepress';
+import {
+ groupIconMdPlugin,
+ groupIconVitePlugin,
+} from 'vitepress-plugin-group-icons';
+
+import { demoPreviewPlugin } from './plugins/demo-preview';
+import { search as zhSearch } from './zh.mts';
+
+export const shared = defineConfig({
+ appearance: 'dark',
+ head: head(),
+ markdown: {
+ preConfig(md) {
+ md.use(demoPreviewPlugin);
+ md.use(groupIconMdPlugin);
+ },
+ },
+ pwa: pwa(),
+ srcDir: 'src',
+ themeConfig: {
+ i18nRouting: true,
+ logo: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp',
+ search: {
+ options: {
+ locales: {
+ ...zhSearch,
+ },
+ },
+ provider: 'local',
+ },
+ siteTitle: 'Vben Admin',
+ socialLinks: [
+ { icon: 'github', link: 'https://github.com/vbenjs/vue-vben-admin' },
+ ],
+ },
+ title: 'Vben Admin',
+ vite: {
+ build: {
+ chunkSizeWarningLimit: Infinity,
+ minify: 'terser',
+ },
+ css: {
+ postcss: {
+ plugins: [
+ tailwind(),
+ postcssIsolateStyles({ includeFiles: [/vp-doc\.css/] }),
+ ],
+ },
+ preprocessorOptions: {
+ scss: {
+ api: 'modern',
+ },
+ },
+ },
+ json: {
+ stringify: true,
+ },
+ plugins: [
+ GitChangelog({
+ mapAuthors: [
+ {
+ mapByNameAliases: ['Vben'],
+ name: 'vben',
+ username: 'anncwb',
+ },
+ {
+ name: 'vince',
+ username: 'vince292007',
+ },
+ {
+ name: 'Li Kui',
+ username: 'likui628',
+ },
+ ],
+ repoURL: () => 'https://github.com/vbenjs/vue-vben-admin',
+ }),
+ GitChangelogMarkdownSection(),
+ viteArchiverPlugin({ outputDir: '.vitepress' }),
+ groupIconVitePlugin(),
+ await viteVxeTableImportsPlugin(),
+ ],
+ server: {
+ fs: {
+ allow: ['../..'],
+ },
+ host: true,
+ port: 6173,
+ },
+
+ ssr: {
+ external: ['@vue/repl'],
+ },
+ },
+});
+
+function head(): HeadConfig[] {
+ return [
+ ['meta', { content: 'Vbenjs Team', name: 'author' }],
+ [
+ 'meta',
+ {
+ content: 'vben, vitejs, vite, shacdn-ui, vue',
+ name: 'keywords',
+ },
+ ],
+ ['link', { href: '/favicon.ico', rel: 'icon', type: 'image/svg+xml' }],
+ [
+ 'meta',
+ {
+ content:
+ 'width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no',
+ name: 'viewport',
+ },
+ ],
+ ['meta', { content: 'vben admin docs', name: 'keywords' }],
+ ['link', { href: '/favicon.ico', rel: 'icon' }],
+ // [
+ // 'script',
+ // {
+ // src: 'https://cdn.tailwindcss.com',
+ // },
+ // ],
+ ];
+}
+
+function pwa(): PwaOptions {
+ return {
+ includeManifestIcons: false,
+ manifest: {
+ description:
+ 'Vben Admin is a modern admin dashboard template based on Vue 3. ',
+ icons: [
+ {
+ sizes: '192x192',
+ src: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/pwa-icon-192.png',
+ type: 'image/png',
+ },
+ {
+ sizes: '512x512',
+ src: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/pwa-icon-512.png',
+ type: 'image/png',
+ },
+ ],
+ id: '/',
+ name: 'Vben Admin Doc',
+ short_name: 'vben_admin_doc',
+ theme_color: '#ffffff',
+ },
+ outDir: resolve(process.cwd(), '.vitepress/dist'),
+ registerType: 'autoUpdate',
+ workbox: {
+ globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'],
+ maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
+ },
+ };
+}
diff --git a/apps/vben5/docs/.vitepress/config/zh.mts b/apps/vben5/docs/.vitepress/config/zh.mts
new file mode 100644
index 000000000..6b31658ed
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/config/zh.mts
@@ -0,0 +1,334 @@
+import { type DefaultTheme, defineConfig } from 'vitepress';
+
+import { version } from '../../../package.json';
+
+export const zh = defineConfig({
+ description: 'Vben Admin & 企业级管理系统框架',
+ lang: 'zh-Hans',
+ themeConfig: {
+ darkModeSwitchLabel: '主题',
+ darkModeSwitchTitle: '切换到深色模式',
+ docFooter: {
+ next: '下一页',
+ prev: '上一页',
+ },
+ editLink: {
+ pattern:
+ 'https://github.com/vbenjs/vue-vben-admin/edit/main/docs/src/:path',
+ text: '在 GitHub 上编辑此页面',
+ },
+ footer: {
+ copyright: `Copyright © 2020-${new Date().getFullYear()} Vben`,
+ message: '基于 MIT 许可发布.',
+ },
+ langMenuLabel: '多语言',
+ lastUpdated: {
+ formatOptions: {
+ dateStyle: 'short',
+ timeStyle: 'medium',
+ },
+ text: '最后更新于',
+ },
+ lightModeSwitchTitle: '切换到浅色模式',
+ nav: nav(),
+
+ outline: {
+ label: '页面导航',
+ },
+ returnToTopLabel: '回到顶部',
+
+ sidebar: {
+ '/commercial/': { base: '/commercial/', items: sidebarCommercial() },
+ '/components/': { base: '/components/', items: sidebarComponents() },
+ '/guide/': { base: '/guide/', items: sidebarGuide() },
+ },
+ sidebarMenuLabel: '菜单',
+ },
+});
+
+function sidebarGuide(): DefaultTheme.SidebarItem[] {
+ return [
+ {
+ collapsed: false,
+ text: '简介',
+ items: [
+ {
+ link: 'introduction/vben',
+ text: '关于 Vben Admin',
+ },
+ {
+ link: 'introduction/why',
+ text: '为什么选择我们?',
+ },
+ { link: 'introduction/quick-start', text: '快速开始' },
+ { link: 'introduction/thin', text: '精简版本' },
+ {
+ base: '/',
+ link: 'components/introduction',
+ text: '组件文档',
+ },
+ ],
+ },
+ {
+ text: '基础',
+ items: [
+ { link: 'essentials/concept', text: '基础概念' },
+ { link: 'essentials/development', text: '本地开发' },
+ { link: 'essentials/route', text: '路由和菜单' },
+ { link: 'essentials/settings', text: '配置' },
+ { link: 'essentials/icons', text: '图标' },
+ { link: 'essentials/styles', text: '样式' },
+ { link: 'essentials/external-module', text: '外部模块' },
+ { link: 'essentials/build', text: '构建与部署' },
+ { link: 'essentials/server', text: '服务端交互与数据Mock' },
+ ],
+ },
+ {
+ text: '深入',
+ items: [
+ { link: 'in-depth/login', text: '登录' },
+ // { link: 'in-depth/layout', text: '布局' },
+ { link: 'in-depth/theme', text: '主题' },
+ { link: 'in-depth/access', text: '权限' },
+ { link: 'in-depth/locale', text: '国际化' },
+ { link: 'in-depth/features', text: '常用功能' },
+ { link: 'in-depth/check-updates', text: '检查更新' },
+ { link: 'in-depth/loading', text: '全局loading' },
+ { link: 'in-depth/ui-framework', text: '组件库切换' },
+ ],
+ },
+ {
+ text: '工程',
+ items: [
+ { link: 'project/standard', text: '规范' },
+ { link: 'project/cli', text: 'CLI' },
+ { link: 'project/dir', text: '目录说明' },
+ { link: 'project/test', text: '单元测试' },
+ { link: 'project/tailwindcss', text: 'Tailwind CSS' },
+ { link: 'project/changeset', text: 'Changeset' },
+ { link: 'project/vite', text: 'Vite Config' },
+ ],
+ },
+ {
+ text: '其他',
+ items: [
+ { link: 'other/project-update', text: '项目更新' },
+ { link: 'other/remove-code', text: '移除代码' },
+ { link: 'other/faq', text: '常见问题' },
+ ],
+ },
+ ];
+}
+
+function sidebarCommercial(): DefaultTheme.SidebarItem[] {
+ return [
+ {
+ link: 'community',
+ text: '交流群',
+ },
+ {
+ link: 'technical-support',
+ text: '技术支持',
+ },
+ {
+ link: 'customized',
+ text: '定制开发',
+ },
+ ];
+}
+
+function sidebarComponents(): DefaultTheme.SidebarItem[] {
+ return [
+ {
+ text: '组件',
+ items: [
+ {
+ link: 'introduction',
+ text: '介绍',
+ },
+ ],
+ },
+ {
+ collapsed: false,
+ text: '通用组件',
+ items: [
+ {
+ link: 'common-ui/vben-modal',
+ text: 'Modal 模态框',
+ },
+ {
+ link: 'common-ui/vben-drawer',
+ text: 'Drawer 抽屉',
+ },
+ {
+ link: 'common-ui/vben-form',
+ text: 'Form 表单',
+ },
+ {
+ link: 'common-ui/vben-vxe-table',
+ text: 'Vxe Table 表格',
+ },
+ {
+ link: 'common-ui/vben-count-to-animator',
+ text: 'CountToAnimator 数字动画',
+ },
+ ],
+ },
+ ];
+}
+
+function nav(): DefaultTheme.NavItem[] {
+ return [
+ {
+ activeMatch: '^/(guide|components)/',
+ text: '文档',
+ items: [
+ {
+ activeMatch: '^/guide/',
+ link: '/guide/introduction/vben',
+ text: '指南',
+ },
+ {
+ activeMatch: '^/components/',
+ link: '/components/introduction',
+ text: '组件',
+ },
+ {
+ text: '历史版本',
+ items: [
+ {
+ link: 'https://doc.vvbin.cn',
+ text: '2.x版本文档',
+ },
+ ],
+ },
+ ],
+ },
+ {
+ text: '演示',
+ items: [
+ {
+ text: 'Vben Admin',
+ items: [
+ {
+ link: 'https://www.vben.pro',
+ text: '演示版本',
+ },
+ {
+ link: 'https://ant.vben.pro',
+ text: 'Ant Design Vue 版本',
+ },
+ {
+ link: 'https://naive.vben.pro',
+ text: 'Naive 版本',
+ },
+ {
+ link: 'https://ele.vben.pro',
+ text: 'Element Plus版本',
+ },
+ ],
+ },
+ {
+ text: '其他',
+ items: [
+ {
+ link: 'https://vben.vvbin.cn',
+ text: 'Vben Admin 2.x',
+ },
+ ],
+ },
+ ],
+ },
+ {
+ text: version,
+ items: [
+ {
+ link: 'https://github.com/vbenjs/vue-vben-admin/releases',
+ text: '更新日志',
+ },
+ {
+ link: 'https://github.com/orgs/vbenjs/projects/5',
+ text: '路线图',
+ },
+ {
+ link: 'https://github.com/vbenjs/vue-vben-admin/blob/main/.github/contributing.md',
+ text: '贡献',
+ },
+ ],
+ },
+ {
+ link: '/commercial/technical-support',
+ text: '🦄 技术支持',
+ },
+ {
+ link: '/sponsor/personal',
+ text: '✨ 赞助',
+ },
+ {
+ link: '/commercial/community',
+ text: '👨👦👦 交流群',
+ // items: [
+ // {
+ // link: 'https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&appChannel=share&inviteCode=22ySzj7pKiw&businessType=9&from=246610&biz=ka&mainSourceId=share&subSourceId=others&jumpsource=shorturl#/pc',
+ // text: 'QQ频道',
+ // },
+ // {
+ // link: 'https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=mjZmlhgVzzUxvdxllB6C1vHpX8O8QRL0&authKey=DBdFbBwERmfaKY95JvRWqLCJIRGJAmKyZbrpzZ41EKDMZ5SR6MfbjOBaaNRN73fr&noverify=0&group_code=4286109',
+ // text: 'QQ群',
+ // },
+ // {
+ // link: 'https://discord.gg/VU62jTecad',
+ // text: 'Discord',
+ // },
+ // ],
+ },
+ // {
+ // link: '/friend-links/',
+ // text: '🤝 友情链接',
+ // },
+ ];
+}
+
+export const search: DefaultTheme.AlgoliaSearchOptions['locales'] = {
+ root: {
+ placeholder: '搜索文档',
+ translations: {
+ button: {
+ buttonAriaLabel: '搜索文档',
+ buttonText: '搜索文档',
+ },
+ modal: {
+ errorScreen: {
+ helpText: '你可能需要检查你的网络连接',
+ titleText: '无法获取结果',
+ },
+ footer: {
+ closeText: '关闭',
+ navigateText: '切换',
+ searchByText: '搜索提供者',
+ selectText: '选择',
+ },
+ noResultsScreen: {
+ noResultsText: '无法找到相关结果',
+ reportMissingResultsLinkText: '点击反馈',
+ reportMissingResultsText: '你认为该查询应该有结果?',
+ suggestedQueryText: '你可以尝试查询',
+ },
+ searchBox: {
+ cancelButtonAriaLabel: '取消',
+ cancelButtonText: '取消',
+ resetButtonAriaLabel: '清除查询条件',
+ resetButtonTitle: '清除查询条件',
+ },
+ startScreen: {
+ favoriteSearchesTitle: '收藏',
+ noRecentSearchesText: '没有搜索历史',
+ recentSearchesTitle: '搜索历史',
+ removeFavoriteSearchButtonTitle: '从收藏中移除',
+ removeRecentSearchButtonTitle: '从搜索历史中移除',
+ saveRecentSearchButtonTitle: '保存至搜索历史',
+ },
+ },
+ },
+ },
+};
diff --git a/apps/vben5/docs/.vitepress/theme/components/site-layout.vue b/apps/vben5/docs/.vitepress/theme/components/site-layout.vue
new file mode 100644
index 000000000..d643cae98
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/theme/components/site-layout.vue
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/.vitepress/theme/components/vben-contributors.vue b/apps/vben5/docs/.vitepress/theme/components/vben-contributors.vue
new file mode 100644
index 000000000..9b887d925
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/theme/components/vben-contributors.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
Contributors
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/.vitepress/theme/index.ts b/apps/vben5/docs/.vitepress/theme/index.ts
new file mode 100644
index 000000000..7d4d3dc2d
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/theme/index.ts
@@ -0,0 +1,29 @@
+// https://vitepress.dev/guide/custom-theme
+import type { EnhanceAppContext, Theme } from 'vitepress';
+
+import { NolebaseGitChangelogPlugin } from '@nolebase/vitepress-plugin-git-changelog/client';
+import DefaultTheme from 'vitepress/theme';
+
+import { DemoPreview } from '../components';
+import SiteLayout from './components/site-layout.vue';
+import VbenContributors from './components/vben-contributors.vue';
+import { initHmPlugin } from './plugins/hm';
+
+import './styles';
+
+import 'virtual:group-icons.css';
+import '@nolebase/vitepress-plugin-git-changelog/client/style.css';
+
+export default {
+ async enhanceApp(ctx: EnhanceAppContext) {
+ const { app } = ctx;
+ app.component('VbenContributors', VbenContributors);
+ app.component('DemoPreview', DemoPreview);
+ app.use(NolebaseGitChangelogPlugin);
+
+ // 百度统计
+ initHmPlugin();
+ },
+ extends: DefaultTheme,
+ Layout: SiteLayout,
+} satisfies Theme;
diff --git a/apps/vben5/docs/.vitepress/theme/plugins/hm.ts b/apps/vben5/docs/.vitepress/theme/plugins/hm.ts
new file mode 100644
index 000000000..5e0a93182
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/theme/plugins/hm.ts
@@ -0,0 +1,28 @@
+import { inBrowser } from 'vitepress';
+
+const SITE_ID = '2e443a834727c065877c01d89921545e';
+
+declare global {
+ interface Window {
+ _hmt: any;
+ }
+}
+
+function registerAnalytics() {
+ window._hmt = window._hmt || [];
+ const script = document.createElement('script');
+ script.innerHTML = `var _hmt = _hmt || [];
+ (function() {
+ var hm = document.createElement("script");
+ hm.src = "https://hm.baidu.com/hm.js?${SITE_ID}";
+ var s = document.getElementsByTagName("script")[0];
+ s.parentNode.insertBefore(hm, s);
+ })()`;
+ document.querySelector('head')?.append(script);
+}
+
+export function initHmPlugin() {
+ if (inBrowser && import.meta.env.PROD) {
+ registerAnalytics();
+ }
+}
diff --git a/apps/vben5/docs/.vitepress/theme/styles/base.css b/apps/vben5/docs/.vitepress/theme/styles/base.css
new file mode 100644
index 000000000..8eb423afa
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/theme/styles/base.css
@@ -0,0 +1,22 @@
+html.dark {
+ color-scheme: dark;
+}
+
+.dark .VPContent {
+ /* background-color: #14161a; */
+}
+
+.form-valid-error p {
+ margin: 0;
+}
+
+/* 顶部导航栏选中项样式 */
+.VPNavBarMenuLink,
+.VPNavBarMenuGroup {
+ border-bottom: 1px solid transparent;
+}
+
+.VPNavBarMenuLink.active,
+.VPNavBarMenuGroup.active {
+ border-bottom-color: var(--vp-c-brand-1);
+}
diff --git a/apps/vben5/docs/.vitepress/theme/styles/index.ts b/apps/vben5/docs/.vitepress/theme/styles/index.ts
new file mode 100644
index 000000000..566e63f8c
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/theme/styles/index.ts
@@ -0,0 +1,4 @@
+import '@vben/styles';
+
+import './variables.css';
+import './base.css';
diff --git a/apps/vben5/docs/.vitepress/theme/styles/variables.css b/apps/vben5/docs/.vitepress/theme/styles/variables.css
new file mode 100644
index 000000000..d633803ce
--- /dev/null
+++ b/apps/vben5/docs/.vitepress/theme/styles/variables.css
@@ -0,0 +1,127 @@
+/**
+ * Customize default theme styling by overriding CSS variables:
+ * https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
+ */
+
+/**
+ * Colors
+ *
+ * Each colors have exact same color scale system with 3 levels of solid
+ * colors with different brightness, and 1 soft color.
+ *
+ * - `XXX-1`: The most solid color used mainly for colored text. It must
+ * satisfy the contrast ratio against when used on top of `XXX-soft`.
+ *
+ * - `XXX-2`: The color used mainly for hover state of the button.
+ *
+ * - `XXX-3`: The color for solid background, such as bg color of the button.
+ * It must satisfy the contrast ratio with pure white (#ffffff) text on
+ * top of it.
+ *
+ * - `XXX-soft`: The color used for subtle background such as custom container
+ * or badges. It must satisfy the contrast ratio when putting `XXX-1` colors
+ * on top of it.
+ *
+ * The soft color must be semi transparent alpha channel. This is crucial
+ * because it allows adding multiple "soft" colors on top of each other
+ * to create a accent, such as when having inline code block inside
+ * custom containers.
+ *
+ * - `default`: The color used purely for subtle indication without any
+ * special meanings attched to it such as bg color for menu hover state.
+ *
+ * - `brand`: Used for primary brand colors, such as link text, button with
+ * brand theme, etc.
+ *
+ * - `tip`: Used to indicate useful information. The default theme uses the
+ * brand color for this by default.
+ *
+ * - `warning`: Used to indicate warning to the users. Used in custom
+ * container, badges, etc.
+ *
+ * - `danger`: Used to show error, or dangerous message to the users. Used
+ * in custom container, badges, etc.
+ * -------------------------------------------------------------------------- */
+
+:root {
+ /* --vp-c-indigo-1: #4f69fd; */
+ --vp-c-default-1: var(--vp-c-gray-1);
+ --vp-c-default-2: var(--vp-c-gray-2);
+ --vp-c-default-3: var(--vp-c-gray-3);
+ --vp-c-default-soft: var(--vp-c-gray-soft);
+ --vp-c-brand-1: var(--vp-c-indigo-1);
+ --vp-c-brand-2: var(--vp-c-indigo-2);
+ --vp-c-brand-3: var(--vp-c-indigo-3);
+ --vp-c-brand-soft: var(--vp-c-indigo-soft);
+ --vp-c-tip-1: var(--vp-c-brand-1);
+ --vp-c-tip-2: var(--vp-c-brand-2);
+ --vp-c-tip-3: var(--vp-c-brand-3);
+ --vp-c-tip-soft: var(--vp-c-brand-soft);
+ --vp-c-warning-1: var(--vp-c-yellow-1);
+ --vp-c-warning-2: var(--vp-c-yellow-2);
+ --vp-c-warning-3: var(--vp-c-yellow-3);
+ --vp-c-warning-soft: var(--vp-c-yellow-soft);
+ --vp-c-danger-1: var(--vp-c-red-1);
+ --vp-c-danger-2: var(--vp-c-red-2);
+ --vp-c-danger-3: var(--vp-c-red-3);
+ --vp-c-danger-soft: var(--vp-c-red-soft);
+
+ /**
+ * Component: Button
+ * -------------------------------------------------------------------------- */
+
+ --vp-button-brand-border: transparent;
+ --vp-button-brand-text: var(--vp-c-white);
+ --vp-button-brand-bg: var(--vp-c-brand-3);
+ --vp-button-brand-hover-border: transparent;
+ --vp-button-brand-hover-text: var(--vp-c-white);
+ --vp-button-brand-hover-bg: var(--vp-c-brand-2);
+ --vp-button-brand-active-border: transparent;
+ --vp-button-brand-active-text: var(--vp-c-white);
+ --vp-button-brand-active-bg: var(--vp-c-brand-1);
+
+ /**
+ * Component: Home
+ * -------------------------------------------------------------------------- */
+
+ --vp-home-hero-name-color: transparent;
+ --vp-home-hero-name-background: linear-gradient(
+ 120deg,
+ var(--vp-c-indigo-1) 30%,
+ #18cefe
+ );
+ --vp-home-hero-image-background-image: linear-gradient(
+ -45deg,
+ #18cefe 50%,
+ #c279ed 50%
+ );
+ --vp-home-hero-image-filter: blur(44px);
+
+ /**
+ * Component: Custom Block
+ * -------------------------------------------------------------------------- */
+ --vp-custom-block-tip-border: transparent;
+ --vp-custom-block-tip-text: var(--vp-c-text-1);
+ --vp-custom-block-tip-bg: var(--vp-c-brand-soft);
+ --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft);
+}
+
+@media (min-width: 640px) {
+ :root {
+ --vp-home-hero-image-filter: blur(56px);
+ }
+}
+
+@media (min-width: 960px) {
+ :root {
+ --vp-home-hero-image-filter: blur(68px);
+ }
+}
+
+/**
+ * Component: Algolia
+ * -------------------------------------------------------------------------- */
+
+.DocSearch {
+ --docsearch-primary-color: var(--vp-c-brand-1) !important;
+}
diff --git a/apps/vben5/docs/package.json b/apps/vben5/docs/package.json
new file mode 100644
index 000000000..15a87bb97
--- /dev/null
+++ b/apps/vben5/docs/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "@vben/docs",
+ "version": "5.4.8",
+ "private": true,
+ "scripts": {
+ "build": "vitepress build",
+ "dev": "vitepress dev",
+ "docs:preview": "vitepress preview"
+ },
+ "imports": {
+ "#/*": {
+ "node": "./src/_env/node/*",
+ "default": "./src/_env/*"
+ }
+ },
+ "dependencies": {
+ "@vben-core/shadcn-ui": "workspace:*",
+ "@vben/common-ui": "workspace:*",
+ "@vben/locales": "workspace:*",
+ "@vben/plugins": "workspace:*",
+ "@vben/styles": "workspace:*",
+ "ant-design-vue": "catalog:",
+ "lucide-vue-next": "catalog:",
+ "medium-zoom": "catalog:",
+ "radix-vue": "catalog:",
+ "vitepress-plugin-group-icons": "catalog:"
+ },
+ "devDependencies": {
+ "@nolebase/vitepress-plugin-git-changelog": "catalog:",
+ "@vben/vite-config": "workspace:*",
+ "@vite-pwa/vitepress": "catalog:",
+ "vitepress": "catalog:",
+ "vue": "catalog:"
+ }
+}
diff --git a/apps/vben5/docs/src/_env/adapter/component.ts b/apps/vben5/docs/src/_env/adapter/component.ts
new file mode 100644
index 000000000..1afa62174
--- /dev/null
+++ b/apps/vben5/docs/src/_env/adapter/component.ts
@@ -0,0 +1,127 @@
+/**
+ * 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
+ * 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
+ */
+
+import type { BaseFormComponentType } from '@vben/common-ui';
+
+import type { Component, SetupContext } from 'vue';
+import { h } from 'vue';
+
+import { globalShareState } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+import {
+ AutoComplete,
+ Button,
+ Checkbox,
+ CheckboxGroup,
+ DatePicker,
+ Divider,
+ Input,
+ InputNumber,
+ InputPassword,
+ Mentions,
+ notification,
+ Radio,
+ RadioGroup,
+ RangePicker,
+ Rate,
+ Select,
+ Space,
+ Switch,
+ Textarea,
+ TimePicker,
+ TreeSelect,
+ Upload,
+} from 'ant-design-vue';
+
+const withDefaultPlaceholder = (
+ component: T,
+ type: 'input' | 'select',
+) => {
+ return (props: any, { attrs, slots }: Omit) => {
+ const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
+ return h(component, { ...props, ...attrs, placeholder }, slots);
+ };
+};
+
+// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
+export type ComponentType =
+ | 'AutoComplete'
+ | 'Checkbox'
+ | 'CheckboxGroup'
+ | 'DatePicker'
+ | 'DefaultButton'
+ | 'Divider'
+ | 'Input'
+ | 'InputNumber'
+ | 'InputPassword'
+ | 'Mentions'
+ | 'PrimaryButton'
+ | 'Radio'
+ | 'RadioGroup'
+ | 'RangePicker'
+ | 'Rate'
+ | 'Select'
+ | 'Space'
+ | 'Switch'
+ | 'Textarea'
+ | 'TimePicker'
+ | 'TreeSelect'
+ | 'Upload'
+ | BaseFormComponentType;
+
+async function initComponentAdapter() {
+ const components: Partial> = {
+ // 如果你的组件体积比较大,可以使用异步加载
+ // Button: () =>
+ // import('xxx').then((res) => res.Button),
+
+ AutoComplete,
+ Checkbox,
+ CheckboxGroup,
+ DatePicker,
+ // 自定义默认按钮
+ DefaultButton: (props, { attrs, slots }) => {
+ return h(Button, { ...props, attrs, type: 'default' }, slots);
+ },
+ Divider,
+ Input: withDefaultPlaceholder(Input, 'input'),
+ InputNumber: withDefaultPlaceholder(InputNumber, 'input'),
+ InputPassword: withDefaultPlaceholder(InputPassword, 'input'),
+ Mentions: withDefaultPlaceholder(Mentions, 'input'),
+ // 自定义主要按钮
+ PrimaryButton: (props, { attrs, slots }) => {
+ return h(Button, { ...props, attrs, type: 'primary' }, slots);
+ },
+ Radio,
+ RadioGroup,
+ RangePicker,
+ Rate,
+ Select: withDefaultPlaceholder(Select, 'select'),
+ Space,
+ Switch,
+ Textarea: withDefaultPlaceholder(Textarea, 'input'),
+ TimePicker,
+ TreeSelect: withDefaultPlaceholder(TreeSelect, 'select'),
+ Upload,
+ };
+
+ // 将组件注册到全局共享状态中
+ globalShareState.setComponents(components);
+
+ // 定义全局共享状态中的消息提示
+ globalShareState.defineMessage({
+ // 复制成功消息提示
+ copyPreferencesSuccess: (title, content) => {
+ notification.success({
+ description: content,
+ message: title,
+ placement: 'bottomRight',
+ });
+ },
+ });
+}
+
+export { initComponentAdapter };
diff --git a/apps/vben5/docs/src/_env/adapter/form.ts b/apps/vben5/docs/src/_env/adapter/form.ts
new file mode 100644
index 000000000..67e2483e5
--- /dev/null
+++ b/apps/vben5/docs/src/_env/adapter/form.ts
@@ -0,0 +1,49 @@
+import type {
+ VbenFormSchema as FormSchema,
+ VbenFormProps,
+} from '@vben/common-ui';
+
+import type { ComponentType } from './component';
+
+import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+import { initComponentAdapter } from './component';
+
+initComponentAdapter();
+setupVbenForm({
+ config: {
+ baseModelPropName: 'value',
+ // naive-ui组件不接受onChang事件,所以需要禁用
+ disabledOnChangeListener: true,
+ // naive-ui组件的空值为null,不能是undefined,否则重置表单时不生效
+ emptyStateValue: null,
+ modelPropNameMap: {
+ Checkbox: 'checked',
+ Radio: 'checked',
+ Switch: 'checked',
+ Upload: 'fileList',
+ },
+ },
+ defineRules: {
+ required: (value, _params, ctx) => {
+ if (value === undefined || value === null || value.length === 0) {
+ return $t('ui.formRules.required', [ctx.label]);
+ }
+ return true;
+ },
+ selectRequired: (value, _params, ctx) => {
+ if (value === undefined || value === null) {
+ return $t('ui.formRules.selectRequired', [ctx.label]);
+ }
+ return true;
+ },
+ },
+});
+
+const useVbenForm = useForm;
+
+export { useVbenForm, z };
+
+export type VbenFormSchema = FormSchema;
+export type { VbenFormProps };
diff --git a/apps/vben5/docs/src/_env/adapter/vxe-table.ts b/apps/vben5/docs/src/_env/adapter/vxe-table.ts
new file mode 100644
index 000000000..bab7f3d38
--- /dev/null
+++ b/apps/vben5/docs/src/_env/adapter/vxe-table.ts
@@ -0,0 +1,70 @@
+import { h } from 'vue';
+
+import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
+
+import { Button, Image } from 'ant-design-vue';
+
+import { useVbenForm } from './form';
+
+if (!import.meta.env.SSR) {
+ setupVbenVxeTable({
+ configVxeTable: (vxeUI) => {
+ vxeUI.setConfig({
+ grid: {
+ align: 'center',
+ border: false,
+ columnConfig: {
+ resizable: true,
+ },
+
+ formConfig: {
+ // 全局禁用vxe-table的表单配置,使用formOptions
+ enabled: false,
+ },
+ minHeight: 180,
+ proxyConfig: {
+ autoLoad: true,
+ response: {
+ result: 'items',
+ total: 'total',
+ list: 'items',
+ },
+ showActiveMsg: true,
+ showResponseMsg: false,
+ },
+ round: true,
+ showOverflow: true,
+ size: 'small',
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellImage' },
+ vxeUI.renderer.add('CellImage', {
+ renderTableDefault(_renderOpts, params) {
+ const { column, row } = params;
+ return h(Image, { src: row[column.field] });
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellLink' },
+ vxeUI.renderer.add('CellLink', {
+ renderTableDefault(renderOpts) {
+ const { props } = renderOpts;
+ return h(
+ Button,
+ { size: 'small', type: 'link' },
+ { default: () => props?.text },
+ );
+ },
+ });
+
+ // 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
+ // vxeUI.formats.add
+ },
+ useVbenForm,
+ });
+}
+
+export { useVbenVxeGrid };
+
+export type * from '@vben/plugins/vxe-table';
diff --git a/apps/vben5/docs/src/_env/node/adapter/form.ts b/apps/vben5/docs/src/_env/node/adapter/form.ts
new file mode 100644
index 000000000..a206c0d8b
--- /dev/null
+++ b/apps/vben5/docs/src/_env/node/adapter/form.ts
@@ -0,0 +1,4 @@
+export const useVbenForm = () => {};
+export const z = {};
+export type VbenFormSchema = any;
+export type VbenFormProps = any;
diff --git a/apps/vben5/docs/src/_env/node/adapter/vxe-table.ts b/apps/vben5/docs/src/_env/node/adapter/vxe-table.ts
new file mode 100644
index 000000000..5ec409fb2
--- /dev/null
+++ b/apps/vben5/docs/src/_env/node/adapter/vxe-table.ts
@@ -0,0 +1,3 @@
+export type * from '@vben/plugins/vxe-table';
+
+export const useVbenVxeGrid = () => {};
diff --git a/apps/vben5/docs/src/commercial/community.md b/apps/vben5/docs/src/commercial/community.md
new file mode 100644
index 000000000..c5b7b7db9
--- /dev/null
+++ b/apps/vben5/docs/src/commercial/community.md
@@ -0,0 +1,30 @@
+# 社区交流
+
+社区交流群主要是为了方便大家交流,提问,解答问题,分享经验等。偏自助方式,如果你有问题,可以通过以下方式加入社区交流群:
+
+- [QQ频道](https://pd.qq.com/s/16p8lvvob):推荐!!!主要提供问题解答,分享经验等。
+- QQ群:[大群](https://qm.qq.com/q/MEmHoCLbG0),[1群](https://qm.qq.com/q/YacMHPYAMu)、[2群](https://qm.qq.com/q/ajVKZvFICk)、[3群](https://qm.qq.com/q/36zdwThP2E),[4群](https://qm.qq.com/q/sCzSlm3504),主要使用者的交流群。
+- [Discord](https://discord.com/invite/VU62jTecad): 主要提供问题解答,分享经验等。
+
+::: tip
+
+免费QQ群人数上限200,将会不定期清理。推荐加入QQ频道进行交流
+
+:::
+
+## 微信群
+
+作者主要通过微信群提供帮助,如果你有问题,可以通过以下方式加入微信群。
+
+通过微信联系作者,注明加群来意:
+
+::: tip
+
+因为微信群人数有限制,加微信群要求:
+
+- 通过[赞助](../sponsor/personal.md)任意金额。
+- 发送赞助`截图`,备注`加入微信群`即可。
+
+:::
+
+
diff --git a/apps/vben5/docs/src/commercial/customized.md b/apps/vben5/docs/src/commercial/customized.md
new file mode 100644
index 000000000..1f0bcecaf
--- /dev/null
+++ b/apps/vben5/docs/src/commercial/customized.md
@@ -0,0 +1,12 @@
+# 定制开发
+
+我们提供基于 Vben Admin 的技术支持服务及定制开发,基本需求我们都可以满足。
+
+详细需求可添加作者了解,并注明来意:
+
+- 通过邮箱联系开发者: [ann.vben@gmail.com](mailto:ann.vben@gmail.com)
+- 通过微信联系开发者:
+
+
+
+我们会在第一时间回复您,定制费用根据需求而定。
diff --git a/apps/vben5/docs/src/commercial/technical-support.md b/apps/vben5/docs/src/commercial/technical-support.md
new file mode 100644
index 000000000..ded9bf2db
--- /dev/null
+++ b/apps/vben5/docs/src/commercial/technical-support.md
@@ -0,0 +1,8 @@
+# 技术支持
+
+## 问题反馈
+
+在使用项目的过程中,如果遇到问题,你可以先详细阅读本文档,未找到解决方案时,可以通过以下方式获取技术支持:
+
+- 通过 [GitHub Issues](https://github.com/vbenjs/vue-vben-admin/issues)
+- 通过 [GitHub Discussions](https://github.com/vbenjs/vue-vben-admin/discussions)
diff --git a/apps/vben5/docs/src/components/common-ui/vben-count-to-animator.md b/apps/vben5/docs/src/components/common-ui/vben-count-to-animator.md
new file mode 100644
index 000000000..301e1a41c
--- /dev/null
+++ b/apps/vben5/docs/src/components/common-ui/vben-count-to-animator.md
@@ -0,0 +1,52 @@
+---
+outline: deep
+---
+
+# Vben CountToAnimator 数字动画
+
+框架提供的数字动画组件,支持数字动画效果。
+
+> 如果文档内没有参数说明,可以尝试在在线示例内寻找
+
+::: info 写在前面
+
+如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。
+
+:::
+
+## 基础用法
+
+通过 `start-val` 和 `end-val`设置数字动画的开始值和结束值, 持续时间`3000`ms。
+
+
+
+## 自定义前缀及分隔符
+
+通过 `prefix` 和 `separator` 设置数字动画的前缀和分隔符。
+
+
+
+### Props
+
+| 属性名 | 描述 | 类型 | 默认值 |
+| ---------- | -------------- | --------- | -------- |
+| startVal | 起始值 | `number` | `0` |
+| endVal | 结束值 | `number` | `2021` |
+| duration | 动画持续时间 | `number` | `1500` |
+| autoplay | 自动执行 | `boolean` | `true` |
+| prefix | 前缀 | `string` | - |
+| suffix | 后缀 | `string` | - |
+| separator | 分隔符 | `string` | `,` |
+| color | 字体颜色 | `string` | - |
+| useEasing | 是否开启动画 | `boolean` | `true` |
+| transition | 动画效果 | `string` | `linear` |
+| decimals | 保留小数点位数 | `number` | `0` |
+
+### Methods
+
+以下事件,只有在 `useVbenModal({onCancel:()=>{}})` 中传入才会生效。
+
+| 事件名 | 描述 | 类型 |
+| ------ | ------------ | ---------- |
+| start | 开始执行动画 | `()=>void` |
+| reset | 重置 | `()=>void` |
diff --git a/apps/vben5/docs/src/components/common-ui/vben-drawer.md b/apps/vben5/docs/src/components/common-ui/vben-drawer.md
new file mode 100644
index 000000000..939593fa9
--- /dev/null
+++ b/apps/vben5/docs/src/components/common-ui/vben-drawer.md
@@ -0,0 +1,129 @@
+---
+outline: deep
+---
+
+# Vben Drawer 抽屉
+
+框架提供的抽屉组件,支持`自动高度`、`loading`等功能。
+
+> 如果文档内没有参数说明,可以尝试在在线示例内寻找
+
+::: info 写在前面
+
+如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。
+
+:::
+
+::: tip README
+
+下方示例代码中的,存在一些国际化、主题色未适配问题,这些问题只在文档内会出现,实际使用并不会有这些问题,可忽略,不必纠结。
+
+:::
+
+## 基础用法
+
+使用 `useVbenDrawer` 创建最基础的模态框。
+
+
+
+## 组件抽离
+
+Drawer 内的内容一般业务中,会比较复杂,所以我们可以将 drawer 内的内容抽离出来,也方便复用。通过 `connectedComponent` 参数,可以将内外组件进行连接,而不用其他任何操作。
+
+
+
+## 自动计算高度
+
+弹窗会自动计算内容高度,超过一定高度会出现滚动条,同时结合 `loading` 效果以及使用 `prepend-footer` 插槽。
+
+
+
+## 使用 Api
+
+通过 `drawerApi` 可以调用 drawer 的方法以及使用 `setState` 更新 drawer 的状态。
+
+
+
+## 数据共享
+
+如果你使用了 `connectedComponent` 参数,那么内外组件会共享数据,比如一些表单回填等操作。可以用 `drawerApi` 来获取数据和设置数据,配合 `onOpenChange`,可以满足大部分的需求。
+
+
+
+::: info 注意
+
+- `VbenDrawer` 组件对与参数的处理优先级是 `slot` > `props` > `state`(通过api更新的状态以及useVbenDrawer参数)。如果你已经传入了 `slot` 或者 `props`,那么 `setState` 将不会生效,这种情况下你可以通过 `slot` 或者 `props` 来更新状态。
+- 如果你使用到了 `connectedComponent` 参数,那么会存在 2 个`useVbenDrawer`, 此时,如果同时设置了相同的参数,那么以内部为准(也就是没有设置 connectedComponent 的代码)。比如 同时设置了 `onConfirm`,那么以内部的 `onConfirm` 为准。`onOpenChange`事件除外,内外都会触发。
+
+:::
+
+## API
+
+```ts
+// Drawer 为弹窗组件
+// drawerApi 为弹窗的方法
+const [Drawer, drawerApi] = useVbenDrawer({
+ // 属性
+ // 事件
+});
+```
+
+### Props
+
+所有属性都可以传入 `useVbenDrawer` 的第一个参数中。
+
+| 属性名 | 描述 | 类型 | 默认值 |
+| --- | --- | --- | --- |
+| title | 标题 | `string\|slot` | - |
+| titleTooltip | 标题提示信息 | `string\|slot` | - |
+| description | 描述信息 | `string\|slot` | - |
+| isOpen | 弹窗打开状态 | `boolean` | `false` |
+| loading | 弹窗加载状态 | `boolean` | `false` |
+| closable | 显示关闭按钮 | `boolean` | `true` |
+| modal | 显示遮罩 | `boolean` | `true` |
+| header | 显示header | `boolean` | `true` |
+| footer | 显示footer | `boolean\|slot` | `true` |
+| confirmLoading | 确认按钮loading状态 | `boolean` | `false` |
+| closeOnClickModal | 点击遮罩关闭弹窗 | `boolean` | `true` |
+| closeOnPressEscape | esc 关闭弹窗 | `boolean` | `true` |
+| confirmText | 确认按钮文本 | `string\|slot` | `确认` |
+| cancelText | 取消按钮文本 | `string\|slot` | `取消` |
+| placement | 抽屉弹出位置 | `'left'\|'right'\|'top'\|'bottom'` | `right` |
+| showCancelButton | 显示取消按钮 | `boolean` | `true` |
+| showConfirmButton | 显示确认按钮文本 | `boolean` | `true` |
+| class | modal的class,宽度通过这个配置 | `string` | - |
+| contentClass | modal内容区域的class | `string` | - |
+| footerClass | modal底部区域的class | `string` | - |
+| headerClass | modal顶部区域的class | `string` | - |
+
+### Event
+
+以下事件,只有在 `useVbenDrawer({onCancel:()=>{}})` 中传入才会生效。
+
+| 事件名 | 描述 | 类型 |
+| --- | --- | --- |
+| onBeforeClose | 关闭前触发,返回 `false`则禁止关闭 | `()=>boolean` |
+| onCancel | 点击取消按钮触发 | `()=>void` |
+| onConfirm | 点击确认按钮触发 | `()=>void` |
+| onOpenChange | 关闭或者打开弹窗时触发 | `(isOpen:boolean)=>void` |
+
+### Slots
+
+除了上面的属性类型包含`slot`,还可以通过插槽来自定义弹窗的内容。
+
+| 插槽名 | 描述 |
+| -------------- | ------------------- |
+| default | 默认插槽 - 弹窗内容 |
+| prepend-footer | 取消按钮左侧 |
+| append-footer | 取消按钮右侧 |
+
+### modalApi
+
+| 事件名 | 描述 | 类型 |
+| --- | --- | --- |
+| setState | 动态设置弹窗状态属性 | `setState(props) \| setState((prev)=>(props))` |
+| open | 打开弹窗 | `()=>void` |
+| close | 关闭弹窗 | `()=>void` |
+| setData | 设置共享数据 | `(data:T)=>void` |
+| getData | 获取共享数据 | `()=>T` |
+| useStore | 获取可响应式状态 | - |
diff --git a/apps/vben5/docs/src/components/common-ui/vben-form.md b/apps/vben5/docs/src/components/common-ui/vben-form.md
new file mode 100644
index 000000000..34e96adfd
--- /dev/null
+++ b/apps/vben5/docs/src/components/common-ui/vben-form.md
@@ -0,0 +1,519 @@
+---
+outline: deep
+---
+
+# Vben Form 表单
+
+框架提供的表单组件,可适配 `Element Plus`、`Ant Design Vue`、`Naive UI` 等框架。
+
+> 如果文档内没有参数说明,可以尝试在在线示例内寻找
+
+::: info 写在前面
+
+如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。
+
+:::
+
+## 适配器
+
+表单底层使用 [vee-validate](https://vee-validate.logaretm.com/v4/) 进行表单验证,所以你可以使用 `vee-validate` 的所有功能。对于不同的 UI 框架,我们提供了适配器,以便更好的适配不同的 UI 框架。
+
+### 适配器说明
+
+每个应用都有不同的 UI 框架,所以在应用的 `src/adapter/form` 和 `src/adapter/component` 内部,你可以根据自己的需求,进行组件适配。下面是 `Ant Design Vue` 的适配器示例代码,可根据注释查看说明:
+
+::: details ant design vue 表单适配器
+
+```ts
+import type {
+ VbenFormSchema as FormSchema,
+ VbenFormProps,
+} from '@vben/common-ui';
+
+import type { ComponentType } from './component';
+
+import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+setupVbenForm({
+ config: {
+ // ant design vue组件库默认都是 v-model:value
+ baseModelPropName: 'value',
+ // 一些组件是 v-model:checked 或者 v-model:fileList
+ modelPropNameMap: {
+ Checkbox: 'checked',
+ Radio: 'checked',
+ Switch: 'checked',
+ Upload: 'fileList',
+ },
+ },
+ defineRules: {
+ // 输入项目必填国际化适配
+ required: (value, _params, ctx) => {
+ if (value === undefined || value === null || value.length === 0) {
+ return $t('ui.formRules.required', [ctx.label]);
+ }
+ return true;
+ },
+ // 选择项目必填国际化适配
+ selectRequired: (value, _params, ctx) => {
+ if (value === undefined || value === null) {
+ return $t('ui.formRules.selectRequired', [ctx.label]);
+ }
+ return true;
+ },
+ },
+});
+
+const useVbenForm = useForm;
+
+export { useVbenForm, z };
+export type VbenFormSchema = FormSchema;
+export type { VbenFormProps };
+```
+
+:::
+
+::: details ant design vue 组件适配器
+
+```ts
+/**
+ * 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
+ * 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
+ */
+
+import type { BaseFormComponentType } from '@vben/common-ui';
+
+import type { Component, SetupContext } from 'vue';
+import { h } from 'vue';
+
+import { globalShareState } from '@vben/common-ui';
+import { $t } from '@vben/locales';
+
+import {
+ AutoComplete,
+ Button,
+ Checkbox,
+ CheckboxGroup,
+ DatePicker,
+ Divider,
+ Input,
+ InputNumber,
+ InputPassword,
+ Mentions,
+ notification,
+ Radio,
+ RadioGroup,
+ RangePicker,
+ Rate,
+ Select,
+ Space,
+ Switch,
+ Textarea,
+ TimePicker,
+ TreeSelect,
+ Upload,
+} from 'ant-design-vue';
+
+const withDefaultPlaceholder = (
+ component: T,
+ type: 'input' | 'select',
+) => {
+ return (props: any, { attrs, slots }: Omit) => {
+ const placeholder = props?.placeholder || $t(`ui.placeholder.${type}`);
+ return h(component, { ...props, ...attrs, placeholder }, slots);
+ };
+};
+
+// 这里需要自行根据业务组件库进行适配,需要用到的组件都需要在这里类型说明
+export type ComponentType =
+ | 'AutoComplete'
+ | 'Checkbox'
+ | 'CheckboxGroup'
+ | 'DatePicker'
+ | 'DefaultButton'
+ | 'Divider'
+ | 'Input'
+ | 'InputNumber'
+ | 'InputPassword'
+ | 'Mentions'
+ | 'PrimaryButton'
+ | 'Radio'
+ | 'RadioGroup'
+ | 'RangePicker'
+ | 'Rate'
+ | 'Select'
+ | 'Space'
+ | 'Switch'
+ | 'Textarea'
+ | 'TimePicker'
+ | 'TreeSelect'
+ | 'Upload'
+ | BaseFormComponentType;
+
+async function initComponentAdapter() {
+ const components: Partial> = {
+ // 如果你的组件体积比较大,可以使用异步加载
+ // Button: () =>
+ // import('xxx').then((res) => res.Button),
+
+ AutoComplete,
+ Checkbox,
+ CheckboxGroup,
+ DatePicker,
+ // 自定义默认按钮
+ DefaultButton: (props, { attrs, slots }) => {
+ return h(Button, { ...props, attrs, type: 'default' }, slots);
+ },
+ Divider,
+ Input: withDefaultPlaceholder(Input, 'input'),
+ InputNumber: withDefaultPlaceholder(InputNumber, 'input'),
+ InputPassword: withDefaultPlaceholder(InputPassword, 'input'),
+ Mentions: withDefaultPlaceholder(Mentions, 'input'),
+ // 自定义主要按钮
+ PrimaryButton: (props, { attrs, slots }) => {
+ return h(Button, { ...props, attrs, type: 'primary' }, slots);
+ },
+ Radio,
+ RadioGroup,
+ RangePicker,
+ Rate,
+ Select: withDefaultPlaceholder(Select, 'select'),
+ Space,
+ Switch,
+ Textarea: withDefaultPlaceholder(Textarea, 'input'),
+ TimePicker,
+ TreeSelect: withDefaultPlaceholder(TreeSelect, 'select'),
+ Upload,
+ };
+
+ // 将组件注册到全局共享状态中
+ globalShareState.setComponents(components);
+
+ // 定义全局共享状态中的消息提示
+ globalShareState.defineMessage({
+ // 复制成功消息提示
+ copyPreferencesSuccess: (title, content) => {
+ notification.success({
+ description: content,
+ message: title,
+ placement: 'bottomRight',
+ });
+ },
+ });
+}
+
+export { initComponentAdapter };
+```
+
+:::
+
+## 基础用法
+
+::: tip README
+
+下方示例代码中的,存在一些国际化、主题色未适配问题,这些问题只在文档内会出现,实际使用并不会有这些问题,可忽略,不必纠结。
+
+:::
+
+使用 `useVbenForm` 创建最基础的表单。
+
+
+
+## 查询表单
+
+查询表单是一种特殊的表单,用于查询数据。查询表单不会触发表单验证,只会触发查询事件。
+
+
+
+## 表单校验
+
+表单校验是一个非常重要的功能,可以通过 `rules` 属性进行校验。
+
+
+
+## 表单联动
+
+表单联动是一个非常常见的功能,可以通过 `dependencies` 属性进行联动。
+
+_注意_ 需要指定 `dependencies` 的 `triggerFields` 属性,设置由谁的改动来触发,以便表单组件能够正确的联动。
+
+
+
+## 自定义组件
+
+如果你的业务组件库没有提供某个组件,你可以自行封装一个组件,然后加到表单内部。
+
+
+
+## 操作
+
+一些常见的表单操作。
+
+
+
+## API
+
+`useVbenForm` 返回一个数组,第一个元素是表单组件,第二个元素是表单的方法。
+
+```vue
+
+
+
+
+
+```
+
+### FormApi
+
+useVbenForm 返回的第二个参数,是一个对象,包含了一些表单的方法。
+
+| 方法名 | 描述 | 类型 |
+| --- | --- | --- |
+| submitForm | 提交表单 | `(e:Event)=>Promise>` |
+| validateAndSubmitForm | 提交并校验表单 | `(e:Event)=>Promise>` |
+| resetForm | 重置表单 | `()=>Promise` |
+| setValues | 设置表单值, 默认会过滤不在schema中定义的field, 可通过filterFields形参关闭过滤 | `(fields: Record, filterFields?: boolean, shouldValidate?: boolean) => Promise` |
+| getValues | 获取表单值 | `(fields:Record,shouldValidate: boolean = false)=>Promise` |
+| validate | 表单校验 | `()=>Promise` |
+| resetValidate | 重置表单校验 | `()=>Promise` |
+| updateSchema | 更新formSchema | `(schema:FormSchema[])=>void` |
+| setFieldValue | 设置字段值 | `(field: string, value: any, shouldValidate?: boolean)=>Promise` |
+| setState | 设置组件状态(props) | `(stateOrFn:\| ((prev: VbenFormProps) => Partial)\| Partial)=>Promise` |
+| getState | 获取组件状态(props) | `()=>Promise` |
+| form | 表单对象实例,可以操作表单,见 [useForm](https://vee-validate.logaretm.com/v4/api/use-form/) | - |
+
+## Props
+
+所有属性都可以传入 `useVbenForm` 的第一个参数中。
+
+| 属性名 | 描述 | 类型 | 默认值 |
+| --- | --- | --- | --- |
+| layout | 表单项布局 | `'horizontal' \| 'vertical'` | `horizontal` |
+| showCollapseButton | 是否显示折叠按钮 | `boolean` | `false` |
+| wrapperClass | 表单的布局,基于tailwindcss | `any` | - |
+| actionWrapperClass | 表单操作区域class | `any` | - |
+| handleReset | 表单重置回调 | `(values: Record,) => Promise \| void` | - |
+| handleSubmit | 表单提交回调 | `(values: Record,) => Promise \| void` | - |
+| resetButtonOptions | 重置按钮组件参数 | `ActionButtonOptions` | - |
+| submitButtonOptions | 提交按钮组件参数 | `ActionButtonOptions` | - |
+| showDefaultActions | 是否显示默认操作按钮 | `boolean` | `true` |
+| collapsed | 是否折叠,在`是否展开,在showCollapseButton=true`时生效 | `boolean` | `false` |
+| collapseTriggerResize | 折叠时,触发`resize`事件 | `boolean` | `false` |
+| collapsedRows | 折叠时保持的行数 | `number` | `1` |
+| fieldMappingTime | 用于将表单内时间区域的应设成 2 个字段 | `[string, [string, string], string?][]` | - |
+| commonConfig | 表单项的通用配置,每个配置都会传递到每个表单项,表单项可覆盖 | `FormCommonConfig` | - |
+| schema | 表单项的每一项配置 | `FormSchema` | - |
+| submitOnEnter | 按下回车健时提交表单 | `boolean` | false |
+
+### TS 类型说明
+
+::: details ActionButtonOptions
+
+```ts
+export interface ActionButtonOptions {
+ /** 样式 */
+ class?: ClassType;
+ /** 是否禁用 */
+ disabled?: boolean;
+ /** 是否加载中 */
+ loading?: boolean;
+ /** 按钮大小 */
+ size?: ButtonVariantSize;
+ /** 按钮类型 */
+ variant?: ButtonVariants;
+ /** 是否显示 */
+ show?: boolean;
+ /** 按钮文本 */
+ text?: string;
+ /** 任意属性 */
+ [key: string]: any;
+}
+```
+
+:::
+
+::: details FormCommonConfig
+
+```ts
+export interface FormCommonConfig {
+ /**
+ * 所有表单项的props
+ */
+ componentProps?: ComponentProps;
+ /**
+ * 所有表单项的控件样式
+ */
+ controlClass?: string;
+ /**
+ * 所有表单项的禁用状态
+ * @default false
+ */
+ disabled?: boolean;
+ /**
+ * 所有表单项的控件样式
+ * @default {}
+ */
+ formFieldProps?: Partial;
+ /**
+ * 所有表单项的栅格布局
+ * @default ""
+ */
+ formItemClass?: string;
+ /**
+ * 隐藏所有表单项label
+ * @default false
+ */
+ hideLabel?: boolean;
+ /**
+ * 是否隐藏必填标记
+ * @default false
+ */
+ hideRequiredMark?: boolean;
+ /**
+ * 所有表单项的label样式
+ * @default ""
+ */
+ labelClass?: string;
+ /**
+ * 所有表单项的label宽度
+ */
+ labelWidth?: number;
+ /**
+ * 所有表单项的wrapper样式
+ */
+ wrapperClass?: string;
+}
+```
+
+:::
+
+::: details FormSchema
+
+```ts
+export interface FormSchema<
+ T extends BaseFormComponentType = BaseFormComponentType,
+> extends FormCommonConfig {
+ /** 组件 */
+ component: Component | T;
+ /** 组件参数 */
+ componentProps?: ComponentProps;
+ /** 默认值 */
+ defaultValue?: any;
+ /** 依赖 */
+ dependencies?: FormItemDependencies;
+ /** 描述 */
+ description?: string;
+ /** 字段名 */
+ fieldName: string;
+ /** 帮助信息 */
+ help?: string;
+ /** 表单项 */
+ label?: string;
+ /** 自定义组件内部渲染 */
+ renderComponentContent?: RenderComponentContentType;
+ /** 字段规则 */
+ rules?: FormSchemaRuleType;
+ /** 后缀 */
+ suffix?: CustomRenderType;
+}
+```
+
+:::
+
+### 表单联动
+
+表单联动需要通过 schema 内的 `dependencies` 属性进行联动,允许您添加字段之间的依赖项,以根据其他字段的值控制字段。
+
+```ts
+dependencies: {
+ // 只有当 name 字段的值变化时,才会触发联动
+ triggerFields: ['name'],
+ // 动态判断当前字段是否需要显示,不显示则直接销毁
+ if(values,formApi){},
+ // 动态判断当前字段是否需要显示,不显示用css隐藏
+ show(values,formApi){},
+ // 动态判断当前字段是否需要禁用
+ disabled(values,formApi){},
+ // 字段变更时,都会触发该函数
+ trigger(values,formApi){},
+ // 动态rules
+ rules(values,formApi){},
+ // 动态必填
+ required(values,formApi){},
+ // 动态组件参数
+ componentProps(values,formApi){},
+}
+```
+
+### 表单校验
+
+表单联动需要通过 schema 内的 `rules` 属性进行配置。
+
+rules的值可以是一个字符串,也可以是一个zod的schema。
+
+#### 字符串
+
+```ts
+// 表示字段必填,默认会根据适配器的required进行国际化
+{
+ rules: 'required';
+}
+
+// 表示字段必填,默认会根据适配器的required进行国际化,用于下拉选择之类
+{
+ rules: 'selectRequired';
+}
+```
+
+#### zod
+
+rules也支持 zod 的 schema,可以进行更复杂的校验,zod 的使用请查看 [zod文档](https://zod.dev/)。
+
+```ts
+import { z } from '#/adapter/form';
+
+// 基础类型
+{
+ rules: z.string().min(1, { message: '请输入字符串' });
+}
+
+// 可选,并且携带默认值
+{
+ rules: z.string().default('默认值').optional(),
+}
+
+// 复杂校验
+{
+ z.string().min(1, { message: "请输入" })
+ .refine((value) => value === "123", {
+ message: "值必须为123",
+ });
+}
+```
+
+## Slots
+
+可以使用以下插槽在表单中插入自定义的内容
+
+| 插槽名 | 描述 |
+| ------------- | ------------------ |
+| reset-before | 重置按钮之前的位置 |
+| submit-before | 提交按钮之前的位置 |
+| expand-before | 展开按钮之前的位置 |
+| expand-after | 展开按钮之后的位置 |
+
+::: tip 字段插槽
+
+除了以上内置插槽之外,`schema`属性中每个字段的`fieldName`都可以作为插槽名称,这些字段插槽的优先级高于`component`定义的组件。也就是说,当提供了与`fieldName`同名的插槽时,这些插槽的内容将会作为这些字段的组件,此时`component`的值将会被忽略。
+
+:::
diff --git a/apps/vben5/docs/src/components/common-ui/vben-modal.md b/apps/vben5/docs/src/components/common-ui/vben-modal.md
new file mode 100644
index 000000000..75f620ae5
--- /dev/null
+++ b/apps/vben5/docs/src/components/common-ui/vben-modal.md
@@ -0,0 +1,142 @@
+---
+outline: deep
+---
+
+# Vben Modal 模态框
+
+框架提供的模态框组件,支持`拖拽`、`全屏`、`自动高度`、`loading`等功能。
+
+> 如果文档内没有参数说明,可以尝试在在线示例内寻找
+
+::: info 写在前面
+
+如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。
+
+:::
+
+::: tip README
+
+下方示例代码中的,存在一些国际化、主题色未适配问题,这些问题只在文档内会出现,实际使用并不会有这些问题,可忽略,不必纠结。
+
+:::
+
+## 基础用法
+
+使用 `useVbenModal` 创建最基础的模态框。
+
+
+
+## 组件抽离
+
+Modal 内的内容一般业务中,会比较复杂,所以我们可以将 modal 内的内容抽离出来,也方便复用。通过 `connectedComponent` 参数,可以将内外组件进行连接,而不用其他任何操作。
+
+
+
+## 开启拖拽
+
+通过 `draggable` 参数,可开启拖拽功能。
+
+
+
+## 自动计算高度
+
+弹窗会自动计算内容高度,超过一定高度会出现滚动条,同时结合 `loading` 效果以及使用 `prepend-footer` 插槽。
+
+
+
+## 使用 Api
+
+通过 `modalApi` 可以调用 modal 的方法以及使用 `setState` 更新 modal 的状态。
+
+
+
+## 数据共享
+
+如果你使用了 `connectedComponent` 参数,那么内外组件会共享数据,比如一些表单回填等操作。可以用 `modalApi` 来获取数据和设置数据,配合 `onOpenChange`,可以满足大部分的需求。
+
+
+
+::: info 注意
+
+- `VbenModal` 组件对与参数的处理优先级是 `slot` > `props` > `state`(通过api更新的状态以及useVbenModal参数)。如果你已经传入了 `slot` 或者 `props`,那么 `setState` 将不会生效,这种情况下你可以通过 `slot` 或者 `props` 来更新状态。
+- 如果你使用到了 `connectedComponent` 参数,那么会存在 2 个`useVbenModal`, 此时,如果同时设置了相同的参数,那么以内部为准(也就是没有设置 connectedComponent 的代码)。比如 同时设置了 `onConfirm`,那么以内部的 `onConfirm` 为准。`onOpenChange`事件除外,内外都会触发。
+
+:::
+
+## API
+
+```ts
+// Modal 为弹窗组件
+// modalApi 为弹窗的方法
+const [Modal, modalApi] = useVbenModal({
+ // 属性
+ // 事件
+});
+```
+
+### Props
+
+所有属性都可以传入 `useVbenModal` 的第一个参数中。
+
+| 属性名 | 描述 | 类型 | 默认值 |
+| --- | --- | --- | --- |
+| title | 标题 | `string\|slot` | - |
+| titleTooltip | 标题提示信息 | `string\|slot` | - |
+| description | 描述信息 | `string\|slot` | - |
+| isOpen | 弹窗打开状态 | `boolean` | `false` |
+| loading | 弹窗加载状态 | `boolean` | `false` |
+| fullscreen | 全屏显示 | `boolean` | `false` |
+| fullscreenButton | 显示全屏按钮 | `boolean` | `true` |
+| draggable | 可拖拽 | `boolean` | `false` |
+| closable | 显示关闭按钮 | `boolean` | `true` |
+| centered | 居中显示 | `boolean` | `false` |
+| modal | 显示遮罩 | `boolean` | `true` |
+| header | 显示header | `boolean` | `true` |
+| footer | 显示footer | `boolean\|slot` | `true` |
+| confirmDisabled | 禁用确认按钮 | `boolean` | `false` |
+| confirmLoading | 确认按钮loading状态 | `boolean` | `false` |
+| closeOnClickModal | 点击遮罩关闭弹窗 | `boolean` | `true` |
+| closeOnPressEscape | esc 关闭弹窗 | `boolean` | `true` |
+| confirmText | 确认按钮文本 | `string\|slot` | `确认` |
+| cancelText | 取消按钮文本 | `string\|slot` | `取消` |
+| showCancelButton | 显示取消按钮 | `boolean` | `true` |
+| showConfirmButton | 显示确认按钮 | `boolean` | `true` |
+| class | modal的class,宽度通过这个配置 | `string` | - |
+| contentClass | modal内容区域的class | `string` | - |
+| footerClass | modal底部区域的class | `string` | - |
+| headerClass | modal顶部区域的class | `string` | - |
+| bordered | 是否显示border | `boolean` | `false` |
+
+### Event
+
+以下事件,只有在 `useVbenModal({onCancel:()=>{}})` 中传入才会生效。
+
+| 事件名 | 描述 | 类型 | 版本号 |
+| --- | --- | --- | --- |
+| onBeforeClose | 关闭前触发,返回 `false`则禁止关闭 | `()=>boolean` | |
+| onCancel | 点击取消按钮触发 | `()=>void` | |
+| onClosed | 关闭动画播放完毕时触发 | `()=>void` | >5.4.3 |
+| onConfirm | 点击确认按钮触发 | `()=>void` | |
+| onOpenChange | 关闭或者打开弹窗时触发 | `(isOpen:boolean)=>void` | |
+| onOpened | 打开动画播放完毕时触发 | `()=>void` | >5.4.3 |
+
+### Slots
+
+除了上面的属性类型包含`slot`,还可以通过插槽来自定义弹窗的内容。
+
+| 插槽名 | 描述 |
+| -------------- | ------------------- |
+| default | 默认插槽 - 弹窗内容 |
+| prepend-footer | 取消按钮左侧 |
+| append-footer | 取消按钮右侧 |
+
+### modalApi
+
+| 事件名 | 描述 | 类型 |
+| --- | --- | --- |
+| setState | 动态设置弹窗状态属性 | `setState(props) \| setState((prev)=>(props))` |
+| open | 打开弹窗 | `()=>void` |
+| close | 关闭弹窗 | `()=>void` |
+| setData | 设置共享数据 | `(data:T)=>void` |
+| getData | 获取共享数据 | `()=>T` |
+| useStore | 获取可响应式状态 | - |
diff --git a/apps/vben5/docs/src/components/common-ui/vben-vxe-table.md b/apps/vben5/docs/src/components/common-ui/vben-vxe-table.md
new file mode 100644
index 000000000..29f679f6a
--- /dev/null
+++ b/apps/vben5/docs/src/components/common-ui/vben-vxe-table.md
@@ -0,0 +1,238 @@
+---
+outline: deep
+---
+
+# Vben Vxe Table 表格
+
+框架提供的Table 列表组件基于 [vxe-table](https://vxetable.cn/v4/#/grid/api?apiKey=grid),结合`Vben Form 表单`进行了二次封装。
+
+其中,表头的 **表单搜索** 部分采用了`Vben Form表单`,表格主体部分使用了`vxe-grid`组件,支持表格的分页、排序、筛选等功能。
+
+> 如果文档内没有参数说明,可以尝试在在线示例或者在 [vxe-grid 官方API 文档](https://vxetable.cn/v4/#/grid/api?apiKey=grid) 内寻找
+
+::: info 写在前面
+
+如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。
+
+:::
+
+## 适配器
+
+表格底层使用 [vxe-table](https://vxetable.cn/#/start/install) 进行实现,所以你可以使用 `vxe-table` 的所有功能。对于不同的 UI 框架,我们提供了适配器,以便更好的适配不同的 UI 框架。
+
+### 适配器说明
+
+每个应用都可以自己配置`vxe-table`的适配器,你可以根据自己的需求。下面是一个简单的配置示例:
+
+::: details vxe-table 表格适配器
+
+```ts
+import { h } from 'vue';
+
+import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
+
+import { Button, Image } from 'ant-design-vue';
+
+import { useVbenForm } from './form';
+
+setupVbenVxeTable({
+ configVxeTable: (vxeUI) => {
+ vxeUI.setConfig({
+ grid: {
+ align: 'center',
+ border: false,
+ columnConfig: {
+ resizable: true,
+ },
+ minHeight: 180,
+ formConfig: {
+ // 全局禁用vxe-table的表单配置,使用formOptions
+ enabled: false,
+ },
+ proxyConfig: {
+ autoLoad: true,
+ response: {
+ result: 'items',
+ total: 'total',
+ list: 'items',
+ },
+ showActiveMsg: true,
+ showResponseMsg: false,
+ },
+ round: true,
+ showOverflow: true,
+ size: 'small',
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellImage' },
+ vxeUI.renderer.add('CellImage', {
+ renderTableDefault(_renderOpts, params) {
+ const { column, row } = params;
+ return h(Image, { src: row[column.field] });
+ },
+ });
+
+ // 表格配置项可以用 cellRender: { name: 'CellLink' },
+ vxeUI.renderer.add('CellLink', {
+ renderTableDefault(renderOpts) {
+ const { props } = renderOpts;
+ return h(
+ Button,
+ { size: 'small', type: 'link' },
+ { default: () => props?.text },
+ );
+ },
+ });
+
+ // 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
+ // vxeUI.formats.add
+ },
+ useVbenForm,
+});
+
+export { useVbenVxeGrid };
+
+export type * from '@vben/plugins/vxe-table';
+```
+
+:::
+
+## 基础表格
+
+使用 `useVbenVxeGrid` 创建最基础的表格。
+
+
+
+## 远程加载
+
+通过指定 `proxyConfig.ajax` 的 `query` 方法,可以实现远程加载数据。
+
+
+
+## 树形表格
+
+树形表格的数据源为扁平结构,可以指定`treeConfig`配置项,实现树形表格。
+
+```typescript
+treeConfig: {
+ transform: true, // 指定表格为树形表格
+ parentField: 'parentId', // 父节点字段名
+ rowField: 'id', // 行数据字段名
+},
+```
+
+
+
+## 固定表头/列
+
+列固定可选参数: `'left' | 'right' | '' | null`
+
+
+
+## 自定义单元格
+
+自定义单元格有两种实现方式
+
+- 通过 `slots` 插槽
+- 通过 `customCell` 自定义单元格,但是要先添加渲染器
+
+```typescript
+// 表格配置项可以用 cellRender: { name: 'CellImage' },
+vxeUI.renderer.add('CellImage', {
+ renderDefault(_renderOpts, params) {
+ const { column, row } = params;
+ return h(Image, { src: row[column.field] } as any); // 注意此处的Image 组件,来源于Antd,需要自行引入,否则会使用js的Image类
+ },
+});
+
+// 表格配置项可以用 cellRender: { name: 'CellLink' },
+vxeUI.renderer.add('CellLink', {
+ renderDefault(renderOpts) {
+ const { props } = renderOpts;
+ return h(
+ Button,
+ { size: 'small', type: 'link' },
+ { default: () => props?.text },
+ );
+ },
+});
+```
+
+
+
+## 搜索表单
+
+**表单搜索** 部分采用了`Vben Form 表单`,参考 [Vben Form 表单文档](/components/common-ui/vben-form)。
+
+
+
+## 单元格编辑
+
+通过指定`editConfig.mode`为`cell`,可以实现单元格编辑。
+
+
+
+## 行编辑
+
+通过指定`editConfig.mode`为`row`,可以实现行编辑。
+
+
+
+## 虚拟滚动
+
+通过 scroll-y.enabled 与 scroll-y.gt 组合开启,其中 enabled 为总开关,gt 是指当总行数大于指定行数时自动开启。
+
+> 参考 [vxe-table 官方文档 - 虚拟滚动](https://vxetable.cn/v4/#/component/grid/scroll/vertical)。
+
+
+
+## API
+
+`useVbenVxeGrid` 返回一个数组,第一个元素是表格组件,第二个元素是表格的方法。
+
+```vue
+
+
+
+
+
+```
+
+### GridApi
+
+useVbenVxeGrid 返回的第二个参数,是一个对象,包含了一些表单的方法。
+
+| 方法名 | 描述 | 类型 |
+| --- | --- | --- |
+| setLoading | 设置loading状态 | `(loading)=>void` |
+| setGridOptions | 设置vxe-table grid组件参数 | `(options: Partialvoid` |
+| reload | 重载表格,会进行初始化 | `(params:any)=>void` |
+| query | 重载表格,会保留当前分页 | `(params:any)=>void` |
+| grid | vxe-table grid实例 | `VxeGridInstance` |
+| formApi | vbenForm api实例 | `FormApi` |
+
+## Props
+
+所有属性都可以传入 `useVbenVxeGrid` 的第一个参数中。
+
+| 属性名 | 描述 | 类型 |
+| -------------- | ------------------ | ------------------- |
+| tableTitle | 表格标题 | `string` |
+| tableTitleHelp | 表格标题帮助信息 | `string` |
+| gridClass | grid组件的class | `string` |
+| gridOptions | grid组件的参数 | `VxeTableGridProps` |
+| gridEvents | grid组件的触发的⌚️ | `VxeGridListeners` |
+| formOptions | 表单参数 | `VbenFormProps` |
diff --git a/apps/vben5/docs/src/components/introduction.md b/apps/vben5/docs/src/components/introduction.md
new file mode 100644
index 000000000..039ec8cd8
--- /dev/null
+++ b/apps/vben5/docs/src/components/introduction.md
@@ -0,0 +1,11 @@
+# 介绍
+
+::: info README
+
+该文档介绍的是框架组件的使用方法、属性、事件等。如果你觉得现有组件的封装不够理想,或者不完全符合你的需求,大可以直接使用原生组件,亦或亲手封装一个适合的组件。框架提供的组件并非束缚,使用与否,完全取决于你的需求与自由。
+
+:::
+
+## 通用组件
+
+通用组件是一些常用的组件,比如弹窗、抽屉、表单等。大部分基于 `Tailwind CSS` 实现,可适用于不同 UI 组件库的应用。
diff --git a/apps/vben5/docs/src/demos/vben-count-to-animator/basic/index.vue b/apps/vben5/docs/src/demos/vben-count-to-animator/basic/index.vue
new file mode 100644
index 000000000..acc76edaa
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-count-to-animator/basic/index.vue
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-count-to-animator/custom/index.vue b/apps/vben5/docs/src/demos/vben-count-to-animator/custom/index.vue
new file mode 100644
index 000000000..5a2434058
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-count-to-animator/custom/index.vue
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-drawer/auto-height/drawer.vue b/apps/vben5/docs/src/demos/vben-drawer/auto-height/drawer.vue
new file mode 100644
index 000000000..9ab433ccb
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-drawer/auto-height/drawer.vue
@@ -0,0 +1,45 @@
+
+
+
+
+ {{ item }}
+
+
+
+ 点击更新数据
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-drawer/auto-height/index.vue b/apps/vben5/docs/src/demos/vben-drawer/auto-height/index.vue
new file mode 100644
index 000000000..59294e538
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-drawer/auto-height/index.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
+ Open
+
+
diff --git a/apps/vben5/docs/src/demos/vben-drawer/basic/index.vue b/apps/vben5/docs/src/demos/vben-drawer/basic/index.vue
new file mode 100644
index 000000000..bd7d92750
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-drawer/basic/index.vue
@@ -0,0 +1,11 @@
+
+
+
+ drawerApi.open()">Open
+ drawer content
+
+
diff --git a/apps/vben5/docs/src/demos/vben-drawer/dynamic/drawer.vue b/apps/vben5/docs/src/demos/vben-drawer/dynamic/drawer.vue
new file mode 100644
index 000000000..50f628316
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-drawer/dynamic/drawer.vue
@@ -0,0 +1,26 @@
+
+
+
+
+
+ 内部动态修改标题
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-drawer/dynamic/index.vue b/apps/vben5/docs/src/demos/vben-drawer/dynamic/index.vue
new file mode 100644
index 000000000..ad7e6565d
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-drawer/dynamic/index.vue
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+ Open
+
+ 从外部修改标题并打开
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-drawer/extra/drawer.vue b/apps/vben5/docs/src/demos/vben-drawer/extra/drawer.vue
new file mode 100644
index 000000000..e84c1939f
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-drawer/extra/drawer.vue
@@ -0,0 +1,8 @@
+
+
+ extra drawer content
+
diff --git a/apps/vben5/docs/src/demos/vben-drawer/extra/index.vue b/apps/vben5/docs/src/demos/vben-drawer/extra/index.vue
new file mode 100644
index 000000000..59294e538
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-drawer/extra/index.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
+ Open
+
+
diff --git a/apps/vben5/docs/src/demos/vben-drawer/shared-data/drawer.vue b/apps/vben5/docs/src/demos/vben-drawer/shared-data/drawer.vue
new file mode 100644
index 000000000..629199b67
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-drawer/shared-data/drawer.vue
@@ -0,0 +1,26 @@
+
+
+
+ 外部传递数据: {{ data }}
+
+
diff --git a/apps/vben5/docs/src/demos/vben-drawer/shared-data/index.vue b/apps/vben5/docs/src/demos/vben-drawer/shared-data/index.vue
new file mode 100644
index 000000000..04885f157
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-drawer/shared-data/index.vue
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ Open
+
+
diff --git a/apps/vben5/docs/src/demos/vben-form/api/index.vue b/apps/vben5/docs/src/demos/vben-form/api/index.vue
new file mode 100644
index 000000000..786dc89e5
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-form/api/index.vue
@@ -0,0 +1,236 @@
+
+
+
+
+
+ updateSchema
+ 更改labelWidth
+ 还原labelWidth
+ 禁用表单
+ 解除禁用
+ 隐藏操作按钮
+ 显示操作按钮
+ 隐藏重置按钮
+ 显示重置按钮
+ 隐藏提交按钮
+ 显示提交按钮
+ 修改重置按钮
+ 修改提交按钮
+
+ 调整操作按钮位置
+
+ 批量添加表单项
+
+ 批量删除表单项
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-form/basic/index.vue b/apps/vben5/docs/src/demos/vben-form/basic/index.vue
new file mode 100644
index 000000000..88d014256
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-form/basic/index.vue
@@ -0,0 +1,231 @@
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-form/custom/index.vue b/apps/vben5/docs/src/demos/vben-form/custom/index.vue
new file mode 100644
index 000000000..e4da38dcc
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-form/custom/index.vue
@@ -0,0 +1,68 @@
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-form/dynamic/index.vue b/apps/vben5/docs/src/demos/vben-form/dynamic/index.vue
new file mode 100644
index 000000000..83d1a7110
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-form/dynamic/index.vue
@@ -0,0 +1,168 @@
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-form/query/index.vue b/apps/vben5/docs/src/demos/vben-form/query/index.vue
new file mode 100644
index 000000000..a0b64f5dd
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-form/query/index.vue
@@ -0,0 +1,94 @@
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-form/rules/index.vue b/apps/vben5/docs/src/demos/vben-form/rules/index.vue
new file mode 100644
index 000000000..7abcc6f6c
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-form/rules/index.vue
@@ -0,0 +1,189 @@
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/auto-height/index.vue b/apps/vben5/docs/src/demos/vben-modal/auto-height/index.vue
new file mode 100644
index 000000000..2addf2e90
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/auto-height/index.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
+ Open
+
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/auto-height/modal.vue b/apps/vben5/docs/src/demos/vben-modal/auto-height/modal.vue
new file mode 100644
index 000000000..8757d5ef0
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/auto-height/modal.vue
@@ -0,0 +1,45 @@
+
+
+
+
+ {{ item }}
+
+
+
+ 点击更新数据
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/basic/index.vue b/apps/vben5/docs/src/demos/vben-modal/basic/index.vue
new file mode 100644
index 000000000..9f8997085
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/basic/index.vue
@@ -0,0 +1,11 @@
+
+
+
+ modalApi.open()">Open
+ modal content
+
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/draggable/index.vue b/apps/vben5/docs/src/demos/vben-modal/draggable/index.vue
new file mode 100644
index 000000000..2addf2e90
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/draggable/index.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
+ Open
+
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/draggable/modal.vue b/apps/vben5/docs/src/demos/vben-modal/draggable/modal.vue
new file mode 100644
index 000000000..ecca497b1
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/draggable/modal.vue
@@ -0,0 +1,10 @@
+
+
+ modal content
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/dynamic/index.vue b/apps/vben5/docs/src/demos/vben-modal/dynamic/index.vue
new file mode 100644
index 000000000..718e532bc
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/dynamic/index.vue
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+ Open
+
+ 从外部修改标题并打开
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/dynamic/modal.vue b/apps/vben5/docs/src/demos/vben-modal/dynamic/modal.vue
new file mode 100644
index 000000000..d46128965
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/dynamic/modal.vue
@@ -0,0 +1,38 @@
+
+
+
+
+
+ 内部动态修改标题
+
+
+ {{ state.fullscreen ? '退出全屏' : '打开全屏' }}
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/extra/index.vue b/apps/vben5/docs/src/demos/vben-modal/extra/index.vue
new file mode 100644
index 000000000..2addf2e90
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/extra/index.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
+ Open
+
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/extra/modal.vue b/apps/vben5/docs/src/demos/vben-modal/extra/modal.vue
new file mode 100644
index 000000000..488fd4a0d
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/extra/modal.vue
@@ -0,0 +1,8 @@
+
+
+ extra modal content
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/shared-data/index.vue b/apps/vben5/docs/src/demos/vben-modal/shared-data/index.vue
new file mode 100644
index 000000000..58c35e24d
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/shared-data/index.vue
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ Open
+
+
diff --git a/apps/vben5/docs/src/demos/vben-modal/shared-data/modal.vue b/apps/vben5/docs/src/demos/vben-modal/shared-data/modal.vue
new file mode 100644
index 000000000..806585d99
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-modal/shared-data/modal.vue
@@ -0,0 +1,26 @@
+
+
+
+ 外部传递数据: {{ data }}
+
+
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/basic/index.vue b/apps/vben5/docs/src/demos/vben-vxe-table/basic/index.vue
new file mode 100644
index 000000000..4b6b5a632
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/basic/index.vue
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+ {{ showBorder ? '隐藏' : '显示' }}边框
+
+
+ 显示loading
+
+
+ {{ showStripe ? '隐藏' : '显示' }}斑马纹
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/custom-cell/index.vue b/apps/vben5/docs/src/demos/vben-vxe-table/custom-cell/index.vue
new file mode 100644
index 000000000..517e73f38
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/custom-cell/index.vue
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ row.status }}
+
+
+ 编辑
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/edit-cell/index.vue b/apps/vben5/docs/src/demos/vben-vxe-table/edit-cell/index.vue
new file mode 100644
index 000000000..711941de3
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/edit-cell/index.vue
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/edit-row/index.vue b/apps/vben5/docs/src/demos/vben-vxe-table/edit-row/index.vue
new file mode 100644
index 000000000..f317f69d1
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/edit-row/index.vue
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+ 保存
+ 取消
+
+
+ 编辑
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/fixed/index.vue b/apps/vben5/docs/src/demos/vben-vxe-table/fixed/index.vue
new file mode 100644
index 000000000..6067a5ebe
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/fixed/index.vue
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+ 编辑
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/form/index.vue b/apps/vben5/docs/src/demos/vben-vxe-table/form/index.vue
new file mode 100644
index 000000000..a5e8a547b
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/form/index.vue
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/mock-api.ts b/apps/vben5/docs/src/demos/vben-vxe-table/mock-api.ts
new file mode 100644
index 000000000..e5c40b61e
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/mock-api.ts
@@ -0,0 +1,36 @@
+import { MOCK_API_DATA } from './table-data';
+
+export namespace DemoTableApi {
+ export interface PageFetchParams {
+ [key: string]: any;
+ page: number;
+ pageSize: number;
+ }
+}
+
+export function sleep(time = 1000) {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve(true);
+ }, time);
+ });
+}
+
+/**
+ * 获取示例表格数据
+ */
+async function getExampleTableApi(params: DemoTableApi.PageFetchParams) {
+ return new Promise<{ items: any; total: number }>((resolve) => {
+ const { page, pageSize } = params;
+ const items = MOCK_API_DATA.slice((page - 1) * pageSize, page * pageSize);
+
+ sleep(1000).then(() => {
+ resolve({
+ total: items.length,
+ items,
+ });
+ });
+ });
+}
+
+export { getExampleTableApi };
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/remote/index.vue b/apps/vben5/docs/src/demos/vben-vxe-table/remote/index.vue
new file mode 100644
index 000000000..bc93d29a9
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/remote/index.vue
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+ gridApi.query()">
+ 刷新当前页面
+
+ gridApi.reload()">
+ 刷新并返回第一页
+
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/table-data.ts b/apps/vben5/docs/src/demos/vben-vxe-table/table-data.ts
new file mode 100644
index 000000000..c37b88ade
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/table-data.ts
@@ -0,0 +1,384 @@
+interface TableRowData {
+ address: string;
+ age: number;
+ id: number;
+ name: string;
+ nickname: string;
+ role: string;
+}
+
+const roles = ['User', 'Admin', 'Manager', 'Guest'];
+
+export const MOCK_TABLE_DATA: TableRowData[] = (() => {
+ const data: TableRowData[] = [];
+ for (let i = 0; i < 10; i++) {
+ data.push({
+ address: `New York${i}`,
+ age: i + 1,
+ id: i,
+ name: `Test${i}`,
+ nickname: `Test${i}`,
+ role: roles[Math.floor(Math.random() * roles.length)] as string,
+ });
+ }
+ return data;
+})();
+
+export const MOCK_TREE_TABLE_DATA = [
+ {
+ date: '2020-08-01',
+ id: 10_000,
+ name: 'Test1',
+ parentId: null,
+ size: 1024,
+ type: 'mp3',
+ },
+ {
+ date: '2021-04-01',
+ id: 10_050,
+ name: 'Test2',
+ parentId: null,
+ size: 0,
+ type: 'mp4',
+ },
+ {
+ date: '2020-03-01',
+ id: 24_300,
+ name: 'Test3',
+ parentId: 10_050,
+ size: 1024,
+ type: 'avi',
+ },
+ {
+ date: '2021-04-01',
+ id: 20_045,
+ name: 'Test4',
+ parentId: 24_300,
+ size: 600,
+ type: 'html',
+ },
+ {
+ date: '2021-04-01',
+ id: 10_053,
+ name: 'Test5',
+ parentId: 24_300,
+ size: 0,
+ type: 'avi',
+ },
+ {
+ date: '2021-10-01',
+ id: 24_330,
+ name: 'Test6',
+ parentId: 10_053,
+ size: 25,
+ type: 'txt',
+ },
+ {
+ date: '2020-01-01',
+ id: 21_011,
+ name: 'Test7',
+ parentId: 10_053,
+ size: 512,
+ type: 'pdf',
+ },
+ {
+ date: '2021-06-01',
+ id: 22_200,
+ name: 'Test8',
+ parentId: 10_053,
+ size: 1024,
+ type: 'js',
+ },
+ {
+ date: '2020-11-01',
+ id: 23_666,
+ name: 'Test9',
+ parentId: null,
+ size: 2048,
+ type: 'xlsx',
+ },
+ {
+ date: '2021-06-01',
+ id: 23_677,
+ name: 'Test10',
+ parentId: 23_666,
+ size: 1024,
+ type: 'js',
+ },
+ {
+ date: '2021-06-01',
+ id: 23_671,
+ name: 'Test11',
+ parentId: 23_677,
+ size: 1024,
+ type: 'js',
+ },
+ {
+ date: '2021-06-01',
+ id: 23_672,
+ name: 'Test12',
+ parentId: 23_677,
+ size: 1024,
+ type: 'js',
+ },
+ {
+ date: '2021-06-01',
+ id: 23_688,
+ name: 'Test13',
+ parentId: 23_666,
+ size: 1024,
+ type: 'js',
+ },
+ {
+ date: '2021-06-01',
+ id: 23_681,
+ name: 'Test14',
+ parentId: 23_688,
+ size: 1024,
+ type: 'js',
+ },
+ {
+ date: '2021-06-01',
+ id: 23_682,
+ name: 'Test15',
+ parentId: 23_688,
+ size: 1024,
+ type: 'js',
+ },
+ {
+ date: '2020-10-01',
+ id: 24_555,
+ name: 'Test16',
+ parentId: null,
+ size: 224,
+ type: 'avi',
+ },
+ {
+ date: '2021-06-01',
+ id: 24_566,
+ name: 'Test17',
+ parentId: 24_555,
+ size: 1024,
+ type: 'js',
+ },
+ {
+ date: '2021-06-01',
+ id: 24_577,
+ name: 'Test18',
+ parentId: 24_555,
+ size: 1024,
+ type: 'js',
+ },
+];
+
+export const MOCK_API_DATA = [
+ {
+ available: true,
+ category: 'Computers',
+ color: 'purple',
+ currency: 'NAD',
+ description:
+ 'Ergonomic executive chair upholstered in bonded black leather and PVC padded seat and back for all-day comfort and support',
+ id: '45a613df-227a-4907-a89f-4a7f1252ca0c',
+ imageUrl: 'https://avatars.githubusercontent.com/u/62715097',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/75395683',
+ inProduction: false,
+ open: true,
+ price: '48.89',
+ productName: 'Handcrafted Steel Salad',
+ quantity: 70,
+ rating: 3.780_582_329_574_367,
+ releaseDate: '2024-09-09T04:06:57.793Z',
+ status: 'error',
+ tags: ['Bespoke', 'Handmade', 'Luxurious'],
+ weight: 1.031_015_671_912_002_5,
+ },
+ {
+ available: true,
+ category: 'Toys',
+ color: 'green',
+ currency: 'CZK',
+ description:
+ 'The Nagasaki Lander is the trademarked name of several series of Nagasaki sport bikes, that started with the 1984 ABC800J',
+ id: 'd02e5ee9-bc98-4de2-98fa-25a6567ecc19',
+ imageUrl: 'https://avatars.githubusercontent.com/u/51512330',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/58698113',
+ inProduction: false,
+ open: false,
+ price: '68.15',
+ productName: 'Generic Cotton Gloves',
+ quantity: 3,
+ rating: 1.681_749_367_682_703_3,
+ releaseDate: '2024-06-16T09:00:36.806Z',
+ status: 'warning',
+ tags: ['Rustic', 'Handcrafted', 'Recycled'],
+ weight: 9.601_076_149_300_575,
+ },
+ {
+ available: true,
+ category: 'Beauty',
+ color: 'teal',
+ currency: 'OMR',
+ description:
+ 'The Apollotech B340 is an affordable wireless mouse with reliable connectivity, 12 months battery life and modern design',
+ id: '2b72521c-225c-4e64-8030-611b76b10b37',
+ imageUrl: 'https://avatars.githubusercontent.com/u/50300075',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/36541691',
+ inProduction: true,
+ open: true,
+ price: '696.94',
+ productName: 'Gorgeous Soft Ball',
+ quantity: 50,
+ rating: 2.361_581_777_372_057_5,
+ releaseDate: '2024-06-03T13:24:19.809Z',
+ status: 'warning',
+ tags: ['Gorgeous', 'Ergonomic', 'Licensed'],
+ weight: 8.882_340_049_286_19,
+ },
+ {
+ available: true,
+ category: 'Games',
+ color: 'silver',
+ currency: 'SOS',
+ description:
+ 'Carbonite web goalkeeper gloves are ergonomically designed to give easy fit',
+ id: 'bafab694-3801-452c-b102-9eb519bd1143',
+ imageUrl: 'https://avatars.githubusercontent.com/u/89827115',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/55952747',
+ inProduction: false,
+ open: false,
+ price: '553.84',
+ productName: 'Bespoke Soft Computer',
+ quantity: 29,
+ rating: 2.176_412_873_760_271_7,
+ releaseDate: '2024-09-17T12:16:27.034Z',
+ status: 'error',
+ tags: ['Elegant', 'Rustic', 'Recycled'],
+ weight: 9.653_285_869_978_038,
+ },
+ {
+ available: true,
+ category: 'Toys',
+ color: 'indigo',
+ currency: 'BIF',
+ description:
+ 'Andy shoes are designed to keeping in mind durability as well as trends, the most stylish range of shoes & sandals',
+ id: 'bf6dea6b-2a55-441d-8773-937e03d99389',
+ imageUrl: 'https://avatars.githubusercontent.com/u/21431092',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/3771350',
+ inProduction: true,
+ open: true,
+ price: '237.39',
+ productName: 'Handcrafted Cotton Mouse',
+ quantity: 54,
+ rating: 4.363_265_388_265_461,
+ releaseDate: '2023-10-23T13:42:34.947Z',
+ status: 'error',
+ tags: ['Unbranded', 'Handmade', 'Generic'],
+ weight: 9.513_203_612_535_571,
+ },
+ {
+ available: false,
+ category: 'Tools',
+ color: 'violet',
+ currency: 'TZS',
+ description:
+ 'New ABC 13 9370, 13.3, 5th Gen CoreA5-8250U, 8GB RAM, 256GB SSD, power UHD Graphics, OS 10 Home, OS Office A & J 2016',
+ id: '135ba6ab-32ee-4989-8189-5cfa658ef970',
+ imageUrl: 'https://avatars.githubusercontent.com/u/29946092',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/23842994',
+ inProduction: false,
+ open: false,
+ price: '825.25',
+ productName: 'Awesome Bronze Ball',
+ quantity: 94,
+ rating: 4.251_159_804_726_753,
+ releaseDate: '2023-12-30T07:31:43.464Z',
+ status: 'warning',
+ tags: ['Handmade', 'Elegant', 'Unbranded'],
+ weight: 2.247_473_385_732_636_8,
+ },
+ {
+ available: true,
+ category: 'Automotive',
+ color: 'teal',
+ currency: 'BOB',
+ description: 'The Football Is Good For Training And Recreational Purposes',
+ id: '652ef256-7d4e-48b7-976c-7afaa781ea92',
+ imageUrl: 'https://avatars.githubusercontent.com/u/2531904',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/15215990',
+ inProduction: false,
+ open: false,
+ price: '780.49',
+ productName: 'Oriental Rubber Pants',
+ quantity: 70,
+ rating: 2.636_323_417_377_916,
+ releaseDate: '2024-02-23T23:30:49.628Z',
+ status: 'success',
+ tags: ['Unbranded', 'Elegant', 'Unbranded'],
+ weight: 4.812_965_858_018_838,
+ },
+ {
+ available: false,
+ category: 'Garden',
+ color: 'plum',
+ currency: 'LRD',
+ description:
+ 'The slim & simple Maple Gaming Keyboard from Dev Byte comes with a sleek body and 7- Color RGB LED Back-lighting for smart functionality',
+ id: '3ea24798-6589-40cc-85f0-ab78752244a0',
+ imageUrl: 'https://avatars.githubusercontent.com/u/23165285',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/14595665',
+ inProduction: false,
+ open: true,
+ price: '583.85',
+ productName: 'Handcrafted Concrete Hat',
+ quantity: 15,
+ rating: 1.371_600_527_752_802_7,
+ releaseDate: '2024-03-02T19:40:50.255Z',
+ status: 'error',
+ tags: ['Rustic', 'Sleek', 'Ergonomic'],
+ weight: 4.926_949_366_405_728_4,
+ },
+ {
+ available: false,
+ category: 'Industrial',
+ color: 'salmon',
+ currency: 'AUD',
+ description:
+ 'The Apollotech B340 is an affordable wireless mouse with reliable connectivity, 12 months battery life and modern design',
+ id: '997113dd-f6e4-4acc-9790-ef554c7498d1',
+ imageUrl: 'https://avatars.githubusercontent.com/u/49021914',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/4690621',
+ inProduction: true,
+ open: false,
+ price: '67.99',
+ productName: 'Generic Rubber Bacon',
+ quantity: 68,
+ rating: 4.129_840_682_128_08,
+ releaseDate: '2023-12-17T01:40:25.415Z',
+ status: 'error',
+ tags: ['Oriental', 'Small', 'Handcrafted'],
+ weight: 1.080_114_331_801_906_4,
+ },
+ {
+ available: false,
+ category: 'Tools',
+ color: 'sky blue',
+ currency: 'NOK',
+ description:
+ 'The Nagasaki Lander is the trademarked name of several series of Nagasaki sport bikes, that started with the 1984 ABC800J',
+ id: 'f697a250-6cb2-46c8-b0f7-871ab1f2fa8d',
+ imageUrl: 'https://avatars.githubusercontent.com/u/95928385',
+ imageUrl2: 'https://avatars.githubusercontent.com/u/47588244',
+ inProduction: false,
+ open: false,
+ price: '613.89',
+ productName: 'Gorgeous Frozen Ball',
+ quantity: 55,
+ rating: 1.646_947_205_998_534_6,
+ releaseDate: '2024-10-13T12:31:04.929Z',
+ status: 'warning',
+ tags: ['Handmade', 'Unbranded', 'Unbranded'],
+ weight: 9.430_690_557_758_114,
+ },
+];
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/tree/index.vue b/apps/vben5/docs/src/demos/vben-vxe-table/tree/index.vue
new file mode 100644
index 000000000..0024765a8
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/tree/index.vue
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+ 展开全部
+
+ 折叠全部
+
+
+
+
diff --git a/apps/vben5/docs/src/demos/vben-vxe-table/virtual/index.vue b/apps/vben5/docs/src/demos/vben-vxe-table/virtual/index.vue
new file mode 100644
index 000000000..81fa00af2
--- /dev/null
+++ b/apps/vben5/docs/src/demos/vben-vxe-table/virtual/index.vue
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/src/en/guide/essentials/build.md b/apps/vben5/docs/src/en/guide/essentials/build.md
new file mode 100644
index 000000000..7f5c95321
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/essentials/build.md
@@ -0,0 +1,243 @@
+# Build and Deployment
+
+::: tip Preface
+
+Since this is a demonstration project, the package size after building is relatively large. If there are plugins in the project that are not used, you can delete the corresponding files or routes. If they are not referenced, they will not be packaged.
+
+:::
+
+## Building
+
+After the project development is completed, execute the following command to build:
+
+**Note:** Please execute the following command in the project root directory.
+
+```bash
+pnpm build
+```
+
+After the build is successful, a `dist` folder for the corresponding application will be generated in the root directory, which contains the built and packaged files, for example: `apps/web-antd/dist/`
+
+## Preview
+
+Before publishing, you can preview it locally in several ways, here are two:
+
+- Using the project's custom command for preview (recommended)
+
+**Note:** Please execute the following command in the project root directory.
+
+```bash
+pnpm preview
+```
+
+After waiting for the build to succeed, visit `http://localhost:4173` to view the effect.
+
+- Local server preview
+
+You can globally install a `serve` service on your computer, such as `live-server`,
+
+```bash
+npm i -g live-server
+```
+
+Then execute the `live-server` command in the `dist` directory to view the effect locally.
+
+```bash
+cd apps/web-antd/dist
+# Local preview, default port 8080
+live-server
+# Specify port
+live-server --port 9000
+```
+
+## Compression
+
+### Enable `gzip` Compression
+
+To enable during the build process, change the `.env.production` configuration:
+
+```bash
+VITE_COMPRESS=gzip
+```
+
+### Enable `brotli` Compression
+
+To enable during the build process, change the `.env.production` configuration:
+
+```bash
+VITE_COMPRESS=brotli
+```
+
+### Enable Both `gzip` and `brotli` Compression
+
+To enable during the build process, change the `.env.production` configuration:
+
+```bash
+VITE_COMPRESS=gzip,brotli
+```
+
+::: tip Note
+
+Both `gzip` and `brotli` require specific modules to be installed for use.
+
+:::
+
+::: details gzip 与 brotli 在 nginx 内的配置
+
+```bash
+http {
+ # Enable gzip
+ gzip on;
+ # Enable gzip_static
+ # After enabling gzip_static, there might be errors, requiring the installation of specific modules. The installation method can be researched independently.
+ # Only with this enabled, the .gz files packaged by vue files will be effective; otherwise, there is no need to enable gzip for packaging.
+ gzip_static on;
+ gzip_proxied any;
+ gzip_min_length 1k;
+ gzip_buffers 4 16k;
+ # If nginx uses multiple layers of proxy, this must be set to enable gzip.
+ gzip_http_version 1.0;
+ gzip_comp_level 2;
+ gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
+ gzip_vary off;
+ gzip_disable "MSIE [1-6]\.";
+
+ # Enable brotli compression
+ # Requires the installation of the corresponding nginx module, which can be researched independently.
+ # Can coexist with gzip without conflict.
+ brotli on;
+ brotli_comp_level 6;
+ brotli_buffers 16 8k;
+ brotli_min_length 20;
+ brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
+}
+```
+
+:::
+
+## Build Analysis
+
+If your build files are large, you can optimize your code by analyzing the code size with the built-in [rollup-plugin-analyzer](https://github.com/doesdev/rollup-plugin-analyzer) plugin. Just execute the following command in the `root directory`:
+
+```bash
+pnpm run build:analyze
+```
+
+After running, you can see the specific distribution of sizes on the automatically opened page to analyze which dependencies are problematic.
+
+
+
+## Deployment
+
+A simple deployment only requires publishing the final static files, the static files in the dist folder, to your CDN or static server. It's important to note that the index.html is usually the entry page for your backend service. After determining the static js and css, you may need to change the page's import path.
+
+For example, to upload to an nginx server, you can upload the files under the dist folder to the server's `/srv/www/project/index.html` directory, and then access the configured domain name.
+
+```bash
+# nginx configuration
+location / {
+ # Do not cache html to prevent cache from continuing to be effective after program updates
+ if ($request_filename ~* .*\.(?:htm|html)$) {
+ add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
+ access_log on;
+ }
+ # This is the storage path for the files inside the vue packaged dist folder
+ root /srv/www/project/;
+ index index.html index.htm;
+}
+```
+
+If you find the resource path is incorrect during deployment, you just need to modify the `.env.production` file.
+
+```bash
+# Configure the change according to your own path
+# Note that it needs to start and end with /
+VITE_BASE=/
+VITE_BASE=/xxx/
+```
+
+### Integration of Frontend Routing and Server
+
+The project uses vue-router for frontend routing, so you can choose between two modes: history and hash.
+
+- `hash` mode will append `#` to the URL by default.
+- `history` mode will not, but `history` mode requires server-side support.
+
+You can modify the mode in `.env.production`:
+
+```bash
+VITE_ROUTER_HISTORY=hash
+```
+
+### Server Configuration for History Mode Routing
+
+Enabling `history` mode requires server configuration. For more details on server configuration, see [history-mode](https://router.vuejs.org/guide/essentials/history-mode.html#html5-mode)
+
+Here is an example of `nginx` configuration:
+
+#### Deployment at the Root Directory
+
+```bash {5}
+server {
+ listen 80;
+ location / {
+ # For use with History mode
+ try_files $uri $uri/ /index.html;
+ }
+}
+```
+
+#### Deployment to a Non-root Directory
+
+- First, you need to change the `.env.production` configuration during packaging:
+
+```bash
+VITE_BASE = /sub/
+```
+
+- Then configure in the nginx configuration file
+
+```bash {8}
+server {
+ listen 80;
+ server_name localhost;
+ location /sub/ {
+ # This is the path where the vue packaged dist files are stored
+ alias /srv/www/project/;
+ index index.html index.htm;
+ try_files $uri $uri/ /sub/index.html;
+ }
+}
+```
+
+## Cross-Domain Handling
+
+Using nginx to handle cross-domain issues after project deployment
+
+1. Configure the frontend project API address in the `.env.production` file in the project directory:
+
+```bash
+VITE_GLOB_API_URL=/api
+```
+
+2. Configure nginx to forward requests to the backend
+
+```bash {10-11}
+server {
+ listen 8080;
+ server_name localhost;
+ # API proxy for solving cross-domain issues
+ location /api {
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ # Backend API address
+ proxy_pass http://110.110.1.1:8080/api;
+ rewrite "^/api/(.*)$" /$1 break;
+ proxy_redirect default;
+ add_header Access-Control-Allow-Origin *;
+ add_header Access-Control-Allow-Headers X-Requested-With;
+ add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
+ }
+}
+```
diff --git a/apps/vben5/docs/src/en/guide/essentials/concept.md b/apps/vben5/docs/src/en/guide/essentials/concept.md
new file mode 100644
index 000000000..8c940a943
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/essentials/concept.md
@@ -0,0 +1,70 @@
+# Basic Concepts
+
+In the new version, the entire project has been restructured. Now, we will introduce some basic concepts to help you better understand the entire document. Please make sure to read this section first.
+
+## Monorepo
+
+Monorepo refers to the repository of the entire project, which includes all code, packages, applications, standards, documentation, configurations, etc., that is, the entire content of a `Monorepo` directory.
+
+## Applications
+
+Applications refer to a complete project; a project can contain multiple applications, which can reuse the code, packages, standards, etc., within the monorepo. Applications are placed in the `apps` directory. Each application is independent and can be run, built, tested, and deployed separately; it can also include different component libraries, etc.
+
+::: tip
+
+Applications are not limited to front-end applications; they can also be back-end applications, mobile applications, etc. For example, `apps/backend-mock` is a back-end service.
+
+:::
+
+## Packages
+
+A package refers to an independent module, which can be a component, a tool, a library, etc. Packages can be referenced by multiple applications or other packages. Packages are placed in the `packages` directory.
+
+You can consider these packages as independent `npm` packages, and they are used in the same way as `npm` packages.
+
+### Package Import
+
+Importing a package in `package.json`:
+
+```json {3}
+{
+ "dependencies": {
+ "@vben/utils": "workspace:*"
+ }
+}
+```
+
+### Package Usage
+
+Importing a package in the code:
+
+```ts
+import { isString } from '@vben/utils';
+```
+
+## Aliases
+
+In the project, you can see some paths starting with `#`, such as `#/api`, `#/views`. These paths are aliases, used for quickly locating a certain directory. They are not implemented through `vite`'s `alias`, but through the principle of [subpath imports](https://nodejs.org/api/packages.html#subpath-imports) in `Node.js` itself. You only need to configure the `imports` field in `package.json`.
+
+```json {3}
+{
+ "imports": {
+ "#/*": "./src/*"
+ }
+}
+```
+
+To make these aliases recognizable by the IDE, we also need to configure them in `tsconfig.json`:
+
+```json {5}
+{
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "#/*": ["src/*"]
+ }
+ }
+}
+```
+
+This way, you can use aliases in your code.
diff --git a/apps/vben5/docs/src/en/guide/essentials/development.md b/apps/vben5/docs/src/en/guide/essentials/development.md
new file mode 100644
index 000000000..da7cfd8ce
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/essentials/development.md
@@ -0,0 +1,188 @@
+# Local Development {#development}
+
+::: tip Code Acquisition
+
+If you haven't acquired the code yet, you can start by reading the documentation from [Quick Start](../introduction/quick-start.md).
+
+:::
+
+## Prerequisites
+
+For a better development experience, we provide some tool configurations and project descriptions to facilitate your development.
+
+### Required Basic Knowledge
+
+This project requires some basic frontend knowledge. Please ensure you are familiar with the basics of Vue to handle common issues. It is recommended to learn the following topics before development. Understanding these will be very helpful for the project:
+
+- [Vue3](https://vuejs.org/)
+- [Tailwind CSS](https://tailwindcss.com/)
+- [TypeScript](https://www.typescriptlang.org/)
+- [Vue Router](https://router.vuejs.org/)
+- [Vitejs](https://vitejs.dev/)
+- [Pnpm](https://pnpm.io/)
+- [Turbo](https://turbo.build/)
+
+### Tool Configuration
+
+If you are using [vscode](https://code.visualstudio.com/) (recommended) as your IDE, you can install the following tools to improve development efficiency and code formatting:
+
+- [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) - Official Vue plugin (essential).
+- [Tailwind CSS](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss) - Tailwind CSS autocomplete plugin.
+- [CSS Variable Autocomplete](https://marketplace.visualstudio.com/items?itemName=vunguyentuan.vscode-css-variables) - CSS variable autocomplete plugin.
+- [Iconify IntelliSense](https://marketplace.visualstudio.com/items?itemName=antfu.iconify) - Iconify icon plugin.
+- [i18n Ally](https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally) - i18n plugin.
+- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - Script code linting.
+- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - Code formatting.
+- [Stylelint](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint) - CSS formatting.
+- [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) - Spelling checker.
+- [DotENV](https://marketplace.visualstudio.com/items?itemName=mikestead.dotenv) - .env file highlighting.
+
+## Npm Scripts
+
+Npm scripts are common configurations used in the project to perform common tasks such as starting the project, building the project, etc. The following scripts can be found in the `package.json` file at the root of the project.
+
+The execution command is: `pnpm run [script]` or `npm run [script]`.
+
+```json
+{
+ "scripts": {
+ // Build the project
+ "build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 turbo build",
+ // Build the project with analysis
+ "build:analyze": "turbo build:analyze",
+ // Build a local Docker image
+ "build:docker": "./build-local-docker-image.sh",
+ // Build the web-antd application separately
+ "build:antd": "pnpm run build --filter=@vben/web-antd",
+ // Build the documentation separately
+ "build:docs": "pnpm run build --filter=@vben/docs",
+ // Build the web-ele application separately
+ "build:ele": "pnpm run build --filter=@vben/web-ele",
+ // Build the web-naive application separately
+ "build:naive": "pnpm run build --filter=@vben/naive",
+ // Build the playground application separately
+ "build:play": "pnpm run build --filter=@vben/playground",
+ // Changeset version management
+ "changeset": "pnpm exec changeset",
+ // Check for various issues in the project
+ "check": "pnpm run check:circular && pnpm run check:dep && pnpm run check:type && pnpm check:cspell",
+ // Check for circular dependencies
+ "check:circular": "vsh check-circular",
+ // Check spelling
+ "check:cspell": "cspell lint **/*.ts **/README.md .changeset/*.md --no-progress"
+ // Check dependencies
+ "check:dep": "vsh check-dep",
+ // Check types
+ "check:type": "turbo run typecheck",
+ // Clean the project (delete node_modules, dist, .turbo, etc.)
+ "clean": "node ./scripts/clean.mjs",
+ // Commit code
+ "commit": "czg",
+ // Start the project (by default, the dev scripts of all packages in the entire repository will run)
+ "dev": "turbo-run dev",
+ // Start the web-antd application
+ "dev:antd": "pnpm -F @vben/web-antd run dev",
+ // Start the documentation
+ "dev:docs": "pnpm -F @vben/docs run dev",
+ // Start the web-ele application
+ "dev:ele": "pnpm -F @vben/web-ele run dev",
+ // Start the web-naive application
+ "dev:naive": "pnpm -F @vben/web-naive run dev",
+ // Start the playground application
+ "dev:play": "pnpm -F @vben/playground run dev",
+ // Format code
+ "format": "vsh lint --format",
+ // Lint code
+ "lint": "vsh lint",
+ // After installing dependencies, execute the stub script for all packages
+ "postinstall": "pnpm -r run stub --if-present",
+ // Only allow using pnpm
+ "preinstall": "npx only-allow pnpm",
+ // Install husky
+ "prepare": "is-ci || husky",
+ // Preview the application
+ "preview": "turbo-run preview",
+ // Package specification check
+ "publint": "vsh publint",
+ // Delete all node_modules, yarn.lock, package.lock.json, and reinstall dependencies
+ "reinstall": "pnpm clean --del-lock && pnpm install",
+ // Run vitest unit tests
+ "test:unit": "vitest run --dom",
+ // Update project dependencies
+ "update:deps": " pnpm update --latest --recursive",
+ // Changeset generation and versioning
+ "version": "pnpm exec changeset version && pnpm install --no-frozen-lockfile"
+ }
+}
+```
+
+## Running the Project Locally
+
+To run the documentation locally and make adjustments, you can execute the following command. This command allows you to select the application you want to develop:
+
+```bash
+pnpm dev
+```
+
+If you want to run a specific application directly, you can execute the following commands:
+
+To run the `web-antd` application:
+
+```bash
+pnpm dev:antd
+```
+
+To run the `web-naive` application:
+
+```bash
+pnpm dev:naive
+```
+
+To run the `web-ele` application:
+
+```bash
+pnpm dev:ele
+```
+
+To run the `docs` application:
+
+```bash
+pnpm dev:docs
+```
+
+## 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"`.
+
+You need to put the resource in the corresponding project's `public/static` directory. The import path for the resource should be `src="/static/xxx.png"`.
+
+## DevTools
+
+The project has a built-in [Vue DevTools](https://github.com/vuejs/devtools-next) plugin, which can be used during development. It is disabled by default, but can be enabled in the `.env.development` file. After enabling it, restart the project:
+
+```bash
+VITE_DEVTOOLS=true
+```
+
+Once enabled, a Vue DevTools icon will appear at the bottom of the page during project runtime. Click it to open the DevTools.
+
+
+
+## Running Documentation Locally
+
+To run the documentation locally and make adjustments, you can execute the following command:
+
+```bash
+pnpm dev:docs
+```
+
+## Troubleshooting
+
+If you encounter dependency-related issues, you can try reinstalling the dependencies:
+
+```bash
+# Execute this command at the root of the project.
+# This command will delete all node_modules, yarn.lock, and package.lock.json files
+# and then reinstall dependencies (this process will be noticeably slower).
+pnpm reinstall
+```
diff --git a/apps/vben5/docs/src/en/guide/essentials/external-module.md b/apps/vben5/docs/src/en/guide/essentials/external-module.md
new file mode 100644
index 000000000..f0a6d6e3f
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/essentials/external-module.md
@@ -0,0 +1,58 @@
+# External Modules
+
+In addition to the external modules that are included by default in the project, sometimes we need to import other external modules. Let's take [ant-design-vue](https://antdv.com/components/overview) as an example:
+
+## Installing Dependencies
+
+::: tip Install dependencies into a specific package
+
+- Since the project uses [pnpm](https://pnpm.io/) as the package management tool, we need to use the `pnpm` command to install dependencies.
+- As the project is managed using a Monorepo module, we need to install dependencies under a specific package. Please make sure you have entered the specific package directory before installing dependencies.
+
+:::
+
+```bash
+# cd /path/to/your/package
+pnpm add ant-design-vue
+```
+
+## Usage
+
+### Global Import
+
+```ts
+import { createApp } from 'vue';
+import Antd from 'ant-design-vue';
+import App from './App';
+import 'ant-design-vue/dist/reset.css';
+
+const app = createApp(App);
+
+app.use(Antd).mount('#app');
+```
+
+#### Usage
+
+```vue
+
+ text
+
+```
+
+### Partial Import
+
+```vue
+
+
+
+ text
+
+```
+
+::: warning Note
+
+- If the component depends on styles, you also need to import the style file.
+
+:::
diff --git a/apps/vben5/docs/src/en/guide/essentials/icons.md b/apps/vben5/docs/src/en/guide/essentials/icons.md
new file mode 100644
index 000000000..0c1631fe8
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/essentials/icons.md
@@ -0,0 +1,78 @@
+# Icons
+
+::: tip About Icon Management
+
+- The icons in the project are mainly provided by the `@vben/icons` package. It is recommended to manage them within this package for unified management and maintenance.
+- If you are using `Vscode`, it is recommended to install the [Iconify IntelliSense](https://marketplace.visualstudio.com/items?itemName=antfu.iconify) plugin, which makes it easy to find and use icons.
+
+:::
+
+There are several ways to use icons in the project, you can choose according to the actual situation:
+
+## Iconify Icons
+
+Integrated with the [iconify](https://github.com/iconify/iconify) icon library
+
+### Adding New Icons
+
+You can add new icons in the `packages/icons/src/iconify` directory:
+
+```ts
+// packages/icons/src/iconify/index.ts
+import { createIconifyIcon } from '@vben-core/icons';
+
+export const MdiKeyboardEsc = createIconifyIcon('mdi:keyboard-esc');
+```
+
+### Usage
+
+```vue
+
+
+
+
+
+
+```
+
+## SVG Icons
+
+Instead of using Svg Sprite, SVG icons are directly imported,
+
+### Adding New Icons
+
+You can add new icon files `test.svg` in the `packages/icons/src/svg/icons` directory, and then import it in `packages/icons/src/svg/index.ts`:
+
+```ts
+// packages/icons/src/svg/index.ts
+import { createIconifyIcon } from '@vben-core/icons';
+
+const SvgTestIcon = createIconifyIcon('svg:test');
+
+export { SvgTestIcon };
+```
+
+### Usage
+
+```vue
+
+
+
+
+
+
+```
+
+## Tailwind CSS Icons
+
+### Usage
+
+You can use the icons by directly adding the Tailwind CSS icon class names, which can be found on [iconify](https://github.com/iconify/iconify) :
+
+```vue
+
+```
diff --git a/apps/vben5/docs/src/en/guide/essentials/route.md b/apps/vben5/docs/src/en/guide/essentials/route.md
new file mode 100644
index 000000000..bef40d691
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/essentials/route.md
@@ -0,0 +1,606 @@
+---
+outline: deep
+---
+
+# Routes and Menus
+
+::: info
+
+This page is translated by machine translation and may not be very accurate.
+
+:::
+
+In the project, the framework provides a basic routing system and **automatically generates the corresponding menu structure based on the routing files**.
+
+## Types of Routes
+
+Routes are divided into core routes, static routes, and dynamic routes. Core routes are built-in routes of the framework, including root routes, login routes, 404 routes, etc.; static routes are routes that are determined when the project starts; dynamic routes are generally generated dynamically based on the user's permissions after the user logs in.
+
+Both static and dynamic routes go through permission control, which can be controlled by configuring the `authority` field in the `meta` property of the route.
+
+### Core Routes
+
+Core routes are built-in routes of the framework, including root routes, login routes, 404 routes, etc. The configuration of core routes is in the `src/router/routes/core` directory under the application.
+
+::: tip
+
+Core routes are mainly used for the basic functions of the framework, so it is not recommended to put business-related routes in core routes. It is recommended to put business-related routes in static or dynamic routes.
+
+:::
+
+### Static Routes
+
+The configuration of static routes is in the `src/router/routes/index` directory under the application. Open the commented file content:
+
+::: tip
+
+Permission control is controlled by the `authority` field in the `meta` property of the route. If your page project does not require permission control, you can omit the `authority` field.
+
+:::
+
+```ts
+// Uncomment if needed and create the folder
+// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true }); // [!code --]
+const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true }); // [!code ++]
+/** Dynamic routes */
+const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
+
+/** External route list, these pages can be accessed without Layout, possibly used for embedding in other systems */
+// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles) // [!code --]
+const externalRoutes: RouteRecordRaw[] = []; // [!code --]
+const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles); // [!code ++]
+```
+
+### Dynamic Routes
+
+The configuration of dynamic routes is in the `src/router/routes/modules` directory under the corresponding application. This directory contains all the route files. The content format of each file is consistent with the Vue Router route configuration format. Below is the configuration of secondary and multi-level routes.
+
+## Route Definition
+
+The configuration method of static routes and dynamic routes is the same. Below is the configuration of secondary and multi-level routes:
+
+### Secondary Routes
+
+::: details Secondary Route Example Code
+
+```ts
+import type { RouteRecordRaw } from 'vue-router';
+
+import { VBEN_LOGO_URL } from '@vben/constants';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ badgeType: 'dot',
+ badgeVariants: 'destructive',
+ icon: VBEN_LOGO_URL,
+ order: 9999,
+ title: $t('page.vben.title'),
+ },
+ name: 'VbenProject',
+ path: '/vben-admin',
+ redirect: '/vben-admin/about',
+ children: [
+ {
+ name: 'VbenAbout',
+ path: '/vben-admin/about',
+ component: () => import('#/views/_core/about/index.vue'),
+ meta: {
+ badgeType: 'dot',
+ badgeVariants: 'destructive',
+ icon: 'lucide:copyright',
+ title: $t('page.vben.about'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
+```
+
+:::
+
+### Multi-level Routes
+
+::: tip
+
+- The parent route of multi-level routes does not need to set the `component` property, just set the `children` property. Unless you really need to display content nested under the parent route.
+- In most cases, the `redirect` property of the parent route does not need to be specified, it will default to the first child route.
+
+:::
+
+::: details Multi-level Route Example Code
+
+```ts
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'ic:baseline-view-in-ar',
+ keepAlive: true,
+ order: 1000,
+ title: $t('demos.title'),
+ },
+ name: 'Demos',
+ path: '/demos',
+ redirect: '/demos/access',
+ children: [
+ // Nested menu
+ {
+ meta: {
+ icon: 'ic:round-menu',
+ title: $t('demos.nested.title'),
+ },
+ name: 'NestedDemos',
+ path: '/demos/nested',
+ redirect: '/demos/nested/menu1',
+ children: [
+ {
+ name: 'Menu1Demo',
+ path: '/demos/nested/menu1',
+ component: () => import('#/views/demos/nested/menu-1.vue'),
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu1'),
+ },
+ },
+ {
+ name: 'Menu2Demo',
+ path: '/demos/nested/menu2',
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu2'),
+ },
+ redirect: '/demos/nested/menu2/menu2-1',
+ children: [
+ {
+ name: 'Menu21Demo',
+ path: '/demos/nested/menu2/menu2-1',
+ component: () => import('#/views/demos/nested/menu-2-1.vue'),
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu2_1'),
+ },
+ },
+ ],
+ },
+ {
+ name: 'Menu3Demo',
+ path: '/demos/nested/menu3',
+ meta: {
+ icon: 'ic:round-menu',
+ title: $t('demos.nested.menu3'),
+ },
+ redirect: '/demos/nested/menu3/menu3-1',
+ children: [
+ {
+ name: 'Menu31Demo',
+ path: 'menu3-1',
+ component: () => import('#/views/demos/nested/menu-3-1.vue'),
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu3_1'),
+ },
+ },
+ {
+ name: 'Menu32Demo',
+ path: 'menu3-2',
+ meta: {
+ icon: 'ic:round-menu',
+ title: $t('demos.nested.menu3_2'),
+ },
+ redirect: '/demos/nested/menu3/menu3-2/menu3-2-1',
+ children: [
+ {
+ name: 'Menu321Demo',
+ path: '/demos/nested/menu3/menu3-2/menu3-2-1',
+ component: () =>
+ import('#/views/demos/nested/menu-3-2-1.vue'),
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu3_2_1'),
+ },
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+];
+
+export default routes;
+```
+
+:::
+
+## Adding a New Page
+
+To add a new page, you only need to add a route and the corresponding page component.
+
+### Adding a Route
+
+Add a route object in the corresponding route file, as follows:
+
+```ts
+import type { RouteRecordRaw } from 'vue-router';
+
+import { VBEN_LOGO_URL } from '@vben/constants';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'mdi:home',
+ title: $t('page.home.title'),
+ },
+ name: 'Home',
+ path: '/home',
+ redirect: '/home/index',
+ children: [
+ {
+ name: 'HomeIndex',
+ path: '/home/index',
+ component: () => import('#/views/home/index.vue'),
+ meta: {
+ icon: 'mdi:home',
+ title: $t('page.home.index'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
+```
+
+### Adding a Page Component
+
+In `#/views/home/`, add a new `index.vue` file, as follows:
+
+```vue
+
+
+
home page
+
+
+```
+
+### Verification
+
+At this point, the page has been added. Visit `http://localhost:5555/home/index` to see the corresponding page.
+
+## Route Configuration
+
+The route configuration items are mainly in the `meta` property of the route object. The following are common configuration items:
+
+```ts {5-8}
+const routes = [
+ {
+ name: 'HomeIndex',
+ path: '/home/index',
+ meta: {
+ icon: 'mdi:home',
+ title: $t('page.home.index'),
+ },
+ },
+];
+```
+
+::: details Route Meta Configuration Type Definition
+
+```ts
+interface RouteMeta {
+ /**
+ * Active icon (menu)
+ */
+ activeIcon?: string;
+ /**
+ * The currently active menu, sometimes you don't want to activate the existing menu, use this to activate the parent menu
+ */
+ activePath?: string;
+ /**
+ * Whether to fix the tab
+ * @default false
+ */
+ affixTab?: boolean;
+ /**
+ * The order of fixed tabs
+ * @default 0
+ */
+ affixTabOrder?: number;
+ /**
+ * Specific roles required to access
+ * @default []
+ */
+ authority?: string[];
+ /**
+ * Badge
+ */
+ badge?: string;
+ /**
+ * Badge type
+ */
+ badgeType?: 'dot' | 'normal';
+ /**
+ * Badge color
+ */
+ badgeVariants?:
+ | 'default'
+ | 'destructive'
+ | 'primary'
+ | 'success'
+ | 'warning'
+ | string;
+ /**
+ * The children of the current route are not displayed in the menu
+ * @default false
+ */
+ hideChildrenInMenu?: boolean;
+ /**
+ * The current route is not displayed in the breadcrumb
+ * @default false
+ */
+ hideInBreadcrumb?: boolean;
+ /**
+ * The current route is not displayed in the menu
+ * @default false
+ */
+ hideInMenu?: boolean;
+ /**
+ * The current route is not displayed in the tab
+ * @default false
+ */
+ hideInTab?: boolean;
+ /**
+ * Icon (menu/tab)
+ */
+ icon?: string;
+ /**
+ * iframe address
+ */
+ iframeSrc?: string;
+ /**
+ * Ignore permissions, can be accessed directly
+ * @default false
+ */
+ ignoreAccess?: boolean;
+ /**
+ * Enable KeepAlive cache
+ */
+ keepAlive?: boolean;
+ /**
+ * External link - jump path
+ */
+ link?: string;
+ /**
+ * Whether the route has been loaded
+ */
+ loaded?: boolean;
+ /**
+ * Maximum number of open tabs
+ * @default false
+ */
+ maxNumOfOpenTab?: number;
+ /**
+ * The menu can be seen, but access will be redirected to 403
+ */
+ menuVisibleWithForbidden?: boolean;
+ /**
+ * Open in a new window
+ */
+ openInNewWindow?: boolean;
+ /**
+ * Used for route -> menu sorting
+ */
+ order?: number;
+ /**
+ * Parameters carried by the menu
+ */
+ query?: Recordable;
+ /**
+ * Title name
+ */
+ title: string;
+}
+```
+
+:::
+
+### title
+
+- Type: `string`
+- Default: `''`
+
+Used to configure the title of the page, which will be displayed in the menu and tab. Generally used with internationalization.
+
+### icon
+
+- Type: `string`
+- Default: `''`
+
+Used to configure the icon of the page, which will be displayed in the menu and tab. Generally used with an icon library, if it is an `http` link, the image will be loaded automatically.
+
+### activeIcon
+
+- Type: `string`
+- Default: `''`
+
+Used to configure the active icon of the page, which will be displayed in the menu. Generally used with an icon library, if it is an `http` link, the image will be loaded automatically.
+
+### keepAlive
+
+- Type: `boolean`
+- Default: `false`
+
+Used to configure whether the page cache is enabled. When enabled, the page will be cached and will not reload, only effective when the tab is enabled.
+
+### hideInMenu
+
+- Type: `boolean`
+- Default: `false`
+
+Used to configure whether the page is hidden in the menu. When hidden, the page will not be displayed in the menu.
+
+### hideInTab
+
+- Type: `boolean`
+- Default: `false`
+
+Used to configure whether the page is hidden in the tab. When hidden, the page will not be displayed in the tab.
+
+### hideInBreadcrumb
+
+- Type: `boolean`
+- Default: `false`
+
+Used to configure whether the page is hidden in the breadcrumb. When hidden, the page will not be displayed in the breadcrumb.
+
+### hideChildrenInMenu
+
+- Type: `boolean`
+- Default: `false`
+
+Used to configure whether the subpages of the page are hidden in the menu. When hidden, the subpages will not be displayed in the menu.
+
+### authority
+
+- Type: `string[]`
+- Default: `[]`
+
+Used to configure the permissions of the page. Only users with the corresponding permissions can access the page. If not configured, no permissions are required.
+
+### badge
+
+- Type: `string`
+- Default: `''`
+
+Used to configure the badge of the page, which will be displayed in the menu.
+
+### badgeType
+
+- Type: `'dot' | 'normal'`
+- Default: `'normal'`
+
+Used to configure the badge type of the page. `dot` is a small red dot, `normal` is text.
+
+### badgeVariants
+
+- Type: `'default' | 'destructive' | 'primary' | 'success' | 'warning' | string`
+- Default: `'success'`
+
+Used to configure the badge color of the page.
+
+### activePath
+
+- Type: `string`
+- Default: `''`
+
+Used to configure the currently active menu. Sometimes the page is not displayed in the menu, and this is used to activate the parent menu.
+
+### affixTab
+
+- Type: `boolean`
+- Default: `false`
+
+Used to configure whether the page is fixed in the tab. When fixed, the page cannot be closed.
+
+### affixTabOrder
+
+- Type: `number`
+- Default: `0`
+
+Used to configure the order of fixed tabs, sorted in ascending order.
+
+### iframeSrc
+
+- Type: `string`
+- Default: `''`
+
+Used to configure the `iframe` address of the embedded page. When set, the corresponding page will be embedded in the current page.
+
+### ignoreAccess
+
+- Type: `boolean`
+- Default: `false`
+
+Used to configure whether the page ignores permissions and can be accessed directly.
+
+### link
+
+- Type: `string`
+- Default: `''`
+
+Used to configure the external link jump path, which will open in a new window.
+
+### maxNumOfOpenTab
+
+- Type: `number`
+- Default: `-1`
+
+Used to configure the maximum number of open tabs. When set, the earliest opened tab will be automatically closed when opening a new tab (only effective when opening tabs with the same name).
+
+### menuVisibleWithForbidden
+
+- Type: `boolean`
+- Default: `false`
+
+Used to configure whether the page can be seen in the menu, but access will be redirected to 403.
+
+### openInNewWindow
+
+- Type: `boolean`
+- Default: `false`
+
+When set to `true`, the page will open in a new window.
+
+### order
+
+- Type: `number`
+- Default: `0`
+
+Used to configure the sorting of the page, used for route to menu sorting.
+
+_Note:_ Sorting is only effective for first-level menus. The sorting of second-level menus needs to be set in the corresponding first-level menu in code order.
+
+### query
+
+- Type: `Recordable`
+- Default: `{}`
+
+Used to configure the menu parameters of the page, which will be passed to the page in the menu.
+
+## Route Refresh
+
+The route refresh method is as follows:
+
+```vue
+
+```
diff --git a/apps/vben5/docs/src/en/guide/essentials/server.md b/apps/vben5/docs/src/en/guide/essentials/server.md
new file mode 100644
index 000000000..95d505c0a
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/essentials/server.md
@@ -0,0 +1,356 @@
+# Server Interaction and Data Mocking
+
+::: tip Note
+
+This document explains how to use Mock data and interact with the server in a development environment, involving technologies such as:
+
+- [Nitro](https://nitro.unjs.io/) A lightweight backend server that can be deployed anywhere, used as a Mock server in the project.
+- [axios](https://axios-http.com/docs/intro) Used to send HTTP requests to interact with the server.
+
+:::
+
+## Interaction in Development Environment
+
+If the frontend application and the backend API server are not running on the same host, you need to proxy the API requests to the API server in the development environment. If they are on the same host, you can directly request the specific API endpoint.
+
+### Local Development CORS Configuration
+
+::: tip Hint
+
+The CORS configuration for local development has already been set up. If you have other requirements, you can add or adjust the configuration as needed.
+
+:::
+
+#### Configuring Local Development API Endpoint
+
+Configure the API endpoint in the `.env.development` file at the project root directory, here it is set to `/api`:
+
+```bash
+VITE_GLOB_API_URL=/api
+```
+
+#### Configuring Development Server Proxy
+
+In the development environment, if you need to handle CORS, configure the API endpoint in the `vite.config.mts` file under the corresponding application directory:
+
+```ts{8-16}
+// apps/web-antd/vite.config.mts
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ vite: {
+ server: {
+ proxy: {// [!code focus:11]
+ '/api': {
+ changeOrigin: true,
+ rewrite: (path) => path.replace(/^\/api/, ''),
+ // mock proxy
+ target: 'http://localhost:5320/api',
+ ws: true,
+ },
+ },
+ },
+ },
+ };
+});
+```
+
+#### API Requests
+
+Based on the above configuration, we can use `/api` as the prefix for API requests in our frontend project, for example:
+
+```ts
+import axios from 'axios';
+
+axios.get('/api/user').then((res) => {
+ console.log(res);
+});
+```
+
+At this point, the request will be proxied to `http://localhost:5320/api/user`.
+
+::: warning Note
+
+From the browser's console Network tab, the request appears as `http://localhost:5555/api/user`. This is because the proxy configuration does not change the local request's URL.
+
+:::
+
+### Configuration Without CORS
+
+If there is no CORS issue, you can directly ignore the [Configure Development Server Proxy](./server.md#configure-development-server-proxy) settings and set the API endpoint directly in `VITE_GLOB_API_URL`.
+
+Configure the API endpoint in the `.env.development` file at the project root directory:
+
+```bash
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+```
+
+## Production Environment Interaction
+
+### API Endpoint Configuration
+
+Configure the API endpoint in the `.env.production` file at the project root directory:
+
+```bash
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+```
+
+::: tip How to Dynamically Modify API Endpoint in Production
+
+Variables starting with `VITE_GLOB_*` in the `.env` file are injected into the `_app.config.js` file during packaging. After packaging, you can modify the corresponding API addresses in `dist/_app.config.js` and refresh the page to apply the changes. This eliminates the need to package multiple times for different environments, allowing a single package to be deployed across multiple API environments.
+
+:::
+
+### Cross-Origin Resource Sharing (CORS) Handling
+
+In the production environment, if CORS issues arise, you can use `nginx` to proxy the API address or enable `cors` on the backend to handle it (refer to the mock service for examples).
+
+## API Request Configuration
+
+The project comes with a default basic request configuration based on `axios`, provided by the `@vben/request` package. The project does not overly complicate things but simply wraps some common configurations. If there are other requirements, you can add or adjust the configurations as needed. Depending on the app, different component libraries and `store` might be used, so under the `src/api/request.ts` folder in the application directory, there are corresponding request configuration files. For example, in the `web-antd` project, there's a `src/api/request.ts` file where you can configure according to your needs.
+
+### Request Examples
+
+#### GET Request
+
+```ts
+import { requestClient } from '#/api/request';
+
+export async function getUserInfoApi() {
+ return requestClient.get('/user/info');
+}
+```
+
+#### POST/PUT Request
+
+```ts
+import { requestClient } from '#/api/request';
+
+export async function saveUserApi(user: UserInfo) {
+ return requestClient.post('/user', user);
+}
+
+export async function saveUserApi(user: UserInfo) {
+ return requestClient.put('/user', user);
+}
+
+export async function saveUserApi(user: UserInfo) {
+ const url = user.id ? `/user/${user.id}` : '/user/';
+ return requestClient.request(url, {
+ data: user,
+ // OR PUT
+ method: user.id ? 'PUT' : 'POST',
+ });
+}
+```
+
+#### DELETE Request
+
+```ts
+import { requestClient } from '#/api/request';
+
+export async function deleteUserApi(user: UserInfo) {
+ return requestClient.delete(`/user/${user.id}`, user);
+}
+```
+
+### Request Configuration
+
+The `src/api/request.ts` within the application can be configured according to the needs of your application:
+
+```ts
+/**
+ * This file can be adjusted according to business logic
+ */
+import type { HttpResponse } from '@vben/request';
+
+import { useAppConfig } from '@vben/hooks';
+import { preferences } from '@vben/preferences';
+import {
+ authenticateResponseInterceptor,
+ errorMessageResponseInterceptor,
+ RequestClient,
+} from '@vben/request';
+import { useAccessStore } from '@vben/stores';
+
+import { message } from 'ant-design-vue';
+
+import { useAuthStore } from '#/store';
+
+import { refreshTokenApi } from './core';
+
+const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+
+function createRequestClient(baseURL: string) {
+ const client = new RequestClient({
+ baseURL,
+ });
+
+ /**
+ * Re-authentication Logic
+ */
+ async function doReAuthenticate() {
+ console.warn('Access token or refresh token is invalid or expired. ');
+ const accessStore = useAccessStore();
+ const authStore = useAuthStore();
+ accessStore.setAccessToken(null);
+ if (preferences.app.loginExpiredMode === 'modal') {
+ accessStore.setLoginExpired(true);
+ } else {
+ await authStore.logout();
+ }
+ }
+
+ /**
+ * Refresh token Logic
+ */
+ async function doRefreshToken() {
+ const accessStore = useAccessStore();
+ const resp = await refreshTokenApi();
+ const newToken = resp.data;
+ accessStore.setAccessToken(newToken);
+ return newToken;
+ }
+
+ function formatToken(token: null | string) {
+ return token ? `Bearer ${token}` : null;
+ }
+
+ // Request Header Processing
+ client.addRequestInterceptor({
+ fulfilled: async (config) => {
+ const accessStore = useAccessStore();
+
+ config.headers.Authorization = formatToken(accessStore.accessToken);
+ config.headers['Accept-Language'] = preferences.app.locale;
+ return config;
+ },
+ });
+
+ // Deal Response Data
+ client.addResponseInterceptor({
+ fulfilled: (response) => {
+ const { data: responseData, status } = response;
+
+ const { code, data } = responseData;
+
+ if (status >= 200 && status < 400 && code === 0) {
+ return data;
+ }
+ throw Object.assign({}, response, { response });
+ },
+ });
+
+ // Handling Token Expiration
+ client.addResponseInterceptor(
+ authenticateResponseInterceptor({
+ client,
+ doReAuthenticate,
+ doRefreshToken,
+ enableRefreshToken: preferences.app.enableRefreshToken,
+ formatToken,
+ }),
+ );
+
+ // Generic error handling; if none of the above error handling logic is triggered, it will fall back to this.
+ client.addResponseInterceptor(
+ errorMessageResponseInterceptor((msg: string, error) => {
+ // 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
+ // 当前mock接口返回的错误字段是 error 或者 message
+ const responseData = error?.response?.data ?? {};
+ const errorMessage = responseData?.error ?? responseData?.message ?? '';
+ // 如果没有错误信息,则会根据状态码进行提示
+ message.error(errorMessage || msg);
+ }),
+ );
+
+ return client;
+}
+
+export const requestClient = createRequestClient(apiURL);
+
+export const baseRequestClient = new RequestClient({ baseURL: apiURL });
+```
+
+### Multiple API Endpoints
+
+To handle multiple API endpoints, simply create multiple `requestClient` instances, as follows:
+
+```ts
+const { apiURL, otherApiURL } = useAppConfig(
+ import.meta.env,
+ import.meta.env.PROD,
+);
+
+export const requestClient = createRequestClient(apiURL);
+
+export const otherRequestClient = createRequestClient(otherApiURL);
+```
+
+## Refresh Token
+
+The project provides a default logic for refreshing tokens. To enable it, follow the configuration below:
+
+- Ensure the refresh token feature is enabled
+
+Adjust the `preferences.ts` in the corresponding application directory to ensure `enableRefreshToken='true'`.
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ enableRefreshToken: true,
+ },
+});
+```
+
+Configure the `doRefreshToken` method in `src/api/request.ts` as follows:
+
+```ts
+// Adjust this to your token format
+function formatToken(token: null | string) {
+ return token ? `Bearer ${token}` : null;
+}
+
+/**
+ * Refresh token logic
+ */
+async function doRefreshToken() {
+ const accessStore = useAccessStore();
+ // Adjust this to your refresh token API
+ const resp = await refreshTokenApi();
+ const newToken = resp.data;
+ accessStore.setAccessToken(newToken);
+ return newToken;
+}
+```
+
+## Data Mocking
+
+::: tip Production Environment Mock
+
+The new version no longer supports mock in the production environment. Please use real interfaces.
+
+:::
+
+Mock data is an indispensable part of frontend development, serving as a key link in separating frontend and backend development. By agreeing on interfaces with the server side in advance and simulating request data and even logic, frontend development can proceed independently, without being blocked by the backend development process.
+
+The project uses [Nitro](https://nitro.unjs.io/) for local mock data processing. The principle is to start an additional backend service locally, which is a real backend service that can handle requests and return data.
+
+### Using Nitro
+
+The mock service code is located in the `apps/backend-mock` directory. It does not need to be started manually and is already integrated into the project. You only need to run `pnpm dev` in the project root directory. After running successfully, the console will print `http://localhost:5320/api`, and you can access this address to view the mock service.
+
+[Nitro](https://nitro.unjs.io/) syntax is simple, and you can configure and develop according to your needs. For specific configurations, you can refer to the [Nitro documentation](https://nitro.unjs.io/).
+
+## Disabling Mock Service
+
+Since mock is essentially a real backend service, if you do not need the mock service, you can configure `VITE_NITRO_MOCK=false` in the `.env.development` file in the project root directory to disable the mock service.
+
+```bash
+# .env.development
+VITE_NITRO_MOCK=false
+```
diff --git a/apps/vben5/docs/src/en/guide/essentials/settings.md b/apps/vben5/docs/src/en/guide/essentials/settings.md
new file mode 100644
index 000000000..68fef3e7e
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/essentials/settings.md
@@ -0,0 +1,514 @@
+# Configuration
+
+## Environment Variable Configuration
+
+The project's environment variable configuration is located in the application directory under `.env`, `.env.development`, `.env.production`.
+
+The rules are consistent with [Vite Env Variables and Modes](https://vitejs.dev/guide/env-and-mode.html). The format is as follows:
+
+```bash
+.env # Loaded in all environments
+.env.local # Loaded in all environments, but ignored by git
+.env.[mode] # Only loaded in the specified mode
+.env.[mode].local # Only loaded in the specified mode, but ignored by git
+```
+
+::: tip
+
+- Only variables starting with `VITE_` will be embedded into the client-side package. You can access them in the project code like this:
+
+ ```ts
+ console.log(import.meta.env.VITE_PROT);
+ ```
+
+- Variables starting with `VITE_GLOB_*` will be added to the `_app.config.js` configuration file during packaging. :::
+
+:::
+
+## Environment Configuration Description
+
+::: code-group
+
+```bash [.env]
+# Application title
+VITE_APP_TITLE=Vben Admin
+
+# Application namespace, used as a prefix for caching, store, etc., to ensure isolation
+VITE_APP_NAMESPACE=vben-web-antd
+```
+
+```bash [.env.development]
+# Port Number
+VITE_PORT=5555
+
+# Public Path for Resources, must start and end with /
+VITE_BASE=/
+
+# API URL
+VITE_GLOB_API_URL=/api
+
+# Whether to enable Nitro Mock service, true to enable, false to disable
+VITE_NITRO_MOCK=true
+
+# Whether to open devtools, true to open, false to close
+VITE_DEVTOOLS=true
+
+# Whether to inject global loading
+VITE_INJECT_APP_LOADING=true
+
+# Whether to generate after packaging dist.zip
+VITE_ARCHIVER=true
+```
+
+:::
+
+## Dynamic Configuration in Production Environment
+
+When executing `pnpm build` in the root directory of the monorepo, a `dist/_app.config.js` file will be automatically generated in the corresponding application and inserted into `index.html`.
+
+`_app.config.js` is a dynamic configuration file that allows for modifications to the configuration dynamically based on different environments after the project has been built. The content is as follows:
+
+```ts
+window._VBEN_ADMIN_PRO_APP_CONF_ = {
+ VITE_GLOB_API_URL: 'https://mock-napi.vben.pro/api',
+};
+Object.freeze(window._VBEN_ADMIN_PRO_APP_CONF_);
+Object.defineProperty(window, '_VBEN_ADMIN_PRO_APP_CONF_', {
+ configurable: false,
+ writable: false,
+});
+```
+
+### Purpose
+
+`_app.config.js` is used for projects that need to dynamically modify configurations after packaging, such as API endpoints. There's no need to repackage; you can simply modify the variables in `/dist/_app.config.js` after packaging, and refresh to update the variables in the code. A `js` file is used to ensure that the configuration file is loaded early in the order.
+
+### Usage
+
+To access the variables inside `_app.config.js`, you need to use the `useAppConfig` method provided by `@vben/hooks`.
+
+```ts
+const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+```
+
+### Adding New
+
+To add a new dynamically modifiable configuration item, simply follow the steps below:
+
+- First, add the variable that needs to be dynamically configurable in the `.env` file or the corresponding development environment configuration file. The variable must start with `VITE_GLOB_*`, for example:
+
+ ```bash
+ VITE_GLOB_OTHER_API_URL=https://mock-napi.vben.pro/other-api
+ ```
+
+- In `packages/types/global.d.ts`, add the corresponding type definition, such as:
+
+ ```ts
+ export interface VbenAdminProAppConfigRaw {
+ VITE_GLOB_API_URL: string;
+ VITE_GLOB_OTHER_API_URL: string; // [!code ++]
+ }
+
+ export interface ApplicationConfig {
+ apiURL: string;
+ otherApiURL: string; // [!code ++]
+ }
+ ```
+
+At this point, you can use the `useAppConfig` method within the project to access the newly added configuration item.
+
+```ts
+const { otherApiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+```
+
+::: warning Warning
+
+The `useAppConfig` method should only be used within the application and not be coupled with the internals of a package. The reason for passing `import.meta.env` and `import.meta.env.PROD` is to avoid such coupling. A pure package should avoid using variables specific to a particular build tool.
+
+:::
+
+## Preferences
+
+The project offers a wide range of preference settings for dynamically configuring various features of the project:
+
+
+
+If you cannot find documentation for a setting, you can try configuring it yourself and then click `Copy Preferences` to override the project defaults. The configuration file is located in the application directory under `preferences.ts`, where you can override the framework's default configurations to achieve custom settings.
+
+```ts
+import { useAppConfig } from '@vben/hooks';
+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
+ */
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+});
+```
+
+### Framework default configuration
+
+::: details View the default configuration of the framework
+
+```ts
+const defaultPreferences: Preferences = {
+ app: {
+ accessMode: 'frontend',
+ authPageLayout: 'panel-right',
+ checkUpdatesInterval: 1,
+ colorGrayMode: false,
+ colorWeakMode: false,
+ compact: false,
+ contentCompact: 'wide',
+ defaultAvatar:
+ 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/avatar-v1.webp',
+ dynamicTitle: true,
+ enableCheckUpdates: true,
+ enablePreferences: true,
+ enableRefreshToken: false,
+ isMobile: false,
+ layout: 'sidebar-nav',
+ locale: 'zh-CN',
+ loginExpiredMode: 'modal',
+ name: 'Vben Admin',
+ preferencesButtonPosition: 'auto',
+ watermark: false,
+ },
+ breadcrumb: {
+ enable: true,
+ hideOnlyOne: false,
+ showHome: false,
+ showIcon: true,
+ styleType: 'normal',
+ },
+ copyright: {
+ companyName: 'Vben',
+ companySiteLink: 'https://www.vben.pro',
+ date: '2024',
+ enable: true,
+ icp: '',
+ icpLink: '',
+ },
+ footer: {
+ enable: true,
+ fixed: false,
+ },
+ header: {
+ enable: true,
+ hidden: false,
+ mode: 'fixed',
+ },
+ logo: {
+ enable: true,
+ source: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp',
+ },
+ navigation: {
+ accordion: true,
+ split: true,
+ styleType: 'rounded',
+ },
+ shortcutKeys: {
+ enable: true,
+ globalLockScreen: true,
+ globalLogout: true,
+ globalPreferences: true,
+ globalSearch: true,
+ },
+ sidebar: {
+ collapsed: false,
+ collapsedShowTitle: false,
+ enable: true,
+ expandOnHover: true,
+ extraCollapse: true,
+ hidden: false,
+ width: 230,
+ },
+ tabbar: {
+ draggable: true,
+ enable: true,
+ height: 36,
+ keepAlive: true,
+ persist: true,
+ showIcon: true,
+ showMaximize: true,
+ showMore: true,
+ styleType: 'chrome',
+ },
+ theme: {
+ builtinType: 'default',
+ colorDestructive: 'hsl(348 100% 61%)',
+ colorPrimary: 'hsl(212 100% 45%)',
+ colorSuccess: 'hsl(144 57% 58%)',
+ colorWarning: 'hsl(42 84% 61%)',
+ mode: 'dark',
+ radius: '0.5',
+ semiDarkHeader: false,
+ semiDarkSidebar: true,
+ },
+ transition: {
+ enable: true,
+ loading: true,
+ name: 'fade-slide',
+ progress: true,
+ },
+ widget: {
+ fullscreen: true,
+ globalSearch: true,
+ languageToggle: true,
+ lockScreen: true,
+ notification: true,
+ sidebarToggle: true,
+ themeToggle: true,
+ refresh: true,
+ },
+};
+```
+
+:::
+
+::: details View the default configuration type of the framework
+
+```ts
+interface AppPreferences {
+ /** Permission mode */
+ accessMode: AccessModeType;
+ /** Layout of the login/registration page */
+ authPageLayout: AuthPageLayoutType;
+ /** Interval for checking updates */
+ checkUpdatesInterval: number;
+ /** Whether to enable gray mode */
+ colorGrayMode: boolean;
+ /** Whether to enable color weakness mode */
+ colorWeakMode: boolean;
+ /** Whether to enable compact mode */
+ compact: boolean;
+ /** Whether to enable content compact mode */
+ contentCompact: ContentCompactType;
+ // /** Default application avatar */
+ defaultAvatar: string;
+ // /** Enable dynamic title */
+ dynamicTitle: boolean;
+ /** Whether to enable update checks */
+ enableCheckUpdates: boolean;
+ /** Whether to display preferences */
+ enablePreferences: boolean;
+ /**
+ * @zh_CN Whether to enable refreshToken
+ */
+ enableRefreshToken: boolean;
+ /** Whether it's mobile */
+ isMobile: boolean;
+ /** Layout method */
+ layout: LayoutType;
+ /** Supported languages */
+ locale: SupportedLanguagesType;
+ /** Login expiration mode */
+ loginExpiredMode: LoginExpiredModeType;
+ /** Application name */
+ name: string;
+ /** Position of the preferences button */
+ preferencesButtonPosition: PreferencesButtonPositionType;
+ /**
+ * @zh_CN Whether to enable watermark
+ */
+ watermark: boolean;
+}
+interface BreadcrumbPreferences {
+ /** Whether breadcrumbs are enabled */
+ enable: boolean;
+ /** Whether to hide breadcrumbs when there is only one */
+ hideOnlyOne: boolean;
+ /** Whether the home icon in breadcrumbs is visible */
+ showHome: boolean;
+ /** Whether the icon in breadcrumbs is visible */
+ showIcon: boolean;
+ /** Breadcrumb style */
+ styleType: BreadcrumbStyleType;
+}
+
+interface CopyrightPreferences {
+ /** Copyright company name */
+ companyName: string;
+ /** Link to the copyright company's site */
+ companySiteLink: string;
+ /** Copyright date */
+ date: string;
+ /** Whether copyright is visible */
+ enable: boolean;
+ /** ICP number */
+ icp: string;
+ /** Link to the ICP */
+ icpLink: string;
+}
+
+interface FooterPreferences {
+ /** Whether the footer is visible */
+ enable: boolean;
+ /** Whether the footer is fixed */
+ fixed: boolean;
+}
+
+interface HeaderPreferences {
+ /** Whether the header is enabled */
+ enable: boolean;
+ /** Whether the header is hidden, css-hidden */
+ hidden: boolean;
+ /** Header display mode */
+ mode: LayoutHeaderModeType;
+}
+
+interface LogoPreferences {
+ /** Whether the logo is visible */
+ enable: boolean;
+ /** Logo URL */
+ source: string;
+}
+
+interface NavigationPreferences {
+ /** Navigation menu accordion mode */
+ accordion: boolean;
+ /** Whether the navigation menu is split, only effective in layout=mixed-nav */
+ split: boolean;
+ /** Navigation menu style */
+ styleType: NavigationStyleType;
+}
+interface SidebarPreferences {
+ /** Whether the sidebar is collapsed */
+ collapsed: boolean;
+ /** Whether to show title when sidebar is collapsed */
+ collapsedShowTitle: boolean;
+ /** Whether the sidebar is visible */
+ enable: boolean;
+ /** Menu auto-expand state */
+ expandOnHover: boolean;
+ /** Whether the sidebar extension area is collapsed */
+ extraCollapse: boolean;
+ /** Whether the sidebar is hidden - css */
+ hidden: boolean;
+ /** Sidebar width */
+ width: number;
+}
+
+interface ShortcutKeyPreferences {
+ /** Whether shortcut keys are enabled globally */
+ enable: boolean;
+ /** Whether the global lock screen shortcut is enabled */
+ globalLockScreen: boolean;
+ /** Whether the global logout shortcut is enabled */
+ globalLogout: boolean;
+ /** Whether the global preferences shortcut is enabled */
+ globalPreferences: boolean;
+ /** Whether the global search shortcut is enabled */
+ globalSearch: boolean;
+}
+
+interface TabbarPreferences {
+ /** Whether dragging of multiple tabs is enabled */
+ draggable: boolean;
+ /** Whether multiple tabs are enabled */
+ enable: boolean;
+ /** Tab height */
+ height: number;
+ /** Whether tab caching is enabled */
+ keepAlive: boolean;
+ /** Whether tabs are persistent */
+ persist: boolean;
+ /** Whether icons in multiple tabs are enabled */
+ showIcon: boolean;
+ /** Whether to show the maximize button */
+ showMaximize: boolean;
+ /** Whether to show the more button */
+ showMore: boolean;
+ /** Tab style */
+ styleType: TabsStyleType;
+}
+interface ThemePreferences {
+ /** Built-in theme name */
+ builtinType: BuiltinThemeType;
+ /** Destructive color */
+ colorDestructive: string;
+ /** Primary color */
+ colorPrimary: string;
+ /** Success color */
+ colorSuccess: string;
+ /** Warning color */
+ colorWarning: string;
+ /** Current theme */
+ mode: ThemeModeType;
+ /** Radius */
+ radius: string;
+ /** Whether to enable semi-dark header (only effective when theme='light') */
+ semiDarkHeader: boolean;
+ /** Whether to enable semi-dark sidebar (only effective when theme='light') */
+ semiDarkSidebar: boolean;
+}
+
+interface TransitionPreferences {
+ /** Whether page transition animations are enabled */
+ enable: boolean;
+ // /** Whether page loading loading is enabled */
+ loading: boolean;
+ /** Page transition animation */
+ name: PageTransitionType | string;
+ /** Whether page loading progress animation is enabled */
+ progress: boolean;
+}
+
+interface WidgetPreferences {
+ /** Whether fullscreen widgets are enabled */
+ fullscreen: boolean;
+ /** Whether global search widget is enabled */
+ globalSearch: boolean;
+ /** Whether language switch widget is enabled */
+ languageToggle: boolean;
+ /** Whether lock screen functionality is enabled */
+ lockScreen: boolean;
+ /** Whether notification widget is displayed */
+ notification: boolean;
+ /** Whether to show the refresh button */
+ refresh: boolean;
+ /** Whether sidebar show/hide widget is displayed */
+ sidebarToggle: boolean;
+ /** Whether theme switch widget is displayed */
+ themeToggle: boolean;
+}
+interface Preferences {
+ /** Global configuration */
+ app: AppPreferences;
+ /** Header configuration */
+ breadcrumb: BreadcrumbPreferences;
+ /** Copyright configuration */
+ copyright: CopyrightPreferences;
+ /** Footer configuration */
+ footer: FooterPreferences;
+ /** Breadcrumb configuration */
+ header: HeaderPreferences;
+ /** Logo configuration */
+ logo: LogoPreferences;
+ /** Navigation configuration */
+ navigation: NavigationPreferences;
+ /** Shortcut key configuration */
+ shortcutKeys: ShortcutKeyPreferences;
+ /** Sidebar configuration */
+ sidebar: SidebarPreferences;
+ /** Tab bar configuration */
+ tabbar: TabbarPreferences;
+ /** Theme configuration */
+ theme: ThemePreferences;
+ /** Animation configuration */
+ transition: TransitionPreferences;
+ /** Widget configuration */
+ widget: WidgetPreferences;
+}
+```
+
+:::
+
+::: warning Warning
+
+- 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.
+
+:::
diff --git a/apps/vben5/docs/src/en/guide/essentials/styles.md b/apps/vben5/docs/src/en/guide/essentials/styles.md
new file mode 100644
index 000000000..16f6681d2
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/essentials/styles.md
@@ -0,0 +1,106 @@
+# Styles
+
+::: tip Preface
+
+For Vue projects, the [official documentation](https://vuejs.org/api/sfc-css-features.html#deep-selectors) already provides a detailed introduction to the syntax. Here, we mainly introduce the structure and usage of style files in the project.
+
+:::
+
+## Project Structure
+
+The style files in the project are stored in `@vben/styles`, which includes some global styles, such as reset styles, global variables, etc. It inherits the styles and capabilities of `@vben-core/design` and can be overridden according to project needs.
+
+## Scss
+
+The project uses `scss` as the style preprocessor, allowing the use of `scss` features such as variables, functions, mixins, etc., within the project.
+
+```vue
+
+```
+
+## Postcss
+
+If you're not accustomed to using `scss`, you can also use `postcss`, which is a more powerful style processor that supports a wider range of plugins. The project includes the [postcss-nested](https://github.com/postcss/postcss-nested) plugin and is configured with `Css Variables`, making it a complete substitute for `scss`.
+
+```vue
+
+```
+
+## Tailwind CSS
+
+The project integrates [Tailwind CSS](https://tailwindcss.com/), allowing the use of `tailwindcss` class names to quickly build pages.
+
+```vue
+
+
+
+```
+
+## BEM Standard
+
+Another option to avoid style conflicts is to use the `BEM` standard. If you choose `scss`, it is recommended to use the `BEM` naming convention for better style management. The project provides a default `useNamespace` function to easily generate namespaces.
+
+```vue
+
+
+
+
+
+```
+
+## CSS Modules
+
+Another solution to address style conflicts is to use the `CSS Modules` modular approach. The usage method is as follows.
+
+```vue
+
+ 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/apps/vben5/docs/src/en/guide/in-depth/access.md b/apps/vben5/docs/src/en/guide/in-depth/access.md
new file mode 100644
index 000000000..05997d7d5
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/in-depth/access.md
@@ -0,0 +1,318 @@
+---
+outline: deep
+---
+
+# Access Control
+
+The framework has built-in two 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
+
+## 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.
+
+## 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
+
+
+
+
+
+ Visible to Super account ["AC_1000001"]
+
+
+ Visible to Admin account ["AC_100010"]
+
+
+ Visible to User account ["AC_1000001"]
+
+
+
+ Visible to Super & Admin account ["AC_100100","AC_1000001"]
+
+
+
+```
+
+#### API Method
+
+```vue
+
+
+
+
+ Visible to Super account ["AC_1000001"]
+
+
+ Visible to Admin account ["AC_100010"]
+
+
+ Visible to User account ["AC_1000001"]
+
+
+ Visible to Super & Admin account ["AC_100100","AC_1000001"]
+
+
+```
+
+#### 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
+
+
+ Visible to Super account 'AC_100100'
+
+
+ Visible to Admin account ["AC_100010"]
+
+
+ Visible to User account ["AC_1000001"]
+
+
+ Visible to Super & Admin account ["AC_100100","AC_1000001"]
+
+
+```
+
+### Roles
+
+The method of determining roles does not require permission codes returned by the interface; it directly determines whether buttons are displayed based on roles.
+
+#### Component Method
+
+```vue
+
+
+
+
+ Visible to Super account
+
+
+ Visible to Admin account
+
+
+ Visible to User account
+
+
+ Super & Visible to Admin account
+
+
+```
+
+#### API Method
+
+```vue
+
+
+
+ Visible to Super account
+ Visible to Admin account
+ Visible to User account
+
+ Super & Visible to Admin account
+
+
+```
+
+#### 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
+
+
+ Visible to Super account
+
+
+ Visible to Admin account
+
+
+ Visible to User account
+
+
+ Super & Visible to Admin account
+
+
+```
diff --git a/apps/vben5/docs/src/en/guide/in-depth/check-updates.md b/apps/vben5/docs/src/en/guide/in-depth/check-updates.md
new file mode 100644
index 000000000..1e5b679dc
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/in-depth/check-updates.md
@@ -0,0 +1,48 @@
+# Check Updates
+
+## Introduction
+
+When there are updates to the website, you might need to check for updates. The framework provides this functionality. By periodically checking for updates, you can configure the `checkUpdatesInterval` and `enableCheckUpdates` fields in your application's preferences.ts file to enable and set the interval for checking updates (in minutes).
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ // Whether to enable check for updates
+ enableCheckUpdates: true,
+ // The interval for checking updates, in minutes
+ checkUpdatesInterval: 1,
+ },
+});
+```
+
+## Effect
+
+When an update is detected, a prompt will pop up asking the user whether to refresh the page:
+
+
+
+## Replacing with Other Update Checking Methods
+
+If you need to check for updates in other ways, such as through an API to more flexibly control the update logic (such as force refresh, display update content, etc.), you can do so by modifying the `src/widgets/check-updates/check-updates.vue` file under `@vben/layouts`.
+
+```ts
+// Replace this with your update checking logic
+async function getVersionTag() {
+ try {
+ const response = await fetch('/', {
+ cache: 'no-cache',
+ method: 'HEAD',
+ });
+
+ return (
+ response.headers.get('etag') || response.headers.get('last-modified')
+ );
+ } catch {
+ console.error('Failed to fetch version tag');
+ return null;
+ }
+}
+```
diff --git a/apps/vben5/docs/src/en/guide/in-depth/features.md b/apps/vben5/docs/src/en/guide/in-depth/features.md
new file mode 100644
index 000000000..24fecea96
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/in-depth/features.md
@@ -0,0 +1,84 @@
+# Common Features
+
+A collection of some commonly used features.
+
+## Login Authentication Expiry
+
+When the interface returns a `401` status code, the framework will consider the login authentication to have expired. Upon login timeout, it will redirect to the login page or open a login popup. This can be configured in `preferences.ts` in the application directory:
+
+### Redirect to Login Page
+
+Upon login timeout, it will redirect to the login page.
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ loginExpiredMode: 'page',
+ },
+});
+```
+
+### Open Login Popup
+
+When login times out, a login popup will open.
+
+
+
+Configuration:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ loginExpiredMode: 'modal',
+ },
+});
+```
+
+## Dynamic Title
+
+- Default value: `true`
+
+When enabled, the webpage title changes according to the route's `title`. You can enable or disable this in the `preferences.ts` file in your application directory.
+
+```ts
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ dynamicTitle: true,
+ },
+});
+```
+
+## Page Watermark
+
+- Default value: `false`
+
+When enabled, the webpage will display a watermark. You can enable or disable this in the `preferences.ts` file in your application directory.
+
+```ts
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ watermark: true,
+ },
+});
+```
+
+If you want to update the content of the watermark, you can do so. The parameters can be referred to [watermark-js-plus](https://zhensherlock.github.io/watermark-js-plus/):
+
+```ts
+import { useWatermark } from '@vben/hooks';
+
+const { destroyWatermark, updateWatermark } = useWatermark();
+
+await updateWatermark({
+ // watermark content
+ content: 'hello my watermark',
+});
+```
diff --git a/apps/vben5/docs/src/en/guide/in-depth/layout.md b/apps/vben5/docs/src/en/guide/in-depth/layout.md
new file mode 100644
index 000000000..412c1cf07
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/in-depth/layout.md
@@ -0,0 +1 @@
+# Layout
diff --git a/apps/vben5/docs/src/en/guide/in-depth/loading.md b/apps/vben5/docs/src/en/guide/in-depth/loading.md
new file mode 100644
index 000000000..0f1cff6ee
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/in-depth/loading.md
@@ -0,0 +1,44 @@
+# Global Loading
+
+Global loading refers to the loading effect that appears when the page is refreshed, usually a spinning icon:
+
+
+
+## Principle
+
+Implemented by the `vite-plugin-inject-app-loading` plugin, the plugin injects a global `loading html` into each application.
+
+## Disable
+
+If you do not need global loading, you can disable it in the `.env` file:
+
+```bash
+VITE_INJECT_APP_LOADING=false
+```
+
+## Customization
+
+If you want to customize the global loading, you can create a `loading.html` file in the application directory, at the same level as `index.html`. The plugin will automatically read and inject this HTML. You can define the style and animation of this HTML as you wish.
+
+::: tip
+
+- You can use the same syntax as in `index.html`, such as the `VITE_APP_TITLE` variable, to get the application's title.
+- You must ensure there is an element with `id="__app-loading__"`.
+- Add a `hidden` class to the element with `id="__app-loading__"`.
+- You must ensure there is a `style[data-app-loading="inject-css"]` element.
+
+```html{1,4}
+
+
+
+
<%= VITE_APP_TITLE %>
+
+```
diff --git a/apps/vben5/docs/src/en/guide/in-depth/locale.md b/apps/vben5/docs/src/en/guide/in-depth/locale.md
new file mode 100644
index 000000000..549bc83f5
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/in-depth/locale.md
@@ -0,0 +1,227 @@
+# Internationalization
+
+The project has integrated [Vue i18n](https://kazupon.github.io/vue-i18n/), and Chinese and English language packs have been configured.
+
+## IDE Plugin
+
+If you are using vscode as your development tool, it is recommended to install the [i18n Ally](https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally) plugin. It can help you manage internationalization copy more conveniently. After installing this plugin, you can see the corresponding language content in your code in real-time:
+
+
+
+## Configure Default Language
+
+You just need to override the default preferences. In the corresponding application, find the `src/preferences.ts` file and modify the value of `locale`:
+
+```ts {3}
+export const overridesPreferences = defineOverridesPreferences({
+ app: {
+ locale: 'en-US',
+ },
+});
+```
+
+## Dynamic Language Switching
+
+Switching languages consists of two parts:
+
+- Updating preferences
+- Loading the corresponding language pack
+
+```ts
+import type { SupportedLanguagesType } from '@vben/locales';
+import { loadLocaleMessages } from '@vben/locales';
+import { updatePreferences } from '@vben/preferences';
+
+async function updateLocale(value: string) {
+ // 1. Update preferences
+ const locale = value as SupportedLanguagesType;
+ updatePreferences({
+ app: {
+ locale,
+ },
+ });
+ // 2. Load the corresponding language pack
+ await loadLocaleMessages(locale);
+}
+
+updateLocale('en-US');
+```
+
+## Adding Translation Texts
+
+::: warning Attention
+
+- Do not place business translation texts inside `@vben/locales` to better manage business and general translation texts.
+- When adding new translation texts and multiple language packs are available, ensure to add the corresponding texts in all language packs.
+
+:::
+
+To add new translation texts, simply find `src/locales/langs/` in the corresponding application and add the texts accordingly, for example:
+
+**src/locales/langs/zh-CN/\*.json**
+
+````ts
+```json
+{
+ "about": {
+ "desc": "Vben Admin 是一个现代的管理模版。"
+ }
+}
+````
+
+**src/locales/langs/en-US.ts**
+
+````ts
+```json
+{
+ "about": {
+ "desc": "Vben Admin is a modern management template."
+ }
+}
+````
+
+## Using Translation Texts
+
+With `@vben/locales`, you can easily use translation texts:
+
+### In Code
+
+```vue
+
+
+ {{ $t('about.desc') }}
+
+ {{ item.title }}
+
+
+```
+
+## Adding a New Language Pack
+
+If you need to add a new language pack, follow these steps:
+
+- Add the corresponding language pack file in the `packages/locales/langs` directory, for example, `zh-TW.json`, and translate the respective texts.
+- In the corresponding application, locate the `src/locales/langs` file and add the new language pack `zh-TW.json`.
+- Add the corresponding language in `packages/constants/src/core.ts`:
+
+ ```ts
+ export interface LanguageOption {
+ label: string;
+ value: 'en-US' | 'zh-CN'; // [!code --]
+ value: 'en-US' | 'zh-CN' | 'zh-TW'; // [!code ++]
+ }
+ export const SUPPORT_LANGUAGES: LanguageOption[] = [
+ {
+ label: '简体中文',
+ value: 'zh-CN',
+ },
+ {
+ label: 'English',
+ value: 'en-US',
+ },
+ {
+ label: '繁体中文', // [!code ++]
+ value: 'zh-TW', // [!code ++]
+ },
+ ];
+ ```
+
+- In `packages/locales/typing.ts`, add a new TypeScript type:
+
+ ```ts
+ export type SupportedLanguagesType = 'en-US' | 'zh-CN'; // [!code --]
+ export type SupportedLanguagesType = 'en-US' | 'zh-CN' | 'zh-TW'; // [!code ++]
+ ```
+
+At this point, you can use the newly added language pack in the project.
+
+## Interface Language Switching Function
+
+If you want to disable the language switching display button on the interface, in the corresponding application, find the `src/preferences.ts` file and modify the value of `locale` accordingly:
+
+```ts {3}
+export const overridesPreferences = defineOverridesPreferences({
+ widget: {
+ languageToggle: false,
+ },
+});
+```
+
+## Remote Loading of Language Packs
+
+::: tip Tip
+
+When making interface requests through the project's built-in `request` tool, the default request header will include [Accept-Language](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language), allowing the server to dynamically internationalize data based on the request header.
+
+:::
+
+Each application has an independent language pack that can override the general language configuration. You can remotely load the corresponding language pack by finding the `src/locales/index.ts` file in the corresponding application and modifying the `loadMessages` method accordingly:
+
+```ts {3-4}
+async function loadMessages(lang: SupportedLanguagesType) {
+ const [appLocaleMessages] = await Promise.all([
+ // Modify here to load data via a remote interface
+ localesMap[lang](),
+ loadThirdPartyMessage(lang),
+ ]);
+ return appLocaleMessages.default;
+}
+```
+
+## Third-Party Language Packs
+
+Different applications may use third-party component libraries or plugins with varying internationalization methods, so they need to be handled differently. If you need to introduce a third-party language pack, you can find the `src/locales/index.ts` file in the corresponding application and modify the `loadThirdPartyMessage` method accordingly:
+
+```ts
+/**
+ * Load the dayjs language pack
+ * @param lang
+ */
+async function loadDayjsLocale(lang: SupportedLanguagesType) {
+ let locale;
+ switch (lang) {
+ case 'zh-CN': {
+ locale = await import('dayjs/locale/zh-cn');
+ break;
+ }
+ case 'en-US': {
+ locale = await import('dayjs/locale/en');
+ break;
+ }
+ // Default to using English
+ default: {
+ locale = await import('dayjs/locale/en');
+ }
+ }
+ if (locale) {
+ dayjs.locale(locale);
+ } else {
+ console.error(`Failed to load dayjs locale for ${lang}`);
+ }
+}
+```
+
+## Removing Internationalization
+
+Firstly, it is not recommended to remove internationalization, as it is a good development practice. However, if you really need to remove it, you can directly use Chinese copy and then retain the project's built-in language pack, which will not affect the overall development experience. The steps to remove internationalization are as follows:
+
+- Hide the language switching button on the interface, see: [Interface Language Switching Function](#interface-language-switching-function)
+- Modify the default language, see: [Configure Default Language](#configure-default-language)
+- Disable `vue-i18n` warning prompts, in the `src/locales/index.ts` file, modify `missingWarn` to `false`:
+
+ ```ts
+ async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
+ await coreSetup(app, {
+ defaultLocale: preferences.app.locale,
+ loadMessages,
+ missingWarn: !import.meta.env.PROD, // [!code --]
+ missingWarn: false, // [!code ++]
+ ...options,
+ });
+ }
+ ```
diff --git a/apps/vben5/docs/src/en/guide/in-depth/login.md b/apps/vben5/docs/src/en/guide/in-depth/login.md
new file mode 100644
index 000000000..7fdac2c6f
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/in-depth/login.md
@@ -0,0 +1,119 @@
+# Login
+
+This document explains how to customize the login page of your application.
+
+## Login Page Adjustment
+
+If you want to adjust the title, description, icon, and toolbar of the login page, you can do so by configuring the `props` parameter of the `AuthPageLayout` component.
+
+
+
+You just need to configure the `props` parameter of `AuthPageLayout` in `src/router/routes/core.ts` within your application:
+
+```ts {4-8}
+ {
+ component: AuthPageLayout,
+ props: {
+ sloganImage: "xxx/xxx.png",
+ pageTitle: "开箱即用的大型中后台管理系统",
+ pageDescription: "工程化、高性能、跨组件库的前端模版",
+ toolbar: true,
+ toolbarList: ['color', 'language', 'layout', 'theme'],
+ }
+ // ...
+ },
+```
+
+::: tip
+
+If these configurations do not meet your needs, you can implement your own login page. Simply implement your own `AuthPageLayout`.
+
+:::
+
+## Login Form Adjustment
+
+If you want to adjust the content of the login form, you can configure the `AuthenticationLogin` component parameters in `src/views/_core/authentication/login.vue` within your application:
+
+```vue
+
+```
+
+::: details AuthenticationLogin Component Props
+
+```ts
+{
+ /**
+ * @en Verification code login path
+ */
+ codeLoginPath?: string;
+ /**
+ * @en Forget password path
+ */
+ forgetPasswordPath?: string;
+
+ /**
+ * @en Whether it is in loading state
+ */
+ loading?: boolean;
+
+ /**
+ * @en QR code login path
+ */
+ qrCodeLoginPath?: string;
+
+ /**
+ * @en Registration path
+ */
+ registerPath?: string;
+
+ /**
+ * @en Whether to show verification code login
+ */
+ showCodeLogin?: boolean;
+ /**
+ * @en Whether to show forget password
+ */
+ showForgetPassword?: boolean;
+
+ /**
+ * @en Whether to show QR code login
+ */
+ showQrcodeLogin?: boolean;
+
+ /**
+ * @en Whether to show registration button
+ */
+ showRegister?: boolean;
+
+ /**
+ * @en Whether to show remember account
+ */
+ showRememberMe?: boolean;
+
+ /**
+ * @en Whether to show third-party login
+ */
+ showThirdPartyLogin?: boolean;
+
+ /**
+ * @en Login box subtitle
+ */
+ subTitle?: string;
+
+ /**
+ * @en Login box title
+ */
+ title?: string;
+}
+```
+
+:::
+
+::: tip
+
+If these configurations do not meet your needs, you can implement your own login form and related login logic.
+
+:::
diff --git a/apps/vben5/docs/src/en/guide/in-depth/theme.md b/apps/vben5/docs/src/en/guide/in-depth/theme.md
new file mode 100644
index 000000000..11c9c992b
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/in-depth/theme.md
@@ -0,0 +1,1293 @@
+# Theme
+
+The framework is built on [shadcn-vue](https://www.shadcn-vue.com/themes.html) and [tailwindcss](https://tailwindcss.com/), offering a rich theme configuration. You can easily switch between various themes through simple configuration to meet personalized needs. You can choose to use CSS variables or Tailwind CSS utility classes for theme settings.
+
+## CSS Variables
+
+The project follows the theme configuration of [shadcn-vue](https://www.shadcn-vue.com/themes.html), for example:
+
+```html
+
+```
+
+We use a simple convention for colors. The `background` variable is used for the background color of components, and the `foreground` variable is used for text color.
+
+For the following components, `background` will be `hsl(var(--primary))`, and `foreground` will be `hsl(var(--primary-foreground))`.
+
+## Detailed List of CSS Variables
+
+::: warning Note
+
+The colors inside CSS variables must use the `hsl` format, such as `0 0% 100%`, without adding `hsl()` and `,`.
+
+:::
+
+You can check the list below to understand all the available variables.
+
+::: details Default theme CSS 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';
+
+ /* Default background color of ...etc */
+ --background: 0 0% 100%;
+
+ /* Main area background color */
+ --background-deep: 216 20.11% 95.47%;
+ --foreground: 210 6% 21%;
+
+ /* Background color for */
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+
+ /* Background color for popovers such as , , */
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+
+ /* Muted backgrounds such as , and */
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+
+ /* Theme Colors */
+
+ --primary: 212 100% 45%;
+ --primary-foreground: 0 0% 98%;
+
+ /* Used for destructive actions such as */
+
+ --destructive: 0 78% 68%;
+ --destructive-foreground: 0 0% 98%;
+
+ /* Used for success actions such as */
+
+ --success: 144 57% 58%;
+ --success-foreground: 0 0% 98%;
+
+ /* Used for warning actions such as */
+
+ --warning: 42 84% 61%;
+ --warning-foreground: 0 0% 98%;
+
+ /* Secondary colors for */
+
+ --secondary: 240 5% 96%;
+ --secondary-foreground: 240 6% 10%;
+
+ /* Used for accents such as hover effects on , ...etc */
+ --accent: 240 5% 96%;
+ --accent-hover: 200deg 10% 90%;
+ --accent-foreground: 240 6% 10%;
+
+ /* Darker color */
+ --heavy: 192deg 9.43% 89.61%;
+ --heavy-foreground: var(--accent-foreground);
+
+ /* Default border color */
+ --border: 240 5.9% 90%;
+
+ /* Border color for inputs such as , , */
+ --input: 240deg 5.88% 90%;
+ --input-placeholder: 217 10.6% 65%;
+ --input-background: 0 0% 100%;
+
+ /* Used for focus ring */
+ --ring: 222.2 84% 4.9%;
+
+ /* Border radius for card, input and buttons */
+ --radius: 0.5rem;
+
+ /* ============= custom ============= */
+
+ /* overlay color */
+ --overlay: 0deg 0% 0% / 30%;
+
+ /* base font size */
+ --font-size-base: 16px;
+
+ /* =============component & UI============= */
+
+ /* menu */
+ --sidebar: 0 0% 100%;
+ --sidebar-deep: 216 20.11% 95.47%;
+ --menu: var(--sidebar);
+
+ /* header */
+ --header: 0 0% 100%;
+
+ accent-color: var(--primary);
+ color-scheme: light;
+}
+```
+
+:::
+
+::: details Default theme dark mode CSS variables
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ /* Default background color of ...etc */
+ --background: 222.34deg 10.43% 12.27%;
+
+ /* Main area background color */
+ --background-deep: 220deg 13.06% 9%;
+ --foreground: 0 0% 95%;
+
+ /* Background color for */
+ --card: 222.34deg 10.43% 12.27%;
+
+ /* --card: 222.2 84% 4.9%; */
+ --card-foreground: 210 40% 98%;
+
+ /* Background color for popovers such as , , */
+ --popover: 222.82deg 8.43% 12.27%;
+ --popover-foreground: 210 40% 98%;
+
+ /* Muted backgrounds such as , and */
+ --muted: 220deg 6.82% 17.25%;
+ --muted-foreground: 215 20.2% 65.1%;
+
+ /* Theme Colors */
+
+ /* --primary: 245 82% 67%; */
+ --primary-foreground: 0 0% 98%;
+
+ /* Used for destructive actions such as */
+
+ --destructive: 0 78% 68%;
+ --destructive-foreground: 0 0% 98%;
+
+ /* Used for success actions such as */
+
+ --success: 144 57% 58%;
+ --success-foreground: 0 0% 98%;
+
+ /* Used for warning actions such as */
+
+ --warning: 42 84% 61%;
+ --warning-foreground: 0 0% 98%;
+
+ /* secondary color */
+ --secondary: 240 5% 17%;
+ --secondary-foreground: 0 0% 98%;
+
+ /* Used for accents such as hover effects on , ...etc */
+ --accent: 0deg 0% 100% / 8%;
+ --accent-hover: 0deg 0% 100% / 12%;
+ --accent-foreground: 0 0% 98%;
+
+ /* Darker color */
+ --heavy: 0deg 0% 100% / 12%;
+ --heavy-foreground: var(--accent-foreground);
+
+ /* Default border color */
+ --border: 240 3.7% 15.9%;
+
+ /* Border color for inputs such as , , */
+ --input: 0deg 0% 100% / 10%;
+ --input-placeholder: 218deg 11% 65%;
+ --input-background: 0deg 0% 100% / 5%;
+
+ /* Used for focus ring */
+ --ring: 222.2 84% 4.9%;
+
+ /* base radius */
+ --radius: 0.5rem;
+
+ /* ============= Custom ============= */
+
+ /* overlay color */
+ --overlay: 0deg 0% 0% / 40%;
+
+ /* base font size */
+ --font-size-base: 16px;
+
+ /* =============component & UI============= */
+
+ --sidebar: 222.34deg 10.43% 12.27%;
+ --sidebar-deep: 220deg 13.06% 9%;
+ --menu: var(--sidebar);
+ --header: 222.34deg 10.43% 12.27%;
+
+ color-scheme: dark;
+}
+```
+
+:::
+
+## Overriding Default CSS Variables
+
+You only need to override the CSS variables you want to change in your project. For example, to change the default card background color, you can add the following content to your CSS file to override it:
+
+### Under the Default Theme
+
+```css
+:root {
+ /* Background color for */
+ --card: 0 0% 30%;
+}
+```
+
+### In Dark Mode
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ /* Background color for */
+ --card: 222.34deg 10.43% 12.27%;
+}
+```
+
+## Changing the Brand Primary Color
+
+::: tip
+
+- You need to use the `hsl` color format.
+- You must clear the cache for the changes to take effect.
+- You can use [third-party tools](https://www.w3schools.com/colors/colors_hsl.asp) to convert colors.
+
+:::
+
+You only need to customize the primary color in the `preferences.ts` file under the application directory:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ theme: {
+ // Error color
+ colorDestructive: 'hsl(348 100% 61%)',
+ // Primary color
+ colorPrimary: 'hsl(212 100% 45%)',
+ // Success color
+ colorSuccess: 'hsl(144 57% 58%)',
+ // Warning color
+ colorWarning: 'hsl(42 84% 61%)',
+ },
+});
+```
+
+## Built-in Themes
+
+The framework includes a variety of built-in themes, which you can configure in the `preferences.ts` file:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ theme: {
+ builtinType: 'default',
+ },
+});
+```
+
+### Built-in Theme List
+
+The framework includes 16 built-in themes and also supports custom themes. Theoretically, you can expand the themes without limit.
+
+::: details List of Built-in Theme Types
+
+```ts
+type BuiltinThemeType =
+ | 'custom'
+ | 'deep-blue'
+ | 'deep-green'
+ | 'default'
+ | 'gray'
+ | 'green'
+ | 'neutral'
+ | 'orange'
+ | 'pink'
+ | 'red'
+ | 'rose'
+ | 'sky-blue'
+ | 'slate'
+ | 'stone'
+ | 'violet'
+ | 'yellow'
+ | 'zinc'
+ | (Record & string);
+```
+
+:::
+
+::: details Built-in Theme CSS Variables - Light
+
+```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';
+
+ /* Default background color of ...etc */
+ --background: 0 0% 100%;
+
+ /* Main area background color */
+ --background-deep: 216 20.11% 95.47%;
+ --foreground: 222 84% 5%;
+
+ /* Background color for */
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+
+ /* Background color for popovers such as , , */
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+
+ /* Muted backgrounds such as , and */
+
+ /* --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%; */
+
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+
+ /* Theme Colors */
+
+ --primary: 212 100% 45%;
+ --primary-foreground: 0 0% 98%;
+
+ /* Used for destructive actions such as */
+
+ --destructive: 0 78% 68%;
+ --destructive-foreground: 0 0% 98%;
+
+ /* Used for success actions such as */
+
+ --success: 144 57% 58%;
+ --success-foreground: 0 0% 98%;
+
+ /* Used for warning actions such as */
+
+ --warning: 42 84% 61%;
+ --warning-foreground: 0 0% 98%;
+
+ /* Secondary colors for */
+
+ --secondary: 240 5% 96%;
+ --secondary-foreground: 240 6% 10%;
+
+ /* Used for accents such as hover effects on , ...etc */
+ --accent: 240 5% 96%;
+ --accent-hover: 200deg 10% 90%;
+ --accent-foreground: 240 6% 10%;
+
+ /* Darker color */
+ --heavy: 192deg 9.43% 89.61%;
+ --heavy-foreground: var(--accent-foreground);
+
+ /* Default border color */
+ --border: 240 5.9% 90%;
+
+ /* Border color for inputs such as , , */
+ --input: 240deg 5.88% 90%;
+ --input-placeholder: 217 10.6% 65%;
+ --input-background: 0 0% 100%;
+
+ /* Used for focus ring */
+ --ring: 222.2 84% 4.9%;
+
+ /* Border radius for card, input and buttons */
+ --radius: 0.5rem;
+
+ /* ============= custom ============= */
+
+ /* overlay color */
+ --overlay: 0deg 0% 0% / 30%;
+
+ /* base font size */
+ --font-size-base: 16px;
+
+ /* =============component & UI============= */
+
+ /* menu */
+ --sidebar: 0 0% 100%;
+ --sidebar-deep: 0 0% 100%;
+ --menu: var(--sidebar);
+
+ /* header */
+ --header: 0 0% 100%;
+
+ accent-color: var(--primary);
+ color-scheme: light;
+}
+
+[data-theme='violet'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 224 71.4% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 224 71.4% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 224 71.4% 4.1%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 220 14.3% 95.9%;
+ --secondary-foreground: 220.9 39.3% 11%;
+ --muted: 220 14.3% 95.9%;
+ --muted-foreground: 220 8.9% 46.1%;
+ --accent: 220 14.3% 95.9%;
+ --accent-foreground: 220.9 39.3% 11%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 220 13% 91%;
+ --input: 220 13% 91%;
+ --ring: 262.1 83.3% 57.8%;
+}
+
+[data-theme='pink'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 346.8 77.2% 49.8%;
+}
+
+[data-theme='rose'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 346.8 77.2% 49.8%;
+}
+
+[data-theme='sky-blue'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 222.2 84% 4.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+ --primary-foreground: 210 40% 98%;
+ --secondary: 210 40% 96.1%;
+ --secondary-foreground: 222.2 47.4% 11.2%;
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+ --accent: 210 40% 96.1%;
+ --accent-foreground: 222.2 47.4% 11.2%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 214.3 31.8% 91.4%;
+ --input: 214.3 31.8% 91.4%;
+ --ring: 221.2 83.2% 53.3%;
+}
+
+[data-theme='deep-blue'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 222.2 84% 4.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+ --primary-foreground: 210 40% 98%;
+ --secondary: 210 40% 96.1%;
+ --secondary-foreground: 222.2 47.4% 11.2%;
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+ --accent: 210 40% 96.1%;
+ --accent-foreground: 222.2 47.4% 11.2%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 214.3 31.8% 91.4%;
+ --input: 214.3 31.8% 91.4%;
+ --ring: 221.2 83.2% 53.3%;
+}
+
+[data-theme='green'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 142.1 76.2% 36.3%;
+}
+
+[data-theme='deep-green'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 142.1 76.2% 36.3%;
+}
+
+[data-theme='orange'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 20 14.3% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 20 14.3% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 20 14.3% 4.1%;
+ --primary-foreground: 60 9.1% 97.8%;
+ --secondary: 60 4.8% 95.9%;
+ --secondary-foreground: 24 9.8% 10%;
+ --muted: 60 4.8% 95.9%;
+ --muted-foreground: 25 5.3% 44.7%;
+ --accent: 60 4.8% 95.9%;
+ --accent-foreground: 24 9.8% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 60 9.1% 97.8%;
+ --border: 20 5.9% 90%;
+ --input: 20 5.9% 90%;
+ --ring: 24.6 95% 53.1%;
+}
+
+[data-theme='yellow'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 20 14.3% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 20 14.3% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 20 14.3% 4.1%;
+ --primary-foreground: 26 83.3% 14.1%;
+ --secondary: 60 4.8% 95.9%;
+ --secondary-foreground: 24 9.8% 10%;
+ --muted: 60 4.8% 95.9%;
+ --muted-foreground: 25 5.3% 44.7%;
+ --accent: 60 4.8% 95.9%;
+ --accent-foreground: 24 9.8% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 60 9.1% 97.8%;
+ --border: 20 5.9% 90%;
+ --input: 20 5.9% 90%;
+ --ring: 20 14.3% 4.1%;
+}
+
+[data-theme='zinc'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 0 0% 98%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 240 5.9% 10%;
+}
+
+[data-theme='neutral'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 0 0% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 0 0% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 0 0% 3.9%;
+ --primary-foreground: 0 0% 98%;
+ --secondary: 0 0% 96.1%;
+ --secondary-foreground: 0 0% 9%;
+ --muted: 0 0% 96.1%;
+ --muted-foreground: 0 0% 45.1%;
+ --accent: 0 0% 96.1%;
+ --accent-foreground: 0 0% 9%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 0 0% 89.8%;
+ --input: 0 0% 89.8%;
+ --ring: 0 0% 3.9%;
+}
+
+[data-theme='slate'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 222.2 84% 4.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+ --primary-foreground: 210 40% 98%;
+ --secondary: 210 40% 96.1%;
+ --secondary-foreground: 222.2 47.4% 11.2%;
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+ --accent: 210 40% 96.1%;
+ --accent-foreground: 222.2 47.4% 11.2%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 214.3 31.8% 91.4%;
+ --input: 214.3 31.8% 91.4%;
+ --ring: 222.2 84% 4.9%;
+}
+
+[data-theme='gray'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 224 71.4% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 224 71.4% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 224 71.4% 4.1%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 220 14.3% 95.9%;
+ --secondary-foreground: 220.9 39.3% 11%;
+ --muted: 220 14.3% 95.9%;
+ --muted-foreground: 220 8.9% 46.1%;
+ --accent: 220 14.3% 95.9%;
+ --accent-foreground: 220.9 39.3% 11%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 220 13% 91%;
+ --input: 220 13% 91%;
+ --ring: 224 71.4% 4.1%;
+}
+```
+
+:::
+
+::: details 内置主题css变量 - dark
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ /* Default background color of ...etc */
+ --background: 222.34deg 10.43% 12.27%;
+
+ /* 主体区域背景色 */
+ --background-deep: 220deg 13.06% 9%;
+ --foreground: 0 0% 95%;
+
+ /* Background color for */
+ --card: 222.34deg 10.43% 12.27%;
+
+ /* --card: 222.2 84% 4.9%; */
+ --card-foreground: 210 40% 98%;
+
+ /* Background color for popovers such as , , */
+ --popover: 222.82deg 8.43% 12.27%;
+ --popover-foreground: 210 40% 98%;
+
+ /* Muted backgrounds such as , and */
+
+ /* --muted: 220deg 6.82% 17.25%; */
+
+ /* --muted-foreground: 215 20.2% 65.1%; */
+
+ --muted: 240 3.7% 15.9%;
+ --muted-foreground: 240 5% 64.9%;
+
+ /* 主题颜色 */
+
+ /* --primary: 245 82% 67%; */
+ --primary-foreground: 0 0% 98%;
+
+ /* Used for destructive actions such as */
+
+ --destructive: 0 78% 68%;
+ --destructive-foreground: 0 0% 98%;
+
+ /* Used for success actions such as */
+
+ --success: 144 57% 58%;
+ --success-foreground: 0 0% 98%;
+
+ /* Used for warning actions such as */
+
+ --warning: 42 84% 61%;
+ --warning-foreground: 0 0% 98%;
+
+ /* 颜色次要 */
+ --secondary: 240 5% 17%;
+ --secondary-foreground: 0 0% 98%;
+
+ /* Used for accents such as hover effects on , ...etc */
+ --accent: 216 5% 19%;
+ --accent-hover: 216 5% 24%;
+ --accent-foreground: 0 0% 98%;
+
+ /* Darker color */
+ --heavy: 216 5% 24%;
+ --heavy-foreground: var(--accent-foreground);
+
+ /* Default border color */
+ --border: 240 3.7% 22%;
+
+ /* Border color for inputs such as , , */
+ --input: 0deg 0% 100% / 10%;
+ --input-placeholder: 218deg 11% 65%;
+ --input-background: 0deg 0% 100% / 5%;
+
+ /* Used for focus ring */
+ --ring: 222.2 84% 4.9%;
+
+ /* 基本圆角大小 */
+ --radius: 0.5rem;
+
+ /* ============= Custom ============= */
+
+ /* overlay color */
+ --overlay: 0deg 0% 0% / 40%;
+
+ /* base font size */
+ --font-size-base: 16px;
+
+ /* =============component & UI============= */
+
+ --sidebar: 222.34deg 10.43% 12.27%;
+ --sidebar-deep: 220deg 13.06% 9%;
+ --menu: var(--sidebar);
+
+ /* header */
+ --header: 222.34deg 10.43% 12.27%;
+
+ color-scheme: dark;
+}
+
+.dark[data-theme='violet'],
+[data-theme='violet'] .dark {
+ --background: 224 71.4% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 210 20% 98%;
+ --card: 224 71.4% 4.1%;
+ --card-foreground: 210 20% 98%;
+ --popover: 224 71.4% 4.1%;
+ --popover-foreground: 210 20% 98%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 215 27.9% 16.9%;
+ --secondary-foreground: 210 20% 98%;
+ --muted: 215 27.9% 16.9%;
+ --muted-foreground: 217.9 10.6% 64.9%;
+ --accent: 215 27.9% 16.9%;
+ --accent-foreground: 210 20% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 215 27.9% 16.9%;
+ --input: 215 27.9% 16.9%;
+ --ring: 263.4 70% 50.4%;
+ --sidebar: 224 71.4% 4.1%;
+ --sidebar-deep: 224 71.4% 4.1%;
+ --header: 224 71.4% 4.1%;
+}
+
+.dark[data-theme='pink'],
+[data-theme='pink'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 95%;
+ --card: 0 0% 9%;
+ --card-foreground: 0 0% 95%;
+ --popover: 0 0% 9%;
+ --popover-foreground: 0 0% 95%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 15%;
+ --muted-foreground: 240 5% 64.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 85.7% 97.3%;
+ --border: 240 3.7% 15.9%;
+ --input: 240 3.7% 15.9%;
+ --ring: 346.8 77.2% 49.8%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='rose'],
+[data-theme='rose'] .dark {
+ --background: 0 0% 3.9%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 98%;
+ --card: 0 0% 3.9%;
+ --card-foreground: 0 0% 98%;
+ --popover: 0 0% 3.9%;
+ --popover-foreground: 0 0% 98%;
+ --primary-foreground: 0 85.7% 97.3%;
+ --secondary: 0 0% 14.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 14.9%;
+ --muted-foreground: 0 0% 63.9%;
+ --accent: 0 0% 14.9%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 0 0% 14.9%;
+ --input: 0 0% 14.9%;
+ --ring: 0 72.2% 50.6%;
+ --sidebar: 0 0% 3.9%;
+ --sidebar-deep: 0 0% 3.9%;
+ --header: 0 0% 3.9%;
+}
+
+.dark[data-theme='sky-blue'],
+[data-theme='sky-blue'] .dark {
+ --background: 222.2 84% 4.9%;
+ --background-deep: var(--background);
+ --foreground: 210 40% 98%;
+ --card: 222.2 84% 4.9%;
+ --card-foreground: 210 40% 98%;
+ --popover: 222.2 84% 4.9%;
+ --popover-foreground: 210 40% 98%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 217.2 32.6% 17.5%;
+ --secondary-foreground: 210 40% 98%;
+ --muted: 217.2 32.6% 17.5%;
+ --muted-foreground: 215 20.2% 65.1%;
+ --accent: 217.2 32.6% 17.5%;
+ --accent-foreground: 210 40% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 217.2 32.6% 17.5%;
+ --input: 217.2 32.6% 17.5%;
+ --ring: 224.3 76.3% 48%;
+ --sidebar: 222.2 84% 4.9%;
+ --sidebar-deep: 222.2 84% 4.9%;
+ --header: 222.2 84% 4.9%;
+}
+
+.dark[data-theme='deep-blue'],
+[data-theme='deep-blue'] .dark {
+ --background: 222.2 84% 4.9%;
+ --background-deep: var(--background);
+ --foreground: 210 40% 98%;
+ --card: 222.2 84% 4.9%;
+ --card-foreground: 210 40% 98%;
+ --popover: 222.2 84% 4.9%;
+ --popover-foreground: 210 40% 98%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 217.2 32.6% 17.5%;
+ --secondary-foreground: 210 40% 98%;
+ --muted: 217.2 32.6% 17.5%;
+ --muted-foreground: 215 20.2% 65.1%;
+ --accent: 217.2 32.6% 17.5%;
+ --accent-foreground: 210 40% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 217.2 32.6% 17.5%;
+ --input: 217.2 32.6% 17.5%;
+ --ring: 224.3 76.3% 48%;
+ --sidebar: 222.2 84% 4.9%;
+ --sidebar-deep: 222.2 84% 4.9%;
+ --header: 222.2 84% 4.9%;
+}
+
+.dark[data-theme='green'],
+[data-theme='green'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 95%;
+ --card: 24 9.8% 6%;
+ --card-foreground: 0 0% 95%;
+ --popover: 0 0% 9%;
+ --popover-foreground: 0 0% 95%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 15%;
+ --muted-foreground: 240 5% 64.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 85.7% 97.3%;
+ --border: 240 3.7% 15.9%;
+ --input: 240 3.7% 15.9%;
+ --ring: 142.4 71.8% 29.2%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='deep-green'],
+[data-theme='deep-green'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 95%;
+ --card: 24 9.8% 6%;
+ --card-foreground: 0 0% 95%;
+ --popover: 0 0% 9%;
+ --popover-foreground: 0 0% 95%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 15%;
+ --muted-foreground: 240 5% 64.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 85.7% 97.3%;
+ --border: 240 3.7% 15.9%;
+ --input: 240 3.7% 15.9%;
+ --ring: 142.4 71.8% 29.2%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='orange'],
+[data-theme='orange'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 60 9.1% 97.8%;
+ --card: 20 14.3% 4.1%;
+ --card-foreground: 60 9.1% 97.8%;
+ --popover: 20 14.3% 4.1%;
+ --popover-foreground: 60 9.1% 97.8%;
+ --primary-foreground: 60 9.1% 97.8%;
+ --secondary: 12 6.5% 15.1%;
+ --secondary-foreground: 60 9.1% 97.8%;
+ --muted: 12 6.5% 15.1%;
+ --muted-foreground: 24 5.4% 63.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 60 9.1% 97.8%;
+ --destructive: 0 72.2% 50.6%;
+ --destructive-foreground: 60 9.1% 97.8%;
+ --border: 12 6.5% 15.1%;
+ --input: 12 6.5% 15.1%;
+ --ring: 20.5 90.2% 48.2%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='yellow'],
+[data-theme='yellow'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 60 9.1% 97.8%;
+ --card: 20 14.3% 4.1%;
+ --card-foreground: 60 9.1% 97.8%;
+ --popover: 20 14.3% 4.1%;
+ --popover-foreground: 60 9.1% 97.8%;
+ --primary-foreground: 26 83.3% 14.1%;
+ --secondary: 12 6.5% 15.1%;
+ --secondary-foreground: 60 9.1% 97.8%;
+ --muted: 12 6.5% 15.1%;
+ --muted-foreground: 24 5.4% 63.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 60 9.1% 97.8%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 60 9.1% 97.8%;
+ --border: 12 6.5% 15.1%;
+ --input: 12 6.5% 15.1%;
+ --ring: 35.5 91.7% 32.9%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='zinc'],
+[data-theme='zinc'] .dark {
+ --background: 240 10% 3.9%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 98%;
+ --card: 240 10% 3.9%;
+ --card-foreground: 0 0% 98%;
+ --popover: 240 10% 3.9%;
+ --popover-foreground: 0 0% 98%;
+ --primary-foreground: 240 5.9% 10%;
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 240 3.7% 15.9%;
+ --muted-foreground: 240 5% 64.9%;
+ --accent: 240 3.7% 15.9%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 3.7% 15.9%;
+ --input: 240 3.7% 15.9%;
+ --ring: 240 4.9% 83.9%;
+ --sidebar: 240 10% 3.9%;
+ --sidebar-deep: 240 10% 3.9%;
+ --header: 240 4.9% 83.9%;
+}
+
+.dark[data-theme='neutral'],
+[data-theme='neutral'] .dark {
+ --background: 0 0% 3.9%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 98%;
+ --card: 0 0% 3.9%;
+ --card-foreground: 0 0% 98%;
+ --popover: 0 0% 3.9%;
+ --popover-foreground: 0 0% 98%;
+ --primary-foreground: 0 0% 9%;
+ --secondary: 0 0% 14.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 14.9%;
+ --muted-foreground: 0 0% 63.9%;
+ --accent: 0 0% 14.9%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 0 0% 14.9%;
+ --input: 0 0% 14.9%;
+ --ring: 0 0% 83.1%;
+ --sidebar: 0 0% 3.9%;
+ --sidebar-deep: 0 0% 3.9%;
+ --header: 0 0% 3.9%;
+}
+
+.dark[data-theme='slate'],
+[data-theme='slate'] .dark {
+ --background: 222.2 84% 4.9%;
+ --background-deep: var(--background);
+ --foreground: 210 40% 98%;
+ --card: 222.2 84% 4.9%;
+ --card-foreground: 210 40% 98%;
+ --popover: 222.2 84% 4.9%;
+ --popover-foreground: 210 40% 98%;
+ --primary-foreground: 222.2 47.4% 11.2%;
+ --secondary: 217.2 32.6% 17.5%;
+ --secondary-foreground: 210 40% 98%;
+ --muted: 217.2 32.6% 17.5%;
+ --muted-foreground: 215 20.2% 65.1%;
+ --accent: 217.2 32.6% 17.5%;
+ --accent-foreground: 210 40% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 217.2 32.6% 17.5%;
+ --input: 217.2 32.6% 17.5%;
+ --ring: 212.7 26.8% 83.9;
+ --sidebar: 222.2 84% 4.9%;
+ --sidebar-deep: 222.2 84% 4.9%;
+ --header: 222.2 84% 4.9%;
+}
+
+.dark[data-theme='gray'],
+[data-theme='gray'] .dark {
+ --background: 224 71.4% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 210 20% 98%;
+ --card: 224 71.4% 4.1%;
+ --card-foreground: 210 20% 98%;
+ --popover: 224 71.4% 4.1%;
+ --popover-foreground: 210 20% 98%;
+ --primary-foreground: 220.9 39.3% 11%;
+ --secondary: 215 27.9% 16.9%;
+ --secondary-foreground: 210 20% 98%;
+ --muted: 215 27.9% 16.9%;
+ --muted-foreground: 217.9 10.6% 64.9%;
+ --accent: 215 27.9% 16.9%;
+ --accent-foreground: 210 20% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 215 27.9% 16.9%;
+ --input: 215 27.9% 16.9%;
+ --ring: 216 12.2% 83.9%;
+ --sidebar: 224 71.4% 4.1%;
+ --sidebar-deep: 224 71.4% 4.1%;
+ --header: 224 71.4% 4.1%;
+}
+```
+
+:::
+
+## Adding a New Theme
+
+To add a new theme, simply follow these steps:
+
+- Add a new theme configuration in the application's `src/preferences.ts`.
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ theme: {
+ builtinType: 'my-theme',
+ },
+});
+```
+
+- Add the theme's CSS variables to your CSS file.
+
+```css
+/* light */
+[data-theme='my-theme'] {
+ --foreground: 224 71.4% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 224 71.4% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 224 71.4% 4.1%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 220 14.3% 95.9%;
+ --secondary-foreground: 220.9 39.3% 11%;
+ --muted: 220 14.3% 95.9%;
+ --muted-foreground: 220 8.9% 46.1%;
+ --accent: 220 14.3% 95.9%;
+ --accent-foreground: 220.9 39.3% 11%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 220 13% 91%;
+ --input: 220 13% 91%;
+ --ring: 262.1 83.3% 57.8%;
+}
+
+/* dark */
+.dark[data-theme='my-theme'],
+[data-theme='my-theme'] .dark {
+ --background: 224 71.4% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 210 20% 98%;
+ --card: 224 71.4% 4.1%;
+ --card-foreground: 210 20% 98%;
+ --popover: 224 71.4% 4.1%;
+ --popover-foreground: 210 20% 98%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 215 27.9% 16.9%;
+ --secondary-foreground: 210 20% 98%;
+ --muted: 215 27.9% 16.9%;
+ --muted-foreground: 217.9 10.6% 64.9%;
+ --accent: 215 27.9% 16.9%;
+ --accent-foreground: 210 20% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 215 27.9% 16.9%;
+ --input: 215 27.9% 16.9%;
+ --ring: 263.4 70% 50.4%;
+ --sidebar: 224 71.4% 4.1%;
+ --sidebar-deep: 224 71.4% 4.1%;
+}
+```
+
+## Dark Mode
+
+The framework includes a variety of built-in themes, which you can configure in `preferences.ts`. The dark theme also uses CSS variables for configuration:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ theme: {
+ mode: 'dark',
+ },
+});
+```
+
+## Customizing Sidebar Color
+
+The sidebar color is configured through the `--sidebar` variable.
+
+### Under the Default Theme
+
+```css
+:root {
+ --sidebar: 0 0% 100%;
+}
+```
+
+### In Dark Mode
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ --sidebar: 222.34deg 10.43% 12.27%;
+}
+```
+
+## Customizing Header Color
+
+The header color is configured through the `--header` variable.
+
+### Under the Default Theme
+
+```css
+:root {
+ --header: 0 0% 100%;
+}
+```
+
+### In Dark Mode
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ --header: 222.34deg 10.43% 12.27%;
+}
+```
+
+## Color Weakness Mode
+
+Typically used in special scenarios, you can set the application to color weakness mode. This can be configured in `preferences.ts`:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ colorWeakMode: true,
+ },
+});
+```
+
+## Gray Mode
+
+Typically used in special scenarios, this mode grays out the webpage. You can configure it in `preferences.ts`:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ colorGrayMode: true,
+ },
+});
+```
diff --git a/apps/vben5/docs/src/en/guide/in-depth/ui-framework.md b/apps/vben5/docs/src/en/guide/in-depth/ui-framework.md
new file mode 100644
index 000000000..667619a67
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/in-depth/ui-framework.md
@@ -0,0 +1,17 @@
+# UI Framework Switching
+
+`Vue Admin` supports your freedom to choose the UI framework. The default UI framework for the demo site is `Ant Design Vue`, consistent with the older version. The framework also has built-in versions for `Element Plus` and `Naive UI`, allowing you to choose according to your preference.
+
+## Adding a New UI Framework
+
+If you want to use a different UI framework, you only need to follow these steps:
+
+1. Create a new folder inside `apps`, for example, `apps/web-xxx`.
+2. Change the `name` field in `apps/web-xxx/package.json` to `web-xxx`.
+3. Remove dependencies and code from other UI frameworks and replace them with your chosen UI framework's logic, which requires minimal changes.
+4. Adjust the language files within `locales`.
+5. Adjust the components in `app.vue`.
+6. Adapt the theme of the UI framework to match `Vben Admin`.
+7. Adjust the application name in `.env`.
+8. Add a `dev:xxx` script in the root directory of the repository.
+9. Run `pnpm install` to install dependencies.
diff --git a/apps/vben5/docs/src/en/guide/introduction/changelog.md b/apps/vben5/docs/src/en/guide/introduction/changelog.md
new file mode 100644
index 000000000..83c822bd8
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/introduction/changelog.md
@@ -0,0 +1,3 @@
+# CHANGE LOG
+
+TODO
diff --git a/apps/vben5/docs/src/en/guide/introduction/quick-start.md b/apps/vben5/docs/src/en/guide/introduction/quick-start.md
new file mode 100644
index 000000000..d4829dcef
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/introduction/quick-start.md
@@ -0,0 +1,95 @@
+---
+outline: deep
+---
+
+# Quick Start {#quick-start}
+
+## Prerequisites
+
+::: info Environment Requirements
+
+Before starting the project, ensure that your environment meets the following requirements:
+
+- [Node.js](https://nodejs.org/en) version 20.15.0 or above. It is recommended to use [fnm](https://github.com/Schniz/fnm), [nvm](https://github.com/nvm-sh/nvm), or directly use [pnpm](https://pnpm.io/cli/env) for version management.
+- [Git](https://git-scm.com/) any version.
+
+To verify if your environment meets the above requirements, you can check the versions using the following commands:
+
+```bash
+# Ensure the correct node LTS version is displayed
+node -v
+# Ensure the correct git version is displayed
+git -v
+```
+
+:::
+
+## Starting the Project
+
+### Obtain the Source Code
+
+::: code-group
+
+```bash [GitHub]
+# Clone the code
+git clone https://github.com/vbenjs/vue-vben-admin.git
+```
+
+```bash [Gitee]
+# Clone the code
+# The Gitee repository may not have the latest code
+git clone https://gitee.com/annsion/vue-vben-admin.git
+```
+
+:::
+
+::: danger Caution
+
+Ensure that the directory where you store the code and all its parent directories do not contain Chinese, Korean, Japanese characters, or spaces, as this may cause errors when installing dependencies and starting the project.
+
+:::
+
+### Install Dependencies
+
+Open a terminal in your code directory and execute the following commands:
+
+```bash
+# Enter the project directory
+cd vue-vben-admin
+
+# Enable the project-specified version of pnpm
+corepack enable
+
+# Install dependencies
+pnpm install
+```
+
+::: tip Note
+
+The project only supports using `pnpm` for installing dependencies. By default, `corepack` will be used to install the specified version of `pnpm`.
+
+:::
+
+### Run the Project
+
+Execute the following command to run the project:
+
+```bash
+# Start the project
+pnpm dev
+```
+
+You will see an output similar to the following, allowing you to select the project you want to run:
+
+```bash
+│
+◆ Select the app you need to run [dev]:
+│ ● @vben/web-antd
+│ ○ @vben/web-ele
+│ ○ @vben/web-naive
+│ ○ @vben/docs
+│ ○ @vben/playground
+└
+```
+
+Now, you can visit `http://localhost:5555` in your browser to view the project.
diff --git a/apps/vben5/docs/src/en/guide/introduction/roadmap.md b/apps/vben5/docs/src/en/guide/introduction/roadmap.md
new file mode 100644
index 000000000..8add7b1be
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/introduction/roadmap.md
@@ -0,0 +1,3 @@
+# Roadmap
+
+TODO:
diff --git a/apps/vben5/docs/src/en/guide/introduction/thin.md b/apps/vben5/docs/src/en/guide/introduction/thin.md
new file mode 100644
index 000000000..a310ef398
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/introduction/thin.md
@@ -0,0 +1,67 @@
+# Slimmed-Down Version
+
+Starting from version `5.0`, we no longer provide slimmed-down repositories or branches. Our goal is to offer a more consistent development experience while reducing maintenance costs. Here’s how we introduce our project, slim down, and remove unnecessary features.
+
+## Application Slimming
+
+First, identify the version of the `UI` component library you need, and then delete the corresponding applications. For example, if you choose to use `Ant Design Vue`, you can delete the other applications. Simply remove the following two folders:
+
+```bash
+apps/web-ele
+apps/web-native
+
+```
+
+::: tip
+
+If your project doesn’t include the `UI` component library you need, you can delete all other applications and create your own new application as needed.
+
+:::
+
+## Demo Code Slimming
+
+If you don’t need demo code, you can simply delete the `playground` folder
+
+## Documentation Slimming
+
+If you don’t need documentation, you can delete the `docs` folder.
+
+## Remove Mock Service
+
+If you don’t need the `Mock` service, you can delete the `apps/backend-mock` folder. Also, remove the `VITE_NITRO_MOCK` variable from the `.env.development` file in your application.
+
+```bash
+# Whether to enable Nitro Mock service, true to enable, false to disable
+VITE_NITRO_MOCK=false
+```
+
+## Installing Dependencies
+
+Now that you’ve completed the slimming operations, you can install the dependencies and start your project:
+
+```bash
+# Run in the root directory
+pnpm install
+
+```
+
+## Adjusting Commands
+
+After slimming down, you may need to adjust commands according to your project. In the `package.json` file in the root directory, you can adjust the `scripts` field and remove any commands you don’t need.
+
+```json
+{
+ "scripts": {
+ "build:antd": "pnpm run build --filter=@vben/web-antd",
+ "build:docs": "pnpm run build --filter=@vben/docs",
+ "build:ele": "pnpm run build --filter=@vben/web-ele",
+ "build:naive": "pnpm run build --filter=@vben/web-naive",
+ "build:play": "pnpm run build --filter=@vben/playground",
+ "dev:antd": "pnpm -F @vben/web-antd run dev",
+ "dev:docs": "pnpm -F @vben/docs run dev",
+ "dev:ele": "pnpm -F @vben/web-ele run dev",
+ "dev:play": "pnpm -F @vben/playground run dev",
+ "dev:naive": "pnpm -F @vben/web-naive run dev"
+ }
+}
+```
diff --git a/apps/vben5/docs/src/en/guide/introduction/vben.md b/apps/vben5/docs/src/en/guide/introduction/vben.md
new file mode 100644
index 000000000..8a2ba1ccd
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/introduction/vben.md
@@ -0,0 +1,49 @@
+# About Vben Admin
+
+::: info You are reading the documentation for [Vben Admin](https://github.com/vbenjs/vue-vben-admin) version `5.0`!
+
+- Vben Admin 2.x is currently archived and only receives critical fixes.
+- The new version is not compatible with the old version. If you are using the old version (v2, v3), please refer to the [Vue Vben Admin 2.x Documentation](https://doc.vvbin.cn).
+- If you find any errors in the documentation, feel free to submit an issue to help us improve.
+- If you just want to experience it, you can check out the [Quick Start](./quick-start.md).
+
+:::
+
+[Vben Admin](https://github.com/vbenjs/vue-vben-admin) is a backend solution based on [Vue 3.0](https://github.com/vuejs/core), [Vite](https://github.com/vitejs/vite), and [TypeScript](https://www.typescriptlang.org/), aimed at providing an out-of-the-box solution for developing medium to large-scale projects. It includes features like component re-encapsulation, utilities, hooks, dynamic menus, permission validation, multi-theme configurations, and button-level permission control. The project uses the latest frontend technology stack, making it a good starting template for quickly building enterprise-level mid- to backend product prototypes. It can also serve as an example for learning `vue3`, `vite`, `ts`, and other mainstream technologies. The project will continue to follow the latest technologies and apply them within the project.
+
+## Features
+
+- **Latest Technology Stack**: Developed using cutting-edge frontend technologies like `Vue 3`, `Vite`, and `TypeScript`.
+- **Internationalization**: Built-in comprehensive internationalization solutions with multi-language support.
+- **Permission Validation**: Comprehensive permission validation solutions, including button-level permission control.
+- **Multi-Theme**: Built-in multiple theme configurations & dark mode to meet personalized needs.
+- **Dynamic Menu**: Supports dynamic menus that can display based on permissions.
+- **Mock Data**: High-performance local Mock data solution based on `Nitro`.
+- **Rich Components**: Provides a wide range of components to meet most business needs.
+- **Standardization**: Code quality is ensured with tools like `ESLint`, `Prettier`, `Stylelint`, `Publint`, and `CSpell`.
+- **Engineering**: Development efficiency is improved with tools like `Pnpm Monorepo`, `TurboRepo`, and `Changeset`.
+- **Multi-UI Library Support**: Supports mainstream UI libraries like `Ant Design Vue`, `Element Plus`, and `Vuetify`, without being restricted to a specific framework.
+
+## Browser Support
+
+- **Local development** is recommended using the **latest version of Chrome**. **Versions below Chrome 80 are not supported**.
+
+- **Production environment** supports modern browsers, IE is not supported.
+
+| [ ](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 |
+
+## Contribution
+
+- [Vben Admin](https://github.com/vbenjs/vue-vben-admin) is still being actively updated. Contributions are welcome to help maintain and improve the project, aiming to create a better mid- to backend solution.
+- If you wish to join us, you can start by contributing in the following ways, and we will invite you to join based on your activity.
+
+::: info Join Us
+
+- Regularly submit `PRs`.
+- Provide valuable suggestions.
+- Participate in discussions and help resolve some `issues`.
+- Help maintain the documentation.
+
+:::
diff --git a/apps/vben5/docs/src/en/guide/introduction/why.md b/apps/vben5/docs/src/en/guide/introduction/why.md
new file mode 100644
index 000000000..f0cabe88e
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/introduction/why.md
@@ -0,0 +1,9 @@
+# Why Choose Us?
+
+First of all, we do not compare ourselves with other frameworks. We believe that every framework has its own characteristics and is suited for different scenarios. Our goal is to provide a simple and easy-to-use framework that allows developers to get started quickly and focus on developing business logic. Therefore, we will continue to improve and optimize our framework to offer a better experience.
+
+## Framework History
+
+Starting from Vue Vben Admin version 1.x, the framework has undergone numerous iterations and optimizations. From initially using `Vite 0.x` when there were no ready-made plugins available, we developed many custom plugins to bridge the gap between Webpack and Vite. Although many of these have since been replaced, our original intention has remained the same: to provide a simple and easy-to-use framework.
+
+Although the community maintained the project for a period, we have always closely monitored the development of Vue Vben Admin. We have witnessed many developers use Vben Admin and provide valuable suggestions and feedback. We are very grateful for everyone's support and contributions, which continue to drive us to improve Vben Admin. In the new version, we have continuously collected user feedback, started anew, and optimized the framework to provide a better user experience. Our goal is to enable developers to get started quickly and focus on developing business logic.
diff --git a/apps/vben5/docs/src/en/guide/other/faq.md b/apps/vben5/docs/src/en/guide/other/faq.md
new file mode 100644
index 000000000..da908f893
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/other/faq.md
@@ -0,0 +1,159 @@
+# Frequently Asked Questions #{faq}
+
+::: tip Listed are some common questions
+
+If you have a question, you can first look here. If not found, you can search or submit your question on [GitHub Issue](https://github.com/vbenjs/vue-vben-admin/issues), or if it's a discussion-type question, you can go to [GitHub Discussions](https://github.com/vbenjs/vue-vben-admin/discussions)
+
+:::
+
+## Instructions
+
+If you encounter a problem, you can start looking from the following aspects:
+
+1. Search the corresponding module's GitHub repository [issue](https://github.com/vbenjs/vue-vben-admin/issues)
+2. Search for the problem on [Google](https://www.google.com)
+3. Search for the problem on [Baidu](https://www.baidu.com)
+4. If you can't find the issue in the list below, you can ask in [issues](https://github.com/vbenjs/vue-vben-admin/issues)
+5. If it's not a problem type and needs discussion, please go to [discussions](https://github.com/vbenjs/vue-vben-admin/discussions) to discuss
+
+## 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.
+
+## About Cache Update Issues
+
+The project configuration is by default cached in `localStorage`, so some configurations may not change after a version update.
+
+The solution is to modify the `version` number in `package.json` each time the code is updated. This is because the key for `localStorage` is based on the version number. Therefore, after an update, the configurations from a previous version will become invalid. Simply re-login to apply the new settings.
+
+## About Modifying Configuration Files
+
+When modifying environment files such as `.env` or the `vite.config.ts` file, Vite will automatically restart the service.
+
+There's a chance that automatic restarts may encounter issues. Simply rerunning the project can resolve these problems.
+
+## Errors When Running Locally
+
+Since Vite does not transform code locally and the code uses relatively new syntax such as optional chaining, local development requires using a higher version of the browser (`Chrome 90+`).
+
+## Blank Page After Switching Pages
+
+This issue occurs because route switching animations are enabled, and the corresponding page component has multiple root nodes. Adding a `
` at the outermost layer of the page can solve this problem.
+
+**Incorrect Example**
+
+```vue
+
+
+ text h1
+ text h2
+
+```
+
+**正确示例**
+
+```vue
+
+
+
text h1
+ text h2
+
+
+```
+
+::: tip Tip
+
+- If you want to use multiple root tags, you can disable route switching animations.
+- Root comment nodes under `template` are also counted as a node.
+
+:::
+
+## My code works locally but not when packaged
+
+The reason for this issue could be one of the following. You can check these reasons, and if there are other possibilities, feel free to add them:
+
+- The variable `ctx` was used, which is not exposed in the instance type. The Vue official documentation also advises against using this property as it is intended for internal use only.
+
+```ts
+import { getCurrentInstance } from 'vue';
+getCurrentInstance().ctx.xxxx;
+```
+
+## Dependency Installation Issues
+
+- If you cannot install dependencies or the startup reports an error, you can try executing `pnpm run reinstall`.
+- If you cannot install dependencies or encounter errors, you can try switching to a mobile hotspot for installing dependencies.
+- If that still doesn't work, you can configure a domestic mirror for installation.
+- You can also create a `.npmrc` file in the project root directory with the following content:
+
+```bash
+# .npmrc
+registry = https://registry.npmmirror.com/
+```
+
+## Package File Too Large
+
+- First, the full version will be larger because it includes many library files. You can use the simplified version for development.
+
+- Secondly, it is recommended to enable gzip, which can reduce the size to about 1/3 of the original. Gzip can be enabled directly by the server. If so, the frontend does not need to build `.gz` format files. If the frontend has built `.gz` files, for example, with nginx, you need to enable the `gzip_static: on` option.
+
+- While enabling gzip, you can also enable `brotli` for better compression than gzip. Both can coexist.
+
+**Note**
+
+- gzip_static: This module requires additional installation in nginx, as the default nginx does not include this module.
+
+- Enabling `brotli` also requires additional nginx module installation.
+
+## Runtime Errors
+
+If you encounter errors similar to the following, please check that the full project path (including all parent paths) does not contain Chinese, Japanese, or Korean characters. Otherwise, you will encounter a 404 error for the path, leading to the following issue:
+
+```ts
+[vite] Failed to resolve module import "ant-design-vue/dist/antd.css-vben-adminode_modulesant-design-vuedistantd.css". (imported by /@/setup/ant-design-vue/index.ts)
+```
+
+## Console Route Warning Issue
+
+If you see the following warning in the console, and the page `can open normally`, you can ignore this warning.
+
+Future versions of `vue-router` may provide an option to disable this warning.
+
+```ts
+[Vue Router warn]: No match found for location with path "xxxx"
+```
+
+## Startup Error
+
+If you encounter the following error message, please check if your nodejs version meets the requirements.
+
+```bash
+TypeError: str.matchAll is not a function
+at Object.extractor (vue-vben-admin-main\node_modules@purge-icons\core\dist\index.js:146:27)
+at Extract (vue-vben-admin-main\node_modules@purge-icons\core\dist\index.js:173:54)
+```
+
+## nginx Deployment
+
+After deploying to `nginx`,you might encounter the following error:
+
+```bash
+Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.
+```
+
+Solution 1:
+
+```bash
+http {
+ #If there is such a configuration, it needs to be commented out
+ #include mime.types;
+
+ types {
+ application/javascript js mjs;
+ }
+}
+```
+
+Solution 2:
+
+Open the `mime.types` file under `nginx` and change `application/javascript js;` to `application/javascript js mjs;`
diff --git a/apps/vben5/docs/src/en/guide/other/project-update.md b/apps/vben5/docs/src/en/guide/other/project-update.md
new file mode 100644
index 000000000..85ceef4d4
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/other/project-update.md
@@ -0,0 +1,54 @@
+# PROJECT UPDATE
+
+## Why Can't It Be Updated Like a npm Plugin
+
+Because the project is a complete project template, not a plugin or a package, it cannot be updated like a plugin. After you use the code, you will develop it further based on business needs, and you need to manually merge and upgrade.
+
+## What Should I Do
+
+The project is managed using a `Monorepo` approach and has abstracted some of the more core code, such as `packages/@core`, `packages/effects`. As long as the business code has not modified this part of the code, you can directly pull the latest code and then merge it into your branch. You only need to handle some conflicts simply. Other folders will only make some minor adjustments, which will not affect the business code.
+
+::: tip Recommendation
+
+It is recommended to follow the repository updates actively and merge them; do not accumulate over a long time, Otherwise, it will lead to too many merge conflicts and increase the difficulty of merging.
+
+:::
+
+## Updating Code Using Git
+
+1. Clone the code
+
+```bash
+git clone https://github.com/vbenjs/vue-vben-admin.git
+```
+
+2. Add your company's git source address
+
+```bash
+# up is the source name, can be set arbitrarily
+# gitUrl is the latest open-source code
+git remote add up gitUrl;
+```
+
+3. Push the code to your company's git
+
+```bash
+# Push the code to your company
+# main is the branch name, adjust according to your situation
+git push up main
+# Sync the company's code
+# main is the branch name, adjust according to your situation
+git pull up main
+```
+
+4. How to sync the latest open-source code
+
+```bash
+git pull origin main
+```
+
+::: tip Tip
+
+When syncing the code, conflicts may occur. Just resolve the conflicts.
+
+:::
diff --git a/apps/vben5/docs/src/en/guide/other/remove-code.md b/apps/vben5/docs/src/en/guide/other/remove-code.md
new file mode 100644
index 000000000..543a937cb
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/other/remove-code.md
@@ -0,0 +1,18 @@
+# Remove Code
+
+## Remove Code
+
+In the corresponding application's `index.html` file, find the following code and delete it:
+
+```html
+
+
+```
diff --git a/apps/vben5/docs/src/en/guide/project/changeset.md b/apps/vben5/docs/src/en/guide/project/changeset.md
new file mode 100644
index 000000000..0f2abe755
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/project/changeset.md
@@ -0,0 +1,21 @@
+# Changeset
+
+The project has integrated [changeset](https://github.com/changesets/changesets) as a version management tool. Changeset is a version management tool that helps us better manage versions, generate changelogs, and automate releases.
+
+For detailed usage, please refer to the official documentation. If you do not need it, you can ignore it directly.
+
+## Command Line
+
+The changeset command is already built into the project:
+
+### Interactively Add Changesets
+
+```bash
+pnpm run changeset
+```
+
+### Uniformly Increment Version Numbers
+
+```bash
+pnpm run version
+```
diff --git a/apps/vben5/docs/src/en/guide/project/cli.md b/apps/vben5/docs/src/en/guide/project/cli.md
new file mode 100644
index 000000000..a9e43fff2
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/project/cli.md
@@ -0,0 +1,106 @@
+---
+outline: deep
+---
+
+# CLI
+
+In the project, some command-line tools are provided for common operations, located in `scripts`.
+
+## vsh
+
+Used for some project operations, such as cleaning the project, checking the project, etc.
+
+### Usage
+
+```bash
+pnpm vsh [command] [options]
+```
+
+### vsh check-circular
+
+Check for circular references throughout the project. If there are circular references, the modules involved will be output to the console.
+
+#### Usage
+
+```bash
+pnpm vsh check-circular
+```
+
+#### Options
+
+| Option | Description |
+| ---------- | --------------------------------------------------------- |
+| `--staged` | Only check files in the git staging area, default `false` |
+
+### vsh check-dep
+
+Check the dependency situation of the entire project and output `unused dependencies`, `uninstalled dependencies` information to the console.
+
+#### Usage
+
+```bash
+pnpm vsh check-dep
+```
+
+### vsh lint
+
+Lint checks the project to see if the code in the project conforms to standards.
+
+#### Usage
+
+```bash
+pnpm vsh lint
+```
+
+#### Options
+
+| Option | Description |
+| ---------- | -------------------------------------------- |
+| `--format` | Check and try to fix errors, default `false` |
+
+### vsh publint
+
+Perform package standard checks on `Monorepo` projects to see if the packages in the project conform to standards.
+
+#### Usage
+
+```bash
+pnpm vsh publint
+```
+
+#### Options
+
+| Option | Description |
+| --------- | ------------------------------------ |
+| `--check` | Only perform checks, default `false` |
+
+### vsh code-workspace
+
+Generate `vben-admin.code-workspace` file. Currently, it does not need to be executed manually and will be executed automatically when code is committed.
+
+#### Usage
+
+```bash
+pnpm vsh code-workspace
+```
+
+#### Options
+
+| Option | Description |
+| --------------- | --------------------------------------------------------- |
+| `--auto-commit` | Automatically commit during `git commit`, default `false` |
+| `--spaces` | Indentation format, default `2` spaces |
+
+## turbo-run
+
+Used to quickly execute scripts in the large repository and provide option-based interactive selection.
+
+### Usage
+
+```bash
+pnpm turbo-run [command]
+```
+
+### turbo-run dev
+
+Quickly execute the `dev` command and provide option-based interactive selection.
diff --git a/apps/vben5/docs/src/en/guide/project/dir.md b/apps/vben5/docs/src/en/guide/project/dir.md
new file mode 100644
index 000000000..e2747f53d
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/project/dir.md
@@ -0,0 +1,68 @@
+# Directory Explanation
+
+The directory uses Monorepo management, and the project structure is as follows:
+
+```bash
+.
+├── Dockerfile # Docker image build file
+├── README.md # Project documentation
+├── apps # Project applications directory
+│ ├── backend-mock # Backend mock service application
+│ ├── web-antd # Frontend application based on Ant Design Vue
+│ ├── web-ele # Frontend application based on Element Plus
+│ └── web-naive # Frontend application based on Naive UI
+├── build-local-docker-image.sh # Script for building Docker images locally
+├── cspell.json # CSpell configuration file
+├── docs # Project documentation directory
+├── eslint.config.mjs # ESLint configuration file
+├── internal # Internal tools directory
+│ ├── lint-configs # Code linting configurations
+│ │ ├── commitlint-config # Commitlint configuration
+│ │ ├── eslint-config # ESLint configuration
+│ │ ├── prettier-config # Prettier configuration
+│ │ └── stylelint-config # Stylelint configuration
+│ ├── node-utils # Node.js tools
+│ ├── tailwind-config # Tailwind configuration
+│ ├── tsconfig # Common tsconfig settings
+│ └── vite-config # Common Vite configuration
+├── package.json # Project dependency configuration
+├── packages # Project packages directory
+│ ├── @core # Core package
+│ │ ├── base # Base package
+│ │ │ ├── design # Design related
+│ │ │ ├── icons # Icons
+│ │ │ ├── shared # Shared
+│ │ │ └── typings # Type definitions
+│ │ ├── composables # Composable APIs
+│ │ ├── preferences # Preferences
+│ │ └── ui-kit # UI component collection
+│ │ ├── layout-ui # Layout UI
+│ │ ├── menu-ui # Menu UI
+│ │ ├── shadcn-ui # shadcn UI
+│ │ └── tabs-ui # Tabs UI
+│ ├── constants # Constants
+│ ├── effects # Effects related packages
+│ │ ├── access # Access control
+│ │ ├── plugins # Plugins
+│ │ ├── common-ui # Common UI
+│ │ ├── hooks # Composable APIs
+│ │ ├── layouts # Layouts
+│ │ └── request # Request
+│ ├── icons # Icons
+│ ├── locales # Internationalization
+│ ├── preferences # Preferences
+│ ├── stores # State management
+│ ├── styles # Styles
+│ ├── types # Type definitions
+│ └── utils # Utilities
+├── playground # Demo directory
+├── pnpm-lock.yaml # pnpm lock file
+├── pnpm-workspace.yaml # pnpm workspace configuration file
+├── scripts # Scripts directory
+│ ├── turbo-run # Turbo run script
+│ └── vsh # VSH script
+├── stylelint.config.mjs # Stylelint configuration file
+├── turbo.json # Turbo configuration file
+├── vben-admin.code-workspace # VS Code workspace configuration file
+└── vitest.config.ts # Vite configuration file
+```
diff --git a/apps/vben5/docs/src/en/guide/project/standard.md b/apps/vben5/docs/src/en/guide/project/standard.md
new file mode 100644
index 000000000..23770c548
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/project/standard.md
@@ -0,0 +1,165 @@
+# Standards
+
+::: tip Contributing Code
+
+- If you want to contribute code to the project, please ensure your code complies with the project's coding standards.
+- If you are using `vscode`, you need to install the following plugins:
+
+ - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - Script code checking
+ - [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - Code formatting
+ - [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) - Word syntax checking
+ - [Stylelint](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint) - CSS formatting
+
+:::
+
+## Purpose
+
+Students with basic engineering literacy always pay attention to coding standards, and code style checking (Code Linting, simply called Lint) is an important means to ensure the consistency of coding standards.
+
+Following the corresponding coding standards has the following benefits:
+
+- Lower bug error rate
+- Efficient development efficiency
+- Higher readability
+
+## Tools
+
+The project's configuration files are located in `internal/lint-configs`, where you can modify various lint configurations.
+
+The project integrates the following code verification tools:
+
+- [ESLint](https://eslint.org/) for JavaScript code checking
+- [Stylelint](https://stylelint.io/) for CSS style checking
+- [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
+
+## ESLint
+
+ESLint is a code standard and error checking tool used to identify and report syntax errors in TypeScript code.
+
+### Command
+
+```bash
+pnpm eslint .
+```
+
+### Configuration
+
+The ESLint configuration file is `eslint.config.mjs`, with its core configuration located in the `internal/lint-configs/eslint-config` directory, which can be modified according to project needs.
+
+## Stylelint
+
+Stylelint is used to check the style of CSS within the project. Coupled with the editor's auto-fix feature, it can effectively unify the CSS style within the project.
+
+### Command
+
+```bash
+pnpm stylelint "**/*.{vue,css,less.scss}"
+```
+
+### Configuration
+
+The Stylelint configuration file is `stylelint.config.mjs`, with its core configuration located in the `internal/lint-configs/stylelint-config` directory, which can be modified according to project needs.
+
+## Prettier
+
+Prettier Can be used to unify project code style, consistent indentation, single and double quotes, trailing commas, and other styles.
+
+### Command
+
+```bash
+pnpm prettier .
+```
+
+### Configuration
+
+The Prettier configuration file is `.prettier.mjs`, with its core configuration located in the `internal/lint-configs/prettier-config` directory, which can be modified according to project needs.
+
+## CommitLint
+
+In a team, everyone's git commit messages can vary widely, making it difficult to ensure standardization without a mechanism. How can standardization be achieved? You might think of using git's hook mechanism to write shell scripts to implement this. Of course, this is possible, but actually, JavaScript has a great tool for implementing this template, which is commitlint (used for verifying the standard of git commit messages).
+
+### Configuration
+
+The CommitLint configuration file is `.commitlintrc.mjs`, with its core configuration located in the `internal/lint-configs/commitlint-config` directory, which can be modified according to project needs.
+
+### Git Commit Standards
+
+Refer to [Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular)
+
+- `feat` Add new features
+- `fix` Fix problems/BUGs
+- `style` Code style changes that do not affect the outcome
+- `perf` Optimization/performance improvement
+- `refactor` Refactoring
+- `revert` Revert changes
+- `test` Related to tests
+- `docs` Documentation/comments
+- `chore` Dependency updates/scaffold configuration modifications, etc.
+- `workflow` Workflow improvements
+- `ci` Continuous integration
+- `types` Type modifications
+
+### Disabling Git Commit Standard Checks
+
+If you want to disable Git commit standard checks, there are two ways:
+
+::: code-group
+
+```bash [Temporary disable]
+git commit -m 'feat: add home page' --no-verify
+```
+
+```bash [Permanent closed]
+# Comment out the following code in .husky/commit-msg to disable
+pnpm exec commitlint --edit "$1" # [!code --]
+```
+
+:::
+
+## Publint
+
+Publint is a tool for checking the standard of npm packages, which can check whether the package version conforms to the standard, whether it conforms to the standard ESM package specification, etc.
+
+### Command
+
+```bash
+pnpm vsh publint
+```
+
+## Cspell
+
+Cspell is a tool for checking spelling errors, which can check for spelling errors in the code, avoiding bugs caused by spelling errors.
+
+### Command
+
+```bash
+pnpm cspell lint \"**/*.ts\" \"**/README.md\" \".changeset/*.md\" --no-progress
+```
+
+### Configuration
+
+The cspell configuration file is `cspell.json`, which can be modified according to project needs.
+
+## Git Hook
+
+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
+
+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.
+
+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 project defines corresponding hooks inside `.husky`.
+
+#### How to Disable Husky
+
+If you want to disable Husky, simply delete the .husky directory.
+
+### lint-staged
+
+Used for automatically fixing style issues of committed files. Its configuration file is `.lintstagedrc.mjs`, which can be modified according to project needs.
diff --git a/apps/vben5/docs/src/en/guide/project/tailwindcss.md b/apps/vben5/docs/src/en/guide/project/tailwindcss.md
new file mode 100644
index 000000000..74df1c8aa
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/project/tailwindcss.md
@@ -0,0 +1,13 @@
+# Tailwind CSS
+
+[Tailwind CSS](https://tailwindcss.com/) is a utility-first CSS framework for quickly building custom designs.
+
+## Configuration
+
+The project's configuration file is located in `internal/tailwind-config`, where you can modify the Tailwind CSS configuration.
+
+::: tip Restrictions on using tailwindcss in packages
+
+Tailwind CSS compilation will only be enabled if there is a `tailwind.config.mjs` file present in the corresponding package. Otherwise, Tailwind CSS will not be enabled. If you have a pure SDK package that does not require Tailwind CSS, you do not need to create a `tailwind.config.mjs` file.
+
+:::
diff --git a/apps/vben5/docs/src/en/guide/project/test.md b/apps/vben5/docs/src/en/guide/project/test.md
new file mode 100644
index 000000000..5989c32ae
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/project/test.md
@@ -0,0 +1,33 @@
+# Unit Testing
+
+The project incorporates [Vitest](https://vitest.dev/) as the unit testing tool. Vitest is a test runner based on Vite, offering a simple API for writing test cases.
+
+## Writing Test Cases
+
+Within the project, we follow the convention of naming test files with a `.test.ts` suffix or placing them inside a `__tests__` directory. For example, if you create a `utils.ts` file, then you would create a corresponding `utils.spec.ts` file in the same directory,
+
+```ts
+// utils.test.ts
+import { expect, test } from 'vitest';
+import { sum } from './sum';
+
+test('adds 1 + 2 to equal 3', () => {
+ expect(sum(1, 2)).toBe(3);
+});
+```
+
+## Running Tests
+
+To run the tests, execute the following command at the root of the monorepo:
+
+```bash
+pnpm test:unit
+```
+
+## Existing Unit Tests
+
+There are already some unit test cases in the project. You can search for files ending with .test.ts to view them. When you make changes to related code, you can run the unit tests to ensure the correctness of your code. It is recommended to maintain the coverage of unit tests during the development process and to run unit tests as part of the CI/CD process to ensure tests pass before deploying the project.
+
+Existing unit test status:
+
+
diff --git a/apps/vben5/docs/src/en/guide/project/vite.md b/apps/vben5/docs/src/en/guide/project/vite.md
new file mode 100644
index 000000000..f4583353d
--- /dev/null
+++ b/apps/vben5/docs/src/en/guide/project/vite.md
@@ -0,0 +1,33 @@
+# Vite Config
+
+The project encapsulates a layer of Vite configuration and integrates some plugins for easy reuse across multiple packages and applications. The usage is as follows:
+
+## Application
+
+```ts
+// vite.config.mts
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ application: {},
+ // Vite configuration, override according to the official Vite documentation
+ vite: {},
+ };
+});
+```
+
+## Package
+
+```ts
+// vite.config.mts
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ library: {},
+ // Vite configuration, override according to the official Vite documentation
+ vite: {},
+ };
+});
+```
diff --git a/apps/vben5/docs/src/en/index.md b/apps/vben5/docs/src/en/index.md
new file mode 100644
index 000000000..42aeef3ff
--- /dev/null
+++ b/apps/vben5/docs/src/en/index.md
@@ -0,0 +1,76 @@
+---
+# https://vitepress.dev/reference/default-theme-home-page
+layout: home
+sidebar: false
+
+hero:
+ name: Vben Admin
+ text: Enterprise-Level Management System Framework
+ tagline: Fully Upgraded, Ready to Use, Simple and Efficient
+ image:
+ src: https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp
+ alt: Vben Admin
+ actions:
+ - theme: brand
+ text: Get Started ->
+ link: /en/guide/introduction/vben
+ - theme: alt
+ text: Live Preview
+ link: https://www.vben.pro
+ - theme: alt
+ text: View on GitHub
+ link: https://github.com/vbenjs/vue-vben-admin
+
+features:
+ - icon: 🚀
+ title: Latest Technology Stack
+ details: Based on the latest technology stack, including Vue3, Pinia, Vue Router, TypeScript, etc.
+ link: /en/guide/introduction/quick-start
+ linkText: Get Started
+ - icon: 🦄
+ title: Rich Configurations
+ details: An enterprise-level frontend solution for middle and back-end systems, offering a wealth of components, templates, and various preference settings.
+ link: /en/guide/essentials/settings
+ linkText: Configuration Documentation
+ - icon: 🎨
+ title: Theme Customization
+ details: Easily switch between various themes through simple configurations, catering to personalized needs.
+ link: /en/guide/in-depth/theme
+ linkText: Theme Documentation
+ - icon: 🌐
+ title: Internationalization
+ details: Built-in internationalization support with multiple languages to meet global needs.
+ link: /en/guide/in-depth/locale
+ linkText: Internationalization Documentation
+ - icon: 🔐
+ title: Access Control
+ details: Built-in access control solutions supporting various permission management methods to meet different access requirements.
+ link: /en/guide/in-depth/access
+ linkText: Access Documentation
+ - title: Vite
+ icon:
+ src: /logos/vite.svg
+ details: Modern frontend build tool with fast cold start and instant hot updates.
+ link: https://vitejs.dev/
+ linkText: Official Site
+ - title: Shadcn UI
+ icon:
+ src: /logos/shadcn-ui.svg
+ details: Core built on Shadcn UI + Tailwindcss, with business support for any UI framework.
+ link: https://www.shadcn-vue.com/
+ linkText: Official Site
+ - title: Turbo Repo
+ icon:
+ src: /logos/turborepo.svg
+ details: Standardized monorepo architecture using pnpm + monorepo + turbo for enterprise-level development standards.
+ link: https://turbo.build/
+ linkText: Official Site
+ - title: Nitro Mock Server
+ icon:
+ src: /logos/nitro.svg
+ details: Built-in Nitro Mock service makes your mock service more powerful.
+ link: https://nitro.unjs.io/
+ linkText: Official Site
+---
+
+
diff --git a/apps/vben5/docs/src/friend-links/index.md b/apps/vben5/docs/src/friend-links/index.md
new file mode 100644
index 000000000..84b61906f
--- /dev/null
+++ b/apps/vben5/docs/src/friend-links/index.md
@@ -0,0 +1,27 @@
+# 友情链接
+
+如果您的网站是与 Vben Admin 相关的,也属于开源项目,欢迎联系我们,我们会将与您的网站加入交换友情链接。
+
+## 交换方式
+
+### 添加作者,并注明来意
+
+- 通过邮箱联系作者: [ann.vben@gmail.com](mailto:ann.vben@gmail.com)
+- 通过微信联系作者:
+
+
+
+### 提供资料
+
+提供您的网站名称、链接、描述、LOGO(可选)等信息,我们会在第一时间添加您的网站。
+
+### 友情链接
+
+- 在您的网站上添加我们的友情链接,链接如下:
+
+ - 名称:Vben Admin
+ - 链接:https://www.vben.pro
+ - 描述:Vben Admin 企业级开箱即用的中后台前端解决方案
+ - Logo:https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp
+
+我们将定期的检查友情链接,如果发现您的网站已经删除了我们的友情链接以及链接地址是否正确。
diff --git a/apps/vben5/docs/src/guide/essentials/build.md b/apps/vben5/docs/src/guide/essentials/build.md
new file mode 100644
index 000000000..ab9828fd5
--- /dev/null
+++ b/apps/vben5/docs/src/guide/essentials/build.md
@@ -0,0 +1,243 @@
+# 构建与部署
+
+::: tip 前言
+
+由于是展示项目,所以打包后相对较大,如果项目中没有用到的插件,可以删除对应的文件或者路由,不引用即可,没有引用就不会打包。
+
+:::
+
+## 构建
+
+项目开发完成之后,执行以下命令进行构建:
+
+**注意:** 请在项目根目录下执行以下命令
+
+```bash
+pnpm build
+```
+
+构建打包成功之后,会在根目录生成对应的应用下的 `dist` 文件夹,里面就是构建打包好的文件,例如: `apps/web-antd/dist/`
+
+## 预览
+
+发布之前可以在本地进行预览,有多种方式,这里介绍两种:
+
+- 使用项目自定的命令进行预览(推荐)
+
+**注意:** 请在项目根目录下执行以下命令
+
+```bash
+pnpm preview
+```
+
+等待构建成功后,访问 `http://localhost:4173` 即可查看效果。
+
+- 本地服务器预览
+
+可以在电脑全局安装 `serve` 服务,如 `live-server`,
+
+```bash
+npm i -g live-server
+```
+
+然后在 `dist` 目录下执行 `live-server` 命令,即可在本地查看效果。
+
+```bash
+cd apps/web-antd/dist
+# 本地预览,默认端口8080
+live-server
+# 指定端口
+live-server --port 9000
+```
+
+## 压缩
+
+### 开启 `gzip` 压缩
+
+需要在打包的时候更改`.env.production`配置:
+
+```bash
+VITE_COMPRESS=gzip
+```
+
+### 开启 `brotli` 压缩
+
+需要在打包的时候更改`.env.production`配置:
+
+```bash
+VITE_COMPRESS=brotli
+```
+
+### 同时开启 `gzip` 和 `brotli` 压缩
+
+需要在打包的时候更改`.env.production`配置:
+
+```bash
+VITE_COMPRESS=gzip,brotli
+```
+
+::: tip 提示
+
+`gzip` 和 `brotli` 都需要安装特定模块才能使用。
+
+:::
+
+::: details gzip 与 brotli 在 nginx 内的配置
+
+```bash
+http {
+ # 开启gzip
+ gzip on;
+ # 开启gzip_static
+ # gzip_static 开启后可能会报错,需要安装相应的模块, 具体安装方式可以自行查询
+ # 只有这个开启,vue文件打包的.gz文件才会有效果,否则不需要开启gzip进行打包
+ gzip_static on;
+ gzip_proxied any;
+ gzip_min_length 1k;
+ gzip_buffers 4 16k;
+ #如果nginx中使用了多层代理 必须设置这个才可以开启gzip。
+ gzip_http_version 1.0;
+ gzip_comp_level 2;
+ gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
+ gzip_vary off;
+ gzip_disable "MSIE [1-6]\.";
+
+ # 开启 brotli压缩
+ # 需要安装对应的nginx模块,具体安装方式可以自行查询
+ # 可以与gzip共存不会冲突
+ brotli on;
+ brotli_comp_level 6;
+ brotli_buffers 16 8k;
+ brotli_min_length 20;
+ brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
+}
+```
+
+:::
+
+## 构建分析
+
+如果你的构建文件很大,可以通过项目内置 [rollup-plugin-analyzer](https://github.com/doesdev/rollup-plugin-analyzer) 插件进行代码体积分析,从而优化你的代码。只需要在`根目录`下执行以下命令:
+
+```bash
+pnpm run build:analyze
+```
+
+运行之后,在自动打开的页面可以看到具体的体积分布,以分析哪些依赖有问题。
+
+
+
+## 部署
+
+简单的部署只需要将最终生成的静态文件,dist 文件夹的静态文件发布到你的 cdn 或者静态服务器即可,需要注意的是其中的 index.html 通常会是你后台服务的入口页面,在确定了 js 和 css 的静态之后可能需要改变页面的引入路径。
+
+例如上传到 nginx 服务器,可以将 dist 文件夹下的文件上传到服务器的 `/srv/www/project/index.html` 目录下,然后访问配置好的域名即可。
+
+```bash
+# nginx配置
+location / {
+ # 不缓存html,防止程序更新后缓存继续生效
+ if ($request_filename ~* .*\.(?:htm|html)$) {
+ add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
+ access_log on;
+ }
+ # 这里是vue打包文件dist内的文件的存放路径
+ root /srv/www/project/;
+ index index.html index.htm;
+}
+```
+
+部署时可能会发现资源路径不对,只需要修改`.env.production`文件即可。
+
+```bash
+# 根据自己路径来配置更改
+# 注意需要以 / 开头和结尾
+VITE_BASE=/
+VITE_BASE=/xxx/
+```
+
+### 前端路由与服务端的结合
+
+项目前端路由使用的是 vue-router,所以你可以选择两种方式:history 和 hash。
+
+- `hash` 默认会在 url 后面拼接`#`
+- `history` 则不会,不过 `history` 需要服务器配合
+
+可在 `.env.production` 内进行 mode 修改
+
+```bash
+VITE_ROUTER_HISTORY=hash
+```
+
+### history 路由模式下服务端配置
+
+开启 `history` 模式需要服务器配置,更多的服务器配置详情可以看 [history-mode](https://router.vuejs.org/guide/essentials/history-mode.html#html5-mode)
+
+这里以 `nginx` 配置为例:
+
+#### 部署到根目录
+
+```bash {5}
+server {
+ listen 80;
+ location / {
+ # 用于配合 History 使用
+ try_files $uri $uri/ /index.html;
+ }
+}
+```
+
+#### 部署到非根目录
+
+- 首先需要在打包的时候更改`.env.production`配置:
+
+```bash
+VITE_BASE = /sub/
+```
+
+- 然后在 nginx 配置文件中配置
+
+```bash {8}
+server {
+ listen 80;
+ server_name localhost;
+ location /sub/ {
+ # 这里是vue打包文件dist内的文件的存放路径
+ alias /srv/www/project/;
+ index index.html index.htm;
+ try_files $uri $uri/ /sub/index.html;
+ }
+}
+```
+
+## 跨域处理
+
+使用 nginx 处理项目部署后的跨域问题
+
+1. 配置前端项目接口地址,在项目目录下的``.env.production`文件中配置:
+
+```bash
+VITE_GLOB_API_URL=/api
+```
+
+2. 在 nginx 配置请求转发到后台
+
+```bash {10-11}
+server {
+ listen 8080;
+ server_name localhost;
+ # 接口代理,用于解决跨域问题
+ location /api {
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ # 后台接口地址
+ proxy_pass http://110.110.1.1:8080/api;
+ rewrite "^/api/(.*)$" /$1 break;
+ proxy_redirect default;
+ add_header Access-Control-Allow-Origin *;
+ add_header Access-Control-Allow-Headers X-Requested-With;
+ add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
+ }
+}
+```
diff --git a/apps/vben5/docs/src/guide/essentials/concept.md b/apps/vben5/docs/src/guide/essentials/concept.md
new file mode 100644
index 000000000..8f9d8b563
--- /dev/null
+++ b/apps/vben5/docs/src/guide/essentials/concept.md
@@ -0,0 +1,70 @@
+# 基础概念
+
+新版本中,整体工程进行了重构,现在我们将会介绍一些基础概念,以便于你更好的理解整个文档。请务必仔细阅读这一部分。
+
+## 大仓
+
+大仓指的是整个项目的仓库,包含了所有的代码、包、应用、规范、文档、配置等,也就是一整个 `Monorepo` 目录的所有内容。
+
+## 应用
+
+应用指的是一个完整的项目,一个项目可以包含多个应用,这些项目可以复用大仓内的代码、包、规范等。应用都被放置在 `apps` 目录下。每个应用都是独立的,可以单独运行、构建、测试、部署,可以引入不同的组件库等等。
+
+::: tip
+
+应用不限于前端应用,也可以是后端应用、移动端应用等,例如 `apps/backend-mock`就是一个后端服务。
+
+:::
+
+## 包
+
+包指的是一个独立的模块,可以是一个组件、一个工具、一个库等。包可以被多个应用引用,也可以被其他包引用。包都被放置在 `packages` 目录下。
+
+对于这些包,你可以把它看作是一个独立的 `npm` 包,使用方式与 `npm` 包一样。
+
+### 包引入
+
+在 `package.json` 中引入包:
+
+```json {3}
+{
+ "dependencies": {
+ "@vben/utils": "workspace:*"
+ }
+}
+```
+
+### 包使用
+
+在代码中引入包:
+
+```ts
+import { isString } from '@vben/utils';
+```
+
+## 别名
+
+在项目中,你可以看到一些 `#` 开头的路径,例如: `#/api`、`#/views`, 这些路径都是别名,用于快速定位到某个目录。它不是通过 `vite` 的 `alias` 实现的,而是通过 `Node.js` 本身的 [subpath imports](https://nodejs.org/api/packages.html#subpath-imports) 原理。只需要在 `package.json` 中配置 `imports` 字段即可。
+
+```json {3}
+{
+ "imports": {
+ "#/*": "./src/*"
+ }
+}
+```
+
+为了 IDE 能够识别这些别名,我们还需要在`tsconfig.json`内配置:
+
+```json {5}
+{
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "#/*": ["src/*"]
+ }
+ }
+}
+```
+
+这样,你就可以在代码中使用别名了。
diff --git a/apps/vben5/docs/src/guide/essentials/development.md b/apps/vben5/docs/src/guide/essentials/development.md
new file mode 100644
index 000000000..556e4c9dd
--- /dev/null
+++ b/apps/vben5/docs/src/guide/essentials/development.md
@@ -0,0 +1,188 @@
+# 本地开发 {#development}
+
+::: tip 代码获取
+
+如果你还没有获取代码,可以先从 [快速开始](../introduction/quick-start.md) 处开始阅读文档。
+
+:::
+
+## 前置准备
+
+为了更好的开发体验,我们提供了一些工具配置、项目说明,以便于您更好的开发。
+
+### 需要掌握的基础知识
+
+本项目需要一定前端基础知识,请确保掌握 Vue 的基础知识,以便能处理一些常见的问题。建议在开发前先学一下以下内容,提前了解和学习这些知识,会对项目理解非常有帮助:
+
+- [Vue3](https://vuejs.org/)
+- [Tailwind CSS](https://tailwindcss.com/)
+- [TypeScript](https://www.typescriptlang.org/)
+- [Vue Router](https://router.vuejs.org/)
+- [Vitejs](https://vitejs.dev/)
+- [Pnpm](https://pnpm.io/)
+- [Turbo](https://turbo.build/)
+
+### 工具配置
+
+如果您使用的 IDE 是[vscode](https://code.visualstudio.com/)(推荐)的话,可以安装以下工具来提高开发效率及代码格式化:
+
+- [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) - Vue 官方插件(必备)。
+- [Tailwind CSS](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss) - Tailwindcss 提示插件。
+- [CSS Variable Autocomplete](https://marketplace.visualstudio.com/items?itemName=bradlc.vunguyentuan.vscode-css-variables) - Css 变量提示插件。
+- [Iconify IntelliSense](https://marketplace.visualstudio.com/items?itemName=antfu.iconify) - Iconify 图标插件
+- [i18n Ally](https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally) - i18n 插件
+- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - 脚本代码检查
+- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - 代码格式化
+- [Stylelint](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint) - css 格式化
+- [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) - 单词语法检查
+- [DotENV](https://marketplace.visualstudio.com/items?itemName=mikestead.dotenv) - .env 文件 高亮
+
+## Npm Scripts
+
+npm 脚本是项目常见的配置,用于执行一些常见的任务,比如启动项目、打包项目等。以下的脚本都可以在项目根目录的 `package.json` 文件中找到。
+
+执行方式为:`pnpm run [script]` 或 `npm run [script]`。
+
+```json
+{
+ "scripts": {
+ // 构建项目
+ "build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 turbo build",
+ // 构建项目并分析
+ "build:analyze": "turbo build:analyze",
+ // 构建本地 docker 镜像
+ "build:docker": "./build-local-docker-image.sh",
+ // 单独构建 web-antd 应用
+ "build:antd": "pnpm run build --filter=@vben/web-antd",
+ // 单独构建文档
+ "build:docs": "pnpm run build --filter=@vben/docs",
+ // 单独构建 web-ele 应用
+ "build:ele": "pnpm run build --filter=@vben/web-ele",
+ // 单独构建 web-naive 应用
+ "build:naive": "pnpm run build --filter=@vben/naive",
+ // 单独构建 playground 应用
+ "build:play": "pnpm run build --filter=@vben/playground",
+ // changeset 版本管理
+ "changeset": "pnpm exec changeset",
+ // 检查项目各种问题
+ "check": "pnpm run check:circular && pnpm run check:dep && pnpm run check:type && pnpm check:cspell",
+ // 检查循环引用
+ "check:circular": "vsh check-circular",
+ // 检查拼写
+ "check:cspell": "cspell lint **/*.ts **/README.md .changeset/*.md --no-progress"
+ // 检查依赖
+ "check:dep": "vsh check-dep",
+ // 检查类型
+ "check:type": "turbo run typecheck",
+ // 清理项目(删除node_modules、dist、.turbo)等目录
+ "clean": "node ./scripts/clean.mjs",
+ // 提交代码
+ "commit": "czg",
+ // 启动项目(默认会运行整个仓库所有包的dev脚本)
+ "dev": "turbo-run dev",
+ // 启动web-antd应用
+ "dev:antd": "pnpm -F @vben/web-antd run dev",
+ // 启动文档
+ "dev:docs": "pnpm -F @vben/docs run dev",
+ // 启动web-ele应用
+ "dev:ele": "pnpm -F @vben/web-ele run dev",
+ // 启动web-naive应用
+ "dev:naive": "pnpm -F @vben/web-naive run dev",
+ // 启动演示应用
+ "dev:play": "pnpm -F @vben/playground run dev",
+ // 格式化代码
+ "format": "vsh lint --format",
+ // lint 代码
+ "lint": "vsh lint",
+ // 依赖安装完成之后,执行所有包的stub脚本
+ "postinstall": "pnpm -r run stub --if-present",
+ // 只允许使用pnpm
+ "preinstall": "npx only-allow pnpm",
+ // husky的安装
+ "prepare": "is-ci || husky",
+ // 预览应用
+ "preview": "turbo-run preview",
+ // 包规范检查
+ "publint": "vsh publint",
+ // 删除所有的node_modules、yarn.lock、package.lock.json,重新安装依赖
+ "reinstall": "pnpm clean --del-lock && pnpm install",
+ // 运行 vitest 单元测试
+ "test:unit": "vitest run --dom",
+ // 更新项目依赖
+ "update:deps": " pnpm update --latest --recursive",
+ // changeset生成提交集
+ "version": "pnpm exec changeset version && pnpm install --no-frozen-lockfile"
+ }
+}
+```
+
+## 本地运行项目
+
+如需本地运行文档,并进行调整,可以执行以下命令,执行该命令,你可以选择需要的应用进行开发:
+
+```bash
+pnpm dev
+```
+
+如果你想直接运行某个应用,可以执行以下命令:
+
+运行 `web-antd` 应用:
+
+```bash
+pnpm dev:antd
+```
+
+运行 `web-naive` 应用:
+
+```bash
+pnpm dev:naive
+```
+
+运行 `web-ele` 应用:
+
+```bash
+pnpm dev:ele
+```
+
+运行 `docs` 应用:
+
+```bash
+pnpm dev:docs
+```
+
+## 公共静态资源
+
+项目中需要使用到的公共静态资源,如:图片、静态HTML等,需要在开发中通过 `src="/xxx.png"` 直接引入的。
+
+需要将资源放在对应项目的 `public/static` 目录下。引入的路径为:`src="/static/xxx.png"`。
+
+## DevTools
+
+项目内置了 [Vue DevTools](https://github.com/vuejs/devtools-next) 插件,可以在开发过程中使用。默认关闭,可在`.env.development` 内开启,并重新运行项目即可:
+
+```bash
+VITE_DEVTOOLS=true
+```
+
+开启后,项目运行会在页面底部显示一个 Vue DevTools 的图标,点击即可打开 DevTools。
+
+
+
+## 本地运行文档
+
+如需本地运行文档,并进行调整,可以执行以下命令:
+
+```bash
+pnpm dev:docs
+```
+
+## 问题解决
+
+如果你在使用过程中遇到依赖相关的问题,可以尝试以下重新安装依赖:
+
+```bash
+# 请在项目根目录下执行
+# 该命令会删除整个仓库所有的 node_modules、yarn.lock、package.lock.json后
+# 再进行依赖重新安装(安装速度会明显变慢)。
+pnpm reinstall
+```
diff --git a/apps/vben5/docs/src/guide/essentials/external-module.md b/apps/vben5/docs/src/guide/essentials/external-module.md
new file mode 100644
index 000000000..fd8e592fb
--- /dev/null
+++ b/apps/vben5/docs/src/guide/essentials/external-module.md
@@ -0,0 +1,58 @@
+# 外部模块
+
+除了项目默认引入的外部模块,有时我们还需要引入其他外部模块。我们以 [ant-design-vue](https://antdv.com/components/overview) 为例:
+
+## 安装依赖
+
+::: tip 安装依赖到指定包
+
+- 由于项目采用了 [pnpm](https://pnpm.io/) 作为包管理工具,所以我们需要使用 `pnpm` 命令来安装依赖。
+- 通过采用了 Monorepo 模块来管理项目,所以我们需要在指定包下安装依赖。安装依赖前请确保已经进入到指定包目录下。
+
+:::
+
+```bash
+# cd /path/to/your/package
+pnpm add ant-design-vue
+```
+
+## 使用
+
+### 全局引入
+
+```ts
+import { createApp } from 'vue';
+import Antd from 'ant-design-vue';
+import App from './App';
+import 'ant-design-vue/dist/reset.css';
+
+const app = createApp(App);
+
+app.use(Antd).mount('#app');
+```
+
+#### 使用
+
+```vue
+
+ text
+
+```
+
+### 局部引入
+
+```vue
+
+
+
+ text
+
+```
+
+::: warning 注意
+
+- 如果组件有依赖样式,则需要再引入样式文件
+
+:::
diff --git a/apps/vben5/docs/src/guide/essentials/icons.md b/apps/vben5/docs/src/guide/essentials/icons.md
new file mode 100644
index 000000000..db4f01de7
--- /dev/null
+++ b/apps/vben5/docs/src/guide/essentials/icons.md
@@ -0,0 +1,78 @@
+# 图标
+
+::: tip 关于图标的管理
+
+- 项目的图标主要由`@vben/icons`包提供,建议统一在该包内部管理,以便于统一管理和维护。
+- 如果你使用的是 `Vscode`,推荐安装 [Iconify IntelliSense](https://marketplace.visualstudio.com/items?itemName=antfu.iconify) 插件,可以方便的查找和使用图标。
+
+:::
+
+项目中有以下多种图标使用方式,可以根据实际情况选择使用:
+
+## Iconify 图标
+
+集成了 [iconify](https://github.com/iconify/iconify) 图标库
+
+### 新增
+
+可在 `packages/icons/src/iconify` 目录下新增图标:
+
+```ts
+// packages/icons/src/iconify/index.ts
+import { createIconifyIcon } from '@vben-core/icons';
+
+export const MdiKeyboardEsc = createIconifyIcon('mdi:keyboard-esc');
+```
+
+### 使用
+
+```vue
+
+
+
+
+
+
+```
+
+## Svg 图标
+
+没有采用 Svg Sprite 的方式,而是直接引入 Svg 图标,
+
+### 新增
+
+可以在 `packages/icons/src/svg/icons` 目录下新增图标文件`test.svg`, 然后在 `packages/icons/src/svg/index.ts` 中引入:
+
+```ts
+// packages/icons/src/svg/index.ts
+import { createIconifyIcon } from '@vben-core/icons';
+
+const SvgTestIcon = createIconifyIcon('svg:test');
+
+export { SvgTestIcon };
+```
+
+### 使用
+
+```vue
+
+
+
+
+
+
+```
+
+## Tailwind CSS 图标
+
+### 使用
+
+直接添加 Tailwind CSS 的图标类名即可使用,图标类名可查看 [iconify](https://github.com/iconify/iconify) :
+
+```vue
+
+```
diff --git a/apps/vben5/docs/src/guide/essentials/route.md b/apps/vben5/docs/src/guide/essentials/route.md
new file mode 100644
index 000000000..0eb74aea4
--- /dev/null
+++ b/apps/vben5/docs/src/guide/essentials/route.md
@@ -0,0 +1,600 @@
+---
+outline: deep
+---
+
+# 路由和菜单
+
+在项目中,框架提供了一套基础的路由系统,并**根据路由文件自动生成对应的菜单结构**。
+
+## 路由类型
+
+路由分为核心路由、静态路由和动态路由,核心路由是框架内置的路由,包含了根路由、登录路由、404路由等;静态路由是在项目启动时就已经确定的路由;动态路由一般是在用户登录后,根据用户的权限动态生成的路由。
+
+静态路由和动态路由都会走权限控制,可以通过配置路由的 `meta` 属性中的 `authority` 字段来控制权限,可以参考[路由权限控制](https://github.com/vbenjs/vue-vben-admin/blob/main/playground/src/router/routes/modules/demos.ts)。
+
+### 核心路由
+
+核心路由是框架内置的路由,包含了根路由、登录路由、404路由等,核心路由的配置在应用下 `src/router/routes/core` 目录下
+
+::: tip
+
+核心路由主要用于框架的基础功能,因此不建议将业务相关的路由放在核心路由中,推荐将业务相关的路由放在静态路由或动态路由中。
+
+:::
+
+### 静态路由
+
+静态路由的配置在应用下 `src/router/routes/index` 目录下,打开注释的文件内容:
+
+::: tip
+
+权限控制是通过路由的 `meta` 属性中的 `authority` 字段来控制的,如果你的页面项目不需要权限控制,可以不设置 `authority` 字段。
+
+:::
+
+```ts
+// 有需要可以自行打开注释,并创建文件夹
+// const externalRouteFiles = import.meta.glob('./external/**/*.ts', { eager: true }); // [!code --]
+const staticRouteFiles = import.meta.glob('./static/**/*.ts', { eager: true }); // [!code ++]
+/** 动态路由 */
+const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
+
+/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统 */
+// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles) // [!code --]
+const externalRoutes: RouteRecordRaw[] = []; // [!code --]
+const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles); // [!code ++]
+```
+
+### 动态路由
+
+动态路由的配置在对应应用 `src/router/routes/modules` 目录下,这个目录下存放了所有的路由文件。每个文件的内容格式如下,与 Vue Router 的路由配置格式一致,以下为二级路由和多级路由的配置。
+
+## 路由定义
+
+静态路由与动态路由的配置方式一致,以下为二级路由和多级路由的配置:
+
+### 二级路由
+
+::: details 二级路由示例代码
+
+```ts
+import type { RouteRecordRaw } from 'vue-router';
+
+import { VBEN_LOGO_URL } from '@vben/constants';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ badgeType: 'dot',
+ badgeVariants: 'destructive',
+ icon: VBEN_LOGO_URL,
+ order: 9999,
+ title: $t('page.vben.title'),
+ },
+ name: 'VbenProject',
+ path: '/vben-admin',
+ redirect: '/vben-admin/about',
+ children: [
+ {
+ name: 'VbenAbout',
+ path: '/vben-admin/about',
+ component: () => import('#/views/_core/about/index.vue'),
+ meta: {
+ badgeType: 'dot',
+ badgeVariants: 'destructive',
+ icon: 'lucide:copyright',
+ title: $t('page.vben.about'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
+```
+
+:::
+
+### 多级路由
+
+::: tip
+
+- 多级路由的父级路由无需设置 `component` 属性,只需设置 `children` 属性即可。除非你真的需要在父级路由嵌套下显示内容。
+- 如果没有特殊情况,父级路由的 `redirect` 属性,不需要指定,默认会指向第一个子路由。
+
+:::
+
+::: details 多级路由示例代码
+
+```ts
+import type { RouteRecordRaw } from 'vue-router';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'ic:baseline-view-in-ar',
+ keepAlive: true,
+ order: 1000,
+ title: $t('demos.title'),
+ },
+ name: 'Demos',
+ path: '/demos',
+ redirect: '/demos/access',
+ children: [
+ // 嵌套菜单
+ {
+ meta: {
+ icon: 'ic:round-menu',
+ title: $t('demos.nested.title'),
+ },
+ name: 'NestedDemos',
+ path: '/demos/nested',
+ redirect: '/demos/nested/menu1',
+ children: [
+ {
+ name: 'Menu1Demo',
+ path: '/demos/nested/menu1',
+ component: () => import('#/views/demos/nested/menu-1.vue'),
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu1'),
+ },
+ },
+ {
+ name: 'Menu2Demo',
+ path: '/demos/nested/menu2',
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu2'),
+ },
+ redirect: '/demos/nested/menu2/menu2-1',
+ children: [
+ {
+ name: 'Menu21Demo',
+ path: '/demos/nested/menu2/menu2-1',
+ component: () => import('#/views/demos/nested/menu-2-1.vue'),
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu2_1'),
+ },
+ },
+ ],
+ },
+ {
+ name: 'Menu3Demo',
+ path: '/demos/nested/menu3',
+ meta: {
+ icon: 'ic:round-menu',
+ title: $t('demos.nested.menu3'),
+ },
+ redirect: '/demos/nested/menu3/menu3-1',
+ children: [
+ {
+ name: 'Menu31Demo',
+ path: 'menu3-1',
+ component: () => import('#/views/demos/nested/menu-3-1.vue'),
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu3_1'),
+ },
+ },
+ {
+ name: 'Menu32Demo',
+ path: 'menu3-2',
+ meta: {
+ icon: 'ic:round-menu',
+ title: $t('demos.nested.menu3_2'),
+ },
+ redirect: '/demos/nested/menu3/menu3-2/menu3-2-1',
+ children: [
+ {
+ name: 'Menu321Demo',
+ path: '/demos/nested/menu3/menu3-2/menu3-2-1',
+ component: () =>
+ import('#/views/demos/nested/menu-3-2-1.vue'),
+ meta: {
+ icon: 'ic:round-menu',
+ keepAlive: true,
+ title: $t('demos.nested.menu3_2_1'),
+ },
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+];
+
+export default routes;
+```
+
+:::
+
+## 新增页面
+
+新增一个页面,你只需要添加一个路由及对应的页面组件即可。
+
+### 添加路由
+
+在对应的路由文件中添加一个路由对象,如下:
+
+```ts
+import type { RouteRecordRaw } from 'vue-router';
+
+import { VBEN_LOGO_URL } from '@vben/constants';
+
+import { BasicLayout } from '#/layouts';
+import { $t } from '#/locales';
+
+const routes: RouteRecordRaw[] = [
+ {
+ component: BasicLayout,
+ meta: {
+ icon: 'mdi:home',
+ title: $t('page.home.title'),
+ },
+ name: 'Home',
+ path: '/home',
+ redirect: '/home/index',
+ children: [
+ {
+ name: 'HomeIndex',
+ path: '/home/index',
+ component: () => import('#/views/home/index.vue'),
+ meta: {
+ icon: 'mdi:home',
+ title: $t('page.home.index'),
+ },
+ },
+ ],
+ },
+];
+
+export default routes;
+```
+
+### 添加页面组件
+
+在`#/views/home/`下,新增一个`index.vue`文件,如下:
+
+```vue
+
+
+
home page
+
+
+```
+
+### 验证
+
+到这里页面已添加完成,访问 `http://localhost:5555/home/index` 出现对应的页面即可。
+
+## 路由配置
+
+路由配置项主要在对象路由的 `meta` 属性中,以下为常用的配置项:
+
+```ts {5-8}
+const routes = [
+ {
+ name: 'HomeIndex',
+ path: '/home/index',
+ meta: {
+ icon: 'mdi:home',
+ title: $t('page.home.index'),
+ },
+ },
+];
+```
+
+::: details 路由Meta配置类型定义
+
+```ts
+interface RouteMeta {
+ /**
+ * 激活图标(菜单)
+ */
+ activeIcon?: string;
+ /**
+ * 当前激活的菜单,有时候不想激活现有菜单,需要激活父级菜单时使用
+ */
+ activePath?: string;
+ /**
+ * 是否固定标签页
+ * @default false
+ */
+ affixTab?: boolean;
+ /**
+ * 固定标签页的顺序
+ * @default 0
+ */
+ affixTabOrder?: number;
+ /**
+ * 需要特定的角色标识才可以访问
+ * @default []
+ */
+ authority?: string[];
+ /**
+ * 徽标
+ */
+ badge?: string;
+ /**
+ * 徽标类型
+ */
+ badgeType?: 'dot' | 'normal';
+ /**
+ * 徽标颜色
+ */
+ badgeVariants?:
+ | 'default'
+ | 'destructive'
+ | 'primary'
+ | 'success'
+ | 'warning'
+ | string;
+ /**
+ * 当前路由的子级在菜单中不展现
+ * @default false
+ */
+ hideChildrenInMenu?: boolean;
+ /**
+ * 当前路由在面包屑中不展现
+ * @default false
+ */
+ hideInBreadcrumb?: boolean;
+ /**
+ * 当前路由在菜单中不展现
+ * @default false
+ */
+ hideInMenu?: boolean;
+ /**
+ * 当前路由在标签页不展现
+ * @default false
+ */
+ hideInTab?: boolean;
+ /**
+ * 图标(菜单/tab)
+ */
+ icon?: string;
+ /**
+ * iframe 地址
+ */
+ iframeSrc?: string;
+ /**
+ * 忽略权限,直接可以访问
+ * @default false
+ */
+ ignoreAccess?: boolean;
+ /**
+ * 开启KeepAlive缓存
+ */
+ keepAlive?: boolean;
+ /**
+ * 外链-跳转路径
+ */
+ link?: string;
+ /**
+ * 路由是否已经加载过
+ */
+ loaded?: boolean;
+ /**
+ * 标签页最大打开数量
+ * @default false
+ */
+ maxNumOfOpenTab?: number;
+ /**
+ * 菜单可以看到,但是访问会被重定向到403
+ */
+ menuVisibleWithForbidden?: boolean;
+ /**
+ * 在新窗口打开
+ */
+ openInNewWindow?: boolean;
+ /**
+ * 用于路由->菜单排序
+ */
+ order?: number;
+ /**
+ * 菜单所携带的参数
+ */
+ query?: Recordable;
+ /**
+ * 标题名称
+ */
+ title: string;
+}
+```
+
+:::
+
+### title
+
+- 类型:`string`
+- 默认值:`''`
+
+用于配置页面的标题,会在菜单和标签页中显示。一般会配合国际化使用。
+
+### icon
+
+- 类型:`string`
+- 默认值:`''`
+
+用于配置页面的图标,会在菜单和标签页中显示。一般会配合图标库使用,如果是`http`链接,会自动加载图片。
+
+### activeIcon
+
+- 类型:`string`
+- 默认值:`''`
+
+用于配置页面的激活图标,会在菜单中显示。一般会配合图标库使用,如果是`http`链接,会自动加载图片。
+
+### keepAlive
+
+- 类型:`boolean`
+- 默认值:`false`
+
+用于配置页面是否开启缓存,开启后页面会缓存,不会重新加载,仅在标签页启用时有效。
+
+### hideInMenu
+
+- 类型:`boolean`
+- 默认值:`false`
+
+用于配置页面是否在菜单中隐藏,隐藏后页面不会在菜单中显示。
+
+### hideInTab
+
+- 类型:`boolean`
+- 默认值:`false`
+
+用于配置页面是否在标签页中隐藏,隐藏后页面不会在标签页中显示。
+
+### hideInBreadcrumb
+
+- 类型:`boolean`
+- 默认值:`false`
+
+用于配置页面是否在面包屑中隐藏,隐藏后页面不会在面包屑中显示。
+
+### hideChildrenInMenu
+
+- 类型:`boolean`
+- 默认值:`false`
+
+用于配置页面的子页面是否在菜单中隐藏,隐藏后子页面不会在菜单中显示。
+
+### authority
+
+- 类型:`string[]`
+- 默认值:`[]`
+
+用于配置页面的权限,只有拥有对应权限的用户才能访问页面,不配置则不需要权限。
+
+### badge
+
+- 类型:`string`
+- 默认值:`''`
+
+用于配置页面的徽标,会在菜单显示。
+
+### badgeType
+
+- 类型:`'dot' | 'normal'`
+- 默认值:`'normal'`
+
+用于配置页面的徽标类型,`dot` 为小红点,`normal` 为文本。
+
+### badgeVariants
+
+- 类型:`'default' | 'destructive' | 'primary' | 'success' | 'warning' | string`
+- 默认值:`'success'`
+
+用于配置页面的徽标颜色。
+
+### activePath
+
+- 类型:`string`
+- 默认值:`''`
+
+用于配置当前激活的菜单,有时候页面没有显示在菜单内,需要激活父级菜单时使用。
+
+### affixTab
+
+- 类型:`boolean`
+- 默认值:`false`
+
+用于配置页面是否固定标签页,固定后页面不可关闭。
+
+### affixTabOrder
+
+- 类型:`number`
+- 默认值:`0`
+
+用于配置页面固定标签页的排序, 采用升序排序。
+
+### iframeSrc
+
+- 类型:`string`
+- 默认值:`''`
+
+用于配置内嵌页面的 `iframe` 地址,设置后会在当前页面内嵌对应的页面。
+
+### ignoreAccess
+
+- 类型:`boolean`
+- 默认值:`false`
+
+用于配置页面是否忽略权限,直接可以访问。
+
+### link
+
+- 类型:`string`
+- 默认值:`''`
+
+用于配置外链跳转路径,会在新窗口打开。
+
+### maxNumOfOpenTab
+
+- 类型:`number`
+- 默认值:`-1`
+
+用于配置标签页最大打开数量,设置后会在打开新标签页时自动关闭最早打开的标签页(仅在打开同名标签页时生效)。
+
+### menuVisibleWithForbidden
+
+- 类型:`boolean`
+- 默认值:`false`
+
+用于配置页面在菜单可以看到,但是访问会被重定向到403。
+
+### openInNewWindow
+
+- 类型:`boolean`
+- 默认值:`false`
+
+设置为 `true` 时,会在新窗口打开页面。
+
+### order
+
+- 类型:`number`
+- 默认值:`0`
+
+用于配置页面的排序,用于路由到菜单排序。
+
+_注意:_ 排序仅针对一级菜单有效,二级菜单的排序需要在对应的一级菜单中按代码顺序设置。
+
+### query
+
+- 类型:`Recordable`
+- 默认值:`{}`
+
+用于配置页面的菜单参数,会在菜单中传递给页面。
+
+## 路由刷新
+
+路由刷新方式如下:
+
+```vue
+
+```
diff --git a/apps/vben5/docs/src/guide/essentials/server.md b/apps/vben5/docs/src/guide/essentials/server.md
new file mode 100644
index 000000000..74a45d2ee
--- /dev/null
+++ b/apps/vben5/docs/src/guide/essentials/server.md
@@ -0,0 +1,359 @@
+# 服务端交互与数据Mock
+
+::: tip 说明
+
+本文档介绍如何在开发环境下使用 Mock 数据和与服务端进行交互,涉及到的技术有:
+
+- [Nitro](https://nitro.unjs.io/) 轻量级后端服务器,可部署在任何地方,项目用作于 Mock 服务器。
+- [axios](https://axios-http.com/docs/intro) 用于发送 HTTP 请求与服务端进行交互。
+
+:::
+
+## 开发环境交互
+
+如果前端应用和后端接口服务器没有运行在同一个主机上,你需要在开发环境下将接口请求代理到接口服务器。如果是同一个主机,可以直接请求具体的接口地址。
+
+### 本地开发跨域配置
+
+::: tip 提示
+
+本地开发跨域配置项目已经配置好了,如有其他需求,可以自行增加或者调整配置。
+
+:::
+
+#### 配置本地开发接口地址
+
+在项目根目录下的 `.env.development` 文件中配置接口地址,这里配置为 `/api`:
+
+```bash
+VITE_GLOB_API_URL=/api
+```
+
+#### 配置开发服务器代理
+
+开发环境时候,如果需要处理跨域,接口地址在对应的应用目录下的 `vite.config.mts` 文件中配置:
+
+```ts{8-16}
+// apps/web-antd/vite.config.mts
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ vite: {
+ server: {
+ proxy: {// [!code focus:11]
+ '/api': {
+ changeOrigin: true,
+ rewrite: (path) => path.replace(/^\/api/, ''),
+ // mock代理目标地址
+ target: 'http://localhost:5320/api',
+ ws: true,
+ },
+ },
+ },
+ },
+ };
+});
+```
+
+#### 接口请求
+
+根据上面的配置,我们可以在前端项目中使用 `/api` 作为接口请求的前缀,例如:
+
+```ts
+import axios from 'axios';
+
+axios.get('/api/user').then((res) => {
+ console.log(res);
+});
+```
+
+此时,请求会被代理到 `http://localhost:5320/api/user`。
+
+::: warning 注意
+
+从浏览器控制台的 Network 看,请求是 `http://localhost:5555/api/user`, 这是因为 proxy 配置不会改变本地请求的 url。
+
+:::
+
+### 没有跨域时的配置
+
+如果没有跨域问题,可以直接忽略 [配置开发服务器代理](./server.md#配置开发服务器代理) 配置,直接将接口地址设置在 `VITE_GLOB_API_URL`
+
+在项目根目录下的 `.env.development` 文件中配置接口地址:
+
+```bash
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+```
+
+## 生产环境交互
+
+### 接口地址配置
+
+在项目根目录下的 `.env.production` 文件中配置接口地址:
+
+```bash
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+```
+
+::: tip 打包如何动态修改接口地址
+
+`.env` 文件内的 `VITE_GLOB_*` 开头的变量会在打包的时候注入 `_app.config.js` 文件内。在 `dist/_app.config.js` 修改相应的接口地址后刷新页面即可,不需要在根据不同环境打包多次,一次打包可以用于多个不同接口环境的部署。
+
+:::
+
+### 跨域处理
+
+生产环境如果出现跨域问题,可以使用 `nginx` 代理接口地址 或者后台开启 `cors` 进行处理即可(可参考mock服务)。
+
+## 接口请求配置
+
+项目中默认自带了基于 `axios` 封装的基础的请求配置,核心由 `@vben/request` 包提供。项目没有过多的封装,只是简单的封装了一些常用的配置,如有其他需求,可以自行增加或者调整配置。针对不同的app,可能是用到了不同的组件库以及`store`,所以在应用目录下的`src/api/request.ts`文件夹下,有对应的请求配置文件,如`web-antd`项目下的`src/api/request.ts`文件,可以根据自己的需求进行配置。
+
+### 请求示例
+
+#### GET 请求
+
+```ts
+import { requestClient } from '#/api/request';
+
+export async function getUserInfoApi() {
+ return requestClient.get('/user/info');
+}
+```
+
+#### POST/PUT 请求
+
+```ts
+import { requestClient } from '#/api/request';
+
+export async function saveUserApi(user: UserInfo) {
+ return requestClient.post('/user', user);
+}
+
+export async function saveUserApi(user: UserInfo) {
+ return requestClient.put('/user', user);
+}
+
+export async function saveUserApi(user: UserInfo) {
+ const url = user.id ? `/user/${user.id}` : '/user/';
+ return requestClient.request(url, {
+ data: user,
+ // 或者 PUT
+ method: user.id ? 'PUT' : 'POST',
+ });
+}
+```
+
+#### DELETE 请求
+
+```ts
+import { requestClient } from '#/api/request';
+
+export async function deleteUserApi(user: UserInfo) {
+ return requestClient.delete(`/user/${user.id}`, user);
+}
+```
+
+### 请求配置
+
+应用内的`src/api/request.ts`可以根据自己应用的情况的需求进行配置:
+
+```ts
+/**
+ * 该文件可自行根据业务逻辑进行调整
+ */
+import type { HttpResponse } from '@vben/request';
+
+import { useAppConfig } from '@vben/hooks';
+import { preferences } from '@vben/preferences';
+import {
+ authenticateResponseInterceptor,
+ errorMessageResponseInterceptor,
+ RequestClient,
+} from '@vben/request';
+import { useAccessStore } from '@vben/stores';
+
+import { message } from 'ant-design-vue';
+
+import { useAuthStore } from '#/store';
+
+import { refreshTokenApi } from './core';
+
+const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+
+function createRequestClient(baseURL: string) {
+ const client = new RequestClient({
+ baseURL,
+ });
+
+ /**
+ * 重新认证逻辑
+ */
+ async function doReAuthenticate() {
+ console.warn('Access token or refresh token is invalid or expired. ');
+ const accessStore = useAccessStore();
+ const authStore = useAuthStore();
+ accessStore.setAccessToken(null);
+ if (
+ preferences.app.loginExpiredMode === 'modal' &&
+ accessStore.isAccessChecked
+ ) {
+ accessStore.setLoginExpired(true);
+ } else {
+ await authStore.logout();
+ }
+ }
+
+ /**
+ * 刷新token逻辑
+ */
+ async function doRefreshToken() {
+ const accessStore = useAccessStore();
+ const resp = await refreshTokenApi();
+ const newToken = resp.data;
+ accessStore.setAccessToken(newToken);
+ return newToken;
+ }
+
+ function formatToken(token: null | string) {
+ return token ? `Bearer ${token}` : null;
+ }
+
+ // 请求头处理
+ client.addRequestInterceptor({
+ fulfilled: async (config) => {
+ const accessStore = useAccessStore();
+
+ config.headers.Authorization = formatToken(accessStore.accessToken);
+ config.headers['Accept-Language'] = preferences.app.locale;
+ return config;
+ },
+ });
+
+ // response数据解构
+ client.addResponseInterceptor({
+ fulfilled: (response) => {
+ const { data: responseData, status } = response;
+
+ const { code, data } = responseData;
+
+ if (status >= 200 && status < 400 && code === 0) {
+ return data;
+ }
+ throw Object.assign({}, response, { response });
+ },
+ });
+
+ // token过期的处理
+ client.addResponseInterceptor(
+ authenticateResponseInterceptor({
+ client,
+ doReAuthenticate,
+ doRefreshToken,
+ enableRefreshToken: preferences.app.enableRefreshToken,
+ formatToken,
+ }),
+ );
+
+ // 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
+ client.addResponseInterceptor(
+ errorMessageResponseInterceptor((msg: string, error) => {
+ // 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
+ // 当前mock接口返回的错误字段是 error 或者 message
+ const responseData = error?.response?.data ?? {};
+ const errorMessage = responseData?.error ?? responseData?.message ?? '';
+ // 如果没有错误信息,则会根据状态码进行提示
+ message.error(errorMessage || msg);
+ }),
+ );
+
+ return client;
+}
+
+export const requestClient = createRequestClient(apiURL);
+
+export const baseRequestClient = new RequestClient({ baseURL: apiURL });
+```
+
+### 多个接口地址
+
+只需要创建多个 `requestClient` 即可,如:
+
+```ts
+const { apiURL, otherApiURL } = useAppConfig(
+ import.meta.env,
+ import.meta.env.PROD,
+);
+
+export const requestClient = createRequestClient(apiURL);
+
+export const otherRequestClient = createRequestClient(otherApiURL);
+```
+
+## 刷新Token
+
+项目中默认提供了刷新 Token 的逻辑,只需要按照下面的配置即可开启:
+
+- 确保当前启用了刷新 Token 的配置
+
+调整对应应用目录下的`preferences.ts`,确保`enableRefreshToken='true'`。
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ enableRefreshToken: true,
+ },
+});
+```
+
+在 `src/api/request.ts` 中配置 `doRefreshToken` 方法即可:
+
+```ts
+// 这里调整为你的token格式
+function formatToken(token: null | string) {
+ return token ? `Bearer ${token}` : null;
+}
+
+/**
+ * 刷新token逻辑
+ */
+async function doRefreshToken() {
+ const accessStore = useAccessStore();
+ // 这里调整为你的刷新token接口
+ const resp = await refreshTokenApi();
+ const newToken = resp.data;
+ accessStore.setAccessToken(newToken);
+ return newToken;
+}
+```
+
+## 数据 Mock
+
+::: tip 生产环境 Mock
+
+新版本不再支持生产环境 mock,请使用真实接口。
+
+:::
+
+Mock 数据是前端开发过程中必不可少的一环,是分离前后端开发的关键链路。通过预先跟服务器端约定好的接口,模拟请求数据甚至逻辑,能够让前端开发独立自主,不会被服务端的开发进程所阻塞。
+
+项目使用 [Nitro](https://nitro.unjs.io/) 来进行本地 mock 数据处理。其原理是本地额外启动一个后端服务,是一个真实的后端服务,可以处理请求,返回数据。
+
+### Nitro 使用
+
+Mock 服务代码位于`apps/backend-mock`目录下,无需手动启动,已经集成在项目中,只需要在项目根目录下运行`pnpm dev`即可,运行成功之后,控制台会打印 `http://localhost:5320/api`, 访问该地址即可查看 mock 服务。
+
+[Nitro](https://nitro.unjs.io/) 语法简单,可以根据自己的需求进行配置及开发,具体配置可以查看 [Nitro 文档](https://nitro.unjs.io/)。
+
+## 关闭 Mock 服务
+
+mock的本质是一个真实的后端服务,如果不需要 mock 服务,可以在项目根目录下的 `.env.development` 文件中配置 `VITE_NITRO_MOCK=false` 即可关闭 mock 服务。
+
+```bash
+# .env.development
+VITE_NITRO_MOCK=false
+```
diff --git a/apps/vben5/docs/src/guide/essentials/settings.md b/apps/vben5/docs/src/guide/essentials/settings.md
new file mode 100644
index 000000000..e33572066
--- /dev/null
+++ b/apps/vben5/docs/src/guide/essentials/settings.md
@@ -0,0 +1,540 @@
+# 配置
+
+## 环境变量配置
+
+项目的环境变量配置位于应用目录下的 `.env`、`.env.development`、`.env.production`。
+
+规则与 [Vite Env Variables and Modes](https://vitejs.dev/guide/env-and-mode.html) 一致。格式如下:
+
+```bash
+.env # 在所有的环境中被载入
+.env.local # 在所有的环境中被载入,但会被 git 忽略
+.env.[mode] # 只在指定的模式中被载入
+.env.[mode].local # 只在指定的模式中被载入,但会被 git 忽略
+```
+
+::: tip
+
+- 只有以 `VITE_` 开头的变量会被嵌入到客户端侧的包中,你可以在项目代码中这样访问它们:
+
+ ```ts
+ console.log(import.meta.env.VITE_PROT);
+ ```
+
+- 以 `VITE_GLOB_*` 开头的的变量,在打包的时候,会被加入 `_app.config.js`配置文件当中. :::
+
+:::
+
+## 环境配置说明
+
+::: code-group
+
+```bash [.env]
+# 应用标题
+VITE_APP_TITLE=Vben Admin
+
+# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
+VITE_APP_NAMESPACE=vben-web-antd
+```
+
+```bash [.env.development]
+# 端口号
+VITE_PORT=5555
+
+# 资源公共路径,需要以 / 开头和结尾
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=/api
+
+# 是否开启 Nitro Mock服务,true 为开启,false 为关闭
+VITE_NITRO_MOCK=true
+
+# 是否打开 devtools,true 为打开,false 为关闭
+VITE_DEVTOOLS=true
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
+
+```
+
+```bash [.env.production]
+# 资源公共路径,需要以 / 开头和结尾
+VITE_BASE=/
+
+# 接口地址
+VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
+
+# 是否开启压缩,可以设置为 none, brotli, gzip
+VITE_COMPRESS=gzip
+
+# 是否开启 PWA
+VITE_PWA=false
+
+# vue-router 的模式
+VITE_ROUTER_HISTORY=hash
+
+# 是否注入全局loading
+VITE_INJECT_APP_LOADING=true
+
+# 打包后是否生成dist.zip
+VITE_ARCHIVER=true
+
+```
+
+:::
+
+## 生产环境动态配置
+
+当在大仓根目录下,执行 `pnpm build`构建项目之后,会自动在对应的应用下生成 `dist/_app.config.js`文件并插入 `index.html`。
+
+`_app.config.js` 是一个动态配置文件,可以在项目构建之后,根据不同的环境动态修改配置。内容如下:
+
+```ts
+window._VBEN_ADMIN_PRO_APP_CONF_ = {
+ VITE_GLOB_API_URL: 'https://mock-napi.vben.pro/api',
+};
+Object.freeze(window._VBEN_ADMIN_PRO_APP_CONF_);
+Object.defineProperty(window, '_VBEN_ADMIN_PRO_APP_CONF_', {
+ configurable: false,
+ writable: false,
+});
+```
+
+### 作用
+
+`_app.config.js` 用于项目在打包后,需要动态修改配置的需求,如接口地址。不用重新进行打包,可在打包后修改 /`dist/_app.config.js` 内的变量,刷新即可更新代码内的局部变量。这里使用`js`文件,是为了确保配置文件加载顺序保持在前面。
+
+### 使用
+
+想要获取 `_app.config.js` 内的变量,需要使用`@vben/hooks`提供的 `useAppConfig`方法。
+
+```ts
+const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+```
+
+### 新增
+
+新增一个可动态修改的配置项,只需要按照如下步骤即可:
+
+- 首先在 `.env` 或者对应的开发环境配置文件内,新增需要可动态配置的变量,需要以 `VITE_GLOB_*` 开头的变量,如:
+
+ ```bash
+ VITE_GLOB_OTHER_API_URL=https://mock-napi.vben.pro/other-api
+ ```
+
+- 在 `packages/types/global.d.ts`,新增对应的类型定义,如:
+
+ ```ts
+ export interface VbenAdminProAppConfigRaw {
+ VITE_GLOB_API_URL: string;
+ VITE_GLOB_OTHER_API_URL: string; // [!code ++]
+ }
+
+ export interface ApplicationConfig {
+ apiURL: string;
+ otherApiURL: string; // [!code ++]
+ }
+ ```
+
+到这里,就可以在项目内使用 `useAppConfig`方法获取到新增的配置项了。
+
+```ts
+const { otherApiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
+```
+
+::: warning 注意
+
+`useAppConfig`方法只能在应用内使用,不要耦合到包内部去使用。这里传入 `import.meta.env`和`import.meta.env.PROD`是为了避免这种情况,一个纯粹的包,应避免使用特定构建工具的变量。
+
+:::
+
+## 偏好设置
+
+项目提供了非常丰富的偏好设置,用于动态配置项目的各种功能:
+
+
+
+如果你找不到文档说明,可以尝试自己配置好以后,点击`复制偏好设置`,覆盖项目默认即可。配置文件位于应用目录下的`preferences.ts`,在这里,你可以覆盖框架默认的配置,实现自定义配置。
+
+```ts
+import { useAppConfig } from '@vben/hooks';
+import { defineOverridesPreferences } from '@vben/preferences';
+
+/**
+ * @description 项目配置文件
+ * 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置
+ * !!! 更改配置后请清空缓存,否则可能不生效
+ */
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+});
+```
+
+### 框架默认配置
+
+::: details 查看框架默认配置
+
+```ts
+const defaultPreferences: Preferences = {
+ app: {
+ accessMode: 'frontend',
+ authPageLayout: 'panel-right',
+ checkUpdatesInterval: 1,
+ colorGrayMode: false,
+ colorWeakMode: false,
+ compact: false,
+ contentCompact: 'wide',
+ defaultAvatar:
+ 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/avatar-v1.webp',
+ dynamicTitle: true,
+ enableCheckUpdates: true,
+ enablePreferences: true,
+ enableRefreshToken: false,
+ isMobile: false,
+ layout: 'sidebar-nav',
+ locale: 'zh-CN',
+ loginExpiredMode: 'modal',
+ name: 'Vben Admin',
+ preferencesButtonPosition: 'auto',
+ watermark: false,
+ },
+ breadcrumb: {
+ enable: true,
+ hideOnlyOne: false,
+ showHome: false,
+ showIcon: true,
+ styleType: 'normal',
+ },
+ copyright: {
+ companyName: 'Vben',
+ companySiteLink: 'https://www.vben.pro',
+ date: '2024',
+ enable: true,
+ icp: '',
+ icpLink: '',
+ },
+ footer: {
+ enable: true,
+ fixed: false,
+ },
+ header: {
+ enable: true,
+ hidden: false,
+ mode: 'fixed',
+ },
+ logo: {
+ enable: true,
+ source: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp',
+ },
+ navigation: {
+ accordion: true,
+ split: true,
+ styleType: 'rounded',
+ },
+ shortcutKeys: {
+ enable: true,
+ globalLockScreen: true,
+ globalLogout: true,
+ globalPreferences: true,
+ globalSearch: true,
+ },
+ sidebar: {
+ collapsed: false,
+ collapsedShowTitle: false,
+ enable: true,
+ expandOnHover: true,
+ extraCollapse: true,
+ hidden: false,
+ width: 230,
+ },
+ tabbar: {
+ draggable: true,
+ enable: true,
+ height: 36,
+ keepAlive: true,
+ persist: true,
+ showIcon: true,
+ showMaximize: true,
+ showMore: true,
+ styleType: 'chrome',
+ },
+ theme: {
+ builtinType: 'default',
+ colorDestructive: 'hsl(348 100% 61%)',
+ colorPrimary: 'hsl(212 100% 45%)',
+ colorSuccess: 'hsl(144 57% 58%)',
+ colorWarning: 'hsl(42 84% 61%)',
+ mode: 'dark',
+ radius: '0.5',
+ semiDarkHeader: false,
+ semiDarkSidebar: true,
+ },
+ transition: {
+ enable: true,
+ loading: true,
+ name: 'fade-slide',
+ progress: true,
+ },
+ widget: {
+ fullscreen: true,
+ globalSearch: true,
+ languageToggle: true,
+ lockScreen: true,
+ notification: true,
+ refresh: true,
+ sidebarToggle: true,
+ themeToggle: true,
+ },
+};
+```
+
+:::
+
+::: details 查看框架默认配置类型
+
+```ts
+interface AppPreferences {
+ /** 权限模式 */
+ accessMode: AccessModeType;
+ /** 登录注册页面布局 */
+ authPageLayout: AuthPageLayoutType;
+ /** 检查更新轮询时间 */
+ checkUpdatesInterval: number;
+ /** 是否开启灰色模式 */
+ colorGrayMode: boolean;
+ /** 是否开启色弱模式 */
+ colorWeakMode: boolean;
+ /** 是否开启紧凑模式 */
+ compact: boolean;
+ /** 是否开启内容紧凑模式 */
+ contentCompact: ContentCompactType;
+ // /** 应用默认头像 */
+ defaultAvatar: string;
+ // /** 开启动态标题 */
+ dynamicTitle: boolean;
+ /** 是否开启检查更新 */
+ enableCheckUpdates: boolean;
+ /** 是否显示偏好设置 */
+ enablePreferences: boolean;
+ /**
+ * @zh_CN 是否开启refreshToken
+ */
+ enableRefreshToken: boolean;
+ /** 是否移动端 */
+ isMobile: boolean;
+ /** 布局方式 */
+ layout: LayoutType;
+ /** 支持的语言 */
+ locale: SupportedLanguagesType;
+ /** 登录过期模式 */
+ loginExpiredMode: LoginExpiredModeType;
+ /** 应用名 */
+ name: string;
+ /** 偏好设置按钮位置 */
+ preferencesButtonPosition: PreferencesButtonPositionType;
+ /**
+ * @zh_CN 是否开启水印
+ */
+ watermark: boolean;
+}
+
+interface BreadcrumbPreferences {
+ /** 面包屑是否启用 */
+ enable: boolean;
+ /** 面包屑是否只有一个时隐藏 */
+ hideOnlyOne: boolean;
+ /** 面包屑首页图标是否可见 */
+ showHome: boolean;
+ /** 面包屑图标是否可见 */
+ showIcon: boolean;
+ /** 面包屑风格 */
+ styleType: BreadcrumbStyleType;
+}
+
+interface CopyrightPreferences {
+ /** 版权公司名 */
+ companyName: string;
+ /** 版权公司名链接 */
+ companySiteLink: string;
+ /** 版权日期 */
+ date: string;
+ /** 版权是否可见 */
+ enable: boolean;
+ /** 备案号 */
+ icp: string;
+ /** 备案号链接 */
+ icpLink: string;
+}
+
+interface FooterPreferences {
+ /** 底栏是否可见 */
+ enable: boolean;
+ /** 底栏是否固定 */
+ fixed: boolean;
+}
+
+interface HeaderPreferences {
+ /** 顶栏是否启用 */
+ enable: boolean;
+ /** 顶栏是否隐藏,css-隐藏 */
+ hidden: boolean;
+ /** header显示模式 */
+ mode: LayoutHeaderModeType;
+}
+
+interface LogoPreferences {
+ /** logo是否可见 */
+ enable: boolean;
+ /** logo地址 */
+ source: string;
+}
+
+interface NavigationPreferences {
+ /** 导航菜单手风琴模式 */
+ accordion: boolean;
+ /** 导航菜单是否切割,只在 layout=mixed-nav 生效 */
+ split: boolean;
+ /** 导航菜单风格 */
+ styleType: NavigationStyleType;
+}
+
+interface SidebarPreferences {
+ /** 侧边栏是否折叠 */
+ collapsed: boolean;
+ /** 侧边栏折叠时,是否显示title */
+ collapsedShowTitle: boolean;
+ /** 侧边栏是否可见 */
+ enable: boolean;
+ /** 菜单自动展开状态 */
+ expandOnHover: boolean;
+ /** 侧边栏扩展区域是否折叠 */
+ extraCollapse: boolean;
+ /** 侧边栏是否隐藏 - css */
+ hidden: boolean;
+ /** 侧边栏宽度 */
+ width: number;
+}
+
+interface ShortcutKeyPreferences {
+ /** 是否启用快捷键-全局 */
+ enable: boolean;
+ /** 是否启用全局锁屏快捷键 */
+ globalLockScreen: boolean;
+ /** 是否启用全局注销快捷键 */
+ globalLogout: boolean;
+ /** 是否启用全局偏好设置快捷键 */
+ globalPreferences: boolean;
+ /** 是否启用全局搜索快捷键 */
+ globalSearch: boolean;
+}
+
+interface TabbarPreferences {
+ /** 是否开启多标签页拖拽 */
+ draggable: boolean;
+ /** 是否开启多标签页 */
+ enable: boolean;
+ /** 标签页高度 */
+ height: number;
+ /** 开启标签页缓存功能 */
+ keepAlive: boolean;
+ /** 是否持久化标签 */
+ persist: boolean;
+ /** 是否开启多标签页图标 */
+ showIcon: boolean;
+ /** 显示最大化按钮 */
+ showMaximize: boolean;
+ /** 显示更多按钮 */
+ showMore: boolean;
+ /** 标签页风格 */
+ styleType: TabsStyleType;
+}
+
+interface ThemePreferences {
+ /** 内置主题名 */
+ builtinType: BuiltinThemeType;
+ /** 错误色 */
+ colorDestructive: string;
+ /** 主题色 */
+ colorPrimary: string;
+ /** 成功色 */
+ colorSuccess: string;
+ /** 警告色 */
+ colorWarning: string;
+ /** 当前主题 */
+ mode: ThemeModeType;
+ /** 圆角 */
+ radius: string;
+ /** 是否开启半深色header(只在theme='light'时生效) */
+ semiDarkHeader: boolean;
+ /** 是否开启半深色菜单(只在theme='light'时生效) */
+ semiDarkSidebar: boolean;
+}
+
+interface TransitionPreferences {
+ /** 页面切换动画是否启用 */
+ enable: boolean;
+ // /** 是否开启页面加载loading */
+ loading: boolean;
+ /** 页面切换动画 */
+ name: PageTransitionType | string;
+ /** 是否开启页面加载进度动画 */
+ progress: boolean;
+}
+
+interface WidgetPreferences {
+ /** 是否启用全屏部件 */
+ fullscreen: boolean;
+ /** 是否启用全局搜索部件 */
+ globalSearch: boolean;
+ /** 是否启用语言切换部件 */
+ languageToggle: boolean;
+ /** 是否开启锁屏功能 */
+ lockScreen: boolean;
+ /** 是否显示通知部件 */
+ notification: boolean;
+ /** 显示刷新按钮 */
+ refresh: boolean;
+ /** 是否显示侧边栏显示/隐藏部件 */
+ sidebarToggle: boolean;
+ /** 是否显示主题切换部件 */
+ themeToggle: boolean;
+}
+
+interface Preferences {
+ /** 全局配置 */
+ app: AppPreferences;
+ /** 顶栏配置 */
+ breadcrumb: BreadcrumbPreferences;
+ /** 版权配置 */
+ copyright: CopyrightPreferences;
+ /** 底栏配置 */
+ footer: FooterPreferences;
+ /** 面包屑配置 */
+ header: HeaderPreferences;
+ /** logo配置 */
+ logo: LogoPreferences;
+ /** 导航配置 */
+ navigation: NavigationPreferences;
+ /** 快捷键配置 */
+ shortcutKeys: ShortcutKeyPreferences;
+ /** 侧边栏配置 */
+ sidebar: SidebarPreferences;
+ /** 标签页配置 */
+ tabbar: TabbarPreferences;
+ /** 主题配置 */
+ theme: ThemePreferences;
+ /** 动画配置 */
+ transition: TransitionPreferences;
+ /** 功能配置 */
+ widget: WidgetPreferences;
+}
+```
+
+:::
+
+::: warning 注意
+
+- `overridesPreferences`方法只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置。
+- 任何配置项都可以覆盖,只需要在`overridesPreferences`方法内覆盖即可,不要修改默认配置文件。
+- 更改配置后请清空缓存,否则可能不生效。:::
diff --git a/apps/vben5/docs/src/guide/essentials/styles.md b/apps/vben5/docs/src/guide/essentials/styles.md
new file mode 100644
index 000000000..3ca3a3e9f
--- /dev/null
+++ b/apps/vben5/docs/src/guide/essentials/styles.md
@@ -0,0 +1,106 @@
+# 样式
+
+::: tip 前言
+
+对于 vue 项目,[官方文档](https://vuejs.org/api/sfc-css-features.html#deep-selectors) 对语法已经有比较详细的介绍,这里主要是介绍项目中的样式文件结构和使用。
+
+:::
+
+## 项目结构
+
+项目中的样式文件存放在 `@vben/styles`,包含一些全局样式,如重置样式、全局变量等,它继承了 `@vben-core/design` 的样式和能力,可以根据项目需求进行覆盖。
+
+## Scss
+
+项目中使用 `scss` 作为样式预处理器,可以在项目中使用 `scss` 的特性,如变量、函数、混合等。
+
+```vue
+
+```
+
+## Postcss
+
+如果你不习惯使用 `scss`,也可以使用 `postcss`,它是一个更加强大的样式处理器,可以使用更多的插件,项目内置了 [postcss-nested](https://github.com/postcss/postcss-nested) 插件,配置 `Css Variables`,完全可以取代 `scss`。
+
+```vue
+
+```
+
+## Tailwind CSS
+
+项目中集成了 [Tailwind CSS](https://tailwindcss.com/),可以在项目中使用 `tailwindcss` 的类名,快速构建页面。
+
+```vue
+
+
+
+```
+
+## BEM 规范
+
+样式冲突的另一种选择,是使用 `BEM` 规范。如果选择 `scss` ,建议使用 `BEM` 命名规范,可以更好的管理样式。项目默认提供了`useNamespace`函数,可以方便的生成命名空间。
+
+```vue
+
+
+
+
+
+```
+
+## CSS Modules
+
+针对样式冲突问题,还有一种方案是使用 `CSS Modules` 模块化方案。使用方式如下。
+
+```vue
+
+ This should be red
+
+
+
+```
+
+更多用法可以见 [CSS Modules 官方文档](https://vuejs.org/api/sfc-css-features.html#css-modules)。
diff --git a/apps/vben5/docs/src/guide/in-depth/access.md b/apps/vben5/docs/src/guide/in-depth/access.md
new file mode 100644
index 000000000..c0c4bc991
--- /dev/null
+++ b/apps/vben5/docs/src/guide/in-depth/access.md
@@ -0,0 +1,311 @@
+---
+outline: deep
+---
+
+# 权限
+
+框架内置了两种权限控制方式:
+
+- 通过用户角色来判断菜单或者按钮是否可以访问
+- 通过接口来判断菜单或者按钮是否可以访问
+
+## 前端访问控制
+
+**实现原理**: 在前端固定写死路由的权限,指定路由有哪些权限可以查看。只初始化通用的路由,需要权限才能访问的路由没有被加入路由表内。在登录后或者其他方式获取用户角色后,通过角色去遍历路由表,获取该角色可以访问的路由表,生成路由表,再通过 `router.addRoute` 添加到路由实例,实现权限的过滤。
+
+**缺点**: 权限相对不自由,如果后台改动角色,前台也需要跟着改动。适合角色较固定的系统
+
+### 步骤
+
+- 确保当前模式为前端访问控制模式
+
+调整对应应用目录下的`preferences.ts`,确保`accessMode='frontend'`。
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ // 默认值,可不填
+ accessMode: 'frontend',
+ },
+});
+```
+
+- 配置路由权限
+
+**如果不配置,默认可见**
+
+```ts {3}
+ {
+ meta: {
+ authority: ['super'],
+ },
+},
+```
+
+- 确保接口返回的角色和路由表的权限匹配
+
+可查看应用下的 `src/store/auth`,找到下面代码,
+
+```ts
+// 设置登录用户信息,需要确保 userInfo.roles 是一个数组,且包含路由表中的权限
+// 例如:userInfo.roles=['super', 'admin']
+authStore.setUserInfo(userInfo);
+```
+
+到这里,就已经配置完成,你需要确保登录后,接口返回的角色和路由表的权限匹配,否则无法访问。
+
+### 菜单可见,但禁止访问
+
+有时候,我们需要菜单可见,但是禁止访问,可以通过下面的方式实现,设置 `menuVisibleWithForbidden` 为 `true`,此时菜单可见,但是禁止访问,会跳转403页面。
+
+```ts
+{
+ meta: {
+ menuVisibleWithForbidden: true,
+ },
+},
+```
+
+## 后端访问控制
+
+**实现原理**: 是通过接口动态生成路由表,且遵循一定的数据结构返回。前端根据需要处理该数据为可识别的结构,再通过 `router.addRoute` 添加到路由实例,实现权限的动态生成。
+
+**缺点**: 后端需要提供符合规范的数据结构,前端需要处理数据结构,适合权限较为复杂的系统。
+
+### 步骤
+
+- 确保当前模式为后端访问控制模式
+
+调整对应应用目录下的`preferences.ts`,确保`accessMode='backend'`。
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ accessMode: 'backend',
+ },
+});
+```
+
+- 确保接口返回的菜单数据结构正确
+
+可查看应用下的 `src/router/access.ts`,找到下面代码,
+
+```ts {5}
+async function generateAccess(options: GenerateMenuAndRoutesOptions) {
+ return await generateAccessible(preferences.app.accessMode, {
+ fetchMenuListAsync: async () => {
+ // 这个接口为后端返回的菜单数据
+ return await getAllMenus();
+ },
+ });
+}
+```
+
+- 接口返回菜单数据,可看注释说明
+
+::: details 接口返回菜单数据示例
+
+```ts
+const dashboardMenus = [
+ {
+ // 这里固定写死 BasicLayout,不可更改
+ component: 'BasicLayout',
+ meta: {
+ order: -1,
+ title: 'page.dashboard.title',
+ },
+ name: 'Dashboard',
+ path: '/',
+ redirect: '/analytics',
+ children: [
+ {
+ name: 'Analytics',
+ path: '/analytics',
+ // 这里为页面的路径,需要去掉 views/ 和 .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',
+ },
+ },
+ ],
+ },
+];
+```
+
+:::
+
+到这里,就已经配置完成,你需要确保登录后,接口返回的菜单格式正确,否则无法访问。
+
+## 按钮细粒度控制
+
+在某些情况下,我们需要对按钮进行细粒度的控制,我们可以借助接口或者角色来控制按钮的显示。
+
+### 权限码
+
+权限码为接口返回的权限码,通过权限码来判断按钮是否显示,逻辑在`src/store/auth`下:
+
+```ts
+const [fetchUserInfoResult, accessCodes] = await Promise.all([
+ fetchUserInfo(),
+ getAccessCodes(),
+]);
+
+userInfo = fetchUserInfoResult;
+authStore.setUserInfo(userInfo);
+accessStore.setAccessCodes(accessCodes);
+```
+
+找到 `getAccessCodes` 对应的接口,可根据业务逻辑进行调整。
+
+权限码返回的数据结构为字符串数组,例如:`['AC_100100', 'AC_100110', 'AC_100120', 'AC_100010']`
+
+有了权限码,就可以使用 `@vben/access` 提供的`AccessControl`组件及API来进行按钮的显示与隐藏。
+
+#### 组件方式
+
+```vue
+
+
+
+
+
+ Super 账号可见 ["AC_1000001"]
+
+
+ Admin 账号可见 ["AC_100010"]
+
+
+ User 账号可见 ["AC_1000001"]
+
+
+ Super & Admin 账号可见 ["AC_100100","AC_1000001"]
+
+
+```
+
+#### API方式
+
+```vue
+
+
+
+
+ Super 账号可见 ["AC_1000001"]
+
+
+ Admin 账号可见 ["AC_100010"]
+
+
+ User 账号可见 ["AC_1000001"]
+
+
+ Super & Admin 账号可见 ["AC_100100","AC_1000001"]
+
+
+```
+
+#### 指令方式
+
+> 指令支持绑定单个或多个权限码。单个时可以直接传入字符串或数组中包含一个权限码,多个权限码则传入数组。
+
+```vue
+
+
+ Super 账号可见 'AC_100100'
+
+
+ Admin 账号可见 ["AC_100010"]
+
+
+ User 账号可见 ["AC_1000001"]
+
+
+ Super & Admin 账号可见 ["AC_100100","AC_1000001"]
+
+
+```
+
+### 角色
+
+角色判断方式不需要接口返回的权限码,直接通过角色来判断按钮是否显示。
+
+#### 组件方式
+
+```vue
+
+
+
+
+ Super 角色可见
+
+
+ Admin 角色可见
+
+
+ User 角色可见
+
+
+ Super & Admin 角色可见
+
+
+```
+
+#### API方式
+
+```vue
+
+
+
+ Super 账号可见
+ Admin 账号可见
+ User 账号可见
+
+ Super & Admin 账号可见
+
+
+```
+
+#### 指令方式
+
+> 指令支持绑定单个或多个权限码。单个时可以直接传入字符串或数组中包含一个权限码,多个权限码则传入数组。
+
+```vue
+
+ Super 角色可见
+ Super 角色可见
+ Admin 角色可见
+ User 角色可见
+
+ Super & Admin 角色可见
+
+
+```
diff --git a/apps/vben5/docs/src/guide/in-depth/check-updates.md b/apps/vben5/docs/src/guide/in-depth/check-updates.md
new file mode 100644
index 000000000..4af9e333a
--- /dev/null
+++ b/apps/vben5/docs/src/guide/in-depth/check-updates.md
@@ -0,0 +1,48 @@
+# 检查更新
+
+## 介绍
+
+当网站有更新时,您可能需要检查更新。框架提供了这一功能,通过定时检查更新,您可以在应用的 preferences.ts 文件中配置 `checkUpdatesInterval`和 `enableCheckUpdates` 字段,以开启和设置检查更新的时间间隔(单位:分钟)。
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ // 是否开启检查更新
+ enableCheckUpdates: true,
+ // 检查更新的时间间隔,单位为分钟
+ checkUpdatesInterval: 1,
+ },
+});
+```
+
+## 效果
+
+检测到更新时,会弹出提示框,询问用户是否刷新页面:
+
+
+
+## 替换为其他检查更新方式
+
+如果需要通过其他方式检查更新,例如通过接口来更灵活地控制更新逻辑(如强制刷新、显示更新内容等),你可以通过修改 `@vben/layouts` 下面的 `src/widgets/check-updates/check-updates.vue`文件来实现。
+
+```ts
+// 这里可以替换为你的检查更新逻辑
+async function getVersionTag() {
+ try {
+ const response = await fetch('/', {
+ cache: 'no-cache',
+ method: 'HEAD',
+ });
+
+ return (
+ response.headers.get('etag') || response.headers.get('last-modified')
+ );
+ } catch {
+ console.error('Failed to fetch version tag');
+ return null;
+ }
+}
+```
diff --git a/apps/vben5/docs/src/guide/in-depth/features.md b/apps/vben5/docs/src/guide/in-depth/features.md
new file mode 100644
index 000000000..53b967002
--- /dev/null
+++ b/apps/vben5/docs/src/guide/in-depth/features.md
@@ -0,0 +1,84 @@
+# 常用功能
+
+一些常用的功能合集。
+
+## 登录认证过期
+
+当接口返回`401`状态码时,框架会认为登录认证过期,登录超时会跳转到登录页或者打开登录弹窗。在应用目录下的`preferences.ts`可以配置:
+
+### 跳转登录页面
+
+登录超时会跳转到登录页
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ loginExpiredMode: 'page',
+ },
+});
+```
+
+### 打开登录弹窗
+
+登录超时会打开登录弹窗
+
+
+
+配置:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ loginExpiredMode: 'modal',
+ },
+});
+```
+
+## 动态标题
+
+- 默认值:`true`
+
+开启后网页标题随着路由的`title`而变化。在应用目录下的`preferences.ts`,开启或者关闭即可。
+
+```ts
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ dynamicTitle: true,
+ },
+});
+```
+
+## 页面水印
+
+- 默认值:`false`
+
+开启后网页会显示水印,在应用目录下的`preferences.ts`,开启或者关闭即可。
+
+```ts
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ watermark: true,
+ },
+});
+```
+
+如果你想更新水印的内容,可以这么做,参数可以参考 [watermark-js-plus](https://zhensherlock.github.io/watermark-js-plus/):
+
+```ts
+import { useWatermark } from '@vben/hooks';
+
+const { destroyWatermark, updateWatermark } = useWatermark();
+
+await updateWatermark({
+ // 水印内容
+ content: 'hello my watermark',
+});
+```
diff --git a/apps/vben5/docs/src/guide/in-depth/layout.md b/apps/vben5/docs/src/guide/in-depth/layout.md
new file mode 100644
index 000000000..f8317bb8a
--- /dev/null
+++ b/apps/vben5/docs/src/guide/in-depth/layout.md
@@ -0,0 +1 @@
+# 布局
diff --git a/apps/vben5/docs/src/guide/in-depth/loading.md b/apps/vben5/docs/src/guide/in-depth/loading.md
new file mode 100644
index 000000000..60e69378c
--- /dev/null
+++ b/apps/vben5/docs/src/guide/in-depth/loading.md
@@ -0,0 +1,46 @@
+# 全局loading
+
+全局 loading 指的是页面刷新时出现的加载效果,通常是一个旋转的图标:
+
+
+
+## 原理
+
+由 `vite-plugin-inject-app-loading` 插件实现,插件会在每个应用都注入一个全局的 `loading html`。
+
+## 关闭
+
+如果你不需要全局 loading,可以在 `.env` 文件中关闭:
+
+```bash
+VITE_INJECT_APP_LOADING=false
+```
+
+## 自定义
+
+如果你想要自定义全局 loading,可以在应用目录下,与`index.html`同级,创建一个`loading.html`文件,插件会自动读取并注入。这个html可以自行定义样式和动画。
+
+::: tip
+
+- 你可以使用跟`index.html`一样的语法,比如`VITE_APP_TITLE`变量,来获取应用的标题。
+- 必须保证有一个`id="__app-loading__"`的元素。
+- 给`id="__app-loading__"`的元素,加一个 `hidden` class。
+- 必须保证有一个`style[data-app-loading="inject-css"]`的元素。
+
+```html{1,4}
+
+
+
+
<%= VITE_APP_TITLE %>
+
+```
+
+:::
diff --git a/apps/vben5/docs/src/guide/in-depth/locale.md b/apps/vben5/docs/src/guide/in-depth/locale.md
new file mode 100644
index 000000000..e4a4a659d
--- /dev/null
+++ b/apps/vben5/docs/src/guide/in-depth/locale.md
@@ -0,0 +1,227 @@
+# 国际化
+
+项目已经集成了 [Vue i18n](https://kazupon.github.io/vue-i18n/),并且已经配置好了中文和英文的语言包。
+
+## IDE 插件
+
+如果你使用的 vscode 开发工具,则推荐安装 [i18n Ally](https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally) 这个插件。它可以帮助你更方便的管理国际化的文案,安装了该插件后,你的代码内可以实时看到对应的语言内容:
+
+
+
+## 配置默认语言
+
+只需要覆盖默认的偏好设置即可,在对应的应用内,找到 `src/preferences.ts` 文件,修改 `locale` 的值即可:
+
+```ts {3}
+export const overridesPreferences = defineOverridesPreferences({
+ app: {
+ locale: 'en-US',
+ },
+});
+```
+
+## 动态切换语言
+
+切换语言有两部分组成:
+
+- 更新偏好设置
+- 加载对应的语言包
+
+```ts
+import type { SupportedLanguagesType } from '@vben/locales';
+import { loadLocaleMessages } from '@vben/locales';
+import { updatePreferences } from '@vben/preferences';
+
+async function updateLocale(value: string) {
+ // 1. 更新偏好设置
+ const locale = value as SupportedLanguagesType;
+ updatePreferences({
+ app: {
+ locale,
+ },
+ });
+ // 2. 加载对应的语言包
+ await loadLocaleMessages(locale);
+}
+
+updateLocale('en-US');
+```
+
+## 新增翻译文本
+
+::: warning 注意
+
+- 请不要将业务翻译文本放到 `@vben/locales` 内,这样可以更好的管理业务和通用的翻译文本。
+- 有多个语言包的情况下,新增翻译文本时,需要在所有语言包内新增对应的文本。
+
+:::
+
+新增翻译文本,只需要在对应的应用内,找到 `src/locales/langs/`,新增对应的文本即可,例:
+
+**src/locales/langs/zh-CN/\*.json**
+
+````ts
+```json
+{
+ "about": {
+ "desc": "Vben Admin 是一个现代的管理模版。"
+ }
+}
+````
+
+**src/locales/langs/en-US.ts**
+
+````ts
+```json
+{
+ "about": {
+ "desc": "Vben Admin is a modern management template."
+ }
+}
+````
+
+## 使用翻译文本
+
+通过 `@vben/locales`,你可以很方便的使用翻译文本:
+
+### 在代码中使用
+
+```vue
+
+
+ {{ $t('about.desc') }}
+
+ {{ item.title }}
+
+
+```
+
+## 新增语言包
+
+如果你需要新增语言包,需要按照以下步骤进行:
+
+- 在 `packages/locales/langs` 目录下新增对应的语言包文件,例:`zh-TW.json`,并翻译对应的文本。
+- 在对应的应用内,找到 `src/locales/langs` 文件,新增对应的语言包 `zh-TW.json`
+- 在 `packages/constants/src/core.ts`内,新增对应的语言:
+
+ ```ts
+ export interface LanguageOption {
+ label: string;
+ value: 'en-US' | 'zh-CN'; // [!code --]
+ value: 'en-US' | 'zh-CN' | 'zh-TW'; // [!code ++]
+ }
+ export const SUPPORT_LANGUAGES: LanguageOption[] = [
+ {
+ label: '简体中文',
+ value: 'zh-CN',
+ },
+ {
+ label: 'English',
+ value: 'en-US',
+ },
+ {
+ label: '繁体中文', // [!code ++]
+ value: 'zh-TW', // [!code ++]
+ },
+ ];
+ ```
+
+- 在 `packages/locales/typing.ts`内,新增 Typescript 类型:
+
+ ```ts
+ export type SupportedLanguagesType = 'en-US' | 'zh-CN'; // [!code --]
+ export type SupportedLanguagesType = 'en-US' | 'zh-CN' | 'zh-TW'; // [!code ++]
+ ```
+
+到这里,你就可以在项目内使用新增的语言包了。
+
+## 界面切换语言功能
+
+如果你想关闭界面上的语言切换显示按钮,在对应的应用内,找到 `src/preferences.ts` 文件,修改 `locale` 的值即可:
+
+```ts {3}
+export const overridesPreferences = defineOverridesPreferences({
+ widget: {
+ languageToggle: false,
+ },
+});
+```
+
+## 远程加载语言包
+
+::: tip 提示
+
+通过项目自带的`request`工具进行接口请求时,默认请求头里会带上 [Accept-Language](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Accept-Language) ,服务端可根据请求头进行动态数据国际化处理。
+
+:::
+
+每个应用都有一个独立的语言包,它可以覆盖通用的语言配置,你可以通过远程加载的方式来获取对应的语言包,只需要在对应的应用内,找到 `src/locales/index.ts` 文件,修改 `loadMessages` 方法即可:
+
+```ts {3-4}
+async function loadMessages(lang: SupportedLanguagesType) {
+ const [appLocaleMessages] = await Promise.all([
+ // 这里修改为远程接口加载数据即可
+ localesMap[lang](),
+ loadThirdPartyMessage(lang),
+ ]);
+ return appLocaleMessages.default;
+}
+```
+
+## 第三方语言包
+
+不同应用内使用的第三方组件库或者插件国际化方式可能不一致,所以需要差别处理。 如果你需要引入第三方的语言包,你可以在对应的应用内,找到 `src/locales/index.ts` 文件,修改 `loadThirdPartyMessage` 方法即可:
+
+```ts
+/**
+ * 加载dayjs的语言包
+ * @param lang
+ */
+async function loadDayjsLocale(lang: SupportedLanguagesType) {
+ let locale;
+ switch (lang) {
+ case 'zh-CN': {
+ locale = await import('dayjs/locale/zh-cn');
+ break;
+ }
+ case 'en-US': {
+ locale = await import('dayjs/locale/en');
+ break;
+ }
+ // 默认使用英语
+ default: {
+ locale = await import('dayjs/locale/en');
+ }
+ }
+ if (locale) {
+ dayjs.locale(locale);
+ } else {
+ console.error(`Failed to load dayjs locale for ${lang}`);
+ }
+}
+```
+
+## 移除国际化
+
+首先,不是很建议移除国际化,因为国际化是一个很好的开发习惯,但是如果你真的需要移除国际化,你可以直接使用中文文案,然后保留项目自带的语言包即可,整体开发体验不会影响。移除国际化的步骤如下:
+
+- 隐藏界面上的语言切换按钮,见:[界面切换语言功能](#界面切换语言功能)
+- 修改默认语言,见:[配置默认语言](#配置默认语言)
+- 关闭 `vue-i18n`的警告提示,在`src/locales/index.ts`文件内,修改`missingWarn`为`false`即可:
+
+ ```ts
+ async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
+ await coreSetup(app, {
+ defaultLocale: preferences.app.locale,
+ loadMessages,
+ missingWarn: !import.meta.env.PROD, // [!code --]
+ missingWarn: false, // [!code ++]
+ ...options,
+ });
+ }
+ ```
diff --git a/apps/vben5/docs/src/guide/in-depth/login.md b/apps/vben5/docs/src/guide/in-depth/login.md
new file mode 100644
index 000000000..adb89b75d
--- /dev/null
+++ b/apps/vben5/docs/src/guide/in-depth/login.md
@@ -0,0 +1,220 @@
+---
+outline: deep
+---
+
+# 登录
+
+本文介绍如何去改造自己的应用程序登录页以及如何快速的对接登录页面接口。
+
+## 登录页面调整
+
+如果你想调整登录页面的标题、描述和图标以及工具栏,你可以通过配置 `AuthPageLayout` 组件的参数来实现。
+
+
+
+只需要在应用下的 `src/layouts/auth.vue` 内,配置`AuthPageLayout`的 `props`参数即可:
+
+```vue {2-7}
+
+
+```
+
+## 登录表单调整
+
+如果你想调整登录表单的相关内容,你可以在应用下的 `src/views/_core/authentication/login.vue` 内,配置`AuthenticationLogin` 组件参数即可:
+
+```vue
+
+```
+
+::: details AuthenticationLogin 组件参数
+
+```ts
+{
+ /**
+ * @zh_CN 验证码登录路径
+ */
+ codeLoginPath?: string;
+ /**
+ * @zh_CN 忘记密码路径
+ */
+ forgetPasswordPath?: string;
+
+ /**
+ * @zh_CN 是否处于加载处理状态
+ */
+ loading?: boolean;
+
+ /**
+ * @zh_CN 二维码登录路径
+ */
+ qrCodeLoginPath?: string;
+
+ /**
+ * @zh_CN 注册路径
+ */
+ registerPath?: string;
+
+ /**
+ * @zh_CN 是否显示验证码登录
+ */
+ showCodeLogin?: boolean;
+ /**
+ * @zh_CN 是否显示忘记密码
+ */
+ showForgetPassword?: boolean;
+
+ /**
+ * @zh_CN 是否显示二维码登录
+ */
+ showQrcodeLogin?: boolean;
+
+ /**
+ * @zh_CN 是否显示注册按钮
+ */
+ showRegister?: boolean;
+
+ /**
+ * @zh_CN 是否显示记住账号
+ */
+ showRememberMe?: boolean;
+
+ /**
+ * @zh_CN 是否显示第三方登录
+ */
+ showThirdPartyLogin?: boolean;
+
+ /**
+ * @zh_CN 登录框子标题
+ */
+ subTitle?: string;
+
+ /**
+ * @zh_CN 登录框标题
+ */
+ title?: string;
+
+}
+```
+
+:::
+
+::: tip Note
+
+如果这些配置不能满足你的需求,你可以自行实现登录表单及相关登录逻辑或者给我们提交 `PR`。
+
+:::
+
+## 接口对接流程
+
+这里将会快速的介绍如何快速对接自己的后端。
+
+### 前置条件
+
+- 首先文档用的后端服务,接口返回的格式统一如下:
+
+```ts
+interface HttpResponse {
+ /**
+ * 0 表示成功 其他表示失败
+ * 0 means success, others means fail
+ */
+ code: number;
+ data: T;
+ message: string;
+}
+```
+
+如果你不符合这个格式,你需要先阅读 [服务端交互](../essentials/server.md) 文档,改造你的`request.ts`配置。
+
+- 其次你需要在先将本地代理地址改为你的真实后端地址,你可以在应用下的 `vite.config.mts` 内配置:
+
+```ts
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ vite: {
+ server: {
+ proxy: {
+ '/api': {
+ changeOrigin: true,
+ rewrite: (path) => path.replace(/^\/api/, ''),
+ // 这里改为你的真实接口地址
+ target: 'http://localhost:5320/api',
+ ws: true,
+ },
+ },
+ },
+ },
+ };
+});
+```
+
+### 登录接口
+
+为了能正常登录,你的后端最少需要提供 `2-3` 个接口:
+
+- 登录接口
+
+接口地址可在应用下的 `src/api/core/auth` 内修改,以下为默认接口地址:
+
+```ts
+/**
+ * 登录
+ */
+export async function loginApi(data: AuthApi.LoginParams) {
+ return requestClient.post('/auth/login', data);
+}
+
+/** 只需要保证登录接口返回值有 `accessToken` 字段即可 */
+export interface LoginResult {
+ accessToken: string;
+}
+```
+
+- 获取用户信息接口
+
+接口地址可在应用下的 `src/api/core/user` 内修改,以下为默认接口地址:
+
+```ts
+export async function getUserInfoApi() {
+ return requestClient.get('/user/info');
+}
+
+/** 只需要保证登录接口返回值有以下字段即可,多的字段可以自行使用 */
+export interface UserInfo {
+ roles: string[];
+ realName: string;
+}
+```
+
+- 获取权限码 (可选)
+
+这个接口用于获取用户的权限码,权限码是用于控制用户的权限的,接口地址可在应用下的 `src/api/core/auth` 内修改,以下为默认接口地址:
+
+```ts
+export async function getAccessCodesApi() {
+ return requestClient.get('/auth/codes');
+}
+```
+
+如果你不需要这个权限,你只需要把代码改为返回一个空数组即可。
+
+```ts {2}
+export async function getAccessCodesApi() {
+ // 这里返回一个空数组即可
+ return [];
+}
+```
diff --git a/apps/vben5/docs/src/guide/in-depth/theme.md b/apps/vben5/docs/src/guide/in-depth/theme.md
new file mode 100644
index 000000000..82fb6fc50
--- /dev/null
+++ b/apps/vben5/docs/src/guide/in-depth/theme.md
@@ -0,0 +1,1293 @@
+# 主题
+
+框架基于 [shadcn-vue](https://www.shadcn-vue.com/themes.html) 和 [tailwindcss](https://tailwindcss.com/) 构建,提供了丰富的主题配置,可以通过简单的配置实现各种主题切换,满足个性化需求。您可以选择使用 CSS 变量或 Tailwind CSS 实用程序类进行主题设置。
+
+## Css 变量
+
+项目遵循 [shadcn-vue](https://www.shadcn-vue.com/themes.html) 的主题配置,示例:
+
+```html
+
+```
+
+我们对颜色使用一个简单的约定。`background`变量用于组件的背景颜色,`foreground`变量用于文本颜色。
+
+以下组件的`background`将为`hsl(var(--primary))`,`foreground`将为`hsl(var(--primary-foreground))`。
+
+## 详细的CSS变量列表
+
+::: warning 注意
+
+css 变量内的颜色,必须使用 `hsl` 格式,如 `0 0% 100%`,不需要加 `hsl()`和 `,`。
+
+:::
+
+你可以查看下面的CSS变量列表,以了解所有可用的变量。
+
+::: details 默认主题 css 变量
+
+```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';
+
+ /* Default background color of ...etc */
+ --background: 0 0% 100%;
+
+ /* 主体区域背景色 */
+ --background-deep: 216 20.11% 95.47%;
+ --foreground: 210 6% 21%;
+
+ /* Background color for */
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+
+ /* Background color for popovers such as , , */
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+
+ /* Muted backgrounds such as , and */
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+
+ /* 主题颜色 */
+
+ --primary: 212 100% 45%;
+ --primary-foreground: 0 0% 98%;
+
+ /* Used for destructive actions such as */
+
+ --destructive: 0 78% 68%;
+ --destructive-foreground: 0 0% 98%;
+
+ /* Used for success actions such as */
+
+ --success: 144 57% 58%;
+ --success-foreground: 0 0% 98%;
+
+ /* Used for warning actions such as */
+
+ --warning: 42 84% 61%;
+ --warning-foreground: 0 0% 98%;
+
+ /* Secondary colors for */
+
+ --secondary: 240 5% 96%;
+ --secondary-foreground: 240 6% 10%;
+
+ /* Used for accents such as hover effects on , ...etc */
+ --accent: 240 5% 96%;
+ --accent-hover: 200deg 10% 90%;
+ --accent-foreground: 240 6% 10%;
+
+ /* Darker color */
+ --heavy: 192deg 9.43% 89.61%;
+ --heavy-foreground: var(--accent-foreground);
+
+ /* Default border color */
+ --border: 240 5.9% 90%;
+
+ /* Border color for inputs such as , , */
+ --input: 240deg 5.88% 90%;
+ --input-placeholder: 217 10.6% 65%;
+ --input-background: 0 0% 100%;
+
+ /* Used for focus ring */
+ --ring: 222.2 84% 4.9%;
+
+ /* Border radius for card, input and buttons */
+ --radius: 0.5rem;
+
+ /* ============= custom ============= */
+
+ /* 遮罩颜色 */
+ --overlay: 0deg 0% 0% / 30%;
+
+ /* 基本文字大小 */
+ --font-size-base: 16px;
+
+ /* =============component & UI============= */
+
+ /* menu */
+ --sidebar: 0 0% 100%;
+ --sidebar-deep: 216 20.11% 95.47%;
+ --menu: var(--sidebar);
+
+ /* header */
+ --header: 0 0% 100%;
+
+ accent-color: var(--primary);
+ color-scheme: light;
+}
+```
+
+:::
+
+::: details 默认主题黑暗模式 css 变量
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ /* Default background color of ...etc */
+ --background: 222.34deg 10.43% 12.27%;
+
+ /* 主体区域背景色 */
+ --background-deep: 220deg 13.06% 9%;
+ --foreground: 0 0% 95%;
+
+ /* Background color for */
+ --card: 222.34deg 10.43% 12.27%;
+
+ /* --card: 222.2 84% 4.9%; */
+ --card-foreground: 210 40% 98%;
+
+ /* Background color for popovers such as , , */
+ --popover: 222.82deg 8.43% 12.27%;
+ --popover-foreground: 210 40% 98%;
+
+ /* Muted backgrounds such as , and */
+ --muted: 220deg 6.82% 17.25%;
+ --muted-foreground: 215 20.2% 65.1%;
+
+ /* 主题颜色 */
+
+ /* --primary: 245 82% 67%; */
+ --primary-foreground: 0 0% 98%;
+
+ /* Used for destructive actions such as */
+
+ --destructive: 0 78% 68%;
+ --destructive-foreground: 0 0% 98%;
+
+ /* Used for success actions such as */
+
+ --success: 144 57% 58%;
+ --success-foreground: 0 0% 98%;
+
+ /* Used for warning actions such as */
+
+ --warning: 42 84% 61%;
+ --warning-foreground: 0 0% 98%;
+
+ /* 颜色次要 */
+ --secondary: 240 5% 17%;
+ --secondary-foreground: 0 0% 98%;
+
+ /* Used for accents such as hover effects on , ...etc */
+ --accent: 0deg 0% 100% / 8%;
+ --accent-hover: 0deg 0% 100% / 12%;
+ --accent-foreground: 0 0% 98%;
+
+ /* Darker color */
+ --heavy: 0deg 0% 100% / 12%;
+ --heavy-foreground: var(--accent-foreground);
+
+ /* Default border color */
+ --border: 240 3.7% 15.9%;
+
+ /* Border color for inputs such as , , */
+ --input: 0deg 0% 100% / 10%;
+ --input-placeholder: 218deg 11% 65%;
+ --input-background: 0deg 0% 100% / 5%;
+
+ /* Used for focus ring */
+ --ring: 222.2 84% 4.9%;
+
+ /* 基本圆角大小 */
+ --radius: 0.5rem;
+
+ /* ============= Custom ============= */
+
+ /* 遮罩颜色 */
+ --overlay: 0deg 0% 0% / 40%;
+
+ /* 基本文字大小 */
+ --font-size-base: 16px;
+
+ /* =============component & UI============= */
+
+ --sidebar: 222.34deg 10.43% 12.27%;
+ --sidebar-deep: 220deg 13.06% 9%;
+ --menu: var(--sidebar);
+ --header: 222.34deg 10.43% 12.27%;
+
+ color-scheme: dark;
+}
+```
+
+:::
+
+## 覆盖默认的 CSS 变量
+
+你只需要在你的项目中覆盖你想要修改的 CSS 变量即可。例如,要更改默认卡片背景色,你可以在你的 CSS 文件中添加以下内容进行覆盖:
+
+### 默认主题下
+
+```css
+:root {
+ /* Background color for */
+ --card: 0 0% 30%;
+}
+```
+
+### 黑暗模式下
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ /* Background color for */
+ --card: 222.34deg 10.43% 12.27%;
+}
+```
+
+## 更改品牌主色
+
+::: tip
+
+- 需要使用 `hsl` 格式颜色格式。
+- 修改后需要清空缓存才可生效。
+- 你可以借助 [第三方工具](https://www.w3schools.com/colors/colors_hsl.asp)来转换颜色。
+
+:::
+
+只需要在应用目录下的`preferences.ts`,自定义配置主色即可:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ theme: {
+ // 错误色
+ colorDestructive: 'hsl(348 100% 61%)',
+ // 主题色
+ colorPrimary: 'hsl(212 100% 45%)',
+ // 成功色
+ colorSuccess: 'hsl(144 57% 58%)',
+ // 警告色
+ colorWarning: 'hsl(42 84% 61%)',
+ },
+});
+```
+
+## 内置主题
+
+框架中内置了多种主题,你可以在`preferences.ts`中进行配置:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ theme: {
+ builtinType: 'default',
+ },
+});
+```
+
+### 内置主题列表
+
+框架内置了 16种主题,且还支持自定义主题。理论上,你可以无限制的扩展主题。
+
+::: details 内置主题类型列表
+
+```ts
+type BuiltinThemeType =
+ | 'custom'
+ | 'deep-blue'
+ | 'deep-green'
+ | 'default'
+ | 'gray'
+ | 'green'
+ | 'neutral'
+ | 'orange'
+ | 'pink'
+ | 'red'
+ | 'rose'
+ | 'sky-blue'
+ | 'slate'
+ | 'stone'
+ | 'violet'
+ | 'yellow'
+ | 'zinc'
+ | (Record & string);
+```
+
+:::
+
+::: details 内置主题css变量 - light
+
+```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';
+
+ /* Default background color of ...etc */
+ --background: 0 0% 100%;
+
+ /* 主体区域背景色 */
+ --background-deep: 216 20.11% 95.47%;
+ --foreground: 222 84% 5%;
+
+ /* Background color for */
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+
+ /* Background color for popovers such as , , */
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+
+ /* Muted backgrounds such as , and */
+
+ /* --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%; */
+
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+
+ /* 主题颜色 */
+
+ --primary: 212 100% 45%;
+ --primary-foreground: 0 0% 98%;
+
+ /* Used for destructive actions such as */
+
+ --destructive: 0 78% 68%;
+ --destructive-foreground: 0 0% 98%;
+
+ /* Used for success actions such as */
+
+ --success: 144 57% 58%;
+ --success-foreground: 0 0% 98%;
+
+ /* Used for warning actions such as */
+
+ --warning: 42 84% 61%;
+ --warning-foreground: 0 0% 98%;
+
+ /* Secondary colors for */
+
+ --secondary: 240 5% 96%;
+ --secondary-foreground: 240 6% 10%;
+
+ /* Used for accents such as hover effects on , ...etc */
+ --accent: 240 5% 96%;
+ --accent-hover: 200deg 10% 90%;
+ --accent-foreground: 240 6% 10%;
+
+ /* Darker color */
+ --heavy: 192deg 9.43% 89.61%;
+ --heavy-foreground: var(--accent-foreground);
+
+ /* Default border color */
+ --border: 240 5.9% 90%;
+
+ /* Border color for inputs such as , , */
+ --input: 240deg 5.88% 90%;
+ --input-placeholder: 217 10.6% 65%;
+ --input-background: 0 0% 100%;
+
+ /* Used for focus ring */
+ --ring: 222.2 84% 4.9%;
+
+ /* Border radius for card, input and buttons */
+ --radius: 0.5rem;
+
+ /* ============= custom ============= */
+
+ /* 遮罩颜色 */
+ --overlay: 0deg 0% 0% / 30%;
+
+ /* 基本文字大小 */
+ --font-size-base: 16px;
+
+ /* =============component & UI============= */
+
+ /* menu */
+ --sidebar: 0 0% 100%;
+ --sidebar-deep: 0 0% 100%;
+ --menu: var(--sidebar);
+
+ /* header */
+ --header: 0 0% 100%;
+
+ accent-color: var(--primary);
+ color-scheme: light;
+}
+
+[data-theme='violet'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 224 71.4% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 224 71.4% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 224 71.4% 4.1%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 220 14.3% 95.9%;
+ --secondary-foreground: 220.9 39.3% 11%;
+ --muted: 220 14.3% 95.9%;
+ --muted-foreground: 220 8.9% 46.1%;
+ --accent: 220 14.3% 95.9%;
+ --accent-foreground: 220.9 39.3% 11%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 220 13% 91%;
+ --input: 220 13% 91%;
+ --ring: 262.1 83.3% 57.8%;
+}
+
+[data-theme='pink'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 346.8 77.2% 49.8%;
+}
+
+[data-theme='rose'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 346.8 77.2% 49.8%;
+}
+
+[data-theme='sky-blue'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 222.2 84% 4.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+ --primary-foreground: 210 40% 98%;
+ --secondary: 210 40% 96.1%;
+ --secondary-foreground: 222.2 47.4% 11.2%;
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+ --accent: 210 40% 96.1%;
+ --accent-foreground: 222.2 47.4% 11.2%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 214.3 31.8% 91.4%;
+ --input: 214.3 31.8% 91.4%;
+ --ring: 221.2 83.2% 53.3%;
+}
+
+[data-theme='deep-blue'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 222.2 84% 4.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+ --primary-foreground: 210 40% 98%;
+ --secondary: 210 40% 96.1%;
+ --secondary-foreground: 222.2 47.4% 11.2%;
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+ --accent: 210 40% 96.1%;
+ --accent-foreground: 222.2 47.4% 11.2%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 214.3 31.8% 91.4%;
+ --input: 214.3 31.8% 91.4%;
+ --ring: 221.2 83.2% 53.3%;
+}
+
+[data-theme='green'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 142.1 76.2% 36.3%;
+}
+
+[data-theme='deep-green'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 142.1 76.2% 36.3%;
+}
+
+[data-theme='orange'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 20 14.3% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 20 14.3% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 20 14.3% 4.1%;
+ --primary-foreground: 60 9.1% 97.8%;
+ --secondary: 60 4.8% 95.9%;
+ --secondary-foreground: 24 9.8% 10%;
+ --muted: 60 4.8% 95.9%;
+ --muted-foreground: 25 5.3% 44.7%;
+ --accent: 60 4.8% 95.9%;
+ --accent-foreground: 24 9.8% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 60 9.1% 97.8%;
+ --border: 20 5.9% 90%;
+ --input: 20 5.9% 90%;
+ --ring: 24.6 95% 53.1%;
+}
+
+[data-theme='yellow'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 20 14.3% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 20 14.3% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 20 14.3% 4.1%;
+ --primary-foreground: 26 83.3% 14.1%;
+ --secondary: 60 4.8% 95.9%;
+ --secondary-foreground: 24 9.8% 10%;
+ --muted: 60 4.8% 95.9%;
+ --muted-foreground: 25 5.3% 44.7%;
+ --accent: 60 4.8% 95.9%;
+ --accent-foreground: 24 9.8% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 60 9.1% 97.8%;
+ --border: 20 5.9% 90%;
+ --input: 20 5.9% 90%;
+ --ring: 20 14.3% 4.1%;
+}
+
+[data-theme='zinc'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 240 10% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 240 10% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 10% 3.9%;
+ --primary-foreground: 0 0% 98%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 240 5.9% 10%;
+}
+
+[data-theme='neutral'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 0 0% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 0 0% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 0 0% 3.9%;
+ --primary-foreground: 0 0% 98%;
+ --secondary: 0 0% 96.1%;
+ --secondary-foreground: 0 0% 9%;
+ --muted: 0 0% 96.1%;
+ --muted-foreground: 0 0% 45.1%;
+ --accent: 0 0% 96.1%;
+ --accent-foreground: 0 0% 9%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 0 0% 89.8%;
+ --input: 0 0% 89.8%;
+ --ring: 0 0% 3.9%;
+}
+
+[data-theme='slate'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 222.2 84% 4.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+ --primary-foreground: 210 40% 98%;
+ --secondary: 210 40% 96.1%;
+ --secondary-foreground: 222.2 47.4% 11.2%;
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+ --accent: 210 40% 96.1%;
+ --accent-foreground: 222.2 47.4% 11.2%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 214.3 31.8% 91.4%;
+ --input: 214.3 31.8% 91.4%;
+ --ring: 222.2 84% 4.9%;
+}
+
+[data-theme='gray'] {
+ /* --background: 0 0% 100%; */
+ --foreground: 224 71.4% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 224 71.4% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 224 71.4% 4.1%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 220 14.3% 95.9%;
+ --secondary-foreground: 220.9 39.3% 11%;
+ --muted: 220 14.3% 95.9%;
+ --muted-foreground: 220 8.9% 46.1%;
+ --accent: 220 14.3% 95.9%;
+ --accent-foreground: 220.9 39.3% 11%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 220 13% 91%;
+ --input: 220 13% 91%;
+ --ring: 224 71.4% 4.1%;
+}
+```
+
+:::
+
+::: details 内置主题css变量 - dark
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ /* Default background color of ...etc */
+ --background: 222.34deg 10.43% 12.27%;
+
+ /* 主体区域背景色 */
+ --background-deep: 220deg 13.06% 9%;
+ --foreground: 0 0% 95%;
+
+ /* Background color for */
+ --card: 222.34deg 10.43% 12.27%;
+
+ /* --card: 222.2 84% 4.9%; */
+ --card-foreground: 210 40% 98%;
+
+ /* Background color for popovers such as , , */
+ --popover: 222.82deg 8.43% 12.27%;
+ --popover-foreground: 210 40% 98%;
+
+ /* Muted backgrounds such as , and */
+
+ /* --muted: 220deg 6.82% 17.25%; */
+
+ /* --muted-foreground: 215 20.2% 65.1%; */
+
+ --muted: 240 3.7% 15.9%;
+ --muted-foreground: 240 5% 64.9%;
+
+ /* 主题颜色 */
+
+ /* --primary: 245 82% 67%; */
+ --primary-foreground: 0 0% 98%;
+
+ /* Used for destructive actions such as */
+
+ --destructive: 0 78% 68%;
+ --destructive-foreground: 0 0% 98%;
+
+ /* Used for success actions such as */
+
+ --success: 144 57% 58%;
+ --success-foreground: 0 0% 98%;
+
+ /* Used for warning actions such as */
+
+ --warning: 42 84% 61%;
+ --warning-foreground: 0 0% 98%;
+
+ /* 颜色次要 */
+ --secondary: 240 5% 17%;
+ --secondary-foreground: 0 0% 98%;
+
+ /* Used for accents such as hover effects on , ...etc */
+ --accent: 216 5% 19%;
+ --accent-hover: 216 5% 24%;
+ --accent-foreground: 0 0% 98%;
+
+ /* Darker color */
+ --heavy: 216 5% 24%;
+ --heavy-foreground: var(--accent-foreground);
+
+ /* Default border color */
+ --border: 240 3.7% 22%;
+
+ /* Border color for inputs such as , , */
+ --input: 0deg 0% 100% / 10%;
+ --input-placeholder: 218deg 11% 65%;
+ --input-background: 0deg 0% 100% / 5%;
+
+ /* Used for focus ring */
+ --ring: 222.2 84% 4.9%;
+
+ /* 基本圆角大小 */
+ --radius: 0.5rem;
+
+ /* ============= Custom ============= */
+
+ /* 遮罩颜色 */
+ --overlay: 0deg 0% 0% / 40%;
+
+ /* 基本文字大小 */
+ --font-size-base: 16px;
+
+ /* =============component & UI============= */
+
+ --sidebar: 222.34deg 10.43% 12.27%;
+ --sidebar-deep: 220deg 13.06% 9%;
+ --menu: var(--sidebar);
+
+ /* header */
+ --header: 222.34deg 10.43% 12.27%;
+
+ color-scheme: dark;
+}
+
+.dark[data-theme='violet'],
+[data-theme='violet'] .dark {
+ --background: 224 71.4% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 210 20% 98%;
+ --card: 224 71.4% 4.1%;
+ --card-foreground: 210 20% 98%;
+ --popover: 224 71.4% 4.1%;
+ --popover-foreground: 210 20% 98%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 215 27.9% 16.9%;
+ --secondary-foreground: 210 20% 98%;
+ --muted: 215 27.9% 16.9%;
+ --muted-foreground: 217.9 10.6% 64.9%;
+ --accent: 215 27.9% 16.9%;
+ --accent-foreground: 210 20% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 215 27.9% 16.9%;
+ --input: 215 27.9% 16.9%;
+ --ring: 263.4 70% 50.4%;
+ --sidebar: 224 71.4% 4.1%;
+ --sidebar-deep: 224 71.4% 4.1%;
+ --header: 224 71.4% 4.1%;
+}
+
+.dark[data-theme='pink'],
+[data-theme='pink'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 95%;
+ --card: 0 0% 9%;
+ --card-foreground: 0 0% 95%;
+ --popover: 0 0% 9%;
+ --popover-foreground: 0 0% 95%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 15%;
+ --muted-foreground: 240 5% 64.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 85.7% 97.3%;
+ --border: 240 3.7% 15.9%;
+ --input: 240 3.7% 15.9%;
+ --ring: 346.8 77.2% 49.8%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='rose'],
+[data-theme='rose'] .dark {
+ --background: 0 0% 3.9%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 98%;
+ --card: 0 0% 3.9%;
+ --card-foreground: 0 0% 98%;
+ --popover: 0 0% 3.9%;
+ --popover-foreground: 0 0% 98%;
+ --primary-foreground: 0 85.7% 97.3%;
+ --secondary: 0 0% 14.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 14.9%;
+ --muted-foreground: 0 0% 63.9%;
+ --accent: 0 0% 14.9%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 0 0% 14.9%;
+ --input: 0 0% 14.9%;
+ --ring: 0 72.2% 50.6%;
+ --sidebar: 0 0% 3.9%;
+ --sidebar-deep: 0 0% 3.9%;
+ --header: 0 0% 3.9%;
+}
+
+.dark[data-theme='sky-blue'],
+[data-theme='sky-blue'] .dark {
+ --background: 222.2 84% 4.9%;
+ --background-deep: var(--background);
+ --foreground: 210 40% 98%;
+ --card: 222.2 84% 4.9%;
+ --card-foreground: 210 40% 98%;
+ --popover: 222.2 84% 4.9%;
+ --popover-foreground: 210 40% 98%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 217.2 32.6% 17.5%;
+ --secondary-foreground: 210 40% 98%;
+ --muted: 217.2 32.6% 17.5%;
+ --muted-foreground: 215 20.2% 65.1%;
+ --accent: 217.2 32.6% 17.5%;
+ --accent-foreground: 210 40% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 217.2 32.6% 17.5%;
+ --input: 217.2 32.6% 17.5%;
+ --ring: 224.3 76.3% 48%;
+ --sidebar: 222.2 84% 4.9%;
+ --sidebar-deep: 222.2 84% 4.9%;
+ --header: 222.2 84% 4.9%;
+}
+
+.dark[data-theme='deep-blue'],
+[data-theme='deep-blue'] .dark {
+ --background: 222.2 84% 4.9%;
+ --background-deep: var(--background);
+ --foreground: 210 40% 98%;
+ --card: 222.2 84% 4.9%;
+ --card-foreground: 210 40% 98%;
+ --popover: 222.2 84% 4.9%;
+ --popover-foreground: 210 40% 98%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 217.2 32.6% 17.5%;
+ --secondary-foreground: 210 40% 98%;
+ --muted: 217.2 32.6% 17.5%;
+ --muted-foreground: 215 20.2% 65.1%;
+ --accent: 217.2 32.6% 17.5%;
+ --accent-foreground: 210 40% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 217.2 32.6% 17.5%;
+ --input: 217.2 32.6% 17.5%;
+ --ring: 224.3 76.3% 48%;
+ --sidebar: 222.2 84% 4.9%;
+ --sidebar-deep: 222.2 84% 4.9%;
+ --header: 222.2 84% 4.9%;
+}
+
+.dark[data-theme='green'],
+[data-theme='green'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 95%;
+ --card: 24 9.8% 6%;
+ --card-foreground: 0 0% 95%;
+ --popover: 0 0% 9%;
+ --popover-foreground: 0 0% 95%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 15%;
+ --muted-foreground: 240 5% 64.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 85.7% 97.3%;
+ --border: 240 3.7% 15.9%;
+ --input: 240 3.7% 15.9%;
+ --ring: 142.4 71.8% 29.2%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='deep-green'],
+[data-theme='deep-green'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 95%;
+ --card: 24 9.8% 6%;
+ --card-foreground: 0 0% 95%;
+ --popover: 0 0% 9%;
+ --popover-foreground: 0 0% 95%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 15%;
+ --muted-foreground: 240 5% 64.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 85.7% 97.3%;
+ --border: 240 3.7% 15.9%;
+ --input: 240 3.7% 15.9%;
+ --ring: 142.4 71.8% 29.2%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='orange'],
+[data-theme='orange'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 60 9.1% 97.8%;
+ --card: 20 14.3% 4.1%;
+ --card-foreground: 60 9.1% 97.8%;
+ --popover: 20 14.3% 4.1%;
+ --popover-foreground: 60 9.1% 97.8%;
+ --primary-foreground: 60 9.1% 97.8%;
+ --secondary: 12 6.5% 15.1%;
+ --secondary-foreground: 60 9.1% 97.8%;
+ --muted: 12 6.5% 15.1%;
+ --muted-foreground: 24 5.4% 63.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 60 9.1% 97.8%;
+ --destructive: 0 72.2% 50.6%;
+ --destructive-foreground: 60 9.1% 97.8%;
+ --border: 12 6.5% 15.1%;
+ --input: 12 6.5% 15.1%;
+ --ring: 20.5 90.2% 48.2%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='yellow'],
+[data-theme='yellow'] .dark {
+ --background: 20 14.3% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 60 9.1% 97.8%;
+ --card: 20 14.3% 4.1%;
+ --card-foreground: 60 9.1% 97.8%;
+ --popover: 20 14.3% 4.1%;
+ --popover-foreground: 60 9.1% 97.8%;
+ --primary-foreground: 26 83.3% 14.1%;
+ --secondary: 12 6.5% 15.1%;
+ --secondary-foreground: 60 9.1% 97.8%;
+ --muted: 12 6.5% 15.1%;
+ --muted-foreground: 24 5.4% 63.9%;
+ --accent: 12 6.5% 15.1%;
+ --accent-foreground: 60 9.1% 97.8%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 60 9.1% 97.8%;
+ --border: 12 6.5% 15.1%;
+ --input: 12 6.5% 15.1%;
+ --ring: 35.5 91.7% 32.9%;
+ --sidebar: 20 14.3% 4.1%;
+ --sidebar-deep: 20 14.3% 4.1%;
+ --header: 20 14.3% 4.1%;
+}
+
+.dark[data-theme='zinc'],
+[data-theme='zinc'] .dark {
+ --background: 240 10% 3.9%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 98%;
+ --card: 240 10% 3.9%;
+ --card-foreground: 0 0% 98%;
+ --popover: 240 10% 3.9%;
+ --popover-foreground: 0 0% 98%;
+ --primary-foreground: 240 5.9% 10%;
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 240 3.7% 15.9%;
+ --muted-foreground: 240 5% 64.9%;
+ --accent: 240 3.7% 15.9%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 3.7% 15.9%;
+ --input: 240 3.7% 15.9%;
+ --ring: 240 4.9% 83.9%;
+ --sidebar: 240 10% 3.9%;
+ --sidebar-deep: 240 10% 3.9%;
+ --header: 240 4.9% 83.9%;
+}
+
+.dark[data-theme='neutral'],
+[data-theme='neutral'] .dark {
+ --background: 0 0% 3.9%;
+ --background-deep: var(--background);
+ --foreground: 0 0% 98%;
+ --card: 0 0% 3.9%;
+ --card-foreground: 0 0% 98%;
+ --popover: 0 0% 3.9%;
+ --popover-foreground: 0 0% 98%;
+ --primary-foreground: 0 0% 9%;
+ --secondary: 0 0% 14.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 14.9%;
+ --muted-foreground: 0 0% 63.9%;
+ --accent: 0 0% 14.9%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 0 0% 14.9%;
+ --input: 0 0% 14.9%;
+ --ring: 0 0% 83.1%;
+ --sidebar: 0 0% 3.9%;
+ --sidebar-deep: 0 0% 3.9%;
+ --header: 0 0% 3.9%;
+}
+
+.dark[data-theme='slate'],
+[data-theme='slate'] .dark {
+ --background: 222.2 84% 4.9%;
+ --background-deep: var(--background);
+ --foreground: 210 40% 98%;
+ --card: 222.2 84% 4.9%;
+ --card-foreground: 210 40% 98%;
+ --popover: 222.2 84% 4.9%;
+ --popover-foreground: 210 40% 98%;
+ --primary-foreground: 222.2 47.4% 11.2%;
+ --secondary: 217.2 32.6% 17.5%;
+ --secondary-foreground: 210 40% 98%;
+ --muted: 217.2 32.6% 17.5%;
+ --muted-foreground: 215 20.2% 65.1%;
+ --accent: 217.2 32.6% 17.5%;
+ --accent-foreground: 210 40% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 40% 98%;
+ --border: 217.2 32.6% 17.5%;
+ --input: 217.2 32.6% 17.5%;
+ --ring: 212.7 26.8% 83.9;
+ --sidebar: 222.2 84% 4.9%;
+ --sidebar-deep: 222.2 84% 4.9%;
+ --header: 222.2 84% 4.9%;
+}
+
+.dark[data-theme='gray'],
+[data-theme='gray'] .dark {
+ --background: 224 71.4% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 210 20% 98%;
+ --card: 224 71.4% 4.1%;
+ --card-foreground: 210 20% 98%;
+ --popover: 224 71.4% 4.1%;
+ --popover-foreground: 210 20% 98%;
+ --primary-foreground: 220.9 39.3% 11%;
+ --secondary: 215 27.9% 16.9%;
+ --secondary-foreground: 210 20% 98%;
+ --muted: 215 27.9% 16.9%;
+ --muted-foreground: 217.9 10.6% 64.9%;
+ --accent: 215 27.9% 16.9%;
+ --accent-foreground: 210 20% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 215 27.9% 16.9%;
+ --input: 215 27.9% 16.9%;
+ --ring: 216 12.2% 83.9%;
+ --sidebar: 224 71.4% 4.1%;
+ --sidebar-deep: 224 71.4% 4.1%;
+ --header: 224 71.4% 4.1%;
+}
+```
+
+:::
+
+## 新增主题
+
+想要新增主题,只需按照以下步骤进行:
+
+- 在应用的 `src/preferences.ts`内新增一个主题配置。
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ theme: {
+ builtinType: 'my-theme',
+ },
+});
+```
+
+- 在你的css文件中,新增主题的css变量。
+
+```css
+/* light */
+[data-theme='my-theme'] {
+ --foreground: 224 71.4% 4.1%;
+ --card: 0 0% 100%;
+ --card-foreground: 224 71.4% 4.1%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 224 71.4% 4.1%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 220 14.3% 95.9%;
+ --secondary-foreground: 220.9 39.3% 11%;
+ --muted: 220 14.3% 95.9%;
+ --muted-foreground: 220 8.9% 46.1%;
+ --accent: 220 14.3% 95.9%;
+ --accent-foreground: 220.9 39.3% 11%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 220 13% 91%;
+ --input: 220 13% 91%;
+ --ring: 262.1 83.3% 57.8%;
+}
+
+/* dark */
+.dark[data-theme='my-theme'],
+[data-theme='my-theme'] .dark {
+ --background: 224 71.4% 4.1%;
+ --background-deep: var(--background);
+ --foreground: 210 20% 98%;
+ --card: 224 71.4% 4.1%;
+ --card-foreground: 210 20% 98%;
+ --popover: 224 71.4% 4.1%;
+ --popover-foreground: 210 20% 98%;
+ --primary-foreground: 210 20% 98%;
+ --secondary: 215 27.9% 16.9%;
+ --secondary-foreground: 210 20% 98%;
+ --muted: 215 27.9% 16.9%;
+ --muted-foreground: 217.9 10.6% 64.9%;
+ --accent: 215 27.9% 16.9%;
+ --accent-foreground: 210 20% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 20% 98%;
+ --border: 215 27.9% 16.9%;
+ --input: 215 27.9% 16.9%;
+ --ring: 263.4 70% 50.4%;
+ --sidebar: 224 71.4% 4.1%;
+ --sidebar-deep: 224 71.4% 4.1%;
+}
+```
+
+## 黑暗模式
+
+框架中内置了多种主题,你可以在`preferences.ts`中进行配置,黑暗主题同样会读取css变量来进行配置:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ theme: {
+ mode: 'dark',
+ },
+});
+```
+
+## 自定义侧边栏颜色
+
+侧边栏颜色通过`--sidebar`变量来配置
+
+### 默认主题下
+
+```css
+:root {
+ --sidebar: 0 0% 100%;
+}
+```
+
+### 黑暗模式下
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ --sidebar: 222.34deg 10.43% 12.27%;
+}
+```
+
+## 自定义顶栏颜色
+
+侧边栏颜色通过`--header`变量来配置
+
+### 默认主题下
+
+```css
+:root {
+ --header: 0 0% 100%;
+}
+```
+
+### 黑暗模式下
+
+```css
+.dark,
+.dark[data-theme='custom'],
+.dark[data-theme='default'] {
+ --header: 222.34deg 10.43% 12.27%;
+}
+```
+
+## 色弱模式
+
+一般用于特殊场景,将设置为色弱模式,你可以在`preferences.ts`中进行配置:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ colorWeakMode: true,
+ },
+});
+```
+
+## 灰色模式
+
+一般用于特殊场景,将网页置灰,你可以在`preferences.ts`中进行配置:
+
+```ts
+import { defineOverridesPreferences } from '@vben/preferences';
+
+export const overridesPreferences = defineOverridesPreferences({
+ // overrides
+ app: {
+ colorGrayMode: true,
+ },
+});
+```
diff --git a/apps/vben5/docs/src/guide/in-depth/ui-framework.md b/apps/vben5/docs/src/guide/in-depth/ui-framework.md
new file mode 100644
index 000000000..ce05608fc
--- /dev/null
+++ b/apps/vben5/docs/src/guide/in-depth/ui-framework.md
@@ -0,0 +1,17 @@
+# 组件库切换
+
+`Vue Admin` 支持你自由选择组件库,目前演示站点的默认组件库是 `Ant Design Vue`,与旧版本保持一致。同时框架还内置了 `Element Plus` 版本和 `Naive UI` 版本,你可以根据自己的喜好选择。
+
+## 新增组件库应用
+
+如果你想用其他别的组件库,你只需要按一下步骤进行操作:
+
+1. 在`apps`内创建一个新的文件夹,例如`apps/web-xxx`。
+2. 更改`apps/web-xxx/package.json`的`name`字段为`web-xxx`。
+3. 移除其他组件库依赖及代码,并用你的组件库进行替换相应逻辑,需要改动的地方不多。
+4. 调整`locales`内的语言文件。
+5. 调整 `app.vue` 内的组件。
+6. 自行适配组件库的主题,与 `Vben Admin` 契合。
+7. 调整 `.env` 内的应用名
+8. 在大仓根目录增加 `dev:xxx` 脚本
+9. 执行 `pnpm install` 安装依赖
diff --git a/apps/vben5/docs/src/guide/introduction/changelog.md b/apps/vben5/docs/src/guide/introduction/changelog.md
new file mode 100644
index 000000000..782056b43
--- /dev/null
+++ b/apps/vben5/docs/src/guide/introduction/changelog.md
@@ -0,0 +1,3 @@
+# 更新日志
+
+TODO
diff --git a/apps/vben5/docs/src/guide/introduction/quick-start.md b/apps/vben5/docs/src/guide/introduction/quick-start.md
new file mode 100644
index 000000000..747c52483
--- /dev/null
+++ b/apps/vben5/docs/src/guide/introduction/quick-start.md
@@ -0,0 +1,111 @@
+---
+outline: deep
+---
+
+# 快速开始 {#quick-start}
+
+## 前置准备
+
+::: info 环境要求
+
+在启动项目前,你需要确保你的环境满足以下要求:
+
+- [Node.js](https://nodejs.org/en) 20.15.0 及以上版本,推荐使用 [fnm](https://github.com/Schniz/fnm) 、 [nvm](https://github.com/nvm-sh/nvm) 或者直接使用[pnpm](https://pnpm.io/cli/env) 进行版本管理。
+- [Git](https://git-scm.com/) 任意版本。
+
+验证你的环境是否满足以上要求,你可以通过以下命令查看版本:
+
+```bash
+# 出现相应 node LTS版本即可
+node -v
+# 出现相应 git 版本即可
+git -v
+```
+
+:::
+
+## 启动项目
+
+### 获取源码
+
+::: code-group
+
+```sh [GitHub]
+# clone 代码
+git clone https://github.com/vbenjs/vue-vben-admin.git
+```
+
+```sh [Gitee]
+# clone 代码
+# Gitee 的代码可能不是最新的
+git clone https://gitee.com/annsion/vue-vben-admin.git
+```
+
+:::
+
+::: danger 注意
+
+注意存放代码的目录及所有父级目录不能存在中文、韩文、日文以及空格,否则安装依赖后启动会出错。
+
+:::
+
+### 安装依赖
+
+在你的代码目录内打开终端,并执行以下命令:
+
+```bash
+# 进入项目目录
+cd vue-vben-admin
+
+# 使用项目指定的pnpm版本进行依赖安装
+corepack enable
+
+# 安装依赖
+pnpm install
+```
+
+::: tip 注意
+
+- 项目只支持使用 `pnpm` 进行依赖安装,默认会使用 `corepack` 来安装指定版本的 `pnpm`。:
+- 如果你的网络环境无法访问npm源,你可以设置系统的环境变量`COREPACK_REGISTRY=https://registry.npmmirror.com`,然后再执行`pnpm install`。
+- 如果你不想使用`corepack`,你需要禁用`corepack`,然后使用你自己的`pnpm`进行安装。
+
+:::
+
+### 运行项目
+
+#### 选择项目
+
+执行以下命令运行项目:
+
+```bash
+# 启动项目
+pnpm dev
+```
+
+此时,你会看到类似如下的输出,选择你需要运行的项目:
+
+```bash
+│
+◆ Select the app you need to run [dev]:
+│ ○ @vben/web-antd
+│ ○ @vben/web-ele
+│ ○ @vben/web-naive
+│ ○ @vben/docs
+│ ● @vben/playground
+└
+```
+
+现在,你可以在浏览器访问 `http://localhost:5555` 查看项目。
+
+#### 运行指定项目
+
+如果你不想选择项目,可以直接运行以下命令运行你需要的应用:
+
+```bash
+pnpm run dev:antd
+pnpm run dev:ele
+pnpm run dev:naive
+pnpm run dev:docs
+pnpm run dev:play
+```
diff --git a/apps/vben5/docs/src/guide/introduction/roadmap.md b/apps/vben5/docs/src/guide/introduction/roadmap.md
new file mode 100644
index 000000000..6aa989645
--- /dev/null
+++ b/apps/vben5/docs/src/guide/introduction/roadmap.md
@@ -0,0 +1,3 @@
+# 路线图
+
+TODO:
diff --git a/apps/vben5/docs/src/guide/introduction/thin.md b/apps/vben5/docs/src/guide/introduction/thin.md
new file mode 100644
index 000000000..4db0e3b3f
--- /dev/null
+++ b/apps/vben5/docs/src/guide/introduction/thin.md
@@ -0,0 +1,94 @@
+---
+outline: deep
+---
+
+# 精简版本
+
+从 `5.0` 版本开始,我们不再提供精简的仓库或者分支。我们的目标是提供一个更加一致的开发体验,同时减少维护成本。在这里,我们将如何介绍自己的项目,如何去精简以及移除不需要的功能。
+
+## 应用精简
+
+首先,确认你需要的 `UI` 组件库版本,然后删除对应的应用,比如你选择使用 `Ant Design Vue`,那么你可以删除其他应用, 只需要删除下面两个文件夹即可:
+
+```bash
+apps/web-ele
+apps/web-naive
+
+```
+
+::: tip
+
+如果项目没有内置你需要的 `UI` 组件库应用,你可以直接全部删除其他应用。然后自行新建应用即可。
+
+:::
+
+## 演示代码精简
+
+如果你不需要演示代码,你可以直接删除的`playground`文件夹。
+
+## 文档精简
+
+如果你不需要文档,你可以直接删除`docs`文件夹。
+
+## Mock 服务精简
+
+如果你不需要`Mock`服务,你可以直接删除`apps/backend-mock`文件夹。同时在你的应用下`.env.development`文件中删除`VITE_NITRO_MOCK`变量。
+
+```bash
+# 是否开启 Nitro Mock服务,true 为开启,false 为关闭
+VITE_NITRO_MOCK=false
+```
+
+## 安装依赖
+
+到这里,你已经完成了精简操作,接下来你可以安装依赖,并启动你的项目:
+
+```bash
+# 根目录下执行
+pnpm install
+
+```
+
+## 命令调整
+
+在精简后,你可能需要根据你的项目调整命令,在根目录下的`package.json`文件中,你可以调整`scripts`字段,移除你不需要的命令。
+
+```json
+{
+ "scripts": {
+ "build:antd": "pnpm run build --filter=@vben/web-antd",
+ "build:docs": "pnpm run build --filter=@vben/docs",
+ "build:ele": "pnpm run build --filter=@vben/web-ele",
+ "build:naive": "pnpm run build --filter=@vben/web-naive",
+ "build:play": "pnpm run build --filter=@vben/playground",
+ "dev:antd": "pnpm -F @vben/web-antd run dev",
+ "dev:docs": "pnpm -F @vben/docs run dev",
+ "dev:ele": "pnpm -F @vben/web-ele run dev",
+ "dev:play": "pnpm -F @vben/playground run dev",
+ "dev:naive": "pnpm -F @vben/web-naive run dev"
+ }
+}
+```
+
+## 其他
+
+如果你想更进一步精简,你可以删除参考一下文件或者文件夹的作用,判断自己是否需要,不需要删除即可:
+
+- `.changeset` 文件夹用于管理版本变更
+- `.github` 文件夹用于存放 GitHub 的配置文件
+- `.vscode` 文件夹用于存放 VSCode 的配置文件,如果你使用其他编辑器,可以删除
+- `./scripts/deploy` 文件夹用于存放部署脚本,如果你不需要docker部署,可以删除
+
+## 应用精简
+
+当你确定了某个应用,你还可以进一步精简:
+
+### 删除不需要的路由及页面
+
+- 在应用的 `src/router/routes` 文件中,你可以删除不需要的路由。其中 `core` 文件夹内,如果只需要登录和忘记密码,你可以删除其他路由,如忘记密码、注册等。路由删除后,你可以删除对应的页面文件,在 `src/views/_core` 文件夹中。
+
+- 在应用的 `src/router/routes` 文件中,你可以按需求删除不需要的路由,如`demos`、`vben` 目录等。路由删除后,你可以删除对应的页面文件,在 `src/views` 文件夹中。
+
+### 删除不需要的组件
+
+- 在应用的 `packages/effects/common-ui/src/ui` 文件夹中,你可以删除不需要的组件,如`about`、`dashboard` 目录等。删除之前请先确保你的路由中没有引用到这些组件。
diff --git a/apps/vben5/docs/src/guide/introduction/vben.md b/apps/vben5/docs/src/guide/introduction/vben.md
new file mode 100644
index 000000000..a4a5f975c
--- /dev/null
+++ b/apps/vben5/docs/src/guide/introduction/vben.md
@@ -0,0 +1,49 @@
+# 关于 Vben Admin
+
+::: info 你正在阅读的是 [Vben Admin](https://github.com/vbenjs/vue-vben-admin) `5.0`版本的文档!
+
+- Vben Admin 2.x 目前已存档,仅进行重大问题修复。
+- 新版本与旧版本不兼容,如果你使用的是旧版本(v2、v3),请查看 [Vue Vben Admin 2.x 文档](https://doc.vvbin.cn)
+- 如发现文档有误,欢迎提交 [issue](https://github.com/vbenjs/vue-vben-admin/issues) 帮助我们改进。
+- 如果你只是想体验一下,你可以查看[快速开始](./quick-start.md)。
+
+:::
+
+[Vben Admin](https://github.com/vbenjs/vue-vben-admin) 是一个基于 [Vue3.0](https://github.com/vuejs/core)、[Vite](https://github.com/vitejs/vite)、 [TypeScript](https://www.typescriptlang.org/) 的中后台解决方案,目标是为开发中大型项目提供开箱即用的解决方案。包括二次封装组件、utils、hooks、动态菜单、权限校验、多主题配置、按钮级别权限控制等功能。项目会使用前端较新的技术栈,可以作为项目的启动模板,以帮助你快速搭建企业级中后台产品原型。也可以作为一个示例,用于学习 `vue3`、`vite`、`ts` 等主流技术。该项目会持续跟进最新技术,并将其应用在项目中。
+
+## 特点
+
+- **最新技术栈**:使用 `Vue3`、`Vite`、`TypeScript` 等前端前沿技术开发。
+- **国际化**:内置完善的国际化方案,支持多语言切换。
+- **权限验证**:完善的权限验证方案,按钮级别权限控制。
+- **多主题**:内置多种主题配置和黑暗模式,满足个性化需求。
+- **动态菜单**:支持动态菜单,可以根据权限配置显示菜单。
+- **Mock 数据**:基于 `Nitro` 的本地高性能 Mock 数据方案。
+- **组件丰富**:提供了丰富的组件,可以满足大部分的业务需求。
+- **规范**:代码规范,使用 `ESLint`、`Prettier`、`Stylelint`、`Publint`、`CSpell` 等工具保证代码质量。
+- **工程化**:使用 `Pnpm Monorepo`、`TurboRepo`、`Changeset` 等工具,提高开发效率。
+- **多UI库支持**:支持 `Ant Design Vue`、`Element Plus`、`Naive` 等主流 UI 库,不再限制于特定框架。
+
+## 浏览器支持
+
+- **本地开发**推荐使用`Chrome 最新版`浏览器,**不支持**`Chrome 80`以下版本。
+
+- **生产环境**支持现代浏览器,不支持 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 |
+| :-: | :-: | :-: | :-: | :-: |
+| 不支持 | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
+
+## 贡献
+
+- [Vben Admin](https://github.com/vbenjs/vue-vben-admin) 还在持续更新中,本项目欢迎您的参与,共同维护,逐步完善,打造更好的中后台解决方案。
+- 如果你有兴趣加入我们,可以通过以下方式开始,我们会根据你的活跃度邀请你加入。
+
+::: info 加入我们
+
+- 长期提交 `PR`。
+- 提供有价值的建议。
+- 参与讨论,帮助解决 `issue`。
+- 共同维护文档。
+
+:::
diff --git a/apps/vben5/docs/src/guide/introduction/why.md b/apps/vben5/docs/src/guide/introduction/why.md
new file mode 100644
index 000000000..4191b3ef6
--- /dev/null
+++ b/apps/vben5/docs/src/guide/introduction/why.md
@@ -0,0 +1,23 @@
+# 为什么选择我们?
+
+::: info 写在前面
+
+我们不会去和其他框架做比较。我们认为每个框架都有自己的特点,适合不同的场景。我们的目标是提供一个简单、易用的框架,让开发者可以快速上手,专注于业务逻辑的开发。所以我们只会不断完善和优化我们的框架,提供更好的体验。
+
+:::
+
+我们致力于为开发者提供一个高效、现代、易用的前端框架。我们的解决方案基于最新的技术栈,如 Vue3、Vite 和 TypeScript,确保您在构建项目时始终走在技术的前沿。同时,我们注重代码的质量与规范,通过严格的工具链保证代码的一致性和可维护性。无论是初创项目还是企业级应用,我们的框架都能帮助您快速构建、迭代和部署。
+
+## 框架历程
+
+从 Vue Vben Admin 1.x 版本开始,框架经历了许多迭代和优化。从一开始使用 `Vite 0.x` 版本,没有现成的插件,开发了很多自定义插件来弥合 Webpack 和 Vite 之间的差异。虽然很多现在已经被代替,但是我们的初衷一直没有变,就是提供一个简单、易用的框架。
+
+虽然中间有段时间由社区维护,但我们一直密切关注 Vue Vben Admin 的发展。见证了许多开发者使用 Vben Admin,并提供了许多宝贵的建议和反馈。非常感谢大家的支持和贡献,这些都是我们持续改进 Vben Admin 的动力。新版本中,我们持续收集用户反馈,重新开始,不断优化框架,以提供更好的用户体验。我们的目标是让开发者能够快速上手,专注于业务逻辑的开发。
+
+## 单元测试
+
+单元测试是确保代码质量的基石。在开发过程中编写和执行单元测试,以捕捉潜在的错误并提升代码的可靠性。框架核心逻辑使用 `vitest` 做了单元测试,并在逐步增加覆盖率。通过单元测试,可以放心地进行代码重构,减少回归问题,从而提高整体开发效率。
+
+## 质量与规范
+
+我们始终高度重视代码的质量与规范。通过使用 ESLint、Prettier、Stylelint、Publint、CSpell 等工具来确保代码质量。我们的代码规范基于 Vue3、Vite、TypeScript 等现代前端技术制定,旨在提供一个简洁、易用的框架,使开发者能够快速上手并专注于业务逻辑的开发。
diff --git a/apps/vben5/docs/src/guide/other/faq.md b/apps/vben5/docs/src/guide/other/faq.md
new file mode 100644
index 000000000..02bbe8b06
--- /dev/null
+++ b/apps/vben5/docs/src/guide/other/faq.md
@@ -0,0 +1,159 @@
+# 常见问题 #{faq}
+
+::: tip 列举了一些常见的问题
+
+有问题可以先来这里寻找,如果没有可以在 [GitHub Issue](https://github.com/vbenjs/vue-vben-admin/issues) 搜索或者提交你的问题, 如果是讨论性的问题可以在 [GitHub Discussions](https://github.com/vbenjs/vue-vben-admin/discussions)
+
+:::
+
+## 说明
+
+遇到问题,可以先从以下几个方面查找
+
+1. 对应模块的 GitHub 仓库 [issue](https://github.com/vbenjs/vue-vben-admin/issues) 搜索
+2. 从[google](https://www.google.com)搜索问题
+3. 从[百度](https://www.baidu.com)搜索问题
+4. 在下面列表找不到问题可以到 issue 提问 [issues](https://github.com/vbenjs/vue-vben-admin/issues)
+5. 如果不是问题类型的,需要讨论的,请到 [discussions](https://github.com/vbenjs/vue-vben-admin/discussions) 讨论
+
+## 依赖问题
+
+在 `Monorepo` 项目下,需要养成每次 `git pull`代码都要执行`pnpm install`的习惯,因为经常会有新的依赖包加入,项目在`.husky/git-merge`已经配置了自动执行`pnpm install`,但是有时候会出现问题,如果没有自动执行,建议手动执行一次。
+
+## 关于缓存更新问题
+
+项目配置默认是缓存在 `localStorage` 内,所以版本更新后可能有些配置没改变。
+
+解决方式是每次更新代码的时候修改 `package.json` 内的 `version` 版本号. 因为 localStorage 的 key 是根据版本号来的。所以更新后版本不同前面的配置会失效。重新登录即可
+
+## 关于修改配置文件的问题
+
+当修改 `.env` 等环境文件以及 `vite.config.ts` 文件时,vite 会自动重启服务。
+
+自动重启有几率出现问题,请重新运行项目即可解决.
+
+## 本地运行报错
+
+由于 vite 在本地没有转换代码,且代码中用到了可选链等比较新的语法。所以本地开发需要使用版本较高的浏览器(`Chrome 90+`)进行开发
+
+## 页面切换后页面空白
+
+这是由于开启了路由切换动画,且对应的页面组件存在多个根节点导致的,在页面最外层添加`
`即可
+
+**错误示例**
+
+```vue
+
+
+ text h1
+ text h2
+
+```
+
+**正确示例**
+
+```vue
+
+
+
text h1
+ text h2
+
+
+```
+
+::: tip 提示
+
+- 如果想使用多个根标签,可以禁用路由切换动画
+- template 下面的根注释节点也算一个节点
+
+:::
+
+## 我的代码本地开发可以,打包就不行了
+
+目前发现这个原因可能有以下,可以从以下原因来排查,如果还有别的可能,欢迎补充
+
+- 使用了 ctx 这个变量,ctx 本身未暴露出在实例类型内,Vue官方也是说了不要用这个属性。这个属性只是用于内部使用。
+
+```ts
+import { getCurrentInstance } from 'vue';
+getCurrentInstance().ctx.xxxx;
+```
+
+## 依赖安装问题
+
+- 如果依赖安装不了或者启动报错可以尝试执行`pnpm run reinstall`。
+- 如果依赖安装不了或者报错,可以尝试切换手机热点来进行依赖安装。
+- 如果还是不行,可以自行配置国内镜像安装。
+- 也可以在项目根目录创建 `.npmrc` 文件,内容如下
+
+```bash
+# .npmrc
+registry = https://registry.npmmirror.com/
+```
+
+## 打包文件过大
+
+- 首先,完整版由于引用了比较多的库文件,所以打包会比较大。可以使用精简版来进行开发
+
+- 其次建议开启 gzip,使用之后体积会只有原先 1/3 左右。gzip 可以由服务器直接开启。如果是这样,前端不需要构建 `.gz` 格式的文件,如果前端构建了 `.gz` 文件,以 nginx 为例,nginx 需要开启 `gzip_static: on` 这个选项。
+
+- 开启 gzip 的同时还可以同时开启 `brotli`,比 gzip 更好的压缩。两者可以共存
+
+**注意**
+
+- gzip_static: 这个模块需要 nginx 另外安装,默认的 nginx 没有安装这个模块。
+
+- 开启 `brotli` 也需要 nginx 另外安装模块
+
+## 运行错误
+
+如果出现类似以下错误,请检查项目全路径(包含所有父级路径)不能出现中文、日文、韩文。否则将会出现路径访问 404 导致以下问题
+
+```ts
+[vite] Failed to resolve module import "ant-design-vue/dist/antd.css-vben-adminode_modulesant-design-vuedistantd.css". (imported by /@/setup/ant-design-vue/index.ts)
+```
+
+## 控制台路由警告问题
+
+如果看到控制台有如下警告,且页面**能正常打开** 可以忽略该警告。
+
+后续 `vue-router` 可能会提供配置项来关闭警告
+
+```ts
+[Vue Router warn]: No match found for location with path "xxxx"
+```
+
+## 启动报错
+
+当出现以下错误信息时,请检查你的 nodejs 版本号是否符合要求
+
+```bash
+TypeError: str.matchAll is not a function
+at Object.extractor (vue-vben-admin-main\node_modules@purge-icons\core\dist\index.js:146:27)
+at Extract (vue-vben-admin-main\node_modules@purge-icons\core\dist\index.js:173:54)
+```
+
+## nginx 部署
+
+部署到 `nginx`后,可能会出现以下错误:
+
+```bash
+Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.
+```
+
+解决方式一:
+
+```bash
+http {
+ #如果有此项配置需要注释掉
+ #include mime.types;
+
+ types {
+ application/javascript js mjs;
+ }
+}
+```
+
+解决方式二:
+
+进入 `nginx` 下的`mime.types`文件, 将`application/javascript js;` 修改为 `application/javascript js mjs;`
diff --git a/apps/vben5/docs/src/guide/other/project-update.md b/apps/vben5/docs/src/guide/other/project-update.md
new file mode 100644
index 000000000..a4030422a
--- /dev/null
+++ b/apps/vben5/docs/src/guide/other/project-update.md
@@ -0,0 +1,55 @@
+# 项目更新
+
+## 为什么无法像 npm 插件一样更新
+
+因为项目是一个完整的项目模版,不是一个插件或者安装包,无法像插件一样更新,你使用代码后,会根据业务需求,进行二次开发,需要自行手动合并升级。
+
+## 我需要怎么做
+
+项目采用了 `Monorepo` 的方式进行管理,并将一些比较核心的代码进行了抽离,比如 `packages/@core`、`packages/effects`,只要业务代码没有修改这部分代码,那么你可以直接拉取最新代码,然后合并到你的分支上,只需要简单的处理部分冲突即可。其余文件夹只会进行一些小的调整,不会对业务代码产生影响。
+
+::: tip 推荐
+
+建议关注仓库动态,积极去合并,不要长时间积累,否则将会导致合并冲突过多,增加合并难度。
+
+:::
+
+## 使用 Git 更新代码
+
+1. 克隆代码
+
+```bash
+git clone https://github.com/vbenjs/vue-vben-admin.git
+```
+
+2. 添加自己的公司 git 源地址
+
+```bash
+# up 为源名称,可以随意设置
+# gitUrl为开源最新代码
+git remote add up gitUrl;
+```
+
+3. 提交代码到自己公司 git
+
+```bash
+# 提交代码到自己公司
+# main为分支名 需要自行根据情况修改
+git push up main
+
+# 同步公司的代码
+# main为分支名 需要自行根据情况修改
+git pull up main
+```
+
+4. 如何同步开源最新代码
+
+```bash
+git pull origin main
+```
+
+::: tip 提示
+
+同步代码的时候会出现冲突。只需要把冲突解决即可
+
+:::
diff --git a/apps/vben5/docs/src/guide/other/remove-code.md b/apps/vben5/docs/src/guide/other/remove-code.md
new file mode 100644
index 000000000..832622417
--- /dev/null
+++ b/apps/vben5/docs/src/guide/other/remove-code.md
@@ -0,0 +1,18 @@
+# 移除代码
+
+## 移除百度统计代码
+
+在对应应用的 `index.html` 文件中,找到如下代码,删除即可:
+
+```html
+
+
+```
diff --git a/apps/vben5/docs/src/guide/project/changeset.md b/apps/vben5/docs/src/guide/project/changeset.md
new file mode 100644
index 000000000..cc206ae99
--- /dev/null
+++ b/apps/vben5/docs/src/guide/project/changeset.md
@@ -0,0 +1,21 @@
+# Changeset
+
+项目内置了 [changeset](https://github.com/changesets/changesets) 作为版本管理工具。Changeset 是一个版本管理工具,它可以帮助我们更好的管理版本,生成 changelog,以及自动发布。
+
+详细使用方式可查看官方文档,这里不再阐述。如果你不需要它,可以直接忽略。
+
+## 命令行
+
+changeset 命令在项目中已经内置:
+
+### 交互式填写变更集
+
+```bash
+pnpm run changeset
+```
+
+### 统一提升版本号
+
+```bash
+pnpm run version
+```
diff --git a/apps/vben5/docs/src/guide/project/cli.md b/apps/vben5/docs/src/guide/project/cli.md
new file mode 100644
index 000000000..3e35242c7
--- /dev/null
+++ b/apps/vben5/docs/src/guide/project/cli.md
@@ -0,0 +1,113 @@
+---
+outline: deep
+---
+
+# CLI
+
+项目中,提供了一些命令行工具,用于一些常用的操作,代码位于 `scrips` 内。
+
+## vsh
+
+用于一些项目操作,如清理项目、检查项目等。
+
+### 用法
+
+```bash
+pnpm vsh [command] [options]
+```
+
+### vsh check-circular
+
+检查整个项目循环引用,如果有循环引用,会在控制台输出循环引用的模块。
+
+#### 用法
+
+```bash
+pnpm vsh check-circular
+```
+
+#### 选项
+
+| 选项 | 说明 |
+| ---------- | ----------------------------------- |
+| `--staged` | 只检查git暂存区内的文件,默认`false` |
+
+### vsh check-dep
+
+检查整个项目依赖情况,并在控制台输出`未使用的依赖`、`未安装的依赖`信息
+
+#### 用法
+
+```bash
+pnpm vsh check-dep
+```
+
+#### 选项
+
+| 选项 | 说明 |
+| ---------------- | --------------------------------------- |
+| `-r,--recursive` | 递归删除整个项目,默认`true` |
+| `--del-lock` | 是否删除`pnpm-lock.yaml`文件,默认`true` |
+
+### vsh lint
+
+对项目进行lint检查,检查项目中的代码是否符合规范。
+
+#### 用法
+
+```bash
+pnpm vsh lint
+```
+
+#### 选项
+
+| 选项 | 说明 |
+| ---------- | ------------------------------ |
+| `--format` | 检查并尝试修复错误,默认`false` |
+
+### vsh publint
+
+对 `Monorepo` 项目进行包规范检查,检查项目中的包是否符合规范。
+
+#### 用法
+
+```bash
+pnpm vsh publint
+```
+
+#### 选项
+
+| 选项 | 说明 |
+| --------- | ---------------------- |
+| `--check` | 仅执行检查,默认`false` |
+
+### vsh code-workspace
+
+生成 `vben-admin.code-workspace` 文件,目前不需要手动执行,会在代码提交时自动执行。
+
+#### 用法
+
+```bash
+pnpm vsh code-workspace
+```
+
+#### 选项
+
+| 选项 | 说明 |
+| --------------- | -------------------------------------- |
+| `--auto-commit` | `git commit`时候,自动提交,默认`false` |
+| `--spaces` | 缩进格式,默认 `2`个缩进 |
+
+## turbo-run
+
+用于快速执行大仓中脚本,并提供选项式交互选择。
+
+### 用法
+
+```bash
+pnpm turbo-run [command]
+```
+
+### turbo-run dev
+
+快速执行`dev`命令,并提供选项式交互选择。
diff --git a/apps/vben5/docs/src/guide/project/dir.md b/apps/vben5/docs/src/guide/project/dir.md
new file mode 100644
index 000000000..e653dc2fa
--- /dev/null
+++ b/apps/vben5/docs/src/guide/project/dir.md
@@ -0,0 +1,68 @@
+# 目录说明
+
+目录使用 Monorepo 管理,项目结构如下:
+
+```bash
+.
+├── Dockerfile # Docker 镜像构建文件
+├── README.md # 项目说明文档
+├── apps # 项目应用目录
+│ ├── backend-mock # 后端模拟服务应用
+│ ├── web-antd # 基于 Ant Design Vue 的前端应用
+│ ├── web-ele # 基于 Element Plus 的前端应用
+│ └── web-naive # 基于 Naive UI 的前端应用
+├── build-local-docker-image.sh # 本地构建 Docker 镜像脚本
+├── cspell.json # CSpell 配置文件
+├── docs # 项目文档目录
+├── eslint.config.mjs # ESLint 配置文件
+├── internal # 内部工具目录
+│ ├── lint-configs # 代码检查配置
+│ │ ├── commitlint-config # Commitlint 配置
+│ │ ├── eslint-config # ESLint 配置
+│ │ ├── prettier-config # Prettier 配置
+│ │ └── stylelint-config # Stylelint 配置
+│ ├── node-utils # Node.js 工具
+│ ├── tailwind-config # Tailwind 配置
+│ ├── tsconfig # 通用 tsconfig 配置
+│ └── vite-config # 通用Vite 配置
+├── package.json # 项目依赖配置
+├── packages # 项目包目录
+│ ├── @core # 核心包
+│ │ ├── base # 基础包
+│ │ │ ├── design # 设计相关
+│ │ │ ├── icons # 图标
+│ │ │ ├── shared # 共享
+│ │ │ └── typings # 类型定义
+│ │ ├── composables # 组合式 API
+│ │ ├── preferences # 偏好设置
+│ │ └── ui-kit # UI 组件集合
+│ │ ├── layout-ui # 布局 UI
+│ │ ├── menu-ui # 菜单 UI
+│ │ ├── shadcn-ui # shadcn UI
+│ │ └── tabs-ui # 标签页 UI
+│ ├── constants # 常量
+│ ├── effects # 副作用相关包
+│ │ ├── access # 访问控制
+│ │ ├── plugins # 第三方大型依赖插件
+│ │ ├── common-ui # 通用 UI
+│ │ ├── hooks # 组合式 API
+│ │ ├── layouts # 布局
+│ │ └── request # 请求
+│ ├── icons # 图标
+│ ├── locales # 国际化
+│ ├── preferences # 偏好设置
+│ ├── stores # 状态管理
+│ ├── styles # 样式
+│ ├── types # 类型定义
+│ └── utils # 工具
+├── playground # 演示目录
+├── pnpm-lock.yaml # pnpm 锁定文件
+├── pnpm-workspace.yaml # pnpm 工作区配置文件
+├── scripts # 脚本目录
+│ ├── turbo-run # Turbo 运行脚本
+│ └── vsh # VSH 脚本
+├── stylelint.config.mjs # Stylelint 配置文件
+├── turbo.json # Turbo 配置文件
+├── vben-admin.code-workspace # VS Code 工作区配置文件
+└── vitest.config.ts # Vite 配置文件
+```
diff --git a/apps/vben5/docs/src/guide/project/standard.md b/apps/vben5/docs/src/guide/project/standard.md
new file mode 100644
index 000000000..3effad2ff
--- /dev/null
+++ b/apps/vben5/docs/src/guide/project/standard.md
@@ -0,0 +1,165 @@
+# 规范
+
+::: tip 贡献代码
+
+- 如果你想向项目贡献代码,请确保你的代码符合项目的代码规范。
+- 如果你使用的是 `vscode`,需要安装以下插件:
+
+ - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - 脚本代码检查
+ - [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - 代码格式化
+ - [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) - 单词语法检查
+ - [Stylelint](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint) - css 格式化
+
+:::
+
+## 作用
+
+具备基本工程素养的同学都会注重编码规范,而代码风格检查(Code Linting,简称 Lint)是保障代码规范一致性的重要手段。
+
+遵循相应的代码规范有以下好处:
+
+- 较少 bug 错误率
+- 高效的开发效率
+- 更高的可读性
+
+## 工具
+
+项目的配置文件位于 `internal/lint-configs` 下,你可以在这里修改各种lint的配置。
+
+项目内集成了以下几种代码校验工具:
+
+- [ESLint](https://eslint.org/) 用于 JavaScript 代码检查
+- [Stylelint](https://stylelint.io/) 用于 CSS 样式检查
+- [Prettier](https://prettier.io/) 用于代码格式化
+- [Commitlint](https://commitlint.js.org/) 用于检查 git 提交信息的规范
+- [Publint](https://publint.dev/) 用于检查 npm 包的规范
+- [Lint Staged](https://github.com/lint-staged/lint-staged) 用于在 git 提交前运行代码校验
+- [Cspell](https://cspell.org/) 用于检查拼写错误
+
+## ESLint
+
+ESLint 是一个代码规范和错误检查工具,用于识别和报告 TypeScript 代码中的语法错误。
+
+### 命令
+
+```bash
+pnpm eslint .
+```
+
+### 配置
+
+eslint 配置文件为 `eslint.config.mjs`,其核心配置放在`internal/lint-configs/eslint-config`目录下,可以根据项目需求进行修改。
+
+## Stylelint
+
+Stylelint 用于校验项目内部 css 的风格,加上编辑器的自动修复,可以很好的统一项目内部 css 风格
+
+### 命令
+
+```bash
+pnpm stylelint "**/*.{vue,css,less.scss}"
+```
+
+### 配置
+
+Stylelint 配置文件为 `stylelint.config.mjs`,其核心配置放在`internal/lint-configs/stylelint-config`目录下,可以根据项目需求进行修改。
+
+## Prettier
+
+Prettier 可以用于统一项目代码风格,统一的缩进,单双引号,尾逗号等等风格
+
+### 命令
+
+```bash
+pnpm prettier .
+```
+
+### 配置
+
+Prettier 配置文件为 `.prettier.mjs`,其核心配置放在`internal/lint-configs/prettier-config`目录下,可以根据项目需求进行修改。
+
+## CommitLint
+
+在一个团队中,每个人的 git 的 commit 信息都不一样,五花八门,没有一个机制很难保证规范化,如何才能规范化呢?可能你想到的是 git 的 hook 机制,去写 shell 脚本去实现。这当然可以,其实 JavaScript 有一个很好的工具可以实现这个模板,它就是 commitlint(用于校验 git 提交信息规范)。
+
+### 配置
+
+CommitLint 配置文件为 `.commitlintrc.mjs`,其核心配置放在`internal/lint-configs/commitlint-config`目录下,可以根据项目需求进行修改。
+
+### Git 提交规范
+
+参考 [Angular](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular)
+
+- `feat` 增加新功能
+- `fix` 修复问题/BUG
+- `style` 代码风格相关无影响运行结果的
+- `perf` 优化/性能提升
+- `refactor` 重构
+- `revert` 撤销修改
+- `test` 测试相关
+- `docs` 文档/注释
+- `chore` 依赖更新/脚手架配置修改等
+- `workflow` 工作流改进
+- `ci` 持续集成
+- `types` 类型修改
+
+### 关闭Git提交规范检查
+
+如果你想关闭 Git 提交规范检查,有两种方式:
+
+::: code-group
+
+```bash [临时关闭]
+git commit -m 'feat: add home page' --no-verify
+```
+
+```bash [永久关闭]
+# 在 .husky/commit-msg 内注释以下代码即可
+pnpm exec commitlint --edit "$1" # [!code --]
+```
+
+:::
+
+## Publint
+
+Publint 是一个用于检查 npm 包的规范的工具,可以检查包的版本号是否符合规范,是否符合标准的 ESM 规范包等等。
+
+### 命令
+
+```bash
+pnpm vsh publint
+```
+
+## Cspell
+
+Cspell 是一个用于检查拼写错误的工具,可以检查代码中的拼写错误,避免因为拼写错误导致的 bug。
+
+### 命令
+
+```bash
+pnpm cspell lint \"**/*.ts\" \"**/README.md\" \".changeset/*.md\" --no-progress
+```
+
+### 配置
+
+cspell 配置文件为 `cspell.json`,可以根据项目需求进行修改。
+
+## Git Hook
+
+git hook 一般结合各种 lint,在 git 提交代码的时候进行代码风格校验,如果校验没通过,则不会进行提交。需要开发者自行修改后再次进行提交
+
+### husky
+
+有一个问题就是校验会校验全部代码,但是我们只想校验我们自己提交的代码,这个时候就可以使用 husky。
+
+最有效的解决方案就是将 Lint 校验放到本地,常见做法是使用 husky 或者 pre-commit 在本地提交之前先做一次 Lint 校验。
+
+项目在 `.husky` 内部定义了相应的 hooks
+
+#### 如何关闭 Husky
+
+如果你想关闭 Husky,直接删除 `.husky` 目录即可。
+
+### lint-staged
+
+用于自动修复提交文件风格问题,其配置文件为 `.lintstagedrc.mjs`,可以根据项目需求进行修改。
diff --git a/apps/vben5/docs/src/guide/project/tailwindcss.md b/apps/vben5/docs/src/guide/project/tailwindcss.md
new file mode 100644
index 000000000..cfab5964d
--- /dev/null
+++ b/apps/vben5/docs/src/guide/project/tailwindcss.md
@@ -0,0 +1,13 @@
+# Tailwind CSS
+
+[Tailwind CSS](https://tailwindcss.com/) 是一个实用性优先的CSS框架,用于快速构建自定义设计。
+
+## 配置
+
+项目的配置文件位于 `internal/tailwind-config` 下,你可以在这里修改 Tailwind CSS 的配置。
+
+::: tip 包使用 tailwindcss 的限制
+
+当前只有对应的包下面存在 `tailwind.config.mjs` 文件才会启用 tailwindcss 的编译,否则不会启用 tailwindcss。如果你是纯粹的 SDK 包,不需要使用 tailwindcss,可以不用创建 `tailwind.config.mjs` 文件。
+
+:::
diff --git a/apps/vben5/docs/src/guide/project/test.md b/apps/vben5/docs/src/guide/project/test.md
new file mode 100644
index 000000000..abf3c5095
--- /dev/null
+++ b/apps/vben5/docs/src/guide/project/test.md
@@ -0,0 +1,33 @@
+# 单元测试
+
+项目内置了 [Vitest](https://vitest.dev/) 作为单元测试工具。Vitest 是一个基于 Vite 的测试运行器,它提供了一套简单的 API 来编写测试用例。
+
+## 编写测试用例
+
+在项目中,我们约定将测试文件名以 `.test.ts` 结尾,或者存放到`__tests__`目录内。例如,创建一个 `utils.ts` 文件,然后同级目录`utils.test.ts` 文件,
+
+```ts
+// utils.test.ts
+import { expect, test } from 'vitest';
+import { sum } from './sum';
+
+test('adds 1 + 2 to equal 3', () => {
+ expect(sum(1, 2)).toBe(3);
+});
+```
+
+## 运行测试
+
+在大仓根目录下运行以下命令即可:
+
+```bash
+pnpm test:unit
+```
+
+## 现有单元测试
+
+项目中已经有一些单元测试用例,可以搜索以`.test.ts`结尾的文件查看,在你更改到相关代码时,可以运行单元测试来保证代码的正确性,建议在开发过程中,保持单元测试的覆盖率,且同时在 CI/CD 流程中运行单元测试,保证测试通过在进行项目部署。
+
+现有单元测试情况:
+
+
diff --git a/apps/vben5/docs/src/guide/project/vite.md b/apps/vben5/docs/src/guide/project/vite.md
new file mode 100644
index 000000000..51b5a38dd
--- /dev/null
+++ b/apps/vben5/docs/src/guide/project/vite.md
@@ -0,0 +1,33 @@
+# Vite Config
+
+项目封装了一层vite配置,并集成了一些插件,方便在多个包以及应用内复用,使用方式如下:
+
+## 应用
+
+```ts
+// vite.config.mts
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ application: {},
+ // vite配置,参考vite官方文档进行覆盖
+ vite: {},
+ };
+});
+```
+
+## 包
+
+```ts
+// vite.config.mts
+import { defineConfig } from '@vben/vite-config';
+
+export default defineConfig(async () => {
+ return {
+ library: {},
+ // vite配置,参考vite官方文档进行覆盖
+ vite: {},
+ };
+});
+```
diff --git a/apps/vben5/docs/src/index.md b/apps/vben5/docs/src/index.md
new file mode 100644
index 000000000..30aaa0aec
--- /dev/null
+++ b/apps/vben5/docs/src/index.md
@@ -0,0 +1,108 @@
+---
+# https://vitepress.dev/reference/default-theme-home-page
+layout: home
+sidebar: false
+
+hero:
+ name: Vben Admin
+ text: 企业级管理系统框架
+ tagline: 全新升级,开箱即用,简单高效
+ image:
+ src: https://unpkg.com/@vbenjs/static-source@0.1.7/source/logo-v1.webp
+ alt: Vben Admin
+ actions:
+ - theme: brand
+ text: 快速开始 ->
+ link: /guide/introduction/vben
+ - theme: alt
+ text: 在线预览
+ link: https://www.vben.pro
+ - theme: alt
+ text: 在 GitHub 查看
+ link: https://github.com/vbenjs/vue-vben-admin
+
+features:
+ - icon: 🚀
+ title: 最新技术栈
+ details: 基于 Vue3、Pinia、Vue Router、TypeScript、等最新技术栈。
+ link: /guide/introduction/quick-start
+ linkText: 快速开始
+ - icon: 🦄
+ title: 丰富的配置
+ details: 企业级中后台前端解决方案,提供丰富的组件和模板以及 N 种偏好设置组合方案。
+ link: /guide/essentials/settings
+ linkText: 配置文档
+ - icon: 🎨
+ title: 主题定制
+ details: 通过简单的配置,即可实现各种主题切换,满足个性化需求。
+ link: /guide/in-depth/theme
+ linkText: 主题文档
+ - icon: 🌐
+ title: 国际化
+ details: 内置国际化方案,支持多语言切换,满足国际化需求。
+ link: /guide/in-depth/locale
+ linkText: 国际化文档
+ - icon: 🔐
+ title: 权限管理
+ details: 内置权限管理方案,支持多种权限控制方式,满足各种权限需求。
+ link: /guide/in-depth/access
+ linkText: 权限文档
+ - title: Vite
+ icon:
+ src: /logos/vite.svg
+ details: 现代化的前端构建工具,快速冷启动,瞬间热更新。
+ link: https://vitejs.dev/
+ linkText: 官方站点
+ - title: Shadcn UI
+ icon:
+ src: /logos/shadcn-ui.svg
+ details: 核心基于 Shadcn UI + Tailwindcss,业务可支持任意的 UI 框架。
+ link: https://www.shadcn-vue.com/
+ linkText: 官方站点
+ - title: Turbo Repo
+ icon:
+ src: /logos/turborepo.svg
+ details: 规范且标准的大仓架构,使用 pnpm + monorepo + turbo 工程管理模式,提供企业级开发规范。
+ link: https://turbo.build/
+ linkText: 官方站点
+ - title: Nitro Mock Server
+ icon:
+ src: /logos/nitro.svg
+ details: 内置 Nitro Mock 服务,让你的 mock 服务更加强大。
+ link: https://nitro.unjs.io/
+ linkText: 官方站点
+---
+
+
+
+
diff --git a/apps/vben5/docs/src/public/favicon.ico b/apps/vben5/docs/src/public/favicon.ico
new file mode 100644
index 000000000..fcf9818e2
Binary files /dev/null and b/apps/vben5/docs/src/public/favicon.ico differ
diff --git a/apps/vben5/docs/src/public/guide/devtools.png b/apps/vben5/docs/src/public/guide/devtools.png
new file mode 100644
index 000000000..b34a68516
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/devtools.png differ
diff --git a/apps/vben5/docs/src/public/guide/loading.png b/apps/vben5/docs/src/public/guide/loading.png
new file mode 100644
index 000000000..e1d0046e9
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/loading.png differ
diff --git a/apps/vben5/docs/src/public/guide/locale.png b/apps/vben5/docs/src/public/guide/locale.png
new file mode 100644
index 000000000..e9c79d055
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/locale.png differ
diff --git a/apps/vben5/docs/src/public/guide/login-expired.png b/apps/vben5/docs/src/public/guide/login-expired.png
new file mode 100644
index 000000000..bc82ba5b8
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/login-expired.png differ
diff --git a/apps/vben5/docs/src/public/guide/login.png b/apps/vben5/docs/src/public/guide/login.png
new file mode 100644
index 000000000..3774b0bd0
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/login.png differ
diff --git a/apps/vben5/docs/src/public/guide/preferences.png b/apps/vben5/docs/src/public/guide/preferences.png
new file mode 100644
index 000000000..9b1582f93
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/preferences.png differ
diff --git a/apps/vben5/docs/src/public/guide/qq.png b/apps/vben5/docs/src/public/guide/qq.png
new file mode 100644
index 000000000..cc76cf7b7
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/qq.png differ
diff --git a/apps/vben5/docs/src/public/guide/qq_channel.png b/apps/vben5/docs/src/public/guide/qq_channel.png
new file mode 100644
index 000000000..5fa807b91
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/qq_channel.png differ
diff --git a/apps/vben5/docs/src/public/guide/report.png b/apps/vben5/docs/src/public/guide/report.png
new file mode 100644
index 000000000..fbff2801c
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/report.png differ
diff --git a/apps/vben5/docs/src/public/guide/test.png b/apps/vben5/docs/src/public/guide/test.png
new file mode 100644
index 000000000..cbd4dc6e3
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/test.png differ
diff --git a/apps/vben5/docs/src/public/guide/update-notice.png b/apps/vben5/docs/src/public/guide/update-notice.png
new file mode 100644
index 000000000..a4436cfbe
Binary files /dev/null and b/apps/vben5/docs/src/public/guide/update-notice.png differ
diff --git a/apps/vben5/docs/src/public/logos/nitro.svg b/apps/vben5/docs/src/public/logos/nitro.svg
new file mode 100644
index 000000000..e5564f27b
--- /dev/null
+++ b/apps/vben5/docs/src/public/logos/nitro.svg
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/src/public/logos/shadcn-ui.svg b/apps/vben5/docs/src/public/logos/shadcn-ui.svg
new file mode 100644
index 000000000..2d584b988
--- /dev/null
+++ b/apps/vben5/docs/src/public/logos/shadcn-ui.svg
@@ -0,0 +1 @@
+
diff --git a/apps/vben5/docs/src/public/logos/turborepo.svg b/apps/vben5/docs/src/public/logos/turborepo.svg
new file mode 100644
index 000000000..9c7035af0
--- /dev/null
+++ b/apps/vben5/docs/src/public/logos/turborepo.svg
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/src/public/logos/vite.svg b/apps/vben5/docs/src/public/logos/vite.svg
new file mode 100644
index 000000000..de4aeddc1
--- /dev/null
+++ b/apps/vben5/docs/src/public/logos/vite.svg
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/vben5/docs/src/sponsor/personal.md b/apps/vben5/docs/src/sponsor/personal.md
new file mode 100644
index 000000000..fa2fa232f
--- /dev/null
+++ b/apps/vben5/docs/src/sponsor/personal.md
@@ -0,0 +1,12 @@
+# 赞助
+
+如果你觉得这个项目对你有帮助,你可以帮作者买一杯咖啡表示支持!
+
+
+
+您的赞助将帮助我们:
+
+- 维持项目的基础设施,如服务器、域名、社群费用。
+- 支持开发者的贡献和加快新功能的开发。
+
+感谢所有现有的和未来的赞助者,您的支持对我们来说至关重要,让我们一起推动项目继续前行。
diff --git a/apps/vben5/docs/tailwind.config.mjs b/apps/vben5/docs/tailwind.config.mjs
new file mode 100644
index 000000000..9dbc8c326
--- /dev/null
+++ b/apps/vben5/docs/tailwind.config.mjs
@@ -0,0 +1,11 @@
+import tailwindcssConfig from '@vben/tailwind-config';
+
+export default {
+ ...tailwindcssConfig,
+ content: [
+ ...tailwindcssConfig.content,
+ '.vitepress/**/*.{js,mts,ts,vue}',
+ 'src/demos/**/*.{js,mts,ts,vue}',
+ 'src/**/*.md',
+ ],
+};
diff --git a/apps/vben5/docs/tsconfig.json b/apps/vben5/docs/tsconfig.json
new file mode 100644
index 000000000..05147a975
--- /dev/null
+++ b/apps/vben5/docs/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/web.json",
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "#/*": ["./src/_env/*"]
+ }
+ },
+ "include": [
+ ".vitepress/*.mts",
+ ".vitepress/**/*.ts",
+ ".vitepress/**/*.vue",
+ "src/*.mts",
+ "src/**/*.ts",
+ "src/**/*.vue"
+ ],
+ "exclude": ["node_modules"]
+}
diff --git a/apps/vben5/eslint.config.mjs b/apps/vben5/eslint.config.mjs
new file mode 100644
index 000000000..b29b567fa
--- /dev/null
+++ b/apps/vben5/eslint.config.mjs
@@ -0,0 +1,5 @@
+// @ts-check
+
+import { defineConfig } from '@vben/eslint-config';
+
+export default defineConfig();
diff --git a/apps/vben5/internal/lint-configs/commitlint-config/index.mjs b/apps/vben5/internal/lint-configs/commitlint-config/index.mjs
new file mode 100644
index 000000000..3d854399f
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/commitlint-config/index.mjs
@@ -0,0 +1,153 @@
+import { execSync } from 'node:child_process';
+
+import { getPackagesSync } from '@vben/node-utils';
+
+const { packages } = getPackagesSync();
+
+const allowedScopes = [
+ ...packages.map((pkg) => pkg.packageJson.name),
+ 'project',
+ 'style',
+ 'lint',
+ 'ci',
+ 'dev',
+ 'deploy',
+ 'other',
+];
+
+// precomputed scope
+const scopeComplete = execSync('git status --porcelain || true')
+ .toString()
+ .trim()
+ .split('\n')
+ .find((r) => ~r.indexOf('M src'))
+ ?.replace(/(\/)/g, '%%')
+ ?.match(/src%%((\w|-)*)/)?.[1]
+ ?.replace(/s$/, '');
+
+/**
+ * @type {import('cz-git').UserConfig}
+ */
+const userConfig = {
+ extends: ['@commitlint/config-conventional'],
+ plugins: ['commitlint-plugin-function-rules'],
+ prompt: {
+ /** @use `pnpm commit :f` */
+ alias: {
+ b: 'build: bump dependencies',
+ c: 'chore: update config',
+ f: 'docs: fix typos',
+ r: 'docs: update README',
+ s: 'style: update code format',
+ },
+ allowCustomIssuePrefixs: false,
+ // scopes: [...scopes, 'mock'],
+ allowEmptyIssuePrefixs: false,
+ customScopesAlign: scopeComplete ? 'bottom' : 'top',
+ defaultScope: scopeComplete,
+ // English
+ typesAppend: [
+ { name: 'workflow: workflow improvements', value: 'workflow' },
+ { name: 'types: type definition file changes', value: 'types' },
+ ],
+
+ // 中英文对照版
+ // messages: {
+ // type: '选择你要提交的类型 :',
+ // scope: '选择一个提交范围 (可选):',
+ // customScope: '请输入自定义的提交范围 :',
+ // subject: '填写简短精炼的变更描述 :\n',
+ // body: '填写更加详细的变更描述 (可选)。使用 "|" 换行 :\n',
+ // breaking: '列举非兼容性重大的变更 (可选)。使用 "|" 换行 :\n',
+ // footerPrefixsSelect: '选择关联issue前缀 (可选):',
+ // customFooterPrefixs: '输入自定义issue前缀 :',
+ // footer: '列举关联issue (可选) 例如: #31, #I3244 :\n',
+ // confirmCommit: '是否提交或修改commit ?',
+ // },
+ // types: [
+ // { value: 'feat', name: 'feat: 新增功能' },
+ // { value: 'fix', name: 'fix: 修复缺陷' },
+ // { value: 'docs', name: 'docs: 文档变更' },
+ // { value: 'style', name: 'style: 代码格式' },
+ // { value: 'refactor', name: 'refactor: 代码重构' },
+ // { value: 'perf', name: 'perf: 性能优化' },
+ // { value: 'test', name: 'test: 添加疏漏测试或已有测试改动' },
+ // { value: 'build', name: 'build: 构建流程、外部依赖变更 (如升级 npm 包、修改打包配置等)' },
+ // { value: 'ci', name: 'ci: 修改 CI 配置、脚本' },
+ // { value: 'revert', name: 'revert: 回滚 commit' },
+ // { value: 'chore', name: 'chore: 对构建过程或辅助工具和库的更改 (不影响源文件、测试用例)' },
+ // { value: 'wip', name: 'wip: 正在开发中' },
+ // { value: 'workflow', name: 'workflow: 工作流程改进' },
+ // { value: 'types', name: 'types: 类型定义文件修改' },
+ // ],
+ // emptyScopesAlias: 'empty: 不填写',
+ // customScopesAlias: 'custom: 自定义',
+ },
+ rules: {
+ /**
+ * type[scope]: [function] description
+ *
+ * ^^^^^^^^^^^^^^ empty line.
+ * - Something here
+ */
+ 'body-leading-blank': [2, 'always'],
+ /**
+ * type[scope]: [function] description
+ *
+ * - something here
+ *
+ * ^^^^^^^^^^^^^^
+ */
+ 'footer-leading-blank': [1, 'always'],
+ /**
+ * type[scope]: [function] description
+ * ^^^^^
+ */
+ 'function-rules/scope-enum': [
+ 2, // level: error
+ 'always',
+ (parsed) => {
+ if (!parsed.scope || allowedScopes.includes(parsed.scope)) {
+ return [true];
+ }
+
+ return [false, `scope must be one of ${allowedScopes.join(', ')}`];
+ },
+ ],
+ /**
+ * type[scope]: [function] description [No more than 108 characters]
+ * ^^^^^
+ */
+ 'header-max-length': [2, 'always', 108],
+
+ 'scope-enum': [0],
+ 'subject-case': [0],
+ 'subject-empty': [2, 'never'],
+ 'type-empty': [2, 'never'],
+ /**
+ * type[scope]: [function] description
+ * ^^^^
+ */
+ 'type-enum': [
+ 2,
+ 'always',
+ [
+ 'feat',
+ 'fix',
+ 'perf',
+ 'style',
+ 'docs',
+ 'test',
+ 'refactor',
+ 'build',
+ 'ci',
+ 'chore',
+ 'revert',
+ 'types',
+ 'release',
+ ],
+ ],
+ },
+};
+
+export default userConfig;
diff --git a/apps/vben5/internal/lint-configs/commitlint-config/package.json b/apps/vben5/internal/lint-configs/commitlint-config/package.json
new file mode 100644
index 000000000..6679a6627
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/commitlint-config/package.json
@@ -0,0 +1,33 @@
+{
+ "name": "@vben/commitlint-config",
+ "version": "5.4.8",
+ "private": true,
+ "homepage": "https://github.com/vbenjs/vue-vben-admin",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "internal/lint-configs/commitlint-config"
+ },
+ "license": "MIT",
+ "type": "module",
+ "files": [
+ "dist"
+ ],
+ "main": "./index.mjs",
+ "module": "./index.mjs",
+ "exports": {
+ ".": {
+ "import": "./index.mjs",
+ "default": "./index.mjs"
+ }
+ },
+ "dependencies": {
+ "@commitlint/cli": "catalog:",
+ "@commitlint/config-conventional": "catalog:",
+ "@vben/node-utils": "workspace:*",
+ "commitlint-plugin-function-rules": "catalog:",
+ "cz-git": "catalog:",
+ "czg": "catalog:"
+ }
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/build.config.ts b/apps/vben5/internal/lint-configs/eslint-config/build.config.ts
new file mode 100644
index 000000000..97e572c56
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/build.config.ts
@@ -0,0 +1,7 @@
+import { defineBuildConfig } from 'unbuild';
+
+export default defineBuildConfig({
+ clean: true,
+ declaration: true,
+ entries: ['src/index'],
+});
diff --git a/apps/vben5/internal/lint-configs/eslint-config/package.json b/apps/vben5/internal/lint-configs/eslint-config/package.json
new file mode 100644
index 000000000..12556ec5c
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/package.json
@@ -0,0 +1,56 @@
+{
+ "name": "@vben/eslint-config",
+ "version": "5.0.0",
+ "private": true,
+ "homepage": "https://github.com/vbenjs/vue-vben-admin",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "internal/lint-configs/eslint-config"
+ },
+ "license": "MIT",
+ "type": "module",
+ "scripts": {
+ "stub": "pnpm unbuild --stub"
+ },
+ "files": [
+ "dist"
+ ],
+ "main": "./dist/index.mjs",
+ "module": "./dist/index.mjs",
+ "types": "./dist/index.d.ts",
+ "exports": {
+ ".": {
+ "types": "./dist/index.d.ts",
+ "import": "./dist/index.mjs"
+ }
+ },
+ "dependencies": {
+ "eslint-config-turbo": "catalog:",
+ "eslint-plugin-command": "catalog:",
+ "eslint-plugin-import-x": "catalog:"
+ },
+ "devDependencies": {
+ "@eslint/js": "catalog:",
+ "@types/eslint": "catalog:",
+ "@typescript-eslint/eslint-plugin": "catalog:",
+ "@typescript-eslint/parser": "catalog:",
+ "eslint": "catalog:",
+ "eslint-plugin-eslint-comments": "catalog:",
+ "eslint-plugin-jsdoc": "catalog:",
+ "eslint-plugin-jsonc": "catalog:",
+ "eslint-plugin-n": "catalog:",
+ "eslint-plugin-no-only-tests": "catalog:",
+ "eslint-plugin-perfectionist": "catalog:",
+ "eslint-plugin-prettier": "catalog:",
+ "eslint-plugin-regexp": "catalog:",
+ "eslint-plugin-unicorn": "catalog:",
+ "eslint-plugin-unused-imports": "catalog:",
+ "eslint-plugin-vitest": "catalog:",
+ "eslint-plugin-vue": "catalog:",
+ "globals": "catalog:",
+ "jsonc-eslint-parser": "catalog:",
+ "vue-eslint-parser": "catalog:"
+ }
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/command.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/command.ts
new file mode 100644
index 000000000..67651b233
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/command.ts
@@ -0,0 +1,10 @@
+import createCommand from 'eslint-plugin-command/config';
+
+export async function command() {
+ return [
+ {
+ // @ts-expect-error - no types
+ ...createCommand(),
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/comments.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/comments.ts
new file mode 100644
index 000000000..77ccd5dde
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/comments.ts
@@ -0,0 +1,24 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function comments(): Promise {
+ const [pluginComments] = await Promise.all([
+ // @ts-expect-error - no types
+ interopDefault(import('eslint-plugin-eslint-comments')),
+ ] as const);
+
+ return [
+ {
+ plugins: {
+ 'eslint-comments': pluginComments,
+ },
+ rules: {
+ 'eslint-comments/no-aggregating-enable': 'error',
+ 'eslint-comments/no-duplicate-disable': 'error',
+ 'eslint-comments/no-unlimited-disable': 'error',
+ 'eslint-comments/no-unused-enable': 'error',
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/disableds.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/disableds.ts
new file mode 100644
index 000000000..152b84cac
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/disableds.ts
@@ -0,0 +1,28 @@
+import type { Linter } from 'eslint';
+
+export async function disableds(): Promise {
+ return [
+ {
+ files: ['**/__tests__/**/*.?([cm])[jt]s?(x)'],
+ name: 'disables/test',
+ rules: {
+ '@typescript-eslint/ban-ts-comment': 'off',
+ 'no-console': 'off',
+ },
+ },
+ {
+ files: ['**/*.d.ts'],
+ name: 'disables/dts',
+ rules: {
+ '@typescript-eslint/triple-slash-reference': 'off',
+ },
+ },
+ {
+ files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
+ name: 'disables/js',
+ rules: {
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/ignores.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/ignores.ts
new file mode 100644
index 000000000..136c956de
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/ignores.ts
@@ -0,0 +1,52 @@
+import type { Linter } from 'eslint';
+
+export async function ignores(): Promise {
+ return [
+ {
+ ignores: [
+ '**/node_modules',
+ '**/dist',
+ '**/dist-*',
+ '**/*-dist',
+ '**/.husky',
+ '**/.nitro',
+ '**/.output',
+ '**/Dockerfile',
+ '**/package-lock.json',
+ '**/yarn.lock',
+ '**/pnpm-lock.yaml',
+ '**/bun.lockb',
+ '**/output',
+ '**/coverage',
+ '**/temp',
+ '**/.temp',
+ '**/tmp',
+ '**/.tmp',
+ '**/.history',
+ '**/.turbo',
+ '**/.nuxt',
+ '**/.next',
+ '**/.vercel',
+ '**/.changeset',
+ '**/.idea',
+ '**/.cache',
+ '**/.output',
+ '**/.vite-inspect',
+
+ '**/CHANGELOG*.md',
+ '**/*.min.*',
+ '**/LICENSE*',
+ '**/__snapshots__',
+ '**/*.snap',
+ '**/fixtures/**',
+ '**/.vitepress/cache/**',
+ '**/auto-import?(s).d.ts',
+ '**/components.d.ts',
+ '**/vite.config.mts.*',
+ '**/*.sh',
+ '**/*.ttf',
+ '**/*.woff',
+ ],
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/import.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/import.ts
new file mode 100644
index 000000000..67a08feaf
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/import.ts
@@ -0,0 +1,24 @@
+import type { Linter } from 'eslint';
+
+import * as pluginImport from 'eslint-plugin-import-x';
+
+export async function importPluginConfig(): Promise {
+ return [
+ {
+ plugins: {
+ // @ts-expect-error - This is a dynamic import
+ import: pluginImport,
+ },
+ rules: {
+ 'import/first': 'error',
+ 'import/newline-after-import': 'error',
+ 'import/no-duplicates': 'error',
+ 'import/no-mutable-exports': 'error',
+ 'import/no-named-default': 'error',
+ 'import/no-self-import': 'error',
+ 'import/no-unresolved': 'off',
+ 'import/no-webpack-loader-syntax': 'error',
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/index.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/index.ts
new file mode 100644
index 000000000..c0284efb2
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/index.ts
@@ -0,0 +1,17 @@
+export * from './command';
+export * from './comments';
+export * from './disableds';
+export * from './ignores';
+export * from './import';
+export * from './javascript';
+export * from './jsdoc';
+export * from './jsonc';
+export * from './node';
+export * from './perfectionist';
+export * from './prettier';
+export * from './regexp';
+export * from './test';
+export * from './turbo';
+export * from './typescript';
+export * from './unicorn';
+export * from './vue';
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/javascript.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/javascript.ts
new file mode 100644
index 000000000..0d87c1ba1
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/javascript.ts
@@ -0,0 +1,242 @@
+import type { Linter } from 'eslint';
+
+// @ts-expect-error - no types
+import js from '@eslint/js';
+import pluginUnusedImports from 'eslint-plugin-unused-imports';
+import globals from 'globals';
+
+export async function javascript(): Promise {
+ return [
+ {
+ languageOptions: {
+ ecmaVersion: 'latest',
+ globals: {
+ ...globals.browser,
+ ...globals.es2021,
+ ...globals.node,
+ document: 'readonly',
+ navigator: 'readonly',
+ window: 'readonly',
+ },
+ parserOptions: {
+ ecmaFeatures: {
+ jsx: true,
+ },
+ ecmaVersion: 'latest',
+ sourceType: 'module',
+ },
+ sourceType: 'module',
+ },
+ linterOptions: {
+ reportUnusedDisableDirectives: true,
+ },
+ plugins: {
+ 'unused-imports': pluginUnusedImports,
+ },
+ rules: {
+ ...js.configs.recommended.rules,
+ 'accessor-pairs': [
+ 'error',
+ { enforceForClassMembers: true, setWithoutGet: true },
+ ],
+ 'array-callback-return': 'error',
+ 'block-scoped-var': 'error',
+ 'constructor-super': 'error',
+ 'default-case-last': 'error',
+ 'dot-notation': ['error', { allowKeywords: true }],
+ eqeqeq: ['error', 'always'],
+ 'keyword-spacing': 'off',
+
+ 'new-cap': [
+ 'error',
+ { capIsNew: false, newIsCap: true, properties: true },
+ ],
+ 'no-alert': 'error',
+ 'no-array-constructor': 'error',
+ 'no-async-promise-executor': 'error',
+ 'no-caller': 'error',
+ 'no-case-declarations': 'error',
+ 'no-class-assign': 'error',
+ 'no-compare-neg-zero': 'error',
+ 'no-cond-assign': ['error', 'always'],
+ 'no-console': ['error', { allow: ['warn', 'error'] }],
+ 'no-const-assign': 'error',
+ 'no-control-regex': 'error',
+ 'no-debugger': 'error',
+ 'no-delete-var': 'error',
+ 'no-dupe-args': 'error',
+ 'no-dupe-class-members': 'error',
+ 'no-dupe-keys': 'error',
+ 'no-duplicate-case': 'error',
+ 'no-empty': ['error', { allowEmptyCatch: true }],
+ 'no-empty-character-class': 'error',
+ 'no-empty-function': 'off',
+ 'no-empty-pattern': 'error',
+ 'no-eval': 'error',
+ 'no-ex-assign': 'error',
+ 'no-extend-native': 'error',
+ 'no-extra-bind': 'error',
+ 'no-extra-boolean-cast': 'error',
+ 'no-fallthrough': 'error',
+ 'no-func-assign': 'error',
+ 'no-global-assign': 'error',
+ 'no-implied-eval': 'error',
+ 'no-import-assign': 'error',
+ 'no-invalid-regexp': 'error',
+ 'no-irregular-whitespace': 'error',
+ 'no-iterator': 'error',
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
+ 'no-lone-blocks': 'error',
+ 'no-loss-of-precision': 'error',
+ 'no-misleading-character-class': 'error',
+ 'no-multi-str': 'error',
+ 'no-new': 'error',
+ 'no-new-func': 'error',
+ 'no-new-object': 'error',
+ 'no-new-symbol': 'error',
+ 'no-new-wrappers': 'error',
+ 'no-obj-calls': 'error',
+ 'no-octal': 'error',
+ 'no-octal-escape': 'error',
+ 'no-proto': 'error',
+ 'no-prototype-builtins': 'error',
+ 'no-redeclare': ['error', { builtinGlobals: false }],
+ 'no-regex-spaces': 'error',
+ 'no-restricted-globals': [
+ 'error',
+ { message: 'Use `globalThis` instead.', name: 'global' },
+ { message: 'Use `globalThis` instead.', name: 'self' },
+ ],
+ 'no-restricted-properties': [
+ 'error',
+ {
+ message:
+ 'Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.',
+ property: '__proto__',
+ },
+ {
+ message: 'Use `Object.defineProperty` instead.',
+ property: '__defineGetter__',
+ },
+ {
+ message: 'Use `Object.defineProperty` instead.',
+ property: '__defineSetter__',
+ },
+ {
+ message: 'Use `Object.getOwnPropertyDescriptor` instead.',
+ property: '__lookupGetter__',
+ },
+ {
+ message: 'Use `Object.getOwnPropertyDescriptor` instead.',
+ property: '__lookupSetter__',
+ },
+ ],
+ 'no-restricted-syntax': [
+ 'error',
+ 'DebuggerStatement',
+ 'LabeledStatement',
+ 'WithStatement',
+ 'TSEnumDeclaration[const=true]',
+ 'TSExportAssignment',
+ ],
+ 'no-self-assign': ['error', { props: true }],
+ 'no-self-compare': 'error',
+ 'no-sequences': 'error',
+ 'no-shadow-restricted-names': 'error',
+ 'no-sparse-arrays': 'error',
+ 'no-template-curly-in-string': 'error',
+ 'no-this-before-super': 'error',
+ 'no-throw-literal': 'error',
+ 'no-undef': 'off',
+ 'no-undef-init': 'error',
+ 'no-unexpected-multiline': 'error',
+ 'no-unmodified-loop-condition': 'error',
+ 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
+ 'no-unreachable': 'error',
+ 'no-unreachable-loop': 'error',
+ 'no-unsafe-finally': 'error',
+ 'no-unsafe-negation': 'error',
+ 'no-unused-expressions': [
+ 'error',
+ {
+ allowShortCircuit: true,
+ allowTaggedTemplates: true,
+ allowTernary: true,
+ },
+ ],
+ 'no-unused-vars': [
+ 'error',
+ {
+ args: 'none',
+ caughtErrors: 'none',
+ ignoreRestSiblings: true,
+ vars: 'all',
+ },
+ ],
+ 'no-use-before-define': [
+ 'error',
+ { classes: false, functions: false, variables: true },
+ ],
+ 'no-useless-backreference': 'error',
+ 'no-useless-call': 'error',
+ 'no-useless-catch': 'error',
+ 'no-useless-computed-key': 'error',
+ 'no-useless-constructor': 'error',
+ 'no-useless-rename': 'error',
+ 'no-useless-return': 'error',
+ 'no-var': 'error',
+ 'no-with': 'error',
+ 'object-shorthand': [
+ 'error',
+ 'always',
+ { avoidQuotes: true, ignoreConstructors: false },
+ ],
+ 'one-var': ['error', { initialized: 'never' }],
+ 'prefer-arrow-callback': [
+ 'error',
+ {
+ allowNamedFunctions: false,
+ allowUnboundThis: true,
+ },
+ ],
+ 'prefer-const': [
+ 'error',
+ {
+ destructuring: 'all',
+ ignoreReadBeforeAssign: true,
+ },
+ ],
+ 'prefer-exponentiation-operator': 'error',
+
+ 'prefer-promise-reject-errors': 'error',
+ 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
+ 'prefer-rest-params': 'error',
+ 'prefer-spread': 'error',
+ 'prefer-template': 'error',
+ 'space-before-function-paren': 'off',
+ 'spaced-comment': 'error',
+ 'symbol-description': 'error',
+ 'unicode-bom': ['error', 'never'],
+
+ 'unused-imports/no-unused-imports': 'error',
+ 'unused-imports/no-unused-vars': [
+ 'error',
+ {
+ args: 'after-used',
+ argsIgnorePattern: '^_',
+ vars: 'all',
+ varsIgnorePattern: '^_',
+ },
+ ],
+ 'use-isnan': [
+ 'error',
+ { enforceForIndexOf: true, enforceForSwitchCase: true },
+ ],
+ 'valid-typeof': ['error', { requireStringLiterals: true }],
+
+ 'vars-on-top': 'error',
+ yoda: ['error', 'never'],
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/jsdoc.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/jsdoc.ts
new file mode 100644
index 000000000..136819769
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/jsdoc.ts
@@ -0,0 +1,34 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function jsdoc(): Promise {
+ const [pluginJsdoc] = await Promise.all([
+ interopDefault(import('eslint-plugin-jsdoc')),
+ ] as const);
+
+ return [
+ {
+ plugins: {
+ jsdoc: pluginJsdoc,
+ },
+ rules: {
+ 'jsdoc/check-access': 'warn',
+ 'jsdoc/check-param-names': 'warn',
+ 'jsdoc/check-property-names': 'warn',
+ 'jsdoc/check-types': 'warn',
+ 'jsdoc/empty-tags': 'warn',
+ 'jsdoc/implements-on-classes': 'warn',
+ 'jsdoc/no-defaults': 'warn',
+ 'jsdoc/no-multi-asterisks': 'warn',
+ 'jsdoc/require-param-name': 'warn',
+ 'jsdoc/require-property': 'warn',
+ 'jsdoc/require-property-description': 'warn',
+ 'jsdoc/require-property-name': 'warn',
+ 'jsdoc/require-returns-check': 'warn',
+ 'jsdoc/require-returns-description': 'warn',
+ 'jsdoc/require-yields-check': 'warn',
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/jsonc.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/jsonc.ts
new file mode 100644
index 000000000..4072e4cdd
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/jsonc.ts
@@ -0,0 +1,258 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function jsonc(): Promise {
+ const [pluginJsonc, parserJsonc] = await Promise.all([
+ interopDefault(import('eslint-plugin-jsonc')),
+ interopDefault(import('jsonc-eslint-parser')),
+ ] as const);
+
+ return [
+ {
+ files: ['**/*.json', '**/*.json5', '**/*.jsonc', '*.code-workspace'],
+ languageOptions: {
+ parser: parserJsonc as any,
+ },
+ plugins: {
+ jsonc: pluginJsonc as any,
+ },
+ rules: {
+ 'jsonc/no-bigint-literals': 'error',
+ 'jsonc/no-binary-expression': 'error',
+ 'jsonc/no-binary-numeric-literals': 'error',
+ 'jsonc/no-dupe-keys': 'error',
+ 'jsonc/no-escape-sequence-in-identifier': 'error',
+ 'jsonc/no-floating-decimal': 'error',
+ 'jsonc/no-hexadecimal-numeric-literals': 'error',
+ 'jsonc/no-infinity': 'error',
+ 'jsonc/no-multi-str': 'error',
+ 'jsonc/no-nan': 'error',
+ 'jsonc/no-number-props': 'error',
+ 'jsonc/no-numeric-separators': 'error',
+ 'jsonc/no-octal': 'error',
+ 'jsonc/no-octal-escape': 'error',
+ 'jsonc/no-octal-numeric-literals': 'error',
+ 'jsonc/no-parenthesized': 'error',
+ 'jsonc/no-plus-sign': 'error',
+ 'jsonc/no-regexp-literals': 'error',
+ 'jsonc/no-sparse-arrays': 'error',
+ 'jsonc/no-template-literals': 'error',
+ 'jsonc/no-undefined-value': 'error',
+ 'jsonc/no-unicode-codepoint-escapes': 'error',
+ 'jsonc/no-useless-escape': 'error',
+ 'jsonc/space-unary-ops': 'error',
+ 'jsonc/valid-json-number': 'error',
+ 'jsonc/vue-custom-block/no-parsing-error': 'error',
+ },
+ },
+ sortTsconfig(),
+ sortPackageJson(),
+ ];
+}
+
+function sortPackageJson(): Linter.Config {
+ return {
+ files: ['**/package.json'],
+ rules: {
+ 'jsonc/sort-array-values': [
+ 'error',
+ {
+ order: { type: 'asc' },
+ pathPattern: '^files$|^pnpm.neverBuiltDependencies$',
+ },
+ ],
+ 'jsonc/sort-keys': [
+ 'error',
+ {
+ order: [
+ 'name',
+ 'version',
+ 'description',
+ 'private',
+ 'keywords',
+ 'homepage',
+ 'bugs',
+ 'repository',
+ 'license',
+ 'author',
+ 'contributors',
+ 'categories',
+ 'funding',
+ 'type',
+ 'scripts',
+ 'files',
+ 'sideEffects',
+ 'bin',
+ 'main',
+ 'module',
+ 'unpkg',
+ 'jsdelivr',
+ 'types',
+ 'typesVersions',
+ 'imports',
+ 'exports',
+ 'publishConfig',
+ 'icon',
+ 'activationEvents',
+ 'contributes',
+ 'peerDependencies',
+ 'peerDependenciesMeta',
+ 'dependencies',
+ 'optionalDependencies',
+ 'devDependencies',
+ 'engines',
+ 'packageManager',
+ 'pnpm',
+ 'overrides',
+ 'resolutions',
+ 'husky',
+ 'simple-git-hooks',
+ 'lint-staged',
+ 'eslintConfig',
+ ],
+ pathPattern: '^$',
+ },
+ {
+ order: { type: 'asc' },
+ pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$',
+ },
+ {
+ order: { type: 'asc' },
+ pathPattern: '^(?:resolutions|overrides|pnpm.overrides)$',
+ },
+ {
+ order: ['types', 'import', 'require', 'default'],
+ pathPattern: '^exports.*$',
+ },
+ ],
+ },
+ };
+}
+
+function sortTsconfig(): Linter.Config {
+ return {
+ files: [
+ '**/tsconfig.json',
+ '**/tsconfig.*.json',
+ 'internal/tsconfig/*.json',
+ ],
+ rules: {
+ 'jsonc/sort-keys': [
+ 'error',
+ {
+ order: [
+ 'extends',
+ 'compilerOptions',
+ 'references',
+ 'files',
+ 'include',
+ 'exclude',
+ ],
+ pathPattern: '^$',
+ },
+ {
+ order: [
+ /* Projects */
+ 'incremental',
+ 'composite',
+ 'tsBuildInfoFile',
+ 'disableSourceOfProjectReferenceRedirect',
+ 'disableSolutionSearching',
+ 'disableReferencedProjectLoad',
+ /* Language and Environment */
+ 'target',
+ 'jsx',
+ 'jsxFactory',
+ 'jsxFragmentFactory',
+ 'jsxImportSource',
+ 'lib',
+ 'moduleDetection',
+ 'noLib',
+ 'reactNamespace',
+ 'useDefineForClassFields',
+ 'emitDecoratorMetadata',
+ 'experimentalDecorators',
+ /* Modules */
+ 'baseUrl',
+ 'rootDir',
+ 'rootDirs',
+ 'customConditions',
+ 'module',
+ 'moduleResolution',
+ 'moduleSuffixes',
+ 'noResolve',
+ 'paths',
+ 'resolveJsonModule',
+ 'resolvePackageJsonExports',
+ 'resolvePackageJsonImports',
+ 'typeRoots',
+ 'types',
+ 'allowArbitraryExtensions',
+ 'allowImportingTsExtensions',
+ 'allowUmdGlobalAccess',
+ /* JavaScript Support */
+ 'allowJs',
+ 'checkJs',
+ 'maxNodeModuleJsDepth',
+ /* Type Checking */
+ 'strict',
+ 'strictBindCallApply',
+ 'strictFunctionTypes',
+ 'strictNullChecks',
+ 'strictPropertyInitialization',
+ 'allowUnreachableCode',
+ 'allowUnusedLabels',
+ 'alwaysStrict',
+ 'exactOptionalPropertyTypes',
+ 'noFallthroughCasesInSwitch',
+ 'noImplicitAny',
+ 'noImplicitOverride',
+ 'noImplicitReturns',
+ 'noImplicitThis',
+ 'noPropertyAccessFromIndexSignature',
+ 'noUncheckedIndexedAccess',
+ 'noUnusedLocals',
+ 'noUnusedParameters',
+ 'useUnknownInCatchVariables',
+ /* Emit */
+ 'declaration',
+ 'declarationDir',
+ 'declarationMap',
+ 'downlevelIteration',
+ 'emitBOM',
+ 'emitDeclarationOnly',
+ 'importHelpers',
+ 'importsNotUsedAsValues',
+ 'inlineSourceMap',
+ 'inlineSources',
+ 'mapRoot',
+ 'newLine',
+ 'noEmit',
+ 'noEmitHelpers',
+ 'noEmitOnError',
+ 'outDir',
+ 'outFile',
+ 'preserveConstEnums',
+ 'preserveValueImports',
+ 'removeComments',
+ 'sourceMap',
+ 'sourceRoot',
+ 'stripInternal',
+ /* Interop Constraints */
+ 'allowSyntheticDefaultImports',
+ 'esModuleInterop',
+ 'forceConsistentCasingInFileNames',
+ 'isolatedModules',
+ 'preserveSymlinks',
+ 'verbatimModuleSyntax',
+ /* Completeness */
+ 'skipDefaultLibCheck',
+ 'skipLibCheck',
+ ],
+ pathPattern: '^compilerOptions$',
+ },
+ ],
+ },
+ };
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/node.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/node.ts
new file mode 100644
index 000000000..fa960d85e
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/node.ts
@@ -0,0 +1,57 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function node(): Promise {
+ const pluginNode = await interopDefault(import('eslint-plugin-n'));
+
+ return [
+ {
+ plugins: {
+ n: pluginNode,
+ },
+ rules: {
+ 'n/handle-callback-err': ['error', '^(err|error)$'],
+ 'n/no-deprecated-api': 'error',
+ 'n/no-exports-assign': 'error',
+ 'n/no-extraneous-import': [
+ 'error',
+ {
+ allowModules: [
+ 'unbuild',
+ '@vben/vite-config',
+ 'vitest',
+ 'vite',
+ '@vue/test-utils',
+ '@vben/tailwind-config',
+ '@playwright/test',
+ ],
+ },
+ ],
+ 'n/no-new-require': 'error',
+ 'n/no-path-concat': 'error',
+ // 'n/no-unpublished-import': 'off',
+ 'n/no-unsupported-features/es-syntax': [
+ 'error',
+ {
+ ignores: [],
+ version: '>=18.0.0',
+ },
+ ],
+ 'n/prefer-global/buffer': ['error', 'never'],
+ // 'n/no-missing-import': 'off',
+ 'n/prefer-global/process': ['error', 'never'],
+ 'n/process-exit-as-throw': 'error',
+ },
+ },
+ {
+ files: [
+ 'scripts/**/*.?([cm])[jt]s?(x)',
+ 'internal/**/*.?([cm])[jt]s?(x)',
+ ],
+ rules: {
+ 'n/prefer-global/process': 'off',
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/perfectionist.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/perfectionist.ts
new file mode 100644
index 000000000..1b17b30f3
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/perfectionist.ts
@@ -0,0 +1,112 @@
+import type { Linter } from 'eslint';
+
+import perfectionistPlugin from 'eslint-plugin-perfectionist';
+
+export async function perfectionist(): Promise {
+ return [
+ perfectionistPlugin.configs['recommended-natural'],
+ {
+ rules: {
+ 'perfectionist/sort-exports': [
+ 'error',
+ {
+ order: 'asc',
+ type: 'natural',
+ },
+ ],
+ 'perfectionist/sort-imports': [
+ 'error',
+ {
+ customGroups: {
+ type: {
+ vben: 'vben',
+ vue: 'vue',
+ },
+ value: {
+ vben: ['@vben*', '@vben/**/**', '@vben-core/**/**'],
+ vue: ['vue', 'vue-*', '@vue*'],
+ },
+ },
+ groups: [
+ ['external-type', 'builtin-type', 'type'],
+ ['parent-type', 'sibling-type', 'index-type'],
+ ['internal-type'],
+ 'builtin',
+ 'vue',
+ 'vben',
+ 'external',
+ 'internal',
+ ['parent', 'sibling', 'index'],
+ 'side-effect',
+ 'side-effect-style',
+ 'style',
+ 'object',
+ 'unknown',
+ ],
+ internalPattern: ['#*', '#*/**'],
+ newlinesBetween: 'always',
+ order: 'asc',
+ type: 'natural',
+ },
+ ],
+ 'perfectionist/sort-named-exports': [
+ 'error',
+ {
+ order: 'asc',
+ type: 'natural',
+ },
+ ],
+ 'perfectionist/sort-objects': [
+ 'error',
+ {
+ customGroups: {
+ items: 'items',
+ list: 'list',
+ children: 'children',
+ },
+ groups: ['unknown', 'items', 'list', 'children'],
+ ignorePattern: ['children'],
+ order: 'asc',
+ partitionByComment: 'Part:**',
+ type: 'natural',
+ },
+ ],
+ 'perfectionist/sort-vue-attributes': [
+ 'error',
+ {
+ // Based on: https://vuejs.org/style-guide/rules-recommended.html#element-attribute-order
+ customGroups: {
+ /* eslint-disable perfectionist/sort-objects */
+ DEFINITION: '*(is|:is|v-is)',
+ LIST_RENDERING: 'v-for',
+ CONDITIONALS: 'v-*(else-if|if|else|show|cloak)',
+ RENDER_MODIFIERS: 'v-*(pre|once)',
+ GLOBAL: '*(:id|id)',
+ UNIQUE: '*(ref|key|:ref|:key)',
+ SLOT: '*(v-slot|slot)',
+ TWO_WAY_BINDING: '*(v-model|v-model:*)',
+ // OTHER_DIRECTIVES e.g. 'v-custom-directive'
+ EVENTS: '*(v-on|@*)',
+ CONTENT: 'v-*(html|text)',
+ /* eslint-enable perfectionist/sort-objects */
+ },
+ groups: [
+ 'DEFINITION',
+ 'LIST_RENDERING',
+ 'CONDITIONALS',
+ 'RENDER_MODIFIERS',
+ 'GLOBAL',
+ 'UNIQUE',
+ 'SLOT',
+ 'TWO_WAY_BINDING',
+ 'unknown',
+ 'EVENTS',
+ 'CONTENT',
+ ],
+ type: 'natural',
+ },
+ ],
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/prettier.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/prettier.ts
new file mode 100644
index 000000000..3cd7af40e
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/prettier.ts
@@ -0,0 +1,19 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function prettier(): Promise {
+ const [pluginPrettier] = await Promise.all([
+ interopDefault(import('eslint-plugin-prettier')),
+ ] as const);
+ return [
+ {
+ plugins: {
+ prettier: pluginPrettier,
+ },
+ rules: {
+ 'prettier/prettier': 'error',
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/regexp.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/regexp.ts
new file mode 100644
index 000000000..c0f4c9f43
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/regexp.ts
@@ -0,0 +1,20 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function regexp(): Promise {
+ const [pluginRegexp] = await Promise.all([
+ interopDefault(import('eslint-plugin-regexp')),
+ ] as const);
+
+ return [
+ {
+ plugins: {
+ regexp: pluginRegexp,
+ },
+ rules: {
+ ...pluginRegexp.configs.recommended.rules,
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/test.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/test.ts
new file mode 100644
index 000000000..ddfde2b87
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/test.ts
@@ -0,0 +1,45 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function test(): Promise {
+ const [pluginTest, pluginNoOnlyTests] = await Promise.all([
+ interopDefault(import('eslint-plugin-vitest')),
+ // @ts-expect-error - no types
+ interopDefault(import('eslint-plugin-no-only-tests')),
+ ] as const);
+
+ return [
+ {
+ files: [
+ `**/__tests__/**/*.?([cm])[jt]s?(x)`,
+ `**/*.spec.?([cm])[jt]s?(x)`,
+ `**/*.test.?([cm])[jt]s?(x)`,
+ `**/*.bench.?([cm])[jt]s?(x)`,
+ `**/*.benchmark.?([cm])[jt]s?(x)`,
+ ],
+ plugins: {
+ test: {
+ ...pluginTest,
+ rules: {
+ ...pluginTest.rules,
+ ...pluginNoOnlyTests.rules,
+ },
+ },
+ },
+ rules: {
+ 'no-console': 'off',
+ 'node/prefer-global/process': 'off',
+ 'test/consistent-test-it': [
+ 'error',
+ { fn: 'it', withinDescribe: 'it' },
+ ],
+ 'test/no-identical-title': 'error',
+ 'test/no-import-node-test': 'error',
+ 'test/no-only-tests': 'error',
+ 'test/prefer-hooks-in-order': 'error',
+ 'test/prefer-lowercase-title': 'error',
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/turbo.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/turbo.ts
new file mode 100644
index 000000000..9f6bf75be
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/turbo.ts
@@ -0,0 +1,18 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function turbo(): Promise {
+ const [pluginTurbo] = await Promise.all([
+ // @ts-expect-error - no types
+ interopDefault(import('eslint-config-turbo')),
+ ] as const);
+
+ return [
+ {
+ plugins: {
+ turbo: pluginTurbo,
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/typescript.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/typescript.ts
new file mode 100644
index 000000000..cff9aa4bc
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/typescript.ts
@@ -0,0 +1,72 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function typescript(): Promise {
+ const [pluginTs, parserTs] = await Promise.all([
+ interopDefault(import('@typescript-eslint/eslint-plugin')),
+ // @ts-expect-error missing types
+ interopDefault(import('@typescript-eslint/parser')),
+ ] as const);
+
+ return [
+ {
+ files: ['**/*.?([cm])[jt]s?(x)'],
+ languageOptions: {
+ parser: parserTs,
+ parserOptions: {
+ createDefaultProgram: false,
+ ecmaFeatures: {
+ jsx: true,
+ },
+ ecmaVersion: 'latest',
+ extraFileExtensions: ['.vue'],
+ jsxPragma: 'React',
+ project: './tsconfig.*.json',
+ sourceType: 'module',
+ },
+ },
+ plugins: {
+ '@typescript-eslint': pluginTs,
+ },
+ rules: {
+ ...pluginTs.configs['eslint-recommended'].overrides?.[0].rules,
+ ...pluginTs.configs.strict.rules,
+ '@typescript-eslint/ban-ts-comment': [
+ 'error',
+ {
+ 'ts-check': false,
+ 'ts-expect-error': 'allow-with-description',
+ 'ts-ignore': 'allow-with-description',
+ 'ts-nocheck': 'allow-with-description',
+ },
+ ],
+
+ // '@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
+ '@typescript-eslint/consistent-type-definitions': 'off',
+ '@typescript-eslint/explicit-function-return-type': 'off',
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
+ '@typescript-eslint/no-empty-function': [
+ 'error',
+ {
+ allow: ['arrowFunctions', 'functions', 'methods'],
+ },
+ ],
+ '@typescript-eslint/no-explicit-any': 'off',
+ '@typescript-eslint/no-namespace': 'off',
+ '@typescript-eslint/no-non-null-assertion': 'error',
+ '@typescript-eslint/no-unused-expressions': 'off',
+ '@typescript-eslint/no-unused-vars': [
+ 'error',
+ {
+ argsIgnorePattern: '^_',
+ varsIgnorePattern: '^_',
+ },
+ ],
+ '@typescript-eslint/no-use-before-define': 'off',
+ '@typescript-eslint/no-var-requires': 'error',
+ 'unused-imports/no-unused-vars': 'off',
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/unicorn.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/unicorn.ts
new file mode 100644
index 000000000..21b19025d
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/unicorn.ts
@@ -0,0 +1,45 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function unicorn(): Promise {
+ const [pluginUnicorn] = await Promise.all([
+ interopDefault(import('eslint-plugin-unicorn')),
+ ] as const);
+
+ return [
+ {
+ plugins: {
+ unicorn: pluginUnicorn,
+ },
+ rules: {
+ ...pluginUnicorn.configs.recommended.rules,
+
+ 'unicorn/better-regex': 'off',
+ 'unicorn/consistent-destructuring': 'off',
+ 'unicorn/consistent-function-scoping': 'off',
+ 'unicorn/expiring-todo-comments': 'off',
+ 'unicorn/filename-case': 'off',
+ 'unicorn/import-style': 'off',
+ 'unicorn/no-array-for-each': 'off',
+ 'unicorn/no-null': 'off',
+ 'unicorn/no-useless-undefined': 'off',
+ 'unicorn/prefer-at': 'off',
+ 'unicorn/prefer-dom-node-text-content': 'off',
+ 'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
+ 'unicorn/prefer-global-this': 'off',
+ 'unicorn/prefer-top-level-await': 'off',
+ 'unicorn/prevent-abbreviations': 'off',
+ },
+ },
+ {
+ files: [
+ 'scripts/**/*.?([cm])[jt]s?(x)',
+ 'internal/**/*.?([cm])[jt]s?(x)',
+ ],
+ rules: {
+ 'unicorn/no-process-exit': 'off',
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/configs/vue.ts b/apps/vben5/internal/lint-configs/eslint-config/src/configs/vue.ts
new file mode 100644
index 000000000..27cc3cf29
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/configs/vue.ts
@@ -0,0 +1,150 @@
+import type { Linter } from 'eslint';
+
+import { interopDefault } from '../util';
+
+export async function vue(): Promise {
+ const [pluginVue, parserVue, parserTs] = await Promise.all([
+ // @ts-expect-error missing types
+ interopDefault(import('eslint-plugin-vue')),
+ interopDefault(import('vue-eslint-parser')),
+ // @ts-expect-error missing types
+ interopDefault(import('@typescript-eslint/parser')),
+ ] as const);
+
+ return [
+ {
+ files: ['**/*.vue'],
+ languageOptions: {
+ // globals: {
+ // computed: 'readonly',
+ // defineEmits: 'readonly',
+ // defineExpose: 'readonly',
+ // defineProps: 'readonly',
+ // onMounted: 'readonly',
+ // onUnmounted: 'readonly',
+ // reactive: 'readonly',
+ // ref: 'readonly',
+ // shallowReactive: 'readonly',
+ // shallowRef: 'readonly',
+ // toRef: 'readonly',
+ // toRefs: 'readonly',
+ // watch: 'readonly',
+ // watchEffect: 'readonly',
+ // },
+ parser: parserVue,
+ parserOptions: {
+ ecmaFeatures: {
+ jsx: true,
+ },
+ extraFileExtensions: ['.vue'],
+ parser: parserTs,
+ sourceType: 'module',
+ },
+ },
+ plugins: {
+ vue: pluginVue,
+ },
+ processor: pluginVue.processors['.vue'],
+ rules: {
+ ...pluginVue.configs.base.rules,
+ ...pluginVue.configs['vue3-essential'].rules,
+ ...pluginVue.configs['vue3-strongly-recommended'].rules,
+ ...pluginVue.configs['vue3-recommended'].rules,
+
+ 'vue/attribute-hyphenation': [
+ 'error',
+ 'always',
+ {
+ ignore: [],
+ },
+ ],
+ 'vue/attributes-order': 'off',
+ 'vue/block-order': [
+ 'error',
+ {
+ order: ['script', 'template', 'style'],
+ },
+ ],
+ 'vue/component-name-in-template-casing': ['error', 'PascalCase'],
+ 'vue/component-options-name-casing': ['error', 'PascalCase'],
+ 'vue/custom-event-name-casing': ['error', 'camelCase'],
+ 'vue/define-macros-order': [
+ 'error',
+ {
+ order: [
+ 'defineOptions',
+ 'defineProps',
+ 'defineEmits',
+ 'defineSlots',
+ ],
+ },
+ ],
+ 'vue/dot-location': ['error', 'property'],
+ 'vue/dot-notation': ['error', { allowKeywords: true }],
+ 'vue/eqeqeq': ['error', 'smart'],
+ 'vue/html-closing-bracket-newline': 'error',
+ 'vue/html-indent': 'off',
+ // 'vue/html-indent': ['error', 2],
+ 'vue/html-quotes': ['error', 'double'],
+ 'vue/html-self-closing': [
+ 'error',
+ {
+ html: {
+ component: 'always',
+ normal: 'never',
+ void: 'always',
+ },
+ math: 'always',
+ svg: 'always',
+ },
+ ],
+ 'vue/max-attributes-per-line': 'off',
+ 'vue/multi-word-component-names': 'off',
+ 'vue/multiline-html-element-content-newline': 'error',
+ 'vue/no-empty-pattern': 'error',
+ 'vue/no-extra-parens': ['error', 'functions'],
+ 'vue/no-irregular-whitespace': 'error',
+ 'vue/no-loss-of-precision': 'error',
+ 'vue/no-reserved-component-names': 'off',
+ 'vue/no-restricted-syntax': [
+ 'error',
+ 'DebuggerStatement',
+ 'LabeledStatement',
+ 'WithStatement',
+ ],
+ 'vue/no-restricted-v-bind': ['error', '/^v-/'],
+ 'vue/no-sparse-arrays': 'error',
+ 'vue/no-unused-refs': 'error',
+ 'vue/no-useless-v-bind': 'error',
+ 'vue/object-shorthand': [
+ 'error',
+ 'always',
+ {
+ avoidQuotes: true,
+ ignoreConstructors: false,
+ },
+ ],
+ 'vue/one-component-per-file': 'error',
+ 'vue/prefer-import-from-vue': 'error',
+ 'vue/prefer-separate-static-class': 'error',
+ 'vue/prefer-template': 'error',
+ 'vue/prop-name-casing': ['error', 'camelCase'],
+ 'vue/require-default-prop': 'error',
+ 'vue/require-explicit-emits': 'error',
+ 'vue/require-prop-types': 'off',
+ 'vue/script-setup-uses-vars': 'error',
+ 'vue/singleline-html-element-content-newline': 'off',
+ 'vue/space-infix-ops': 'error',
+ 'vue/space-unary-ops': ['error', { nonwords: false, words: true }],
+ 'vue/v-on-event-hyphenation': [
+ 'error',
+ 'always',
+ {
+ autofix: true,
+ ignore: [],
+ },
+ ],
+ },
+ },
+ ];
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/custom-config.ts b/apps/vben5/internal/lint-configs/eslint-config/src/custom-config.ts
new file mode 100644
index 000000000..410b8991a
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/custom-config.ts
@@ -0,0 +1,166 @@
+import type { Linter } from 'eslint';
+
+const restrictedImportIgnores = [
+ '**/vite.config.mts',
+ '**/tailwind.config.mjs',
+ '**/postcss.config.mjs',
+];
+
+const customConfig: Linter.Config[] = [
+ // shadcn-ui 内部组件是自动生成的,不做太多限制
+ {
+ files: ['packages/@core/ui-kit/shadcn-ui/**/**'],
+ rules: {
+ 'vue/require-default-prop': 'off',
+ },
+ },
+ {
+ files: [
+ 'apps/**/**',
+ 'packages/effects/**/**',
+ 'packages/utils/**/**',
+ 'packages/types/**/**',
+ 'packages/locales/**/**',
+ ],
+ ignores: restrictedImportIgnores,
+ rules: {
+ 'perfectionist/sort-interfaces': 'off',
+ 'perfectionist/sort-objects': 'off',
+ },
+ },
+ {
+ // apps内部的一些基础规则
+ files: ['apps/**/**'],
+ ignores: restrictedImportIgnores,
+ rules: {
+ 'no-restricted-imports': [
+ 'error',
+ {
+ patterns: [
+ {
+ group: ['#/api/*'],
+ message:
+ 'The #/api package cannot be imported, please use the @core package itself',
+ },
+ {
+ group: ['#/layouts/*'],
+ message:
+ 'The #/layouts package cannot be imported, please use the @core package itself',
+ },
+ {
+ group: ['#/locales/*'],
+ message:
+ 'The #/locales package cannot be imported, please use the @core package itself',
+ },
+ {
+ group: ['#/stores/*'],
+ message:
+ 'The #/stores package cannot be imported, please use the @core package itself',
+ },
+ ],
+ },
+ ],
+ 'perfectionist/sort-interfaces': 'off',
+ },
+ },
+ {
+ // @core内部组件,不能引入@vben/* 里面的包
+ files: ['packages/@core/**/**'],
+ ignores: restrictedImportIgnores,
+ rules: {
+ 'no-restricted-imports': [
+ 'error',
+ {
+ patterns: [
+ {
+ group: ['@vben/*'],
+ message:
+ 'The @core package cannot import the @vben package, please use the @core package itself',
+ },
+ ],
+ },
+ ],
+ },
+ },
+ {
+ // @core/shared内部组件,不能引入@vben/* 或者 @vben-core/* 里面的包
+ files: ['packages/@core/base/**/**'],
+ ignores: restrictedImportIgnores,
+ rules: {
+ 'no-restricted-imports': [
+ 'error',
+ {
+ patterns: [
+ {
+ group: ['@vben/*', '@vben-core/*'],
+ message:
+ 'The @vben-core/shared package cannot import the @vben package, please use the @core/shared package itself',
+ },
+ ],
+ },
+ ],
+ },
+ },
+
+ {
+ // 不能引入@vben/*里面的包
+ files: [
+ 'packages/types/**/**',
+ 'packages/utils/**/**',
+ 'packages/icons/**/**',
+ 'packages/constants/**/**',
+ 'packages/styles/**/**',
+ 'packages/stores/**/**',
+ 'packages/preferences/**/**',
+ 'packages/locales/**/**',
+ ],
+ ignores: restrictedImportIgnores,
+ rules: {
+ 'no-restricted-imports': [
+ 'error',
+ {
+ patterns: [
+ {
+ group: ['@vben/*'],
+ message:
+ 'The @vben package cannot be imported, please use the @core package itself',
+ },
+ ],
+ },
+ ],
+ },
+ },
+ // 后端模拟代码,不需要太多规则
+ {
+ files: ['apps/backend-mock/**/**', 'docs/**/**'],
+ rules: {
+ '@typescript-eslint/no-extraneous-class': 'off',
+ 'n/no-extraneous-import': 'off',
+ 'n/prefer-global/buffer': 'off',
+ 'n/prefer-global/process': 'off',
+ 'no-console': 'off',
+ 'unicorn/prefer-module': 'off',
+ },
+ },
+ {
+ files: ['**/**/playwright.config.ts'],
+ rules: {
+ 'n/prefer-global/buffer': 'off',
+ 'n/prefer-global/process': 'off',
+ 'no-console': 'off',
+ },
+ },
+ {
+ files: ['internal/**/**', 'scripts/**/**'],
+ rules: {
+ 'no-console': 'off',
+ },
+ },
+ {
+ // abp 包规则
+ files: ['packages/@abp/**'],
+ rules: {},
+ },
+];
+
+export { customConfig };
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/index.ts b/apps/vben5/internal/lint-configs/eslint-config/src/index.ts
new file mode 100644
index 000000000..c9f08bd54
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/index.ts
@@ -0,0 +1,60 @@
+import type { Linter } from 'eslint';
+
+import {
+ command,
+ comments,
+ disableds,
+ ignores,
+ importPluginConfig,
+ javascript,
+ jsdoc,
+ jsonc,
+ node,
+ perfectionist,
+ prettier,
+ regexp,
+ test,
+ turbo,
+ typescript,
+ unicorn,
+ vue,
+} from './configs';
+import { customConfig } from './custom-config';
+
+type FlatConfig = Linter.Config;
+
+type FlatConfigPromise =
+ | FlatConfig
+ | FlatConfig[]
+ | Promise
+ | Promise;
+
+async function defineConfig(config: FlatConfig[] = []) {
+ const configs: FlatConfigPromise[] = [
+ vue(),
+ javascript(),
+ ignores(),
+ prettier(),
+ typescript(),
+ jsonc(),
+ disableds(),
+ importPluginConfig(),
+ node(),
+ perfectionist(),
+ comments(),
+ jsdoc(),
+ unicorn(),
+ test(),
+ regexp(),
+ command(),
+ turbo(),
+ ...customConfig,
+ ...config,
+ ];
+
+ const resolved = await Promise.all(configs);
+
+ return resolved.flat();
+}
+
+export { defineConfig };
diff --git a/apps/vben5/internal/lint-configs/eslint-config/src/util.ts b/apps/vben5/internal/lint-configs/eslint-config/src/util.ts
new file mode 100644
index 000000000..d1a10ad8c
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/src/util.ts
@@ -0,0 +1,8 @@
+export type Awaitable = Promise | T;
+
+export async function interopDefault(
+ m: Awaitable,
+): Promise {
+ const resolved = await m;
+ return (resolved as any).default || resolved;
+}
diff --git a/apps/vben5/internal/lint-configs/eslint-config/tsconfig.json b/apps/vben5/internal/lint-configs/eslint-config/tsconfig.json
new file mode 100644
index 000000000..b2ec3b61e
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/eslint-config/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/node.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/apps/vben5/internal/lint-configs/prettier-config/index.mjs b/apps/vben5/internal/lint-configs/prettier-config/index.mjs
new file mode 100644
index 000000000..f6a20c8b4
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/prettier-config/index.mjs
@@ -0,0 +1,18 @@
+export default {
+ endOfLine: 'auto',
+ overrides: [
+ {
+ files: ['*.json5'],
+ options: {
+ quoteProps: 'preserve',
+ singleQuote: false,
+ },
+ },
+ ],
+ plugins: ['prettier-plugin-tailwindcss'],
+ printWidth: 80,
+ proseWrap: 'never',
+ semi: true,
+ singleQuote: true,
+ trailingComma: 'all',
+};
diff --git a/apps/vben5/internal/lint-configs/prettier-config/package.json b/apps/vben5/internal/lint-configs/prettier-config/package.json
new file mode 100644
index 000000000..65e8b8f88
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/prettier-config/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "@vben/prettier-config",
+ "version": "5.0.0",
+ "private": true,
+ "homepage": "https://github.com/vbenjs/vue-vben-admin",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "internal/lint-configs/prettier-config"
+ },
+ "license": "MIT",
+ "type": "module",
+ "files": [
+ "dist"
+ ],
+ "main": "./index.mjs",
+ "module": "./index.mjs",
+ "exports": {
+ ".": {
+ "default": "./index.mjs"
+ }
+ },
+ "dependencies": {
+ "prettier": "catalog:",
+ "prettier-plugin-tailwindcss": "catalog:"
+ }
+}
diff --git a/apps/vben5/internal/lint-configs/stylelint-config/index.mjs b/apps/vben5/internal/lint-configs/stylelint-config/index.mjs
new file mode 100644
index 000000000..7ef175cca
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/stylelint-config/index.mjs
@@ -0,0 +1,140 @@
+export default {
+ extends: ['stylelint-config-standard', 'stylelint-config-recess-order'],
+ ignoreFiles: [
+ '**/*.js',
+ '**/*.jsx',
+ '**/*.tsx',
+ '**/*.ts',
+ '**/*.json',
+ '**/*.md',
+ ],
+ overrides: [
+ {
+ customSyntax: 'postcss-html',
+ files: ['*.(html|vue)', '**/*.(html|vue)'],
+ rules: {
+ 'selector-pseudo-class-no-unknown': [
+ true,
+ {
+ ignorePseudoClasses: ['global', 'deep'],
+ },
+ ],
+ 'selector-pseudo-element-no-unknown': [
+ true,
+ {
+ ignorePseudoElements: ['v-deep', 'v-global', 'v-slotted'],
+ },
+ ],
+ },
+ },
+ {
+ customSyntax: 'postcss-scss',
+ extends: [
+ 'stylelint-config-recommended-scss',
+ 'stylelint-config-recommended-vue/scss',
+ ],
+ files: ['*.scss', '**/*.scss'],
+ },
+ ],
+ plugins: [
+ 'stylelint-order',
+ '@stylistic/stylelint-plugin',
+ 'stylelint-prettier',
+ 'stylelint-scss',
+ ],
+ rules: {
+ 'at-rule-no-unknown': [
+ true,
+ {
+ ignoreAtRules: [
+ 'extends',
+ 'ignores',
+ 'include',
+ 'mixin',
+ 'if',
+ 'else',
+ 'media',
+ 'for',
+ 'at-root',
+ 'tailwind',
+ 'apply',
+ 'variants',
+ 'responsive',
+ 'screen',
+ 'function',
+ 'each',
+ 'use',
+ 'forward',
+ 'return',
+ ],
+ },
+ ],
+ 'font-family-no-missing-generic-family-keyword': null,
+ 'function-no-unknown': null,
+ 'import-notation': null,
+ 'media-feature-range-notation': null,
+ 'named-grid-areas-no-invalid': null,
+ 'no-descending-specificity': null,
+ 'no-empty-source': null,
+ 'order/order': [
+ [
+ 'dollar-variables',
+ 'custom-properties',
+ 'at-rules',
+ 'declarations',
+ {
+ name: 'supports',
+ type: 'at-rule',
+ },
+ {
+ name: 'media',
+ type: 'at-rule',
+ },
+ {
+ name: 'include',
+ type: 'at-rule',
+ },
+ 'rules',
+ ],
+ { severity: 'error' },
+ ],
+ 'prettier/prettier': true,
+ 'rule-empty-line-before': [
+ 'always',
+ {
+ ignore: ['after-comment', 'first-nested'],
+ },
+ ],
+ 'scss/at-rule-no-unknown': [
+ true,
+ {
+ ignoreAtRules: [
+ 'extends',
+ 'ignores',
+ 'include',
+ 'mixin',
+ 'if',
+ 'else',
+ 'media',
+ 'for',
+ 'at-root',
+ 'tailwind',
+ 'apply',
+ 'variants',
+ 'responsive',
+ 'screen',
+ 'function',
+ 'each',
+ 'use',
+ 'forward',
+ 'return',
+ ],
+ },
+ ],
+ 'scss/operator-no-newline-after': null,
+ 'selector-class-pattern':
+ '^(?:(?:o|c|u|t|s|is|has|_|js|qa)-)?[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*(?:__[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)?(?:--[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)?(?:[.+])?$',
+
+ 'selector-not-notation': null,
+ },
+};
diff --git a/apps/vben5/internal/lint-configs/stylelint-config/package.json b/apps/vben5/internal/lint-configs/stylelint-config/package.json
new file mode 100644
index 000000000..c9e8cf539
--- /dev/null
+++ b/apps/vben5/internal/lint-configs/stylelint-config/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "@vben/stylelint-config",
+ "version": "5.4.8",
+ "private": true,
+ "homepage": "https://github.com/vbenjs/vue-vben-admin",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "internal/lint-configs/stylelint-config"
+ },
+ "license": "MIT",
+ "type": "module",
+ "files": [
+ "dist"
+ ],
+ "main": "./index.mjs",
+ "module": "./index.mjs",
+ "exports": {
+ ".": {
+ "import": "./index.mjs",
+ "default": "./index.mjs"
+ }
+ },
+ "dependencies": {
+ "@stylistic/stylelint-plugin": "catalog:",
+ "stylelint-config-recess-order": "catalog:",
+ "stylelint-scss": "catalog:"
+ },
+ "devDependencies": {
+ "postcss": "catalog:",
+ "postcss-html": "catalog:",
+ "postcss-scss": "catalog:",
+ "prettier": "catalog:",
+ "stylelint": "catalog:",
+ "stylelint-config-recommended": "catalog:",
+ "stylelint-config-recommended-scss": "catalog:",
+ "stylelint-config-recommended-vue": "catalog:",
+ "stylelint-config-standard": "catalog:",
+ "stylelint-order": "catalog:",
+ "stylelint-prettier": "catalog:"
+ }
+}
diff --git a/apps/vben5/internal/node-utils/build.config.ts b/apps/vben5/internal/node-utils/build.config.ts
new file mode 100644
index 000000000..97e572c56
--- /dev/null
+++ b/apps/vben5/internal/node-utils/build.config.ts
@@ -0,0 +1,7 @@
+import { defineBuildConfig } from 'unbuild';
+
+export default defineBuildConfig({
+ clean: true,
+ declaration: true,
+ entries: ['src/index'],
+});
diff --git a/apps/vben5/internal/node-utils/package.json b/apps/vben5/internal/node-utils/package.json
new file mode 100644
index 000000000..0cd1eaa3d
--- /dev/null
+++ b/apps/vben5/internal/node-utils/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "@vben/node-utils",
+ "version": "5.4.8",
+ "private": true,
+ "homepage": "https://github.com/vbenjs/vue-vben-admin",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "internal/node-utils"
+ },
+ "license": "MIT",
+ "type": "module",
+ "scripts": {
+ "stub": "pnpm unbuild --stub"
+ },
+ "files": [
+ "dist"
+ ],
+ "main": "./dist/index.mjs",
+ "module": "./dist/index.mjs",
+ "types": "./dist/index.d.ts",
+ "exports": {
+ ".": {
+ "types": "./src/index.ts",
+ "import": "./dist/index.mjs",
+ "default": "./dist/index.mjs"
+ }
+ },
+ "dependencies": {
+ "@changesets/git": "catalog:",
+ "@manypkg/get-packages": "catalog:",
+ "chalk": "catalog:",
+ "consola": "catalog:",
+ "dayjs": "catalog:",
+ "execa": "catalog:",
+ "find-up": "catalog:",
+ "ora": "catalog:",
+ "pkg-types": "catalog:",
+ "prettier": "catalog:",
+ "rimraf": "catalog:"
+ }
+}
diff --git a/apps/vben5/internal/node-utils/src/__tests__/hash.test.ts b/apps/vben5/internal/node-utils/src/__tests__/hash.test.ts
new file mode 100644
index 000000000..385130606
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/__tests__/hash.test.ts
@@ -0,0 +1,52 @@
+import { createHash } from 'node:crypto';
+
+import { describe, expect, it } from 'vitest';
+
+import { generatorContentHash } from '../hash';
+
+describe('generatorContentHash', () => {
+ it('should generate an MD5 hash for the content', () => {
+ const content = 'example content';
+ const expectedHash = createHash('md5')
+ .update(content, 'utf8')
+ .digest('hex');
+ const actualHash = generatorContentHash(content);
+ expect(actualHash).toBe(expectedHash);
+ });
+
+ it('should generate an MD5 hash with specified length', () => {
+ const content = 'example content';
+ const hashLength = 10;
+ const generatedHash = generatorContentHash(content, hashLength);
+ expect(generatedHash).toHaveLength(hashLength);
+ });
+
+ it('should correctly generate the hash with specified length', () => {
+ const content = 'example content';
+ const hashLength = 8;
+ const expectedHash = createHash('md5')
+ .update(content, 'utf8')
+ .digest('hex')
+ .slice(0, hashLength);
+ const generatedHash = generatorContentHash(content, hashLength);
+ expect(generatedHash).toBe(expectedHash);
+ });
+
+ it('should return full hash if hash length parameter is not provided', () => {
+ const content = 'example content';
+ const expectedHash = createHash('md5')
+ .update(content, 'utf8')
+ .digest('hex');
+ const actualHash = generatorContentHash(content);
+ expect(actualHash).toBe(expectedHash);
+ });
+
+ it('should handle empty content', () => {
+ const content = '';
+ const expectedHash = createHash('md5')
+ .update(content, 'utf8')
+ .digest('hex');
+ const actualHash = generatorContentHash(content);
+ expect(actualHash).toBe(expectedHash);
+ });
+});
diff --git a/apps/vben5/internal/node-utils/src/__tests__/path.test.ts b/apps/vben5/internal/node-utils/src/__tests__/path.test.ts
new file mode 100644
index 000000000..3bab5a167
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/__tests__/path.test.ts
@@ -0,0 +1,67 @@
+// pathUtils.test.ts
+
+import { describe, expect, it } from 'vitest';
+
+import { toPosixPath } from '../path';
+
+describe('toPosixPath', () => {
+ // 测试 Windows 风格路径到 POSIX 风格路径的转换
+ it('converts Windows-style paths to POSIX paths', () => {
+ const windowsPath = String.raw`C:\Users\Example\file.txt`;
+ const expectedPosixPath = 'C:/Users/Example/file.txt';
+ expect(toPosixPath(windowsPath)).toBe(expectedPosixPath);
+ });
+
+ // 确认 POSIX 风格路径不会被改变
+ it('leaves POSIX-style paths unchanged', () => {
+ const posixPath = '/home/user/file.txt';
+ expect(toPosixPath(posixPath)).toBe(posixPath);
+ });
+
+ // 测试带有多个分隔符的路径
+ it('converts paths with mixed separators', () => {
+ const mixedPath = String.raw`C:/Users\Example\file.txt`;
+ const expectedPosixPath = 'C:/Users/Example/file.txt';
+ expect(toPosixPath(mixedPath)).toBe(expectedPosixPath);
+ });
+
+ // 测试空字符串
+ it('handles empty strings', () => {
+ const emptyPath = '';
+ expect(toPosixPath(emptyPath)).toBe('');
+ });
+
+ // 测试仅包含分隔符的路径
+ it('handles path with only separators', () => {
+ const separatorsPath = '\\\\\\';
+ const expectedPosixPath = '///';
+ expect(toPosixPath(separatorsPath)).toBe(expectedPosixPath);
+ });
+
+ // 测试不包含任何分隔符的路径
+ it('handles path without separators', () => {
+ const noSeparatorPath = 'file.txt';
+ expect(toPosixPath(noSeparatorPath)).toBe('file.txt');
+ });
+
+ // 测试以分隔符结尾的路径
+ it('handles path ending with a separator', () => {
+ const endingSeparatorPath = 'C:\\Users\\Example\\';
+ const expectedPosixPath = 'C:/Users/Example/';
+ expect(toPosixPath(endingSeparatorPath)).toBe(expectedPosixPath);
+ });
+
+ // 测试以分隔符开头的路径
+ it('handles path starting with a separator', () => {
+ const startingSeparatorPath = String.raw`\Users\Example`;
+ const expectedPosixPath = '/Users/Example';
+ expect(toPosixPath(startingSeparatorPath)).toBe(expectedPosixPath);
+ });
+
+ // 测试包含非法字符的路径
+ it('handles path with invalid characters', () => {
+ const invalidCharsPath = String.raw`C:\Us*?ers\Ex|file.txt`;
+ const expectedPosixPath = 'C:/Us*?ers/Ex|file.txt';
+ expect(toPosixPath(invalidCharsPath)).toBe(expectedPosixPath);
+ });
+});
diff --git a/apps/vben5/internal/node-utils/src/constants.ts b/apps/vben5/internal/node-utils/src/constants.ts
new file mode 100644
index 000000000..71d8a6cbc
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/constants.ts
@@ -0,0 +1,6 @@
+enum UNICODE {
+ FAILURE = '\u2716', // ✖
+ SUCCESS = '\u2714', // ✔
+}
+
+export { UNICODE };
diff --git a/apps/vben5/internal/node-utils/src/date.ts b/apps/vben5/internal/node-utils/src/date.ts
new file mode 100644
index 000000000..d36572d97
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/date.ts
@@ -0,0 +1,12 @@
+import dayjs from 'dayjs';
+import timezone from 'dayjs/plugin/timezone';
+import utc from 'dayjs/plugin/utc';
+
+dayjs.extend(utc);
+dayjs.extend(timezone);
+
+dayjs.tz.setDefault('Asia/Shanghai');
+
+const dateUtil = dayjs;
+
+export { dateUtil };
diff --git a/apps/vben5/internal/node-utils/src/fs.ts b/apps/vben5/internal/node-utils/src/fs.ts
new file mode 100644
index 000000000..8eec35734
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/fs.ts
@@ -0,0 +1,39 @@
+import { promises as fs } from 'node:fs';
+import { dirname } from 'node:path';
+
+export async function outputJSON(
+ filePath: string,
+ data: any,
+ spaces: number = 2,
+) {
+ try {
+ const dir = dirname(filePath);
+ await fs.mkdir(dir, { recursive: true });
+ const jsonData = JSON.stringify(data, null, spaces);
+ await fs.writeFile(filePath, jsonData, 'utf8');
+ } catch (error) {
+ console.error('Error writing JSON file:', error);
+ throw error;
+ }
+}
+
+export async function ensureFile(filePath: string) {
+ try {
+ const dir = dirname(filePath);
+ await fs.mkdir(dir, { recursive: true });
+ await fs.writeFile(filePath, '', { flag: 'a' });
+ } catch (error) {
+ console.error('Error ensuring file:', error);
+ throw error;
+ }
+}
+
+export async function readJSON(filePath: string) {
+ try {
+ const data = await fs.readFile(filePath, 'utf8');
+ return JSON.parse(data);
+ } catch (error) {
+ console.error('Error reading JSON file:', error);
+ throw error;
+ }
+}
diff --git a/apps/vben5/internal/node-utils/src/git.ts b/apps/vben5/internal/node-utils/src/git.ts
new file mode 100644
index 000000000..88f159cc5
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/git.ts
@@ -0,0 +1,34 @@
+import path from 'node:path';
+
+import { execa } from 'execa';
+
+export * from '@changesets/git';
+
+/**
+ * 获取暂存区文件
+ */
+async function getStagedFiles(): Promise {
+ try {
+ const { stdout } = await execa('git', [
+ '-c',
+ 'submodule.recurse=false',
+ 'diff',
+ '--staged',
+ '--diff-filter=ACMR',
+ '--name-only',
+ '--ignore-submodules',
+ '-z',
+ ]);
+
+ let changedList = stdout ? stdout.replace(/\0$/, '').split('\0') : [];
+ changedList = changedList.map((item) => path.resolve(process.cwd(), item));
+ const changedSet = new Set(changedList);
+ changedSet.delete('');
+ return [...changedSet];
+ } catch (error) {
+ console.error('Failed to get staged files:', error);
+ return [];
+ }
+}
+
+export { getStagedFiles };
diff --git a/apps/vben5/internal/node-utils/src/hash.ts b/apps/vben5/internal/node-utils/src/hash.ts
new file mode 100644
index 000000000..81f6b05c4
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/hash.ts
@@ -0,0 +1,18 @@
+import { createHash } from 'node:crypto';
+
+/**
+ * 生产基于内容的 hash,可自定义长度
+ * @param content
+ * @param hashLSize
+ */
+function generatorContentHash(content: string, hashLSize?: number) {
+ const hash = createHash('md5').update(content, 'utf8').digest('hex');
+
+ if (hashLSize) {
+ return hash.slice(0, hashLSize);
+ }
+
+ return hash;
+}
+
+export { generatorContentHash };
diff --git a/apps/vben5/internal/node-utils/src/index.ts b/apps/vben5/internal/node-utils/src/index.ts
new file mode 100644
index 000000000..2e39ccff6
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/index.ts
@@ -0,0 +1,19 @@
+export * from './constants';
+export * from './date';
+export * from './fs';
+export * from './git';
+export { add as gitAdd, getStagedFiles } from './git';
+export { generatorContentHash } from './hash';
+export * from './monorepo';
+export { toPosixPath } from './path';
+export { prettierFormat } from './prettier';
+export * from './spinner';
+export type { Package } from '@manypkg/get-packages';
+export { default as colors } from 'chalk';
+export { consola } from 'consola';
+export * from 'execa';
+
+export { default as fs } from 'node:fs/promises';
+
+export { type PackageJson, readPackageJSON } from 'pkg-types';
+export { rimraf } from 'rimraf';
diff --git a/apps/vben5/internal/node-utils/src/monorepo.ts b/apps/vben5/internal/node-utils/src/monorepo.ts
new file mode 100644
index 000000000..b6373e78b
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/monorepo.ts
@@ -0,0 +1,46 @@
+import { dirname } from 'node:path';
+
+import {
+ getPackages as getPackagesFunc,
+ getPackagesSync as getPackagesSyncFunc,
+} from '@manypkg/get-packages';
+import { findUpSync } from 'find-up';
+
+/**
+ * 查找大仓的根目录
+ * @param cwd
+ */
+function findMonorepoRoot(cwd: string = process.cwd()) {
+ const lockFile = findUpSync('pnpm-lock.yaml', {
+ cwd,
+ type: 'file',
+ });
+ return dirname(lockFile || '');
+}
+
+/**
+ * 获取大仓的所有包
+ */
+function getPackagesSync() {
+ const root = findMonorepoRoot();
+ return getPackagesSyncFunc(root);
+}
+
+/**
+ * 获取大仓的所有包
+ */
+async function getPackages() {
+ const root = findMonorepoRoot();
+
+ return await getPackagesFunc(root);
+}
+
+/**
+ * 获取大仓指定的包
+ */
+async function getPackage(pkgName: string) {
+ const { packages } = await getPackages();
+ return packages.find((pkg) => pkg.packageJson.name === pkgName);
+}
+
+export { findMonorepoRoot, getPackage, getPackages, getPackagesSync };
diff --git a/apps/vben5/internal/node-utils/src/path.ts b/apps/vben5/internal/node-utils/src/path.ts
new file mode 100644
index 000000000..e625fd2f9
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/path.ts
@@ -0,0 +1,11 @@
+import { posix } from 'node:path';
+
+/**
+ * 将给定的文件路径转换为 POSIX 风格。
+ * @param {string} pathname - 原始文件路径。
+ */
+function toPosixPath(pathname: string) {
+ return pathname.split(`\\`).join(posix.sep);
+}
+
+export { toPosixPath };
diff --git a/apps/vben5/internal/node-utils/src/prettier.ts b/apps/vben5/internal/node-utils/src/prettier.ts
new file mode 100644
index 000000000..1e1525db1
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/prettier.ts
@@ -0,0 +1,21 @@
+import fs from 'node:fs/promises';
+
+import { format, getFileInfo, resolveConfig } from 'prettier';
+
+async function prettierFormat(filepath: string) {
+ const prettierOptions = await resolveConfig(filepath, {});
+
+ const fileInfo = await getFileInfo(filepath);
+
+ const input = await fs.readFile(filepath, 'utf8');
+ const output = await format(input, {
+ ...prettierOptions,
+ parser: fileInfo.inferredParser as any,
+ });
+ if (output !== input) {
+ await fs.writeFile(filepath, output, 'utf8');
+ }
+ return output;
+}
+
+export { prettierFormat };
diff --git a/apps/vben5/internal/node-utils/src/spinner.ts b/apps/vben5/internal/node-utils/src/spinner.ts
new file mode 100644
index 000000000..f07cc2567
--- /dev/null
+++ b/apps/vben5/internal/node-utils/src/spinner.ts
@@ -0,0 +1,24 @@
+import ora, { type Ora } from 'ora';
+
+interface SpinnerOptions {
+ failedText?: string;
+ successText?: string;
+ title: string;
+}
+export async function spinner(
+ { failedText, successText, title }: SpinnerOptions,
+ callback: () => Promise,
+): Promise {
+ const loading: Ora = ora(title).start();
+
+ try {
+ const result = await callback();
+ loading.succeed(successText || 'Success!');
+ return result;
+ } catch (error) {
+ loading.fail(failedText || 'Failed!');
+ throw error;
+ } finally {
+ loading.stop();
+ }
+}
diff --git a/apps/vben5/internal/node-utils/tsconfig.json b/apps/vben5/internal/node-utils/tsconfig.json
new file mode 100644
index 000000000..b2ec3b61e
--- /dev/null
+++ b/apps/vben5/internal/node-utils/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/node.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/apps/vben5/internal/tailwind-config/build.config.ts b/apps/vben5/internal/tailwind-config/build.config.ts
new file mode 100644
index 000000000..1f3c3c220
--- /dev/null
+++ b/apps/vben5/internal/tailwind-config/build.config.ts
@@ -0,0 +1,10 @@
+import { defineBuildConfig } from 'unbuild';
+
+export default defineBuildConfig({
+ clean: true,
+ declaration: true,
+ entries: ['src/index', './src/postcss.config'],
+ rollup: {
+ emitCJS: true,
+ },
+});
diff --git a/apps/vben5/internal/tailwind-config/package.json b/apps/vben5/internal/tailwind-config/package.json
new file mode 100644
index 000000000..004ae0bc1
--- /dev/null
+++ b/apps/vben5/internal/tailwind-config/package.json
@@ -0,0 +1,66 @@
+{
+ "name": "@vben/tailwind-config",
+ "version": "5.4.8",
+ "private": true,
+ "homepage": "https://github.com/vbenjs/vue-vben-admin",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "internal/tailwind-config"
+ },
+ "license": "MIT",
+ "type": "module",
+ "scripts": {
+ "stub": "pnpm unbuild"
+ },
+ "files": [
+ "dist"
+ ],
+ "main": "./dist/index.mjs",
+ "module": "./dist/index.mjs",
+ "types": "./dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "./dist/*",
+ "./*"
+ ]
+ }
+ },
+ "exports": {
+ ".": {
+ "types": "./src/index.ts",
+ "import": "./dist/index.mjs",
+ "require": "./dist/index.cjs"
+ },
+ "./postcss": {
+ "types": "./src/postcss.config.ts",
+ "import": "./dist/postcss.config.mjs",
+ "require": "./dist/postcss.config.cjs",
+ "default": "./dist/postcss.config.mjs"
+ },
+ "./*": "./*"
+ },
+ "peerDependencies": {
+ "tailwindcss": "^3.4.3"
+ },
+ "dependencies": {
+ "@iconify/json": "catalog:",
+ "@iconify/tailwind": "catalog:",
+ "@manypkg/get-packages": "catalog:",
+ "@tailwindcss/nesting": "catalog:",
+ "@tailwindcss/typography": "catalog:",
+ "autoprefixer": "catalog:",
+ "cssnano": "catalog:",
+ "postcss": "catalog:",
+ "postcss-antd-fixes": "catalog:",
+ "postcss-import": "catalog:",
+ "postcss-preset-env": "catalog:",
+ "tailwindcss": "catalog:",
+ "tailwindcss-animate": "catalog:"
+ },
+ "devDependencies": {
+ "@types/postcss-import": "catalog:"
+ }
+}
diff --git a/apps/vben5/internal/tailwind-config/src/index.ts b/apps/vben5/internal/tailwind-config/src/index.ts
new file mode 100644
index 000000000..dafaaf91e
--- /dev/null
+++ b/apps/vben5/internal/tailwind-config/src/index.ts
@@ -0,0 +1,266 @@
+import type { Config } from 'tailwindcss';
+
+import path from 'node:path';
+
+import { addDynamicIconSelectors } from '@iconify/tailwind';
+import { getPackagesSync } from '@manypkg/get-packages';
+import typographyPlugin from '@tailwindcss/typography';
+import animate from 'tailwindcss-animate';
+
+import { enterAnimationPlugin } from './plugins/entry';
+
+// import defaultTheme from 'tailwindcss/defaultTheme';
+
+const { packages } = getPackagesSync(process.cwd());
+
+const tailwindPackages: string[] = [];
+
+packages.forEach((pkg) => {
+ // apps目录下和 @vben-core/tailwind-ui 包需要使用到 tailwindcss ui
+ // if (fs.existsSync(path.join(pkg.dir, 'tailwind.config.mjs'))) {
+ tailwindPackages.push(pkg.dir);
+ // }
+});
+
+const shadcnUiColors = {
+ accent: {
+ DEFAULT: 'hsl(var(--accent))',
+ foreground: 'hsl(var(--accent-foreground))',
+ hover: 'hsl(var(--accent-hover))',
+ lighter: 'has(val(--accent-lighter))',
+ },
+ background: {
+ deep: 'hsl(var(--background-deep))',
+ DEFAULT: 'hsl(var(--background))',
+ },
+ border: {
+ DEFAULT: 'hsl(var(--border))',
+ },
+ card: {
+ DEFAULT: 'hsl(var(--card))',
+ foreground: 'hsl(var(--card-foreground))',
+ },
+ destructive: {
+ ...createColorsPalette('destructive'),
+ DEFAULT: 'hsl(var(--destructive))',
+ },
+
+ foreground: {
+ DEFAULT: 'hsl(var(--foreground))',
+ },
+
+ input: {
+ background: 'hsl(var(--input-background))',
+ DEFAULT: 'hsl(var(--input))',
+ },
+ muted: {
+ DEFAULT: 'hsl(var(--muted))',
+ foreground: 'hsl(var(--muted-foreground))',
+ },
+ popover: {
+ DEFAULT: 'hsl(var(--popover))',
+ foreground: 'hsl(var(--popover-foreground))',
+ },
+ primary: {
+ ...createColorsPalette('primary'),
+ DEFAULT: 'hsl(var(--primary))',
+ },
+
+ ring: 'hsl(var(--ring))',
+ secondary: {
+ DEFAULT: 'hsl(var(--secondary))',
+ desc: 'hsl(var(--secondary-desc))',
+ foreground: 'hsl(var(--secondary-foreground))',
+ },
+};
+
+const customColors = {
+ green: {
+ ...createColorsPalette('green'),
+ foreground: 'hsl(var(--success-foreground))',
+ },
+ header: {
+ DEFAULT: 'hsl(var(--header))',
+ },
+ heavy: {
+ DEFAULT: 'hsl(var(--heavy))',
+ foreground: 'hsl(var(--heavy-foreground))',
+ },
+ main: {
+ DEFAULT: 'hsl(var(--main))',
+ },
+ overlay: {
+ content: 'hsl(var(--overlay-content))',
+ DEFAULT: 'hsl(var(--overlay))',
+ },
+ red: {
+ ...createColorsPalette('red'),
+ foreground: 'hsl(var(--destructive-foreground))',
+ },
+ sidebar: {
+ deep: 'hsl(var(--sidebar-deep))',
+ DEFAULT: 'hsl(var(--sidebar))',
+ },
+ success: {
+ ...createColorsPalette('success'),
+ DEFAULT: 'hsl(var(--success))',
+ },
+ warning: {
+ ...createColorsPalette('warning'),
+ DEFAULT: 'hsl(var(--warning))',
+ },
+ yellow: {
+ ...createColorsPalette('yellow'),
+ foreground: 'hsl(var(--warning-foreground))',
+ },
+};
+
+export default {
+ content: [
+ './index.html',
+ ...tailwindPackages.map((item) =>
+ path.join(item, 'src/**/*.{vue,js,ts,jsx,tsx,svelte,astro,html}'),
+ ),
+ ],
+ darkMode: 'selector',
+ plugins: [
+ animate,
+ typographyPlugin,
+ addDynamicIconSelectors(),
+ enterAnimationPlugin,
+ ],
+ prefix: '',
+ safelist: ['dark'],
+ theme: {
+ container: {
+ center: true,
+ padding: '2rem',
+ screens: {
+ '2xl': '1400px',
+ },
+ },
+ extend: {
+ animation: {
+ 'accordion-down': 'accordion-down 0.2s ease-out',
+ 'accordion-up': 'accordion-up 0.2s ease-out',
+ 'collapsible-down': 'collapsible-down 0.2s ease-in-out',
+ 'collapsible-up': 'collapsible-up 0.2s ease-in-out',
+ float: 'float 5s linear 0ms infinite',
+ },
+
+ animationDuration: {
+ '2000': '2000ms',
+ '3000': '3000ms',
+ },
+ borderRadius: {
+ lg: 'var(--radius)',
+ md: 'calc(var(--radius) - 2px)',
+ sm: 'calc(var(--radius) - 4px)',
+ xl: 'calc(var(--radius) + 4px)',
+ },
+ boxShadow: {
+ float: `0 6px 16px 0 rgb(0 0 0 / 8%),
+ 0 3px 6px -4px rgb(0 0 0 / 12%),
+ 0 9px 28px 8px rgb(0 0 0 / 5%)`,
+ },
+ colors: {
+ ...customColors,
+ ...shadcnUiColors,
+ },
+ fontFamily: {
+ sans: [
+ 'var(--font-family)',
+ // ...defaultTheme.fontFamily.sans
+ ],
+ },
+ keyframes: {
+ 'accordion-down': {
+ from: { height: '0' },
+ to: { height: 'var(--radix-accordion-content-height)' },
+ },
+ 'accordion-up': {
+ from: { height: 'var(--radix-accordion-content-height)' },
+ to: { height: '0' },
+ },
+ 'collapsible-down': {
+ from: { height: '0' },
+ to: { height: 'var(--radix-collapsible-content-height)' },
+ },
+ 'collapsible-up': {
+ from: { height: 'var(--radix-collapsible-content-height)' },
+ to: { height: '0' },
+ },
+ float: {
+ '0%': { transform: 'translateY(0)' },
+ '50%': { transform: 'translateY(-20px)' },
+ '100%': { transform: 'translateY(0)' },
+ },
+ },
+ zIndex: {
+ '100': '100',
+ '1000': '1000',
+ },
+ },
+ },
+} as Config;
+
+function createColorsPalette(name: string) {
+ // backgroundLightest: '#EFF6FF', // Tailwind CSS 默认的 `blue-50`
+ // backgroundLighter: '#DBEAFE', // Tailwind CSS 默认的 `blue-100`
+ // backgroundLight: '#BFDBFE', // Tailwind CSS 默认的 `blue-200`
+ // borderLight: '#93C5FD', // Tailwind CSS 默认的 `blue-300`
+ // border: '#60A5FA', // Tailwind CSS 默认的 `blue-400`
+ // main: '#3B82F6', // Tailwind CSS 默认的 `blue-500`
+ // hover: '#2563EB', // Tailwind CSS 默认的 `blue-600`
+ // active: '#1D4ED8', // Tailwind CSS 默认的 `blue-700`
+ // backgroundDark: '#1E40AF', // Tailwind CSS 默认的 `blue-800`
+ // backgroundDarker: '#1E3A8A', // Tailwind CSS 默认的 `blue-900`
+ // backgroundDarkest: '#172554', // Tailwind CSS 默认的 `blue-950`
+
+ // • backgroundLightest (#EFF6FF): 适用于最浅的背景色,可能用于非常轻微的阴影或卡片的背景。
+ // • backgroundLighter (#DBEAFE): 适用于略浅的背景色,通常用于次要背景或略浅的区域。
+ // • backgroundLight (#BFDBFE): 适用于浅色背景,可能用于输入框或表单区域的背景。
+ // • borderLight (#93C5FD): 适用于浅色边框,可能用于输入框或卡片的边框。
+ // • border (#60A5FA): 适用于普通边框,可能用于按钮或卡片的边框。
+ // • main (#3B82F6): 适用于主要的主题色,通常用于按钮、链接或主要的强调色。
+ // • hover (#2563EB): 适用于鼠标悬停状态下的颜色,例如按钮悬停时的背景色或边框色。
+ // • active (#1D4ED8): 适用于激活状态下的颜色,例如按钮按下时的背景色或边框色。
+ // • backgroundDark (#1E40AF): 适用于深色背景,可能用于主要按钮或深色卡片背景。
+ // • backgroundDarker (#1E3A8A): 适用于更深的背景,通常用于头部导航栏或页脚。
+ // • backgroundDarkest (#172554): 适用于最深的背景,可能用于非常深色的区域或极端对比色。
+
+ return {
+ 50: `hsl(var(--${name}-50))`,
+ 100: `hsl(var(--${name}-100))`,
+ 200: `hsl(var(--${name}-200))`,
+ 300: `hsl(var(--${name}-300))`,
+ 400: `hsl(var(--${name}-400))`,
+ 500: `hsl(var(--${name}-500))`,
+ 600: `hsl(var(--${name}-600))`,
+ 700: `hsl(var(--${name}-700))`,
+ // 800: `hsl(var(--${name}-800))`,
+ // 900: `hsl(var(--${name}-900))`,
+ // 950: `hsl(var(--${name}-950))`,
+ // 激活状态下的颜色,适用于按钮按下时的背景色或边框色。
+ active: `hsl(var(--${name}-700))`,
+ // 浅色背景,适用于输入框或表单区域的背景。
+ 'background-light': `hsl(var(--${name}-200))`,
+ // 适用于略浅的背景色,通常用于次要背景或略浅的区域。
+ 'background-lighter': `hsl(var(--${name}-100))`,
+ // 最浅的背景色,适用于非常轻微的阴影或卡片的背景。
+ 'background-lightest': `hsl(var(--${name}-50))`,
+ // 适用于普通边框,可能用于按钮或卡片的边框。
+ border: `hsl(var(--${name}-400))`,
+ // 浅色边框,适用于输入框或卡片的边框。
+ 'border-light': `hsl(var(--${name}-300))`,
+ foreground: `hsl(var(--${name}-foreground))`,
+ // 鼠标悬停状态下的颜色,适用于按钮悬停时的背景色或边框色。
+ hover: `hsl(var(--${name}-600))`,
+ // 主色文本
+ text: `hsl(var(--${name}-500))`,
+ // 主色文本激活态
+ 'text-active': `hsl(var(--${name}-700))`,
+ // 主色文本悬浮态
+ 'text-hover': `hsl(var(--${name}-600))`,
+ };
+}
diff --git a/apps/vben5/internal/tailwind-config/src/module.d.ts b/apps/vben5/internal/tailwind-config/src/module.d.ts
new file mode 100644
index 000000000..a3996533f
--- /dev/null
+++ b/apps/vben5/internal/tailwind-config/src/module.d.ts
@@ -0,0 +1,3 @@
+declare module '@tailwindcss/nesting' {
+ export default any;
+}
diff --git a/apps/vben5/internal/tailwind-config/src/plugins/entry.ts b/apps/vben5/internal/tailwind-config/src/plugins/entry.ts
new file mode 100644
index 000000000..0d8e8ec80
--- /dev/null
+++ b/apps/vben5/internal/tailwind-config/src/plugins/entry.ts
@@ -0,0 +1,53 @@
+import plugin from 'tailwindcss/plugin.js';
+
+const enterAnimationPlugin = plugin(({ addUtilities }) => {
+ const maxChild = 5;
+ const utilities: Record = {};
+ for (let i = 1; i <= maxChild; i++) {
+ const baseDelay = 0.1;
+ const delay = `${baseDelay * i}s`;
+
+ utilities[`.enter-x:nth-child(${i})`] = {
+ animation: `enter-x-animation 0.3s ease-in-out ${delay} forwards`,
+ opacity: '0',
+ transform: `translateX(50px)`,
+ };
+
+ utilities[`.enter-y:nth-child(${i})`] = {
+ animation: `enter-y-animation 0.3s ease-in-out ${delay} forwards`,
+ opacity: '0',
+ transform: `translateY(50px)`,
+ };
+
+ utilities[`.-enter-x:nth-child(${i})`] = {
+ animation: `enter-x-animation 0.3s ease-in-out ${delay} forwards`,
+ opacity: '0',
+ transform: `translateX(-50px)`,
+ };
+
+ utilities[`.-enter-y:nth-child(${i})`] = {
+ animation: `enter-y-animation 0.3s ease-in-out ${delay} forwards`,
+ opacity: '0',
+ transform: `translateY(-50px)`,
+ };
+ }
+
+ // 添加动画关键帧
+ addUtilities(utilities);
+ addUtilities({
+ '@keyframes enter-x-animation': {
+ to: {
+ opacity: '1',
+ transform: 'translateX(0)',
+ },
+ },
+ '@keyframes enter-y-animation': {
+ to: {
+ opacity: '1',
+ transform: 'translateY(0)',
+ },
+ },
+ });
+});
+
+export { enterAnimationPlugin };
diff --git a/apps/vben5/internal/tailwind-config/src/postcss.config.ts b/apps/vben5/internal/tailwind-config/src/postcss.config.ts
new file mode 100644
index 000000000..43b30b356
--- /dev/null
+++ b/apps/vben5/internal/tailwind-config/src/postcss.config.ts
@@ -0,0 +1,15 @@
+import config from '.';
+
+export default {
+ plugins: {
+ ...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {}),
+ // Specifying the config is not necessary in most cases, but it is included
+ autoprefixer: {},
+ // 修复 element-plus 和 ant-design-vue 的样式和tailwindcss冲突问题
+ 'postcss-antd-fixes': { prefixes: ['ant', 'el'] },
+ 'postcss-import': {},
+ 'postcss-preset-env': {},
+ tailwindcss: { config },
+ 'tailwindcss/nesting': {},
+ },
+};
diff --git a/apps/vben5/internal/tailwind-config/tsconfig.json b/apps/vben5/internal/tailwind-config/tsconfig.json
new file mode 100644
index 000000000..b2ec3b61e
--- /dev/null
+++ b/apps/vben5/internal/tailwind-config/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/node.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/apps/vben5/internal/tsconfig/base.json b/apps/vben5/internal/tsconfig/base.json
new file mode 100644
index 000000000..1e45a7843
--- /dev/null
+++ b/apps/vben5/internal/tsconfig/base.json
@@ -0,0 +1,40 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "display": "Base",
+ "compilerOptions": {
+ "composite": false,
+ "target": "ESNext",
+
+ "moduleDetection": "force",
+ "experimentalDecorators": true,
+
+ "baseUrl": ".",
+ "module": "ESNext",
+
+ "moduleResolution": "node",
+ "resolveJsonModule": true,
+
+ "strict": true,
+ "strictNullChecks": true,
+ "noFallthroughCasesInSwitch": true,
+ "noImplicitAny": true,
+ "noImplicitOverride": true,
+ "noImplicitThis": true,
+ "noUncheckedIndexedAccess": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+
+ "inlineSources": false,
+ "noEmit": true,
+ "removeComments": true,
+ "sourceMap": false,
+ "allowSyntheticDefaultImports": true,
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "isolatedModules": true,
+ "verbatimModuleSyntax": true,
+ "skipLibCheck": true,
+ "preserveWatchOutput": true
+ },
+ "exclude": ["**/node_modules/**", "**/dist/**", "**/.turbo/**"]
+}
diff --git a/apps/vben5/internal/tsconfig/library.json b/apps/vben5/internal/tsconfig/library.json
new file mode 100644
index 000000000..7a976f09b
--- /dev/null
+++ b/apps/vben5/internal/tsconfig/library.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "display": "Web Application",
+ "extends": "./base.json",
+ "compilerOptions": {
+ "jsx": "preserve",
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
+ "useDefineForClassFields": true,
+ "moduleResolution": "bundler",
+ "declaration": true,
+ "noEmit": false
+ }
+}
diff --git a/apps/vben5/internal/tsconfig/node.json b/apps/vben5/internal/tsconfig/node.json
new file mode 100644
index 000000000..31ce8f18f
--- /dev/null
+++ b/apps/vben5/internal/tsconfig/node.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "display": "Node Config",
+ "extends": "./base.json",
+ "compilerOptions": {
+ "composite": false,
+ "lib": ["ESNext"],
+ "baseUrl": "./",
+ "types": ["node"],
+ "noImplicitAny": true
+ }
+}
diff --git a/apps/vben5/internal/tsconfig/package.json b/apps/vben5/internal/tsconfig/package.json
new file mode 100644
index 000000000..d6bae6239
--- /dev/null
+++ b/apps/vben5/internal/tsconfig/package.json
@@ -0,0 +1,25 @@
+{
+ "name": "@vben/tsconfig",
+ "version": "5.4.8",
+ "private": true,
+ "homepage": "https://github.com/vbenjs/vue-vben-admin",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "internal/tsconfig"
+ },
+ "license": "MIT",
+ "type": "module",
+ "files": [
+ "base.json",
+ "library.json",
+ "node.json",
+ "web-app.json",
+ "web.json"
+ ],
+ "dependencies": {
+ "@vben/types": "workspace:*",
+ "vite": "catalog:"
+ }
+}
diff --git a/apps/vben5/internal/tsconfig/web-app.json b/apps/vben5/internal/tsconfig/web-app.json
new file mode 100644
index 000000000..00479cb8e
--- /dev/null
+++ b/apps/vben5/internal/tsconfig/web-app.json
@@ -0,0 +1,8 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "display": "Web Application",
+ "extends": "./web.json",
+ "compilerOptions": {
+ "types": ["vite/client", "@vben/types/global"]
+ }
+}
diff --git a/apps/vben5/internal/tsconfig/web.json b/apps/vben5/internal/tsconfig/web.json
new file mode 100644
index 000000000..a4b60ceca
--- /dev/null
+++ b/apps/vben5/internal/tsconfig/web.json
@@ -0,0 +1,14 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "display": "Web Package",
+ "extends": "./base.json",
+ "compilerOptions": {
+ "jsx": "preserve",
+ "jsxImportSource": "vue",
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
+ "useDefineForClassFields": true,
+ "moduleResolution": "bundler",
+ "types": ["vite/client"],
+ "declaration": false
+ }
+}
diff --git a/apps/vben5/internal/vite-config/build.config.ts b/apps/vben5/internal/vite-config/build.config.ts
new file mode 100644
index 000000000..97e572c56
--- /dev/null
+++ b/apps/vben5/internal/vite-config/build.config.ts
@@ -0,0 +1,7 @@
+import { defineBuildConfig } from 'unbuild';
+
+export default defineBuildConfig({
+ clean: true,
+ declaration: true,
+ entries: ['src/index'],
+});
diff --git a/apps/vben5/internal/vite-config/package.json b/apps/vben5/internal/vite-config/package.json
new file mode 100644
index 000000000..2d68b95b7
--- /dev/null
+++ b/apps/vben5/internal/vite-config/package.json
@@ -0,0 +1,59 @@
+{
+ "name": "@vben/vite-config",
+ "version": "5.4.8",
+ "private": true,
+ "homepage": "https://github.com/vbenjs/vue-vben-admin",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+ "directory": "internal/vite-config"
+ },
+ "license": "MIT",
+ "type": "module",
+ "scripts": {
+ "stub": "pnpm unbuild --stub"
+ },
+ "files": [
+ "dist"
+ ],
+ "main": "./dist/index.mjs",
+ "module": "./dist/index.mjs",
+ "types": "./dist/index.d.ts",
+ "exports": {
+ ".": {
+ "types": "./src/index.ts",
+ "default": "./dist/index.mjs"
+ }
+ },
+ "dependencies": {
+ "@intlify/unplugin-vue-i18n": "catalog:",
+ "@jspm/generator": "catalog:",
+ "archiver": "catalog:",
+ "cheerio": "catalog:",
+ "get-port": "catalog:",
+ "html-minifier-terser": "catalog:",
+ "nitropack": "catalog:",
+ "resolve.exports": "catalog:",
+ "vite-plugin-pwa": "catalog:",
+ "vite-plugin-vue-devtools": "catalog:"
+ },
+ "devDependencies": {
+ "@pnpm/workspace.read-manifest": "catalog:",
+ "@types/archiver": "catalog:",
+ "@types/html-minifier-terser": "catalog:",
+ "@vben/node-utils": "workspace:*",
+ "@vitejs/plugin-vue": "catalog:",
+ "@vitejs/plugin-vue-jsx": "catalog:",
+ "dayjs": "catalog:",
+ "dotenv": "catalog:",
+ "rollup": "catalog:",
+ "rollup-plugin-visualizer": "catalog:",
+ "sass": "catalog:",
+ "vite": "catalog:",
+ "vite-plugin-compression": "catalog:",
+ "vite-plugin-dts": "catalog:",
+ "vite-plugin-html": "catalog:",
+ "vite-plugin-lazy-import": "catalog:"
+ }
+}
diff --git a/apps/vben5/internal/vite-config/src/config/application.ts b/apps/vben5/internal/vite-config/src/config/application.ts
new file mode 100644
index 000000000..f22760944
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/config/application.ts
@@ -0,0 +1,125 @@
+import type { UserConfig } from 'vite';
+
+import type { DefineApplicationOptions } from '../typing';
+
+import path, { relative } from 'node:path';
+
+import { findMonorepoRoot } from '@vben/node-utils';
+
+import { NodePackageImporter } from 'sass';
+import { defineConfig, loadEnv, mergeConfig } from 'vite';
+
+import { defaultImportmapOptions, getDefaultPwaOptions } from '../options';
+import { loadApplicationPlugins } from '../plugins';
+import { loadAndConvertEnv } from '../utils/env';
+import { getCommonConfig } from './common';
+
+function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
+ return defineConfig(async (config) => {
+ const options = await userConfigPromise?.(config);
+ const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
+ const { command, mode } = config;
+ const { application = {}, vite = {} } = options || {};
+ const root = process.cwd();
+ const isBuild = command === 'build';
+ const env = loadEnv(mode, root);
+
+ const plugins = await loadApplicationPlugins({
+ archiver: true,
+ archiverPluginOptions: {},
+ compress: false,
+ compressTypes: ['brotli', 'gzip'],
+ devtools: true,
+ env,
+ extraAppConfig: true,
+ html: true,
+ i18n: true,
+ importmapOptions: defaultImportmapOptions,
+ injectAppLoading: true,
+ injectMetadata: true,
+ isBuild,
+ license: true,
+ mode,
+ nitroMock: !isBuild,
+ nitroMockOptions: {},
+ print: !isBuild,
+ printInfoMap: {
+ 'Vben Admin Docs': 'https://doc.vben.pro',
+ },
+ pwa: true,
+ pwaOptions: getDefaultPwaOptions(appTitle),
+ vxeTableLazyImport: true,
+ ...envConfig,
+ ...application,
+ });
+
+ const { injectGlobalScss = true } = application;
+
+ const applicationConfig: UserConfig = {
+ base,
+ build: {
+ rollupOptions: {
+ output: {
+ assetFileNames: '[ext]/[name]-[hash].[ext]',
+ chunkFileNames: 'js/[name]-[hash].js',
+ entryFileNames: 'jse/index-[name]-[hash].js',
+ },
+ },
+ target: 'es2015',
+ },
+ css: createCssOptions(injectGlobalScss),
+ esbuild: {
+ drop: isBuild
+ ? [
+ // 'console',
+ 'debugger',
+ ]
+ : [],
+ legalComments: 'none',
+ },
+ plugins,
+ server: {
+ host: true,
+ port,
+ warmup: {
+ // 预热文件
+ clientFiles: [
+ './index.html',
+ './src/bootstrap.ts',
+ './src/{views,layouts,router,store,api,adapter}/*',
+ ],
+ },
+ },
+ };
+
+ const mergedCommonConfig = mergeConfig(
+ await getCommonConfig(),
+ applicationConfig,
+ );
+ return mergeConfig(mergedCommonConfig, vite);
+ });
+}
+
+function createCssOptions(injectGlobalScss = true) {
+ const root = findMonorepoRoot();
+ return {
+ preprocessorOptions: injectGlobalScss
+ ? {
+ scss: {
+ additionalData: (content: string, filepath: string) => {
+ const relativePath = relative(root, filepath);
+ // apps下的包注入全局样式
+ if (relativePath.startsWith(`apps${path.sep}`)) {
+ return `@use "@vben/styles/global" as *;\n${content}`;
+ }
+ return content;
+ },
+ api: 'modern',
+ importers: [new NodePackageImporter()],
+ },
+ }
+ : {},
+ };
+}
+
+export { defineApplicationConfig };
diff --git a/apps/vben5/internal/vite-config/src/config/common.ts b/apps/vben5/internal/vite-config/src/config/common.ts
new file mode 100644
index 000000000..653f21040
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/config/common.ts
@@ -0,0 +1,13 @@
+import type { UserConfig } from 'vite';
+
+async function getCommonConfig(): Promise {
+ return {
+ build: {
+ chunkSizeWarningLimit: 2000,
+ reportCompressedSize: false,
+ sourcemap: false,
+ },
+ };
+}
+
+export { getCommonConfig };
diff --git a/apps/vben5/internal/vite-config/src/config/index.ts b/apps/vben5/internal/vite-config/src/config/index.ts
new file mode 100644
index 000000000..d04a84a86
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/config/index.ts
@@ -0,0 +1,37 @@
+import type { DefineConfig } from '../typing';
+
+import { existsSync } from 'node:fs';
+import { join } from 'node:path';
+
+import { defineApplicationConfig } from './application';
+import { defineLibraryConfig } from './library';
+
+export * from './application';
+export * from './library';
+
+function defineConfig(
+ userConfigPromise?: DefineConfig,
+ type: 'application' | 'auto' | 'library' = 'auto',
+) {
+ let projectType = type;
+
+ // 根据包是否存在 index.html,自动判断类型
+ if (projectType === 'auto') {
+ const htmlPath = join(process.cwd(), 'index.html');
+ projectType = existsSync(htmlPath) ? 'application' : 'library';
+ }
+
+ switch (projectType) {
+ case 'application': {
+ return defineApplicationConfig(userConfigPromise);
+ }
+ case 'library': {
+ return defineLibraryConfig(userConfigPromise);
+ }
+ default: {
+ throw new Error(`Unsupported project type: ${projectType}`);
+ }
+ }
+}
+
+export { defineConfig };
diff --git a/apps/vben5/internal/vite-config/src/config/library.ts b/apps/vben5/internal/vite-config/src/config/library.ts
new file mode 100644
index 000000000..08b813520
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/config/library.ts
@@ -0,0 +1,59 @@
+import type { ConfigEnv, UserConfig } from 'vite';
+
+import type { DefineLibraryOptions } from '../typing';
+
+import { readPackageJSON } from '@vben/node-utils';
+
+import { defineConfig, mergeConfig } from 'vite';
+
+import { loadLibraryPlugins } from '../plugins';
+import { getCommonConfig } from './common';
+
+function defineLibraryConfig(userConfigPromise?: DefineLibraryOptions) {
+ return defineConfig(async (config: ConfigEnv) => {
+ const options = await userConfigPromise?.(config);
+ const { command, mode } = config;
+ const { library = {}, vite = {} } = options || {};
+ const root = process.cwd();
+ const isBuild = command === 'build';
+
+ const plugins = await loadLibraryPlugins({
+ dts: false,
+ injectMetadata: true,
+ isBuild,
+ mode,
+ ...library,
+ });
+
+ const { dependencies = {}, peerDependencies = {} } =
+ await readPackageJSON(root);
+
+ const externalPackages = [
+ ...Object.keys(dependencies),
+ ...Object.keys(peerDependencies),
+ ];
+
+ const packageConfig: UserConfig = {
+ build: {
+ lib: {
+ entry: 'src/index.ts',
+ fileName: () => 'index.mjs',
+ formats: ['es'],
+ },
+ rollupOptions: {
+ external: (id) => {
+ return externalPackages.some(
+ (pkg) => id === pkg || id.startsWith(`${pkg}/`),
+ );
+ },
+ },
+ },
+ plugins,
+ };
+ const commonConfig = await getCommonConfig();
+ const mergedConmonConfig = mergeConfig(commonConfig, packageConfig);
+ return mergeConfig(mergedConmonConfig, vite);
+ });
+}
+
+export { defineLibraryConfig };
diff --git a/apps/vben5/internal/vite-config/src/index.ts b/apps/vben5/internal/vite-config/src/index.ts
new file mode 100644
index 000000000..352a3235a
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/index.ts
@@ -0,0 +1,4 @@
+export * from './config';
+export * from './options';
+export * from './plugins';
+export { loadAndConvertEnv } from './utils/env';
diff --git a/apps/vben5/internal/vite-config/src/options.ts b/apps/vben5/internal/vite-config/src/options.ts
new file mode 100644
index 000000000..f1e2401c7
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/options.ts
@@ -0,0 +1,45 @@
+import type { Options as PwaPluginOptions } from 'vite-plugin-pwa';
+
+import type { ImportmapPluginOptions } from './typing';
+
+const isDevelopment = process.env.NODE_ENV === 'development';
+
+const getDefaultPwaOptions = (name: string): Partial => ({
+ manifest: {
+ description:
+ 'Vben Admin is a modern admin dashboard template based on Vue 3. ',
+ icons: [
+ {
+ sizes: '192x192',
+ src: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/pwa-icon-192.png',
+ type: 'image/png',
+ },
+ {
+ sizes: '512x512',
+ src: 'https://unpkg.com/@vbenjs/static-source@0.1.7/source/pwa-icon-512.png',
+ type: 'image/png',
+ },
+ ],
+ name: `${name}${isDevelopment ? ' dev' : ''}`,
+ short_name: `${name}${isDevelopment ? ' dev' : ''}`,
+ },
+});
+
+/**
+ * importmap CDN 暂时不开启,因为有些包不支持,且网络不稳定
+ */
+const defaultImportmapOptions: ImportmapPluginOptions = {
+ // 通过 Importmap CDN 方式引入,
+ // 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
+ defaultProvider: 'esm.sh',
+ importmap: [
+ { name: 'vue' },
+ { name: 'pinia' },
+ { name: 'vue-router' },
+ // { name: 'vue-i18n' },
+ { name: 'dayjs' },
+ { name: 'vue-demi' },
+ ],
+};
+
+export { defaultImportmapOptions, getDefaultPwaOptions };
diff --git a/apps/vben5/internal/vite-config/src/plugins/archiver.ts b/apps/vben5/internal/vite-config/src/plugins/archiver.ts
new file mode 100644
index 000000000..8eec8a0e9
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/archiver.ts
@@ -0,0 +1,75 @@
+import type { PluginOption } from 'vite';
+
+import type { ArchiverPluginOptions } from '../typing';
+
+import fs from 'node:fs';
+import fsp from 'node:fs/promises';
+import { join } from 'node:path';
+
+import archiver from 'archiver';
+
+export const viteArchiverPlugin = (
+ options: ArchiverPluginOptions = {},
+): PluginOption => {
+ return {
+ apply: 'build',
+ closeBundle: {
+ handler() {
+ const { name = 'dist', outputDir = '.' } = options;
+
+ setTimeout(async () => {
+ const folderToZip = 'dist';
+
+ const zipOutputDir = join(process.cwd(), outputDir);
+ const zipOutputPath = join(zipOutputDir, `${name}.zip`);
+ try {
+ await fsp.mkdir(zipOutputDir, { recursive: true });
+ } catch {
+ // ignore
+ }
+
+ try {
+ await zipFolder(folderToZip, zipOutputPath);
+ console.log(`Folder has been zipped to: ${zipOutputPath}`);
+ } catch (error) {
+ console.error('Error zipping folder:', error);
+ }
+ }, 0);
+ },
+ order: 'post',
+ },
+ enforce: 'post',
+ name: 'vite:archiver',
+ };
+};
+
+async function zipFolder(
+ folderPath: string,
+ outputPath: string,
+): Promise {
+ return new Promise((resolve, reject) => {
+ const output = fs.createWriteStream(outputPath);
+ const archive = archiver('zip', {
+ zlib: { level: 9 }, // 设置压缩级别为 9 以实现最高压缩率
+ });
+
+ output.on('close', () => {
+ console.log(
+ `ZIP file created: ${outputPath} (${archive.pointer()} total bytes)`,
+ );
+ resolve();
+ });
+
+ archive.on('error', (err) => {
+ reject(err);
+ });
+
+ archive.pipe(output);
+
+ // 使用 directory 方法以流的方式压缩文件夹,减少内存消耗
+ archive.directory(folderPath, false);
+
+ // 流式处理完成
+ archive.finalize();
+ });
+}
diff --git a/apps/vben5/internal/vite-config/src/plugins/extra-app-config.ts b/apps/vben5/internal/vite-config/src/plugins/extra-app-config.ts
new file mode 100644
index 000000000..813819bbd
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/extra-app-config.ts
@@ -0,0 +1,92 @@
+import type { PluginOption } from 'vite';
+
+import {
+ colors,
+ generatorContentHash,
+ readPackageJSON,
+} from '@vben/node-utils';
+
+import { loadEnv } from '../utils/env';
+
+interface PluginOptions {
+ isBuild: boolean;
+ root: string;
+}
+
+const GLOBAL_CONFIG_FILE_NAME = '_app.config.js';
+const VBEN_ADMIN_PRO_APP_CONF = '_VBEN_ADMIN_PRO_APP_CONF_';
+
+/**
+ * 用于将配置文件抽离出来并注入到项目中
+ * @returns
+ */
+
+async function viteExtraAppConfigPlugin({
+ isBuild,
+ root,
+}: PluginOptions): Promise {
+ let publicPath: string;
+ let source: string;
+
+ if (!isBuild) {
+ return;
+ }
+
+ const { version = '' } = await readPackageJSON(root);
+
+ return {
+ async configResolved(config) {
+ publicPath = ensureTrailingSlash(config.base);
+ source = await getConfigSource();
+ },
+ async generateBundle() {
+ try {
+ this.emitFile({
+ fileName: GLOBAL_CONFIG_FILE_NAME,
+ source,
+ type: 'asset',
+ });
+
+ console.log(colors.cyan(`✨configuration file is build successfully!`));
+ } catch (error) {
+ console.log(
+ colors.red(
+ `configuration file configuration file failed to package:\n${error}`,
+ ),
+ );
+ }
+ },
+ name: 'vite:extra-app-config',
+ async transformIndexHtml(html) {
+ const hash = `v=${version}-${generatorContentHash(source, 8)}`;
+
+ const appConfigSrc = `${publicPath}${GLOBAL_CONFIG_FILE_NAME}?${hash}`;
+
+ return {
+ html,
+ tags: [{ attrs: { src: appConfigSrc }, tag: 'script' }],
+ };
+ },
+ };
+}
+
+async function getConfigSource() {
+ const config = await loadEnv();
+ const windowVariable = `window.${VBEN_ADMIN_PRO_APP_CONF}`;
+ // 确保变量不会被修改
+ let source = `${windowVariable}=${JSON.stringify(config)};`;
+ source += `
+ Object.freeze(${windowVariable});
+ Object.defineProperty(window, "${VBEN_ADMIN_PRO_APP_CONF}", {
+ configurable: false,
+ writable: false,
+ });
+ `.replaceAll(/\s/g, '');
+ return source;
+}
+
+function ensureTrailingSlash(path: string) {
+ return path.endsWith('/') ? path : `${path}/`;
+}
+
+export { viteExtraAppConfigPlugin };
diff --git a/apps/vben5/internal/vite-config/src/plugins/importmap.ts b/apps/vben5/internal/vite-config/src/plugins/importmap.ts
new file mode 100644
index 000000000..c6154c9ea
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/importmap.ts
@@ -0,0 +1,245 @@
+/**
+ * 参考 https://github.com/jspm/vite-plugin-jspm,调整为需要的功能
+ */
+import type { GeneratorOptions } from '@jspm/generator';
+import type { Plugin } from 'vite';
+
+import { Generator } from '@jspm/generator';
+import { load } from 'cheerio';
+import { minify } from 'html-minifier-terser';
+
+const DEFAULT_PROVIDER = 'jspm.io';
+
+type pluginOptions = {
+ debug?: boolean;
+ defaultProvider?: 'esm.sh' | 'jsdelivr' | 'jspm.io';
+ importmap?: Array<{ name: string; range?: string }>;
+} & GeneratorOptions;
+
+// async function getLatestVersionOfShims() {
+// const result = await fetch('https://ga.jspm.io/npm:es-module-shims');
+// const version = result.text();
+// return version;
+// }
+
+async function getShimsUrl(provide: string) {
+ // const version = await getLatestVersionOfShims();
+ const version = '1.10.0';
+
+ const shimsSubpath = `dist/es-module-shims.js`;
+ const providerShimsMap: Record = {
+ 'esm.sh': `https://esm.sh/es-module-shims@${version}/${shimsSubpath}`,
+ // unpkg: `https://unpkg.com/es-module-shims@${version}/${shimsSubpath}`,
+ jsdelivr: `https://cdn.jsdelivr.net/npm/es-module-shims@${version}/${shimsSubpath}`,
+
+ // 下面两个CDN不稳定,暂时不用
+ 'jspm.io': `https://ga.jspm.io/npm:es-module-shims@${version}/${shimsSubpath}`,
+ };
+
+ return providerShimsMap[provide] || providerShimsMap[DEFAULT_PROVIDER];
+}
+
+let generator: Generator;
+
+async function viteImportMapPlugin(
+ pluginOptions?: pluginOptions,
+): Promise {
+ const { importmap } = pluginOptions || {};
+
+ let isSSR = false;
+ let isBuild = false;
+ let installed = false;
+ let installError: Error | null = null;
+
+ const options: pluginOptions = Object.assign(
+ {},
+ {
+ debug: false,
+ defaultProvider: 'jspm.io',
+ env: ['production', 'browser', 'module'],
+ importmap: [],
+ },
+ pluginOptions,
+ );
+
+ generator = new Generator({
+ ...options,
+ baseUrl: process.cwd(),
+ });
+
+ if (options?.debug) {
+ (async () => {
+ for await (const { message, type } of generator.logStream()) {
+ console.log(`${type}: ${message}`);
+ }
+ })();
+ }
+
+ const imports = options.inputMap?.imports ?? {};
+ const scopes = options.inputMap?.scopes ?? {};
+ const firstLayerKeys = Object.keys(scopes);
+ const inputMapScopes: string[] = [];
+ firstLayerKeys.forEach((key) => {
+ inputMapScopes.push(...Object.keys(scopes[key] || {}));
+ });
+ const inputMapImports = Object.keys(imports);
+
+ const allDepNames: string[] = [
+ ...(importmap?.map((item) => item.name) || []),
+ ...inputMapImports,
+ ...inputMapScopes,
+ ];
+ const depNames = new Set(allDepNames);
+
+ const installDeps = importmap?.map((item) => ({
+ range: item.range,
+ target: item.name,
+ }));
+
+ return [
+ {
+ async config(_, { command, isSsrBuild }) {
+ isBuild = command === 'build';
+ isSSR = !!isSsrBuild;
+ },
+ enforce: 'pre',
+ name: 'importmap:external',
+ resolveId(id) {
+ if (isSSR || !isBuild) {
+ return null;
+ }
+
+ if (!depNames.has(id)) {
+ return null;
+ }
+ return { external: true, id };
+ },
+ },
+ {
+ enforce: 'post',
+ name: 'importmap:install',
+ async resolveId() {
+ if (isSSR || !isBuild || installed) {
+ return null;
+ }
+ try {
+ installed = true;
+ await Promise.allSettled(
+ (installDeps || []).map((dep) => generator.install(dep)),
+ );
+ } catch (error: any) {
+ installError = error;
+ installed = false;
+ }
+ return null;
+ },
+ },
+ {
+ buildEnd() {
+ // 未生成importmap时,抛出错误,防止被turbo缓存
+ if (!installed && !isSSR) {
+ installError && console.error(installError);
+ throw new Error('Importmap installation failed.');
+ }
+ },
+ enforce: 'post',
+ name: 'importmap:html',
+ transformIndexHtml: {
+ async handler(html) {
+ if (isSSR || !isBuild) {
+ return html;
+ }
+
+ const importmapJson = generator.getMap();
+
+ if (!importmapJson) {
+ return html;
+ }
+
+ const esModuleShimsSrc = await getShimsUrl(
+ options.defaultProvider || DEFAULT_PROVIDER,
+ );
+
+ const resultHtml = await injectShimsToHtml(
+ html,
+ esModuleShimsSrc || '',
+ );
+ html = await minify(resultHtml || html, {
+ collapseWhitespace: true,
+ minifyCSS: true,
+ minifyJS: true,
+ removeComments: false,
+ });
+
+ return {
+ html,
+ tags: [
+ {
+ attrs: {
+ type: 'importmap',
+ },
+ injectTo: 'head-prepend',
+ tag: 'script',
+ children: `${JSON.stringify(importmapJson)}`,
+ },
+ ],
+ };
+ },
+ order: 'post',
+ },
+ },
+ ];
+}
+
+async function injectShimsToHtml(html: string, esModuleShimUrl: string) {
+ const $ = load(html);
+
+ const $script = $(`script[type='module']`);
+
+ if (!$script) {
+ return;
+ }
+
+ const entry = $script.attr('src');
+
+ $script.removeAttr('type');
+ $script.removeAttr('crossorigin');
+ $script.removeAttr('src');
+ $script.html(`
+if (!HTMLScriptElement.supports || !HTMLScriptElement.supports('importmap')) {
+ self.importShim = function () {
+ const promise = new Promise((resolve, reject) => {
+ document.head.appendChild(
+ Object.assign(document.createElement('script'), {
+ src: '${esModuleShimUrl}',
+ crossorigin: 'anonymous',
+ async: true,
+ onload() {
+ if (!importShim.$proxy) {
+ resolve(importShim);
+ } else {
+ reject(new Error('No globalThis.importShim found:' + esModuleShimUrl));
+ }
+ },
+ onerror(error) {
+ reject(error);
+ },
+ }),
+ );
+ });
+ importShim.$proxy = true;
+ return promise.then((importShim) => importShim(...arguments));
+ };
+}
+
+var modules = ['${entry}'];
+typeof importShim === 'function'
+ ? modules.forEach((moduleName) => importShim(moduleName))
+ : modules.forEach((moduleName) => import(moduleName));
+ `);
+ $('body').after($script);
+ $('head').remove(`script[type='module']`);
+ return $.html();
+}
+
+export { viteImportMapPlugin };
diff --git a/apps/vben5/internal/vite-config/src/plugins/index.ts b/apps/vben5/internal/vite-config/src/plugins/index.ts
new file mode 100644
index 000000000..da08db4b8
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/index.ts
@@ -0,0 +1,247 @@
+import type { PluginOption } from 'vite';
+
+import type {
+ ApplicationPluginOptions,
+ CommonPluginOptions,
+ ConditionPlugin,
+ LibraryPluginOptions,
+} from '../typing';
+
+import viteVueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
+import viteVue from '@vitejs/plugin-vue';
+import viteVueJsx from '@vitejs/plugin-vue-jsx';
+import { visualizer as viteVisualizerPlugin } from 'rollup-plugin-visualizer';
+import viteCompressPlugin from 'vite-plugin-compression';
+import viteDtsPlugin from 'vite-plugin-dts';
+import { createHtmlPlugin as viteHtmlPlugin } from 'vite-plugin-html';
+import { VitePWA } from 'vite-plugin-pwa';
+import viteVueDevTools from 'vite-plugin-vue-devtools';
+
+import { viteArchiverPlugin } from './archiver';
+import { viteExtraAppConfigPlugin } from './extra-app-config';
+import { viteImportMapPlugin } from './importmap';
+import { viteInjectAppLoadingPlugin } from './inject-app-loading';
+import { viteMetadataPlugin } from './inject-metadata';
+import { viteLicensePlugin } from './license';
+import { viteNitroMockPlugin } from './nitro-mock';
+import { vitePrintPlugin } from './print';
+import { viteVxeTableImportsPlugin } from './vxe-table';
+
+/**
+ * 获取条件成立的 vite 插件
+ * @param conditionPlugins
+ */
+async function loadConditionPlugins(conditionPlugins: ConditionPlugin[]) {
+ const plugins: PluginOption[] = [];
+ for (const conditionPlugin of conditionPlugins) {
+ if (conditionPlugin.condition) {
+ const realPlugins = await conditionPlugin.plugins();
+ plugins.push(...realPlugins);
+ }
+ }
+ return plugins.flat();
+}
+
+/**
+ * 根据条件获取通用的vite插件
+ */
+async function loadCommonPlugins(
+ options: CommonPluginOptions,
+): Promise {
+ const { devtools, injectMetadata, isBuild, visualizer } = options;
+ return [
+ {
+ condition: true,
+ plugins: () => [
+ viteVue({
+ script: {
+ defineModel: true,
+ // propsDestructure: true,
+ },
+ }),
+ viteVueJsx(),
+ ],
+ },
+
+ {
+ condition: !isBuild && devtools,
+ plugins: () => [viteVueDevTools()],
+ },
+ {
+ condition: injectMetadata,
+ plugins: async () => [await viteMetadataPlugin()],
+ },
+ {
+ condition: isBuild && !!visualizer,
+ plugins: () => [viteVisualizerPlugin({
+ filename: './node_modules/.cache/visualizer/stats.html',
+ gzipSize: true,
+ open: true,
+ })],
+ },
+ ];
+}
+
+/**
+ * 根据条件获取应用类型的vite插件
+ */
+async function loadApplicationPlugins(
+ options: ApplicationPluginOptions,
+): Promise {
+ // 单独取,否则commonOptions拿不到
+ const isBuild = options.isBuild;
+ const env = options.env;
+
+ const {
+ archiver,
+ archiverPluginOptions,
+ compress,
+ compressTypes,
+ extraAppConfig,
+ html,
+ i18n,
+ importmap,
+ importmapOptions,
+ injectAppLoading,
+ license,
+ nitroMock,
+ nitroMockOptions,
+ print,
+ printInfoMap,
+ pwa,
+ pwaOptions,
+ vxeTableLazyImport,
+ ...commonOptions
+ } = options;
+
+ const commonPlugins = await loadCommonPlugins(commonOptions);
+
+ return await loadConditionPlugins([
+ ...commonPlugins,
+ {
+ condition: i18n,
+ plugins: async () => {
+ return [
+ viteVueI18nPlugin({
+ compositionOnly: true,
+ fullInstall: true,
+ runtimeOnly: true,
+ }),
+ ];
+ },
+ },
+ {
+ condition: print,
+ plugins: async () => {
+ return [await vitePrintPlugin({ infoMap: printInfoMap })];
+ },
+ },
+ {
+ condition: vxeTableLazyImport,
+ plugins: async () => {
+ return [await viteVxeTableImportsPlugin()];
+ },
+ },
+ {
+ condition: nitroMock,
+ plugins: async () => {
+ return [await viteNitroMockPlugin(nitroMockOptions)];
+ },
+ },
+
+ {
+ condition: injectAppLoading,
+ plugins: async () => [await viteInjectAppLoadingPlugin(!!isBuild, env)],
+ },
+ {
+ condition: license,
+ plugins: async () => [await viteLicensePlugin()],
+ },
+ {
+ condition: pwa,
+ plugins: () =>
+ VitePWA({
+ injectRegister: false,
+ workbox: {
+ globPatterns: [],
+ },
+ ...pwaOptions,
+ manifest: {
+ display: 'standalone',
+ start_url: '/',
+ theme_color: '#ffffff',
+ ...pwaOptions?.manifest,
+ },
+ }),
+ },
+ {
+ condition: isBuild && !!compress,
+ plugins: () => {
+ const compressPlugins: PluginOption[] = [];
+ if (compressTypes?.includes('brotli')) {
+ compressPlugins.push(
+ viteCompressPlugin({ deleteOriginFile: false, ext: '.br' }),
+ );
+ }
+ if (compressTypes?.includes('gzip')) {
+ compressPlugins.push(
+ viteCompressPlugin({ deleteOriginFile: false, ext: '.gz' }),
+ );
+ }
+ return compressPlugins;
+ },
+ },
+ {
+ condition: !!html,
+ plugins: () => [viteHtmlPlugin({ minify: true })],
+ },
+ {
+ condition: isBuild && importmap,
+ plugins: () => {
+ return [viteImportMapPlugin(importmapOptions)];
+ },
+ },
+ {
+ condition: isBuild && extraAppConfig,
+ plugins: async () => [
+ await viteExtraAppConfigPlugin({ isBuild: true, root: process.cwd() }),
+ ],
+ },
+ {
+ condition: archiver,
+ plugins: async () => {
+ return [await viteArchiverPlugin(archiverPluginOptions)];
+ },
+ },
+ ]);
+}
+
+/**
+ * 根据条件获取库类型的vite插件
+ */
+async function loadLibraryPlugins(
+ options: LibraryPluginOptions,
+): Promise {
+ // 单独取,否则commonOptions拿不到
+ const isBuild = options.isBuild;
+ const { dts, ...commonOptions } = options;
+ const commonPlugins = await loadCommonPlugins(commonOptions);
+ return await loadConditionPlugins([
+ ...commonPlugins,
+ {
+ condition: isBuild && !!dts,
+ plugins: () => [viteDtsPlugin({ logLevel: 'error' })],
+ },
+ ]);
+}
+
+export {
+ loadApplicationPlugins,
+ loadLibraryPlugins,
+ viteArchiverPlugin,
+ viteCompressPlugin,
+ viteDtsPlugin,
+ viteHtmlPlugin,
+ viteVisualizerPlugin,
+ viteVxeTableImportsPlugin,
+};
diff --git a/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/README.md b/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/README.md
new file mode 100644
index 000000000..8d2358f78
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/README.md
@@ -0,0 +1,3 @@
+# inject-app-loading
+
+用于在应用加载时显示加载动画的插件,可自行选择加载动画的样式。
diff --git a/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/default-loading-antd.html b/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/default-loading-antd.html
new file mode 100644
index 000000000..20a21fb79
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/default-loading-antd.html
@@ -0,0 +1,107 @@
+
+
+
+
<%= VITE_APP_TITLE %>
+
diff --git a/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/default-loading.html b/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/default-loading.html
new file mode 100644
index 000000000..289570586
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/default-loading.html
@@ -0,0 +1,113 @@
+
+
+
+
<%= VITE_APP_TITLE %>
+
diff --git a/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/index.ts b/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/index.ts
new file mode 100644
index 000000000..9f6e2a5c8
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/inject-app-loading/index.ts
@@ -0,0 +1,66 @@
+import fs from 'node:fs';
+import fsp from 'node:fs/promises';
+import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+import { readPackageJSON } from '@vben/node-utils';
+
+import { type PluginOption } from 'vite';
+
+/**
+ * 用于生成将loading样式注入到项目中
+ * 为多app提供loading样式,无需在每个 app -> index.html单独引入
+ */
+async function viteInjectAppLoadingPlugin(
+ isBuild: boolean,
+ env: Record = {},
+ loadingTemplate = 'loading.html',
+): Promise {
+ const loadingHtml = await getLoadingRawByHtmlTemplate(loadingTemplate);
+ const { version } = await readPackageJSON(process.cwd());
+ const envRaw = isBuild ? 'prod' : 'dev';
+ const cacheName = `'${env.VITE_APP_NAMESPACE}-${version}-${envRaw}-preferences-theme'`;
+
+ // 获取缓存的主题
+ // 保证黑暗主题下,刷新页面时,loading也是黑暗主题
+ const injectScript = `
+
+`;
+
+ if (!loadingHtml) {
+ return;
+ }
+
+ return {
+ enforce: 'pre',
+ name: 'vite:inject-app-loading',
+ transformIndexHtml: {
+ handler(html) {
+ const re = //;
+ html = html.replace(re, `${injectScript}${loadingHtml}`);
+ return html;
+ },
+ order: 'pre',
+ },
+ };
+}
+
+/**
+ * 用于获取loading的html模板
+ */
+async function getLoadingRawByHtmlTemplate(loadingTemplate: string) {
+ // 支持在app内自定义loading模板,模版参考default-loading.html即可
+ let appLoadingPath = join(process.cwd(), loadingTemplate);
+
+ if (!fs.existsSync(appLoadingPath)) {
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
+ appLoadingPath = join(__dirname, './default-loading.html');
+ }
+
+ return await fsp.readFile(appLoadingPath, 'utf8');
+}
+
+export { viteInjectAppLoadingPlugin };
diff --git a/apps/vben5/internal/vite-config/src/plugins/inject-metadata.ts b/apps/vben5/internal/vite-config/src/plugins/inject-metadata.ts
new file mode 100644
index 000000000..41c4db404
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/inject-metadata.ts
@@ -0,0 +1,111 @@
+import type { PluginOption } from 'vite';
+
+import {
+ dateUtil,
+ findMonorepoRoot,
+ getPackages,
+ readPackageJSON,
+} from '@vben/node-utils';
+
+import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest';
+
+function resolvePackageVersion(
+ pkgsMeta: Record,
+ name: string,
+ value: string,
+ catalog: Record,
+) {
+ if (value.includes('catalog:')) {
+ return catalog[name];
+ }
+
+ if (value.includes('workspace')) {
+ return pkgsMeta[name];
+ }
+
+ return value;
+}
+
+async function resolveMonorepoDependencies() {
+ const { packages } = await getPackages();
+ const manifest = await readWorkspaceManifest(findMonorepoRoot());
+ const catalog = manifest?.catalog || {};
+
+ const resultDevDependencies: Record = {};
+ const resultDependencies: Record = {};
+ const pkgsMeta: Record = {};
+
+ for (const { packageJson } of packages) {
+ pkgsMeta[packageJson.name] = packageJson.version;
+ }
+
+ for (const { packageJson } of packages) {
+ const { dependencies = {}, devDependencies = {} } = packageJson;
+ for (const [key, value] of Object.entries(dependencies)) {
+ resultDependencies[key] = resolvePackageVersion(
+ pkgsMeta,
+ key,
+ value,
+ catalog,
+ );
+ }
+ for (const [key, value] of Object.entries(devDependencies)) {
+ resultDevDependencies[key] = resolvePackageVersion(
+ pkgsMeta,
+ key,
+ value,
+ catalog,
+ );
+ }
+ }
+ return {
+ dependencies: resultDependencies,
+ devDependencies: resultDevDependencies,
+ };
+}
+
+/**
+ * 用于注入项目信息
+ */
+async function viteMetadataPlugin(
+ root = process.cwd(),
+): Promise {
+ const { author, description, homepage, license, version } =
+ await readPackageJSON(root);
+
+ const buildTime = dateUtil().format('YYYY-MM-DD HH:mm:ss');
+
+ return {
+ async config() {
+ const { dependencies, devDependencies } =
+ await resolveMonorepoDependencies();
+
+ const isAuthorObject = typeof author === 'object';
+ const authorName = isAuthorObject ? author.name : author;
+ const authorEmail = isAuthorObject ? author.email : null;
+ const authorUrl = isAuthorObject ? author.url : null;
+
+ return {
+ define: {
+ __VBEN_ADMIN_METADATA__: JSON.stringify({
+ authorEmail,
+ authorName,
+ authorUrl,
+ buildTime,
+ dependencies,
+ description,
+ devDependencies,
+ homepage,
+ license,
+ version,
+ }),
+ 'import.meta.env.VITE_APP_VERSION': JSON.stringify(version),
+ },
+ };
+ },
+ enforce: 'post',
+ name: 'vite:inject-metadata',
+ };
+}
+
+export { viteMetadataPlugin };
diff --git a/apps/vben5/internal/vite-config/src/plugins/license.ts b/apps/vben5/internal/vite-config/src/plugins/license.ts
new file mode 100644
index 000000000..81fc4ff07
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/license.ts
@@ -0,0 +1,63 @@
+import type {
+ NormalizedOutputOptions,
+ OutputBundle,
+ OutputChunk,
+} from 'rollup';
+import type { PluginOption } from 'vite';
+
+import { EOL } from 'node:os';
+
+import { dateUtil, readPackageJSON } from '@vben/node-utils';
+
+/**
+ * 用于注入版权信息
+ * @returns
+ */
+
+async function viteLicensePlugin(
+ root = process.cwd(),
+): Promise {
+ const {
+ description = '',
+ homepage = '',
+ version = '',
+ } = await readPackageJSON(root);
+
+ return {
+ apply: 'build',
+ enforce: 'post',
+ generateBundle: {
+ handler: (_options: NormalizedOutputOptions, bundle: OutputBundle) => {
+ const date = dateUtil().format('YYYY-MM-DD ');
+ const copyrightText = `/*!
+ * Vben Admin
+ * Version: ${version}
+ * Author: vben
+ * Copyright (C) 2024 Vben
+ * License: MIT License
+ * Description: ${description}
+ * Date Created: ${date}
+ * Homepage: ${homepage}
+ * Contact: ann.vben@gmail.com
+*/
+ `.trim();
+
+ for (const [, fileContent] of Object.entries(bundle)) {
+ if (fileContent.type === 'chunk' && fileContent.isEntry) {
+ const chunkContent = fileContent as OutputChunk;
+ // 插入版权信息
+ const content = chunkContent.code;
+ const updatedContent = `${copyrightText}${EOL}${content}`;
+
+ // 更新bundle
+ (fileContent as OutputChunk).code = updatedContent;
+ }
+ }
+ },
+ order: 'post',
+ },
+ name: 'vite:license',
+ };
+}
+
+export { viteLicensePlugin };
diff --git a/apps/vben5/internal/vite-config/src/plugins/nitro-mock.ts b/apps/vben5/internal/vite-config/src/plugins/nitro-mock.ts
new file mode 100644
index 000000000..60d7327d9
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/nitro-mock.ts
@@ -0,0 +1,98 @@
+import type { PluginOption } from 'vite';
+
+import type { NitroMockPluginOptions } from '../typing';
+
+import { colors, consola, getPackage } from '@vben/node-utils';
+
+import getPort from 'get-port';
+import { build, createDevServer, createNitro, prepare } from 'nitropack';
+
+const hmrKeyRe = /^runtimeConfig\.|routeRules\./;
+
+export const viteNitroMockPlugin = ({
+ mockServerPackage = '@vben/backend-mock',
+ port = 5320,
+ verbose = true,
+}: NitroMockPluginOptions = {}): PluginOption => {
+ return {
+ async configureServer(server) {
+ const availablePort = await getPort({ port });
+ if (availablePort !== port) {
+ return;
+ }
+
+ const pkg = await getPackage(mockServerPackage);
+ if (!pkg) {
+ consola.log(
+ `Package ${mockServerPackage} not found. Skip mock server.`,
+ );
+ return;
+ }
+
+ runNitroServer(pkg.dir, port, verbose);
+
+ const _printUrls = server.printUrls;
+ server.printUrls = () => {
+ _printUrls();
+
+ consola.log(
+ ` ${colors.green('➜')} ${colors.bold('Nitro Mock Server')}: ${colors.cyan(`http://localhost:${port}/api`)}`,
+ );
+ };
+ },
+ enforce: 'pre',
+ name: 'vite:mock-server',
+ };
+};
+
+async function runNitroServer(rootDir: string, port: number, verbose: boolean) {
+ let nitro: any;
+ const reload = async () => {
+ if (nitro) {
+ consola.info('Restarting dev server...');
+ if ('unwatch' in nitro.options._c12) {
+ await nitro.options._c12.unwatch();
+ }
+ await nitro.close();
+ }
+ nitro = await createNitro(
+ {
+ dev: true,
+ preset: 'nitro-dev',
+ rootDir,
+ },
+ {
+ c12: {
+ async onUpdate({ getDiff, newConfig }) {
+ const diff = getDiff();
+ if (diff.length === 0) {
+ return;
+ }
+ verbose &&
+ consola.info(
+ `Nitro config updated:\n${diff
+ .map((entry) => ` ${entry.toString()}`)
+ .join('\n')}`,
+ );
+ await (diff.every((e) => hmrKeyRe.test(e.key))
+ ? nitro.updateConfig(newConfig.config)
+ : reload());
+ },
+ },
+ watch: true,
+ },
+ );
+ nitro.hooks.hookOnce('restart', reload);
+
+ const server = createDevServer(nitro);
+ await server.listen(port, { showURL: false });
+ await prepare(nitro);
+ await build(nitro);
+
+ if (verbose) {
+ console.log('');
+ consola.success(colors.bold(colors.green('Nitro Mock Server started.')));
+ }
+ };
+ return await reload();
+}
diff --git a/apps/vben5/internal/vite-config/src/plugins/print.ts b/apps/vben5/internal/vite-config/src/plugins/print.ts
new file mode 100644
index 000000000..0146b8a2a
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/print.ts
@@ -0,0 +1,28 @@
+import type { PluginOption } from 'vite';
+
+import type { PrintPluginOptions } from '../typing';
+
+import { colors } from '@vben/node-utils';
+
+export const vitePrintPlugin = (
+ options: PrintPluginOptions = {},
+): PluginOption => {
+ const { infoMap = {} } = options;
+
+ return {
+ configureServer(server) {
+ const _printUrls = server.printUrls;
+ server.printUrls = () => {
+ _printUrls();
+
+ for (const [key, value] of Object.entries(infoMap)) {
+ console.log(
+ ` ${colors.green('➜')} ${colors.bold(key)}: ${colors.cyan(value)}`,
+ );
+ }
+ };
+ },
+ enforce: 'pre',
+ name: 'vite:print-info',
+ };
+};
diff --git a/apps/vben5/internal/vite-config/src/plugins/vxe-table.ts b/apps/vben5/internal/vite-config/src/plugins/vxe-table.ts
new file mode 100644
index 000000000..3c107a7f5
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/plugins/vxe-table.ts
@@ -0,0 +1,20 @@
+import type { PluginOption } from 'vite';
+
+import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import';
+
+async function viteVxeTableImportsPlugin(): Promise {
+ return [
+ lazyImport({
+ resolvers: [
+ VxeResolver({
+ libraryName: 'vxe-table',
+ }),
+ VxeResolver({
+ libraryName: 'vxe-pc-ui',
+ }),
+ ],
+ }),
+ ];
+}
+
+export { viteVxeTableImportsPlugin };
diff --git a/apps/vben5/internal/vite-config/src/typing.ts b/apps/vben5/internal/vite-config/src/typing.ts
new file mode 100644
index 000000000..31683cc75
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/typing.ts
@@ -0,0 +1,164 @@
+import type { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
+import type { ConfigEnv, PluginOption, UserConfig } from 'vite';
+import type { PluginOptions } from 'vite-plugin-dts';
+import type { Options as PwaPluginOptions } from 'vite-plugin-pwa';
+
+interface IImportMap {
+ imports?: Record;
+ scopes?: {
+ [scope: string]: Record;
+ };
+}
+interface PrintPluginOptions {
+ /**
+ * 打印的数据
+ */
+ infoMap?: Record;
+}
+
+interface NitroMockPluginOptions {
+ /**
+ * mock server 包名
+ */
+ mockServerPackage?: string;
+
+ /**
+ * mock 服务端口
+ */
+ port?: number;
+
+ /**
+ * mock 日志是否打印
+ */
+ verbose?: boolean;
+}
+
+interface ArchiverPluginOptions {
+ /**
+ * 输出文件名
+ * @default dist
+ */
+ name?: string;
+ /**
+ * 输出目录
+ * @default .
+ */
+ outputDir?: string;
+}
+
+/**
+ * importmap 插件配置
+ */
+interface ImportmapPluginOptions {
+ /**
+ * CDN 供应商
+ * @default jspm.io
+ */
+ defaultProvider?: 'esm.sh' | 'jspm.io';
+ /** importmap 配置 */
+ importmap?: Array<{ name: string; range?: string }>;
+ /** 手动配置importmap */
+ inputMap?: IImportMap;
+}
+
+/**
+ * 用于判断是否需要加载插件
+ */
+interface ConditionPlugin {
+ // 判断条件
+ condition?: boolean;
+ // 插件对象
+ plugins: () => PluginOption[] | PromiseLike;
+}
+
+interface CommonPluginOptions {
+ /** 是否开启devtools */
+ devtools?: boolean;
+ /** 环境变量 */
+ env?: Record;
+ /** 是否注入metadata */
+ injectMetadata?: boolean;
+ /** 是否构建模式 */
+ isBuild?: boolean;
+ /** 构建模式 */
+ mode?: string;
+ /** 开启依赖分析 */
+ visualizer?: boolean | PluginVisualizerOptions;
+}
+
+interface ApplicationPluginOptions extends CommonPluginOptions {
+ /** 开启后,会在打包dist同级生成dist.zip */
+ archiver?: boolean;
+ /** 压缩归档插件配置 */
+ archiverPluginOptions?: ArchiverPluginOptions;
+ /** 开启 gzip|brotli 压缩 */
+ compress?: boolean;
+ /** 压缩类型 */
+ compressTypes?: ('brotli' | 'gzip')[];
+ /** 在构建的时候抽离配置文件 */
+ extraAppConfig?: boolean;
+ /** 是否开启html插件 */
+ html?: boolean;
+ /** 是否开启i18n */
+ i18n?: boolean;
+ /** 是否开启 importmap CDN */
+ importmap?: boolean;
+ /** importmap 插件配置 */
+ importmapOptions?: ImportmapPluginOptions;
+ /** 是否注入app loading */
+ injectAppLoading?: boolean;
+ /** 是否注入全局scss */
+ injectGlobalScss?: boolean;
+ /** 是否注入版权信息 */
+ license?: boolean;
+ /** 是否开启nitro mock */
+ nitroMock?: boolean;
+ /** nitro mock 插件配置 */
+ nitroMockOptions?: NitroMockPluginOptions;
+ /** 开启控制台自定义打印 */
+ print?: boolean;
+ /** 打印插件配置 */
+ printInfoMap?: PrintPluginOptions['infoMap'];
+ /** 是否开启pwa */
+ pwa?: boolean;
+ /** pwa 插件配置 */
+ pwaOptions?: Partial;
+ /** 是否开启vxe-table懒加载 */
+ vxeTableLazyImport?: boolean;
+}
+
+interface LibraryPluginOptions extends CommonPluginOptions {
+ /** 开启 dts 输出 */
+ dts?: boolean | PluginOptions;
+}
+
+type ApplicationOptions = ApplicationPluginOptions;
+
+type LibraryOptions = LibraryPluginOptions;
+
+type DefineApplicationOptions = (config?: ConfigEnv) => Promise<{
+ application?: ApplicationOptions;
+ vite?: UserConfig;
+}>;
+
+type DefineLibraryOptions = (config?: ConfigEnv) => Promise<{
+ library?: LibraryOptions;
+ vite?: UserConfig;
+}>;
+
+type DefineConfig = DefineApplicationOptions | DefineLibraryOptions;
+
+export type {
+ ApplicationPluginOptions,
+ ArchiverPluginOptions,
+ CommonPluginOptions,
+ ConditionPlugin,
+ DefineApplicationOptions,
+ DefineConfig,
+ DefineLibraryOptions,
+ IImportMap,
+ ImportmapPluginOptions,
+ LibraryPluginOptions,
+ NitroMockPluginOptions,
+ PrintPluginOptions,
+};
diff --git a/apps/vben5/internal/vite-config/src/utils/env.ts b/apps/vben5/internal/vite-config/src/utils/env.ts
new file mode 100644
index 000000000..1dfd18086
--- /dev/null
+++ b/apps/vben5/internal/vite-config/src/utils/env.ts
@@ -0,0 +1,107 @@
+import type { ApplicationPluginOptions } from '../typing';
+
+import { join } from 'node:path';
+
+import { fs } from '@vben/node-utils';
+
+import dotenv from 'dotenv';
+
+const getBoolean = (value: string | undefined) => value === 'true';
+
+const getString = (value: string | undefined, fallback: string) =>
+ value ?? fallback;
+
+const getNumber = (value: string | undefined, fallback: number) =>
+ Number(value) || fallback;
+
+/**
+ * 获取当前环境下生效的配置文件名
+ */
+function getConfFiles() {
+ const script = process.env.npm_lifecycle_script as string;
+ const reg = /--mode ([\d_a-z]+)/;
+ const result = reg.exec(script);
+
+ if (result) {
+ const mode = result[1];
+ return ['.env', `.env.${mode}`];
+ }
+ return ['.env', '.env.production'];
+}
+
+/**
+ * Get the environment variables starting with the specified prefix
+ * @param match prefix
+ * @param confFiles ext
+ */
+async function loadEnv>(
+ match = 'VITE_GLOB_',
+ confFiles = getConfFiles(),
+) {
+ let envConfig = {};
+
+ for (const confFile of confFiles) {
+ try {
+ const envPath = await fs.readFile(join(process.cwd(), confFile), {
+ encoding: 'utf8',
+ });
+ const env = dotenv.parse(envPath);
+ envConfig = { ...envConfig, ...env };
+ } catch (error) {
+ console.error(`Error while parsing ${confFile}`, error);
+ }
+ }
+ const reg = new RegExp(`^(${match})`);
+ Object.keys(envConfig).forEach((key) => {
+ if (!reg.test(key)) {
+ Reflect.deleteProperty(envConfig, key);
+ }
+ });
+ return envConfig as T;
+}
+
+async function loadAndConvertEnv(
+ match = 'VITE_',
+ confFiles = getConfFiles(),
+): Promise<
+ {
+ appTitle: string;
+ base: string;
+ port: number;
+ } & Partial
+> {
+ const envConfig = await loadEnv(match, confFiles);
+
+ const {
+ VITE_APP_TITLE,
+ VITE_ARCHIVER,
+ VITE_BASE,
+ VITE_COMPRESS,
+ VITE_DEVTOOLS,
+ VITE_INJECT_APP_LOADING,
+ VITE_NITRO_MOCK,
+ VITE_PORT,
+ VITE_PWA,
+ VITE_VISUALIZER,
+ } = envConfig;
+
+ const compressTypes = (VITE_COMPRESS ?? '')
+ .split(',')
+ .filter((item) => item === 'brotli' || item === 'gzip');
+
+ return {
+ appTitle: getString(VITE_APP_TITLE, 'Vben Admin'),
+ archiver: getBoolean(VITE_ARCHIVER),
+ base: getString(VITE_BASE, '/'),
+ compress: compressTypes.length > 0,
+ compressTypes,
+ devtools: getBoolean(VITE_DEVTOOLS),
+ injectAppLoading: getBoolean(VITE_INJECT_APP_LOADING),
+ nitroMock: getBoolean(VITE_NITRO_MOCK),
+ port: getNumber(VITE_PORT, 5173),
+ pwa: getBoolean(VITE_PWA),
+ visualizer: getBoolean(VITE_VISUALIZER),
+ };
+}
+
+export { loadAndConvertEnv, loadEnv };
diff --git a/apps/vben5/internal/vite-config/tsconfig.json b/apps/vben5/internal/vite-config/tsconfig.json
new file mode 100644
index 000000000..b2ec3b61e
--- /dev/null
+++ b/apps/vben5/internal/vite-config/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/node.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/apps/vben5/package.json b/apps/vben5/package.json
new file mode 100644
index 000000000..1bf68b17d
--- /dev/null
+++ b/apps/vben5/package.json
@@ -0,0 +1,123 @@
+{
+ "name": "vben-admin-monorepo",
+ "version": "5.4.8",
+ "private": true,
+ "keywords": [
+ "monorepo",
+ "turbo",
+ "vben",
+ "vben admin",
+ "vben pro",
+ "vue",
+ "vue admin",
+ "vue vben admin",
+ "vue vben admin pro",
+ "vue3"
+ ],
+ "homepage": "https://github.com/vbenjs/vue-vben-admin",
+ "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
+ "repository": "vbenjs/vue-vben-admin.git",
+ "license": "MIT",
+ "author": {
+ "name": "vben",
+ "email": "ann.vben@gmail.com",
+ "url": "https://github.com/anncwb"
+ },
+ "type": "module",
+ "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:docker": "./scripts/deploy/build-local-docker-image.sh",
+ "build:docs": "pnpm run build --filter=@vben/docs",
+ "build:ele": "pnpm run build --filter=@vben/web-ele",
+ "build:naive": "pnpm run build --filter=@vben/web-naive",
+ "build:play": "pnpm run build --filter=@vben/playground",
+ "changeset": "pnpm exec changeset",
+ "check": "pnpm run check:circular && pnpm run check:dep && pnpm run check:type && pnpm check:cspell",
+ "check:circular": "vsh check-circular",
+ "check:cspell": "cspell lint **/*.ts **/README.md .changeset/*.md --no-progress",
+ "check:dep": "vsh check-dep",
+ "check:type": "turbo run typecheck",
+ "clean": "node ./scripts/clean.mjs",
+ "commit": "czg",
+ "dev": "turbo-run dev",
+ "dev:app": "pnpm -F @vben/app-antd run dev",
+ "dev:antd": "pnpm -F @vben/web-antd run dev",
+ "dev:docs": "pnpm -F @vben/docs run dev",
+ "dev:ele": "pnpm -F @vben/web-ele run dev",
+ "dev:naive": "pnpm -F @vben/web-naive run dev",
+ "dev:play": "pnpm -F @vben/playground run dev",
+ "format": "vsh lint --format",
+ "lint": "vsh lint",
+ "postinstall": "pnpm -r run stub --if-present",
+ "preinstall": "npx only-allow pnpm",
+ "prepare": "is-ci || husky",
+ "preview": "turbo-run preview",
+ "publint": "vsh publint",
+ "reinstall": "pnpm clean --del-lock && pnpm install",
+ "test:unit": "vitest run --dom",
+ "test:e2e": "turbo run test:e2e",
+ "update:deps": "npx taze -r -w",
+ "version": "pnpm exec changeset version && pnpm install --no-frozen-lockfile"
+ },
+ "devDependencies": {
+ "@ant-design/icons-vue": "catalog:",
+ "@changesets/changelog-github": "catalog:",
+ "@changesets/cli": "catalog:",
+ "@playwright/test": "catalog:",
+ "@types/node": "catalog:",
+ "@vben/commitlint-config": "workspace:*",
+ "@vben/eslint-config": "workspace:*",
+ "@vben/prettier-config": "workspace:*",
+ "@vben/stylelint-config": "workspace:*",
+ "@vben/tailwind-config": "workspace:*",
+ "@vben/tsconfig": "workspace:*",
+ "@vben/turbo-run": "workspace:*",
+ "@vben/vite-config": "workspace:*",
+ "@vben/vsh": "workspace:*",
+ "@vitejs/plugin-vue": "catalog:",
+ "@vitejs/plugin-vue-jsx": "catalog:",
+ "@vue/test-utils": "catalog:",
+ "autoprefixer": "catalog:",
+ "cross-env": "catalog:",
+ "cspell": "catalog:",
+ "happy-dom": "catalog:",
+ "husky": "catalog:",
+ "is-ci": "catalog:",
+ "lint-staged": "catalog:",
+ "playwright": "catalog:",
+ "rimraf": "catalog:",
+ "tailwindcss": "catalog:",
+ "turbo": "catalog:",
+ "typescript": "catalog:",
+ "unbuild": "catalog:",
+ "vite": "catalog:",
+ "vitest": "catalog:",
+ "vue": "catalog:",
+ "vue-tsc": "catalog:"
+ },
+ "engines": {
+ "node": ">=20.10.0",
+ "pnpm": ">=9.12.0"
+ },
+ "packageManager": "pnpm@9.14.4",
+ "pnpm": {
+ "peerDependencyRules": {
+ "allowedVersions": {
+ "eslint": "*"
+ }
+ },
+ "overrides": {
+ "@ast-grep/napi": "catalog:",
+ "@ctrl/tinycolor": "catalog:",
+ "clsx": "catalog:",
+ "pinia": "catalog:",
+ "vue": "catalog:"
+ },
+ "neverBuiltDependencies": [
+ "canvas",
+ "node-gyp"
+ ]
+ }
+}
diff --git a/apps/vben5/packages/@abp/account/package.json b/apps/vben5/packages/@abp/account/package.json
new file mode 100644
index 000000000..2a5a46074
--- /dev/null
+++ b/apps/vben5/packages/@abp/account/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "@abp/account",
+ "version": "8.2.3",
+ "homepage": "https://github.com/colinin/abp-next-admin",
+ "bugs": "https://github.com/colinin/abp-next-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/colinin/abp-next-admin.git",
+ "directory": "packages/@abp/account"
+ },
+ "license": "MIT",
+ "type": "module",
+ "sideEffects": [
+ "**/*.css"
+ ],
+ "exports": {
+ ".": {
+ "types": "./src/index.ts",
+ "default": "./src/index.ts"
+ }
+ },
+ "dependencies": {
+ "@abp/core": "workspace:*",
+ "@abp/request": "workspace:*",
+ "@abp/ui": "workspace:*",
+ "@vben/hooks": "workspace:*",
+ "@vben/layouts": "workspace:*",
+ "@vben/locales": "workspace:*",
+ "ant-design-vue": "catalog:",
+ "vue": "catalog:*"
+ }
+}
diff --git a/apps/vben5/packages/@abp/account/src/api/index.ts b/apps/vben5/packages/@abp/account/src/api/index.ts
new file mode 100644
index 000000000..76ba2a014
--- /dev/null
+++ b/apps/vben5/packages/@abp/account/src/api/index.ts
@@ -0,0 +1,2 @@
+export * from './token';
+export * from './user';
diff --git a/apps/vben5/packages/@abp/account/src/api/token.ts b/apps/vben5/packages/@abp/account/src/api/token.ts
new file mode 100644
index 000000000..212cc707c
--- /dev/null
+++ b/apps/vben5/packages/@abp/account/src/api/token.ts
@@ -0,0 +1,46 @@
+import type {
+ OAuthTokenResult,
+ PasswordTokenRequestModel,
+ TokenResult,
+} from '../types';
+
+import { useAppConfig } from '@vben/hooks';
+
+import { requestClient } from '@abp/request';
+
+/**
+ * 用户登录
+ * @param request 参数
+ * @returns 用户token
+ */
+export async function loginApi(
+ request: PasswordTokenRequestModel,
+): Promise {
+ const { clientId, clientSecret } = useAppConfig(
+ import.meta.env,
+ import.meta.env.PROD,
+ );
+ const result = await requestClient.post(
+ '/connect/token',
+ {
+ client_id: clientId,
+ client_secret: clientSecret,
+ grant_type: 'password',
+ password: request.password,
+ scope:
+ 'openid email address phone profile offline_access lingyun-abp-application',
+ username: request.username,
+ },
+ {
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ },
+ },
+ );
+ return {
+ accessToken: result.access_token,
+ expiresIn: result.expires_in,
+ refreshToken: result.refresh_token,
+ tokenType: result.token_type,
+ };
+}
diff --git a/apps/vben5/packages/@abp/account/src/api/user.ts b/apps/vben5/packages/@abp/account/src/api/user.ts
new file mode 100644
index 000000000..87611be89
--- /dev/null
+++ b/apps/vben5/packages/@abp/account/src/api/user.ts
@@ -0,0 +1,18 @@
+import type { OAuthUserInfo, UserInfo } from '../types/user';
+
+import { requestClient } from '@abp/request';
+
+/**
+ * 获取用户信息
+ */
+export async function getUserInfoApi(): Promise {
+ const result = await requestClient.get('/connect/userinfo');
+ return {
+ ...result,
+ emailVerified: result.email_verified,
+ givenName: result.given_name,
+ phoneNumberVerified: result.phone_number_verified,
+ preferredUsername: result.preferred_username,
+ uniqueName: result.unique_name,
+ };
+}
diff --git a/apps/vben5/packages/@abp/account/src/index.ts b/apps/vben5/packages/@abp/account/src/index.ts
new file mode 100644
index 000000000..4d4b4e299
--- /dev/null
+++ b/apps/vben5/packages/@abp/account/src/index.ts
@@ -0,0 +1,2 @@
+export * from './api';
+export * from './types';
diff --git a/apps/vben5/packages/@abp/account/src/types/index.ts b/apps/vben5/packages/@abp/account/src/types/index.ts
new file mode 100644
index 000000000..76ba2a014
--- /dev/null
+++ b/apps/vben5/packages/@abp/account/src/types/index.ts
@@ -0,0 +1,2 @@
+export * from './token';
+export * from './user';
diff --git a/apps/vben5/packages/@abp/account/src/types/token.ts b/apps/vben5/packages/@abp/account/src/types/token.ts
new file mode 100644
index 000000000..b8bb274d3
--- /dev/null
+++ b/apps/vben5/packages/@abp/account/src/types/token.ts
@@ -0,0 +1,53 @@
+/** 授权请求数据模型 */
+interface TokenRequest {
+ /** 客户端id */
+ clientId: string;
+ /** 客户端密钥 */
+ clientSecret: string;
+}
+/** 用户密码授权请求数据模型 */
+interface PasswordTokenRequest extends TokenRequest {
+ /** 用户密码 */
+ password: string;
+ /** 授权范围 */
+ scope?: string;
+ /** 用户名 */
+ userName: string;
+}
+/** 用户密码授权请求数据模型 */
+interface PasswordTokenRequestModel {
+ /** 用户密码 */
+ password: string;
+ /** 用户名 */
+ username: string;
+}
+/** 令牌返回数据模型 */
+interface TokenResult {
+ /** 访问令牌 */
+ accessToken: string;
+ /** 过期时间 */
+ expiresIn: number;
+ /** 刷新令牌 */
+ refreshToken: string;
+ /** 令牌类型 */
+ tokenType: string;
+}
+/** oauth标准令牌返回结构 */
+interface OAuthTokenResult {
+ /** 访问令牌 */
+ access_token: string;
+ /** 过期时间 */
+ expires_in: number;
+ /** 刷新令牌 */
+ refresh_token: string;
+ /** 令牌类型 */
+ token_type: string;
+}
+
+export type {
+ OAuthTokenResult,
+ PasswordTokenRequest,
+ PasswordTokenRequestModel,
+ TokenRequest,
+ TokenResult,
+};
diff --git a/apps/vben5/packages/@abp/account/src/types/user.ts b/apps/vben5/packages/@abp/account/src/types/user.ts
new file mode 100644
index 000000000..b571e11a3
--- /dev/null
+++ b/apps/vben5/packages/@abp/account/src/types/user.ts
@@ -0,0 +1,81 @@
+interface UserInfo {
+ [property: string]: any;
+ /**
+ * 邮箱地址
+ */
+ email: string;
+ /**
+ * 邮件地址是否已验证
+ */
+ emailVerified: string;
+ /**
+ * 名称
+ */
+ givenName: string;
+ /**
+ * 用户名
+ */
+ name: string;
+ /**
+ * 手机号是否已验证
+ */
+ phoneNumberVerified: string;
+ /**
+ * 用户名
+ */
+ preferredUsername: string;
+ /**
+ * 角色列表
+ */
+ role: string[];
+ /**
+ * 用户标识
+ */
+ sub: string;
+ /**
+ * 用户名
+ */
+ uniqueName: string;
+}
+/** oauth标准用户信息结构 */
+interface OAuthUserInfo {
+ [property: string]: any;
+ /**
+ * 邮箱地址
+ */
+ email: string;
+ /**
+ * 邮件地址是否已验证
+ */
+ email_verified: string;
+ /**
+ * 名称
+ */
+ given_name: string;
+ /**
+ * 用户名
+ */
+ name: string;
+ /**
+ * 手机号是否已验证
+ */
+ phone_number_verified: string;
+ /**
+ * 用户名
+ */
+ preferred_username: string;
+ /**
+ * 角色列表
+ */
+ role: string[];
+ /**
+ * 用户标识
+ */
+ sub: string;
+ /**
+ * 用户名
+ */
+ unique_name: string;
+}
+
+export type { OAuthUserInfo, UserInfo };
diff --git a/apps/vben5/packages/@abp/account/tsconfig.json b/apps/vben5/packages/@abp/account/tsconfig.json
new file mode 100644
index 000000000..ce1a891fb
--- /dev/null
+++ b/apps/vben5/packages/@abp/account/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@vben/tsconfig/web.json",
+ "include": ["src"],
+ "exclude": ["node_modules"]
+}
diff --git a/apps/vben5/packages/@abp/core/package.json b/apps/vben5/packages/@abp/core/package.json
new file mode 100644
index 000000000..7ffa6d8e4
--- /dev/null
+++ b/apps/vben5/packages/@abp/core/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "@abp/core",
+ "version": "8.3.2",
+ "homepage": "https://github.com/colinin/abp-next-admin",
+ "bugs": "https://github.com/colinin/abp-next-admin/issues",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/colinin/abp-next-admin.git",
+ "directory": "packages/@abp/core"
+ },
+ "license": "MIT",
+ "type": "module",
+ "scripts": {
+ "build": "pnpm vite build",
+ "prepublishOnly": "npm run build"
+ },
+ "files": [
+ "dist",
+ "src"
+ ],
+ "main": "./dist/index.mjs",
+ "module": "./dist/index.mjs",
+ "exports": {
+ ".": {
+ "types": "./src/index.ts",
+ "development": "./src/index.ts",
+ "default": "./dist/index.mjs"
+ }
+ },
+ "publishConfig": {
+ "exports": {
+ ".": {
+ "default": "./dist/index.mjs"
+ }
+ }
+ },
+ "dependencies": {
+ "dayjs": "catalog:",
+ "pinia": "catalog:",
+ "vue": "catalog:"
+ }
+}
diff --git a/apps/vben5/packages/@abp/core/src/index.ts b/apps/vben5/packages/@abp/core/src/index.ts
new file mode 100644
index 000000000..48ebf8d9a
--- /dev/null
+++ b/apps/vben5/packages/@abp/core/src/index.ts
@@ -0,0 +1,3 @@
+export * from './store';
+export * from './types';
+export * from './utils';
diff --git a/apps/vben5/packages/@abp/core/src/store/abp.ts b/apps/vben5/packages/@abp/core/src/store/abp.ts
new file mode 100644
index 000000000..4134845b2
--- /dev/null
+++ b/apps/vben5/packages/@abp/core/src/store/abp.ts
@@ -0,0 +1,63 @@
+import type {
+ ApplicationConfigurationDto,
+ ApplicationLocalizationDto,
+} from '../types/dto';
+
+import { ref } from 'vue';
+
+import { acceptHMRUpdate, defineStore } from 'pinia';
+
+export const useAbpStore = defineStore('abp', () => {
+ const application = ref();
+ const localization = ref();
+ /** 获取 i18n 格式本地化文本 */
+ function getI18nLocales() {
+ const abpLocales: Record = {};
+ if (!localization.value) {
+ return abpLocales;
+ }
+ const resources = localization.value.resources;
+ // AbpValidation.The field {0} is invalid.
+ Object.keys(resources).forEach((resource) => {
+ // resource --> AbpValidation
+ const resourceLocales: Record = {};
+ const resourcesByName = resources[resource];
+ if (resourcesByName) {
+ Object.keys(resourcesByName.texts).forEach((key) => {
+ // The field {0} is invalid. --> The field {0} is invalid_
+ let localeKey = key.replaceAll('.', '_');
+ // The field {0} is invalid. --> The field {0} is invalid
+ localeKey.endsWith('_') &&
+ (localeKey = localeKey.slice(0, Math.max(0, localeKey.length - 1)));
+ // _The field {0} is invalid --> The field {0} is invalid
+ localeKey.startsWith('_') &&
+ (localeKey = localeKey.slice(0, Math.max(1, localeKey.length)));
+ resourceLocales[localeKey] = resourcesByName.texts[key];
+ });
+ abpLocales[resource] = resourceLocales;
+ }
+ });
+ return abpLocales;
+ }
+ function setApplication(val: ApplicationConfigurationDto) {
+ application.value = val;
+ }
+
+ function setLocalization(val: ApplicationLocalizationDto) {
+ localization.value = val;
+ }
+
+ return {
+ application,
+ getI18nLocales,
+ localization,
+ setApplication,
+ setLocalization,
+ };
+});
+
+// 解决热更新问题
+const hot = import.meta.hot;
+if (hot) {
+ hot.accept(acceptHMRUpdate(useAbpStore, hot));
+}
diff --git a/apps/vben5/packages/@abp/core/src/store/index.ts b/apps/vben5/packages/@abp/core/src/store/index.ts
new file mode 100644
index 000000000..c0475756d
--- /dev/null
+++ b/apps/vben5/packages/@abp/core/src/store/index.ts
@@ -0,0 +1 @@
+export * from './abp';
diff --git a/apps/vben5/packages/@abp/core/src/types/dto.ts b/apps/vben5/packages/@abp/core/src/types/dto.ts
new file mode 100644
index 000000000..41d17932f
--- /dev/null
+++ b/apps/vben5/packages/@abp/core/src/types/dto.ts
@@ -0,0 +1,412 @@
+import {
+ type Clock,
+ type CurrentCulture,
+ type CurrentTenant,
+ type CurrentUser,
+ type Dictionary,
+ type ExtraPropertyDictionary,
+ type IHasExtraProperties,
+ type LanguageInfo,
+ type MultiTenancyInfo,
+ type NameValue,
+ type TimeZone,
+} from './global';
+/** 包装器数据传输对象 */
+interface WrapResult {
+ /**
+ * 错误代码
+ * @summary '0' 表示正常
+ */
+ code: string;
+ /** 错误详情 */
+ details?: string;
+ /** 错误消息 */
+ message: string;
+ /** 返回数据 */
+ result: T;
+}
+/** 远程服务验证错误描述 */
+interface RemoteServiceValidationErrorInfo {
+ /** 字段名称列表 */
+ members: string[];
+ /** 错误消息 */
+ message: string;
+}
+/** 远程服务错误描述(仅适用于接口代理) */
+interface RemoteServiceErrorInfo {
+ /** 错误代码 */
+ code?: string;
+ /** 异常数据 */
+ data?: { [key: string]: any };
+ /** 错误详情 */
+ details?: string;
+ /** 错误消息 */
+ message?: string;
+ /** 验证错误列表 */
+ validationErrors: RemoteServiceValidationErrorInfo[];
+}
+/** 扩展属性数据传输对象 */
+interface ExtensibleObject {
+ /** 扩展属性 */
+ extraProperties: ExtraPropertyDictionary;
+}
+/** 实体数据传输对象 */
+interface EntityDto {
+ /** 实体标识 */
+ id: TPrimaryKey;
+}
+/** 实体新增属性数据传输对象 */
+interface CreationAuditedEntityDto extends EntityDto {
+ /** 创建时间 */
+ creationTime: Date;
+ /** 创建人标识 */
+ creatorId?: string;
+}
+/** 实体新增用户属性数据传输对象 */
+interface CreationAuditedEntityWithUserDto
+ extends CreationAuditedEntityDto {
+ /** 创建人实体数据传输对象 */
+ creator: TUserDto;
+}
+/** 实体审计属性数据传输对象 */
+interface AuditedEntityDto
+ extends CreationAuditedEntityDto {
+ /** 上次变更过时间 */
+ lastModificationTime?: Date;
+ /** 上次变更人 */
+ lastModifierId?: string;
+}
+/** 实体审计用户属性数据传输对象 */
+interface AuditedEntityWithUserDto
+ extends AuditedEntityDto {
+ /** 创建人实体数据传输对象 */
+ creator: TUserDto;
+ /** 变更人实体数据传输对象 */
+ lastModifier: TUserDto;
+}
+/** 实体审计全属性数据传输对象 */
+interface FullAuditedEntityDto
+ extends AuditedEntityDto {
+ /** 删除人标识 */
+ deleterId?: string;
+ /** 删除时间 */
+ deletionTime?: Date;
+ /** 是否已删除 */
+ isDeleted: boolean;
+}
+/** 实体审计用户全属性数据传输对象 */
+interface FullAuditedEntityWithUserDto
+ extends AuditedEntityWithUserDto,
+ FullAuditedEntityDto {
+ /** 删除人实体数据传输对象 */
+ deleter: TUserDto;
+}
+/** 实体扩展属性数据传输对象 */
+interface ExtensibleEntityDto extends ExtensibleObject, EntityDto {}
+/** 实体新增扩展属性数据传输对象 */
+interface ExtensibleCreationAuditedEntityDto
+ extends CreationAuditedEntityDto,
+ ExtensibleEntityDto {}
+/** 实体新增用户扩展属性数据传输对象 */
+interface ExtensibleCreationAuditedEntityWithUserDto
+ extends CreationAuditedEntityWithUserDto,
+ ExtensibleEntityDto {}
+/** 实体审计扩展属性数据传输对象 */
+interface ExtensibleAuditedEntityDto
+ extends AuditedEntityDto