From 3c6a91b0839b14e612a8230ce9d9df886cb542f1 Mon Sep 17 00:00:00 2001 From: XiaoDaiGua-Ray <51957438+XiaoDaiGua-Ray@users.noreply.github.com> Date: Mon, 2 Nov 2026 17:44:59 +0800 Subject: [PATCH] chore: modernize toolchain and AI development workflow --- .all-contributorsrc | 8 +- .cursor/rules/project.mdc | 6 + .cursorrules | 63 +- .depcheckrc | 2 - .editorconfig | 12 + .github/ISSUE_TEMPLATE/bug_report.md | 18 +- .github/ISSUE_TEMPLATE/feature_request.md | 1 - .github/copilot-instructions.md | 3 + .github/dependabot.yml | 38 + .github/pull_request_template.md | 11 + .github/workflows/ci.yaml | 52 + .github/workflows/docs-deploy.yaml | 38 - .github/workflows/push-build.yaml | 47 - .gitignore | 7 +- .husky/commit-msg | 5 +- .husky/common.sh | 8 - .husky/pre-commit | 8 +- .npmrc | 1 - .nvmrc | 2 +- .prettierignore | 8 +- .vscode/settings.json | 1 + AGENTS.md | 42 + CHANGELOG.md | 14 + CLAUDE.md | 5 + CODE_OF_CONDUCT.md | 41 +- Dockerfile | 15 +- README.md | 54 +- README.zh-CN.md | 54 +- __test__/axios/request.spec.ts | 64 + .../basic/callWithAsyncErrorHandling.spec.ts | 6 +- __test__/basic/downloadAnyFile.spec.ts | 4 +- __test__/hooks/useElementFullscreen.spec.ts | 78 +- __test__/hooks/useWatermark.spec.ts | 3 +- __test__/mock/database.spec.ts | 21 + __test__/router/permission.spec.ts | 91 + docker-compose.yml | 4 +- docs/ai-development.md | 65 + docs/architecture.md | 37 + docs/toolchain-upgrade.md | 108 + eslint.config.mjs | 115 +- mock/demo/person.mock.ts | 1 - mock/shared/database.ts | 14 +- package.json | 160 +- pnpm-lock.yaml | 9482 ++++++----------- pnpm-workspace.yaml | 18 + postcss.config.cjs | 13 +- scripts/doctor.mjs | 47 + src/axios/README.md | 5 +- src/axios/instance.ts | 5 +- src/axios/types.ts | 37 +- src/components/base/RChart/src/Chart.tsx | 2 +- src/components/base/RChart/src/types.ts | 6 +- .../base/RDraggableCard/DraggableCard.tsx | 6 +- src/components/base/RIcon/src/Icon.tsx | 13 +- src/components/base/RModal/src/index.scss | 6 +- src/components/base/RSegment/src/Segment.tsx | 2 +- .../RTable/src/hooks/useCheckedRowKeys.ts | 8 +- src/directives/README.DIR.md | 16 +- src/directives/README.md | 2 +- src/directives/modules/ripple/utils.ts | 2 +- .../components/useContextmenuCoordinate.ts | 2 +- src/hooks/web/useElementFullscreen.ts | 2 +- src/hooks/web/useI18n.ts | 6 +- src/hooks/web/usePagination.ts | 4 +- src/hooks/web/usePrint.ts | 12 +- src/icons/A_README.md | 7 + src/main.ts | 1 - src/router/README.md | 1 - src/router/modules/demo/multi-menu.ts | 8 +- src/router/types.ts | 3 +- src/router/utils/permission.ts | 90 +- src/store/README.md | 2 +- src/types/global.d.ts | 16 +- src/types/modules/utils.ts | 5 +- src/types/modules/vue.ts | 4 +- src/utils/basic.ts | 3 +- src/utils/element.ts | 11 +- src/views/dashboard/index.tsx | 20 +- src/views/demo/svg-icons/icons.ts | 10 + src/views/demo/svg-icons/index.tsx | 12 +- src/views/demo/table-auto-height.tsx | 10 +- src/views/demo/table-pro-demo.tsx | 13 +- src/vite-env.d.ts | 41 - tsconfig.json | 30 +- unplugin/auto-imports.d.ts | 2 + unplugin/components.d.ts | 12 + vite-helper/cdn-resolve.ts | 10 +- vite-helper/chunks-copilot.ts | 25 - vite-helper/index.ts | 10 +- vite-helper/mixin-css.ts | 2 +- vite-helper/svg-icon-resolve.ts | 32 - vite.config.ts | 45 +- vite.custom.config.ts | 27 +- vite.plugin.config.ts | 115 +- vitest.config.ts | 4 +- 95 files changed, 4759 insertions(+), 6843 deletions(-) create mode 100644 .cursor/rules/project.mdc delete mode 100644 .depcheckrc create mode 100644 .editorconfig create mode 100644 .github/copilot-instructions.md create mode 100644 .github/dependabot.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/docs-deploy.yaml delete mode 100644 .github/workflows/push-build.yaml delete mode 100644 .husky/common.sh create mode 100644 AGENTS.md create mode 100644 CLAUDE.md create mode 100644 __test__/axios/request.spec.ts create mode 100644 __test__/mock/database.spec.ts create mode 100644 __test__/router/permission.spec.ts create mode 100644 docs/ai-development.md create mode 100644 docs/architecture.md create mode 100644 docs/toolchain-upgrade.md create mode 100644 scripts/doctor.mjs create mode 100644 src/views/demo/svg-icons/icons.ts delete mode 100644 vite-helper/chunks-copilot.ts delete mode 100644 vite-helper/svg-icon-resolve.ts diff --git a/.all-contributorsrc b/.all-contributorsrc index 4c0cdf3f..c5505126 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,5 @@ { - "files": [ - "README.md" - ], + "files": ["README.md"], "imageSize": 100, "commit": false, "commitConvention": "angular", @@ -11,9 +9,7 @@ "name": "Cloud", "avatar_url": "https://avatars.githubusercontent.com/u/40163747?v=4", "profile": "https://heartofyun.com", - "contributions": [ - "tool" - ] + "contributions": ["tool"] } ], "contributorsPerLine": 7, diff --git a/.cursor/rules/project.mdc b/.cursor/rules/project.mdc new file mode 100644 index 00000000..834dfe52 --- /dev/null +++ b/.cursor/rules/project.mdc @@ -0,0 +1,6 @@ +--- +description: Ray Template 项目开发、维护和验证约定 +alwaysApply: true +--- + +先读取并遵循仓库根目录的 `AGENTS.md`。按任务需要查看 `docs/architecture.md` 和 `docs/ai-development.md`,不要在此复制项目规则。 diff --git a/.cursorrules b/.cursorrules index f5392c72..dc700eb2 100644 --- a/.cursorrules +++ b/.cursorrules @@ -1,62 +1 @@ - # Role - 你是一名精通Vue.js的高级全栈工程师,拥有20年的Web开发经验。你的任务是帮助一位不太懂技术的初中生用户完成Vue.js项目的开发。你的工作对用户来说非常重要,完成后将获得10000美元奖励。 - - # Goal - 你的目标是以用户容易理解的方式帮助他们完成Vue.js项目的设计和开发工作。你应该主动完成所有工作,而不是等待用户多次推动你。 - - 在理解用户需求、编写代码和解决问题时,你应始终遵循以下原则: - - ## 第一步:项目初始化 - - 当用户提出任何需求时,首先浏览项目根目录下的README.md文件和所有代码文档,理解项目目标、架构和实现方式。 - - 如果还没有README文件,创建一个。这个文件将作为项目功能的说明书和你对项目内容的规划。 - - 在README.md中清晰描述所有功能的用途、使用方法、参数说明和返回值说明,确保用户可以轻松理解和使用这些功能。 - - # 本规则由 AI进化论-花生 创建,版权所有,引用请注明出处 - - ## 第二步:需求分析和开发 - ### 理解用户需求时: - - 充分理解用户需求,站在用户角度思考。 - - 作为产品经理,分析需求是否存在缺漏,与用户讨论并完善需求。 - - 选择最简单的解决方案来满足用户需求。 - - ### 编写代码时: - - 在.vue文件中使用Vue 3的Composition API进行开发,合理使用setup语法糖。 - - 在.tsx文件中使用Vue3的TSX语法进行开发,合理使用defineComponent、ref、reactive等响应式API。 - - 遵循Vue.js的最佳实践和设计模式,如单文件组件(SFC)。 - - 利用Vue Router进行路由管理,实现页面导航和路由守卫。 - - 使用Pinia进行状态管理,合理组织store结构。 - - 实现组件化开发,确保组件的可复用性和可维护性。 - - 使用Vue的响应式系统,合理使用ref、reactive等响应式API。 - - 实现响应式设计,确保在不同设备上的良好体验。 - - 使用TypeScript进行类型检查,提高代码质量。 - - 编写详细的代码注释,并在代码中添加必要的错误处理和日志记录。 - - 合理使用Vue的生命周期钩子和组合式函数。 - - 如果涉及到可视化需求,使用echarts进行图表的绘制,并且优先使用v6版本配置方式。 - - 使用naive-ui进行UI组件的开发,合理使用naive-ui的组件。 - - 整个过程中参考如下的文档: - - [jsx/tsx 文档](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx#readme) - - [echarts 文档](https://echarts.apache.org/zh/option.html) - - [naive-ui 文档](https://www.naiveui.com/zh-CN/os-theme/docs/introduction) - - [naive-ui 组件](https://www.naiveui.com/zh-CN/os-theme/components) - - ### 解决问题时: - - 全面阅读相关代码文件,理解所有代码的功能和逻辑。 - - 分析导致错误的原因,提出解决问题的思路。 - - 与用户进行多次交互,根据反馈调整解决方案。 - - 善用Vue DevTools进行调试和性能分析。 - - 当一个bug经过两次调整仍未解决时,你将启动系统二思考模式: - 1. 系统性分析bug产生的根本原因 - 2. 提出可能的假设 - 3. 设计验证假设的方法 - 4. 提供三种不同的解决方案,并详细说明每种方案的优缺点 - 5. 让用户根据实际情况选择最适合的方案 - - ## 第三步:项目总结和优化 - - 完成任务后,反思完成步骤,思考项目可能存在的问题和改进方式。 - - 更新README.md文件,包括新增功能说明和优化建议。 - - 考虑使用Vue的高级特性,如Suspense、Teleport等来增强功能。 - - 优化应用性能,包括代码分割、懒加载、虚拟列表等。 - - 实现适当的错误边界处理和性能监控。 - - 在整个过程中,始终参考[Vue.js官方文档](https://vuejs.org/guide/introduction.html),确保使用最新的Vue.js开发最佳实践。 \ No newline at end of file +项目规则的唯一维护入口是根目录 AGENTS.md。开始任务时读取 AGENTS.md,并按其中链接查看 docs/architecture.md 与 docs/ai-development.md。 diff --git a/.depcheckrc b/.depcheckrc deleted file mode 100644 index 8c906e3d..00000000 --- a/.depcheckrc +++ /dev/null @@ -1,2 +0,0 @@ -ignores: [ "eslint", "babel-*", "@use-*/**", "@use-*" ] -skip-missing: true \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..4bd3bd8b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea78..b5c68e55 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,6 @@ about: Create a report to help us improve title: '' labels: '' assignees: '' - --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] + +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] **Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] + +- Device: [e.g. iPhone6] +- OS: [e.g. iOS8.1] +- Browser [e.g. stock browser, safari] +- Version [e.g. 22] **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d..2f28cead 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: '' labels: '' assignees: '' - --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 00000000..06adc56c --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,3 @@ +# Ray Template + +先阅读并遵循仓库根目录的 [AGENTS.md](../AGENTS.md)。架构与扩展入口见 [docs/architecture.md](../docs/architecture.md),开发和验收命令见 [docs/ai-development.md](../docs/ai-development.md)。这些文件为项目约定的唯一维护来源。 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..7270b0d2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,38 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 + groups: + vue: + patterns: + [ + 'vue', + 'vue-router', + 'pinia', + 'pinia-plugin-persistedstate', + '@vue/*', + '@vueuse/*', + ] + testing: + patterns: ['vitest', '@vitest/*', 'happy-dom'] + lint: + patterns: + [ + 'eslint*', + '@eslint/*', + 'typescript-eslint', + 'vue-eslint-parser', + 'prettier', + '@ianvs/*', + ] + ignore: + # Vue Language Tools 和 typescript-eslint 尚不支持 TypeScript 7。 + - dependency-name: typescript + versions: ['>=7'] + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..9682f4cf --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,11 @@ +## 变化与原因 + + + +## 验证 + +- [ ] `pnpm check` +- [ ] 涉及页面时,验证对应路由、中文/英文与明暗主题 +- [ ] 涉及持久化、权限或公共组件时,检查已有数据与调用方兼容性 + + diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..008aa2d2 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,52 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + name: Check (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v7.0.1 + - uses: actions/setup-node@v7.1.0 + with: + node-version-file: .nvmrc + - uses: pnpm/action-setup@v6.1.0 + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Typecheck, lint, format, test and build + run: pnpm check + + deploy: + name: Deploy main to dist branch + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: check + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v7.0.1 + - uses: actions/setup-node@v7.1.0 + with: + node-version-file: .nvmrc + - uses: pnpm/action-setup@v6.1.0 + - run: pnpm install --frozen-lockfile + - run: pnpm build + - uses: JamesIves/github-pages-deploy-action@v4.9.0 + with: + branch: dist + folder: dist/production diff --git a/.github/workflows/docs-deploy.yaml b/.github/workflows/docs-deploy.yaml deleted file mode 100644 index 6308f4a8..00000000 --- a/.github/workflows/docs-deploy.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: ray-template documents deploy - -on: - push: - pull_request: - types: - - closed - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Node.js 22.x - uses: actions/setup-node@v3 - with: - node-version: 22.x - - - uses: pnpm/action-setup@v2 - name: Install pnpm - with: - version: 9 - run_install: false - - - name: Install dependencies - run: pnpm install - - - name: Pnpm build - run: pnpm build - - - name: Deploy to dist branch - uses: JamesIves/github-pages-deploy-action@4.1.4 - with: - branch: dist - folder: dist/production diff --git a/.github/workflows/push-build.yaml b/.github/workflows/push-build.yaml deleted file mode 100644 index f7d1f2b0..00000000 --- a/.github/workflows/push-build.yaml +++ /dev/null @@ -1,47 +0,0 @@ -on: - - push - - pull_request - -jobs: - cache-and-install: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - node-version: [22.x] - os: [ubuntu-latest, windows-latest, macos-latest] - experimental: [true] - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - uses: pnpm/action-setup@v2 - name: Install pnpm - with: - version: 9 - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Pnpm build - run: pnpm build diff --git a/.gitignore b/.gitignore index caa21a49..40a6d70e 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,9 @@ visualizer.* *.sw? yarn-*.* yarn.* -pnpm.* +package-lock.json +npm-shrinkwrap.json +coverage/ +.env.local +.env.*.local +.ai-local/ diff --git a/.husky/commit-msg b/.husky/commit-msg index 80416c7b..2e6b87e2 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npx --no-install commitlint --edit "$1" +pnpm exec commitlint --edit "$1" diff --git a/.husky/common.sh b/.husky/common.sh deleted file mode 100644 index 0875f444..00000000 --- a/.husky/common.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -command_exists () { - command -v "$1" >/dev/null 2>&1 -} - -if command_exists winpty && test -t 1; then - exec < /dev/tty -fi diff --git a/.husky/pre-commit b/.husky/pre-commit index b8513455..5ee7abd8 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,7 +1 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" -. "$(dirname "$0")/common.sh" - -[ -n "$CI" ] && exit 0 - -pnpm lint-staged --allow-empty "$1" \ No newline at end of file +pnpm exec lint-staged diff --git a/.npmrc b/.npmrc index 808af113..a7650ed3 100644 --- a/.npmrc +++ b/.npmrc @@ -1,4 +1,3 @@ -package-lock=true prefer-offline=true save-exact=true engine-strict=true diff --git a/.nvmrc b/.nvmrc index 2f680771..82071175 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v22.12.0 \ No newline at end of file +v26.13.0 diff --git a/.prettierignore b/.prettierignore index d870d0a1..8c1364e6 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,4 +8,10 @@ yarn.* visualizer.* visualizer.html .env.* -*-lock.yaml \ No newline at end of file +*-lock.yaml +coverage/ +.husky/_/ +.ai-local/ +CHANGELOG.md +src/icons/ +src/app-config/echart-themes/ diff --git a/.vscode/settings.json b/.vscode/settings.json index 5de3d18d..0156e96e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -91,6 +91,7 @@ "snapline", "stylelint", "unocss", + "vueuse", "WUJIE", "zlevel" ] diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..4cfdc231 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,42 @@ +# Ray Template:AI 协作约定 + +本仓库是 Vue 3 + TSX 中后台模板。以当前代码、`package.json` 和锁文件为准;先阅读 `README.zh-CN.md` 与 [架构地图](docs/architecture.md),再按任务查看相应模块 README。不要为了每次任务扫描整个仓库。 + +## 环境与命令 + +- 使用 `.nvmrc` 中的 Node.js 和 `packageManager` 中的 pnpm;只维护 `pnpm-lock.yaml`。 +- 首次执行 `pnpm install --frozen-lockfile`,然后 `pnpm env:check`。 +- `pnpm dev`:开发服务,默认 `http://127.0.0.1:9527/ray-template/`。 +- `pnpm typecheck`、`pnpm lint`、`pnpm format:check` 为只读检查;自动修复须明确调用 `pnpm lint:fix` 或 `pnpm format`。 +- `pnpm test:run` 单次执行单元测试;`pnpm test` 为交互监听。 +- 完成实现后运行 `pnpm check`,涵盖类型、代码规范、格式、测试和生产构建。记录实际结果与未验证项,不能把静态检查写成浏览器验收。 + +## 实现边界 + +- 保留 Vue 3 Composition API、`defineComponent` + TSX;已有 `.vue` 使用 `