commit 08e79c60e725f2540bd8631079a4044dcede7ae5 Author: liangzai <2440983361@qq.com> Date: Sun Jun 8 20:16:51 2025 +0800 第一基础版 diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 0000000..dc3bc09 --- /dev/null +++ b/.browserslistrc @@ -0,0 +1,4 @@ +> 1% +last 2 versions +not dead +not ie 11 diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000..5654e89 --- /dev/null +++ b/.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/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000..f954fb4 --- /dev/null +++ b/.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/.commitlintrc.js b/.commitlintrc.js new file mode 100644 index 0000000..02e33fa --- /dev/null +++ b/.commitlintrc.js @@ -0,0 +1 @@ +export { default } from '@vben/commitlint-config'; diff --git a/.cursor/rules/vben.mdc b/.cursor/rules/vben.mdc new file mode 100644 index 0000000..47cdcc5 --- /dev/null +++ b/.cursor/rules/vben.mdc @@ -0,0 +1,329 @@ +--- +description: +globs: +alwaysApply: true +--- +# Vue Vben Admin 开发规范与模板 + +## 1. 目录结构规范 +``` +views/ + ├── [module]/ # 模块目录 + │ ├── data.ts # 表单schema、表格列配置等 + │ ├── list.vue # 主列表页面 + │ └── modules/ # 子模块组件 + │ └── form.vue # 表单抽屉组件 +``` + +## 2. 代码模板 + +### 2.1 列表页面模板 (list.vue) +```vue + + + +``` + +### 2.2 数据配置模板 (data.ts) +```typescript +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { [Module]Api } from '#/api'; + +import { $t } from '#/locales'; + +// 表单配置 +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'field_name', + label: $t('module.field.label'), + rules: 'required', + }, + // ... 其他表单项 + ]; +} + +// 搜索表单配置 +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'search_field', + label: $t('module.search.label'), + }, + // ... 其他搜索项 + ]; +} + +// 表格列配置 +export function useColumns( + onActionClick: OnActionClickFn, + onStatusChange?: (newStatus: any, row: T) => PromiseLike, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'field_name', + title: $t('module.field.label'), + width: 200, + }, + // ... 其他列 + { + align: 'center', + cellRender: { + attrs: { + nameField: 'name_field', + nameTitle: $t('module.name.label'), + onClick: onActionClick, + }, + name: 'CellOperation', + }, + field: 'operation', + fixed: 'right', + title: $t('module.operation'), + width: 130, + }, + ]; +} +``` + +### 2.3 表单组件模板 (form.vue) +```vue + + + +``` + +### 2.4 API 接口定义模板 +```typescript +import type { BaseApi } from '#/api'; + +export namespace [Module]Api { + export interface [Module]Item { + id: number; + // ... 其他字段 + } + + export interface [Module]ListParams extends BaseApi.ListParams { + // ... 其他查询参数 + } + + export interface [Module]ListResult extends BaseApi.ListResult<[Module]Item> {} +} + +export function get[Module]List(params: [Module]Api.[Module]ListParams) { + return request.get<[Module]Api.[Module]ListResult>('/api/[module]/list', { params }); +} + +export function create[Module](mdc:data: Omit<[Module]Api.[Module]Item, 'id'>) { + return request.post<[Module]Api.[Module]Item>('/api/[module]/create', data); +} + +export function update[Module](mdc:id: number, data: Partial<[Module]Api.[Module]Item>) { + return request.put<[Module]Api.[Module]Item>(`/api/[module]/update/${id}`, data); +} + +export function delete[Module](mdc:id: number) { + return request.delete(`/api/[module]/delete/${id}`); +} +``` + +### 2.5 国际化文案模板 +```typescript +export default { + module: { + name: '[模块名称]', + list: '[模块名称]列表', + field: { + label: '[字段标签]', + }, + search: { + label: '[搜索标签]', + }, + operation: '操作', + }, +}; +``` + +## 3. 使用说明 + +1. 创建新模块时,按照目录结构规范创建相应的文件 +2. 复制对应的模板代码到相应文件中 +3. 替换所有 `[Module]` 为你的模块名称(如 `Product`) +4. 根据实际需求修改: + - 表单字段配置 + - 搜索表单配置 + - 表格列配置 + - API 接口定义 + - 国际化文案 + +## 4. 注意事项 + +1. 确保 API 接口已定义并正确实现 +2. 确保国际化文案已配置 +3. 根据实际需求调整表单和表格配置 +4. 注意处理特殊字段(如时间、状态等) +5. 保持代码风格统一 +6. 遵循项目的命名规范 + +## 5. 参考示例 + +可以参考以下现有模块的实现: +- @system/role +- @system/user +- @order diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..52b833a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules +.git +.gitignore +*.md +dist +.turbo +dist.zip diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..179aec6 --- /dev/null +++ b/.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/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d4e5bd3 --- /dev/null +++ b/.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/.gitconfig b/.gitconfig new file mode 100644 index 0000000..4b28a69 --- /dev/null +++ b/.gitconfig @@ -0,0 +1,2 @@ +[core] + ignorecase = false diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..b95ff94 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,14 @@ +# default onwer +* anncwb@126.com vince292007@gmail.com netfan@foxmail.com jinmao88@qq.com + +# vben core onwer +/.github/ anncwb@126.com vince292007@gmail.com netfan@foxmail.com jinmao88@qq.com +/.vscode/ anncwb@126.com vince292007@gmail.com netfan@foxmail.com jinmao88@qq.com +/packages/ anncwb@126.com vince292007@gmail.com netfan@foxmail.com jinmao88@qq.com +/packages/@core/ anncwb@126.com vince292007@gmail.com netfan@foxmail.com jinmao88@qq.com +/internal/ anncwb@126.com vince292007@gmail.com netfan@foxmail.com jinmao88@qq.com +/scripts/ anncwb@126.com vince292007@gmail.com netfan@foxmail.com jinmao88@qq.com + +# vben team onwer +apps/ anncwb@126.com vince292007@gmail.com netfan@foxmail.com @vbenjs/team-v5 jinmao88@qq.com +docs/ anncwb@126.com vince292007@gmail.com netfan@foxmail.com @vbenjs/team-v5 jinmao88@qq.com diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 0000000..ae92780 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,74 @@ +name: 🐞 Bug Report +description: Report an issue with Vben Admin to help us make it better. +title: 'Bug: ' +labels: ['bug: pending triage'] + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: dropdown + id: version + attributes: + label: Version + description: What version of our software are you running? + options: + - Vben Admin V5 + - Vben Admin V2 + default: 0 + validations: + required: true + + - type: textarea + id: bug-desc + attributes: + label: Describe the bug? + description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks! + placeholder: Bug Description + validations: + required: true + + - type: textarea + id: reproduction + attributes: + label: Reproduction + description: Please provide a link to [StackBlitz](https://stackblitz.com/fork/github/vitest-dev/vitest/tree/main/examples/basic?initialPath=__vitest__/) (you can also use [examples](https://github.com/vitest-dev/vitest/tree/main/examples)) or a github repo that can reproduce the problem you ran into. A [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) is required unless you are absolutely sure that the issue is obvious and the provided information is enough to understand the problem. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "needs reproduction" label. If no reproduction is provided after 3 days, it will be auto-closed. + placeholder: Reproduction + validations: + required: true + + - type: textarea + id: system-info + attributes: + label: System Info + description: Output of `npx envinfo --system --npmPackages '{vue}' --binaries --browsers` + render: shell + placeholder: System, Binaries, Browsers + validations: + required: true + + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell + + - type: checkboxes + id: terms + attributes: + label: Validations + description: Before submitting the issue, please make sure you do the following + # description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com). + options: + - label: Read the [docs](https://doc.vben.pro/) + required: true + - label: Ensure the code is up to date. (Some issues have been fixed in the latest version) + required: true + - label: I have searched the [existing issues](https://github.com/vbenjs/vue-vben-admin/issues) and checked that my issue does not duplicate any existing issues. + required: true + - label: Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vbenjs/vue-vben-admin/discussions) or join our [Discord Chat Server](https://discord.gg/8GuAdwDhj6). + required: true + - label: The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug. + required: true diff --git a/.github/ISSUE_TEMPLATE/docs.yml b/.github/ISSUE_TEMPLATE/docs.yml new file mode 100644 index 0000000..d2bf16e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/docs.yml @@ -0,0 +1,38 @@ +name: 📚 Documentation +description: Report an issue with Vben Admin Website to help us make it better. +title: 'Docs: ' +labels: [documentation] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this issue! + - type: checkboxes + id: documentation_is + attributes: + label: Documentation is + options: + - label: Missing + - label: Outdated + - label: Confusing + - label: Not sure? + - type: textarea + id: description + attributes: + label: Explain in Detail + description: A clear and concise description of your suggestion. If you intend to submit a PR for this issue, tell us in the description. Thanks! + placeholder: The description of ... page is not clear. I thought it meant ... but it wasn't. + validations: + required: true + - type: textarea + id: suggestion + attributes: + label: Your Suggestion for Changes + validations: + required: true + - type: textarea + id: reproduction-steps + attributes: + label: Steps to reproduce + description: Please provide any reproduction steps that may need to be described. E.g. if it happens only when running the dev or build script make sure it's clear which one to use. + placeholder: Run `pnpm install` followed by `pnpm run docs:dev` diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 0000000..393334e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,70 @@ +name: ✨ New Feature Proposal +description: Propose a new feature to be added to Vben Admin +title: 'FEATURE: ' +labels: ['enhancement: pending triage'] +body: + - type: markdown + attributes: + value: | + Thank you for suggesting a feature for our project! Please fill out the information below to help us understand and implement your request! + - type: dropdown + id: version + attributes: + label: Version + description: What version of our software are you running? + options: + - Vben Admin V5 + - Vben Admin V2 + default: 0 + validations: + required: true + + - type: textarea + id: description + attributes: + label: Description + description: A detailed description of the feature request. + placeholder: Please describe the feature you would like to see, and why it would be useful. + validations: + required: true + + - type: textarea + id: proposed-solution + attributes: + label: Proposed Solution + description: A clear and concise description of what you want to happen. + placeholder: Describe the solution you'd like to see + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Alternatives Considered + description: | + A clear and concise description of any alternative solutions or features you've considered. + placeholder: Describe any alternative solutions or features you've considered + validations: + required: false + + - type: input + id: additional-context + attributes: + label: Additional Context + description: Add any other context or screenshots about the feature request here. + placeholder: Any additional information + validations: + required: false + + - type: checkboxes + id: checkboxes + attributes: + label: Validations + description: Before submitting the issue, please make sure you do the following + options: + - label: Read the [docs](https://doc.vben.pro/) + required: true + - label: Ensure the code is up to date. (Some issues have been fixed in the latest version) + required: true + - label: I have searched the [existing issues](https://github.com/vbenjs/vue-vben-admin/issues) and checked that my issue does not duplicate any existing issues. + required: true diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml new file mode 100644 index 0000000..35fa41c --- /dev/null +++ b/.github/actions/setup-node/action.yml @@ -0,0 +1,40 @@ +name: 'Setup Node' + +description: 'Setup node and pnpm' + +runs: + using: 'composite' + steps: + - name: Install pnpm + uses: pnpm/action-setup@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: 'pnpm' + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + if: ${{ github.ref_name == 'main' }} + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - uses: actions/cache/restore@v4 + if: ${{ github.ref_name != 'main' }} + with: + path: ${{ env.STORE_PATH }} + key: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + shell: bash + run: pnpm install --frozen-lockfile diff --git a/.github/commit-convention.md b/.github/commit-convention.md new file mode 100644 index 0000000..a1a969e --- /dev/null +++ b/.github/commit-convention.md @@ -0,0 +1,89 @@ +## Git Commit Message Convention + +> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular). + +#### TL;DR: + +Messages must be matched by the following regex: + +```js +/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|types|wip): .{1,50}/; +``` + +#### Examples + +Appears under "Features" header, `dev` subheader: + +``` +feat(dev): add 'comments' option +``` + +Appears under "Bug Fixes" header, `dev` subheader, with a link to issue #28: + +``` +fix(dev): fix dev error + +close #28 +``` + +Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation: + +``` +perf(build): remove 'foo' option + +BREAKING CHANGE: The 'foo' option has been removed. +``` + +The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header. + +``` +revert: feat(compiler): add 'comments' option + +This reverts commit 667ecc1654a317a13331b17617d973392f415f02. +``` + +### Full Message Format + +A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: + +``` +(): + + + +