第一版

This commit is contained in:
Ls
2026-04-16 08:38:54 +08:00
parent c9aeba0949
commit 7dba9711a9
29 changed files with 5832 additions and 2447 deletions

303
AGENTS.md
View File

@@ -1,143 +1,212 @@
# AGENTS.md - Swimming uni-app Project
## Build & Development Commands
## Scope
- This file applies to the entire repository rooted at `D:\Project\游泳\swimming`.
- There are currently no deeper `AGENTS.md` files in subdirectories.
- No `.cursor/rules/`, `.cursorrules`, or `.github/copilot-instructions.md` files exist in this repo.
### Development Servers
## Project Overview
- This is a `uni-app` + Vue 3 + TypeScript project built with Vite.
- Main app source lives under `src/`.
- The app appears to target H5, app, and multiple mini-program platforms.
- Primary UI library is `uview-plus`.
- Charting-related code exists under `src/uni_modules/qiun-data-charts` and `src/uni_modules/lime-echart`.
- Service-layer code is centralized under `src/Service/`.
## Tooling Snapshot
- Package manager: `npm`.
- Bundler/dev server: `vite` via `@dcloudio/vite-plugin-uni`.
- Type checking: `vue-tsc --noEmit`.
- Language level: TypeScript `^4.9.4`.
- Framework: Vue `^3.4.21`.
- No ESLint config is present.
- No Prettier config is present.
- No unit or e2e test runner config is present.
## Install
```bash
npm run dev:h5 # Run H5 development server
npm run dev:mp-weixin # Run WeChat mini-program development
npm run dev:app # Run app development
npm run dev:app-android # Run Android app development
npm run dev:app-ios # Run iOS app development
npm run dev:mp-alipay # Run Alipay mini-program
npm run dev:mp-baidu # Run Baidu mini-program
npm run dev:mp-qq # Run QQ mini-program
npm run dev:mp-toutiao # Run Toutiao mini-program
npm install
```
### Build Commands
## Build And Dev Commands
### Common Development
```bash
npm run build:h5 # Build for H5
npm run build:mp-weixin # Build for WeChat mini-program
npm run build:app # Build for app
npm run build:app-android # Build for Android
npm run build:app-ios # Build for iOS
npm run dev:h5
npm run dev:h5:ssr
npm run dev:app
npm run dev:app-android
npm run dev:app-ios
npm run dev:mp-weixin
npm run dev:mp-alipay
npm run dev:mp-baidu
npm run dev:mp-jd
npm run dev:mp-kuaishou
npm run dev:mp-lark
npm run dev:mp-qq
npm run dev:mp-toutiao
npm run dev:mp-xhs
npm run dev:quickapp-webview
npm run dev:quickapp-webview-huawei
npm run dev:quickapp-webview-union
```
### Type Checking
### Common Build
```bash
npm run type-check # Run TypeScript type checking (vue-tsc --noEmit)
npm run build:h5
npm run build:h5:ssr
npm run build:app
npm run build:app-android
npm run build:app-ios
npm run build:mp-weixin
npm run build:mp-alipay
npm run build:mp-baidu
npm run build:mp-jd
npm run build:mp-kuaishou
npm run build:mp-lark
npm run build:mp-qq
npm run build:mp-toutiao
npm run build:mp-xhs
npm run build:quickapp-webview
npm run build:quickapp-webview-huawei
npm run build:quickapp-webview-union
```
### Testing
- **Note**: No test framework configured in this project yet.
## Code Style Guidelines
### Imports & Path Aliases
- Use `@/` alias for imports from `src/` directory (configured in `tsconfig.json`)
- Example: `import { Service } from '@/Service/Service'`
- Import Vue composition API functions from 'vue'
- Import uni-app lifecycle hooks from `@dcloudio/uni-app`
### File Structure
### Validation
```bash
npm run type-check
```
## Lint And Test Status
- There is no configured lint command in `package.json`.
- There is no ESLint or Prettier configuration in the repository root.
- There is no configured test framework such as Vitest, Jest, Playwright, Cypress, Mocha, or Ava.
- There are no repository test files matching `*.spec.*` or `*.test.*` in app code.
- Because no test runner exists, there is currently no supported command for running a single test.
- For validation, prefer `npm run type-check` and, when relevant, a targeted platform build such as `npm run build:h5`.
## Single-Test Guidance
- Single-test execution is not available in the current repo state.
- If a future test runner is added, update this file with:
- the root test command,
- the single-test command pattern,
- any platform-specific test setup,
- and the location/naming convention for test files.
## Important Paths
- `src/main.ts` bootstraps the app and registers `uview-plus`.
- `src/App.vue` contains global app shell styles and setup.
- `src/pages.json` defines pages and tab bar configuration.
- `src/uni.scss` contains shared uni-app styling variables and theme-level styles.
- `src/Service/` contains application services and shared app behavior.
- `src/common/` contains shared domain models and utilities.
- `src/components/` contains reusable Vue components.
- `src/pages/` contains page-level Vue SFCs.
- `src/uni_modules/` contains vendored or external uni-app modules.
## Source Layout Conventions
```text
src/
├── pages/ # Page components (with sub-packages)
├── components/ # Reusable Vue components
├── Service/ # API services and utilities
├── common/ # Common utilities and helpers
├── static/ # Static assets (images, etc.)
├── types/ # TypeScript type definitions
├── uni_modules/ # Uni-app modules
── colorui/ # ColorUI CSS framework
├── Service/ Service classes and base config
├── common/ Shared utilities and domain models
├── components/ Reusable Vue SFC components
├── pages/ Routed uni-app pages
├── static/ Static assets
├── types/ Type declarations
├── uni_modules/ Third-party or packaged uni modules
── colorui/ ColorUI-related assets/components
├── App.vue Root application component
├── main.ts App bootstrap
├── pages.json Route and tab-bar registration
└── uni.scss Global uni-app SCSS
```
### Naming Conventions
- **Files**: PascalCase for components (e.g., `ImageCropper.vue`), camelCase for utilities
- **Components**: PascalCase for component names
- **Variables**: camelCase for local variables and functions
- **Constants**: UPPER_SNAKE_CASE for constants
- **Classes**: PascalCase for class names (e.g., `Service`)
- **CSS Classes**: kebab-case (e.g., `home-container`, `timer-card`)
## Imports And Module Usage
- Use the `@/` alias for imports rooted in `src/`.
- `tsconfig.json` maps `@/*` to `./src/*`.
- Prefer alias imports for app code instead of long relative paths.
- Import Vue composition helpers from `vue`.
- Import uni-app page lifecycle APIs from `@dcloudio/uni-app` when needed.
- Keep imports grouped with framework imports first, then app services/types, then local modules.
- Existing code sometimes re-exports shared utilities from `src/common/Common.ts`; preserve that pattern where it already exists.
### TypeScript
- Use `lang="ts"` in Vue SFC `<script>` tags
- Use `<script setup>` syntax for Vue 3 composition API
- Type function parameters and return values
- Use `any` sparingly, prefer proper type definitions
- Path alias: `@/*` maps to `./src/*`
## Vue SFC Conventions
- Use Vue 3 `<script setup lang="ts">` for page and component SFCs.
- Keep file sections in the order: `<template>`, `<script setup lang="ts">`, `<style lang="scss" scoped>`.
- Use `scoped` styles for page/component-local styling unless a global rule is required.
- Prefer reactive state via `ref` and `reactive` from Vue.
- Use uni-app page lifecycle hooks such as `onLoad` from `@dcloudio/uni-app`.
- Clean up timers or intervals in `onUnmounted()`.
### Vue Component Structure
```vue
<template>
<!-- Template with tabs for indentation -->
</template>
## TypeScript Guidelines
- Use `lang="ts"` in Vue SFC scripts.
- Add explicit parameter types and return types for exported functions and service methods where practical.
- Prefer concrete interfaces or domain models over `any`.
- Existing code uses `any` in several places; reduce new `any` usage instead of expanding it.
- Keep class names in PascalCase.
- Preserve existing static-service patterns unless there is a strong reason to refactor more broadly.
<script setup lang="ts">
// Imports first
// Composition API logic
// Functions
// Lifecycle hooks
</script>
## Service Layer Patterns
- Base configuration lives in `src/Service/BaseConfig.ts`.
- Shared service helpers live in `src/Service/Service.ts`.
- Feature services under `src/Service/swimming/` usually:
- define endpoint path constants as `private static` fields,
- expose `static` methods,
- delegate network calls to `Service.Request()`,
- and export both the service class and `Service` where existing files already do so.
- `Service.Request()` wraps request handling and normalizes API responses into `ResultData`.
- `ResultData` lives in `src/common/Domain/ResultData.ts`.
<style lang="scss" scoped>
/* SCSS styles with nested structure */
</style>
```
## Error Handling And User Feedback
- Use `Service.Msg()` for toast-style user feedback.
- Use `Service.Alert()` or `Service.Confirm()` for modal interactions.
- Route authenticated API requests through `Service.Request()`.
- Be aware that `Service.Request()` already handles several auth and permission codes such as `401`, `40101`, `1004`, and `40188`.
- When adding new service methods, return the request promise rather than swallowing errors silently.
- Follow existing user-facing Chinese messaging style unless the surrounding screen uses a different language.
### Formatting
- **Indentation**: Use tabs (not spaces) for indentation
- **Quotes**: Single quotes for strings in TypeScript/JavaScript
- **Semicolons**: Optional but consistent (project uses semicolons)
- **Line endings**: CRLF (Windows)
- **SCSS**: Use nested selectors, kebab-case class names
## Naming Conventions
- Vue component filenames: PascalCase, for example `ImageCropper.vue`.
- Utility and service helper filenames: usually camelCase or existing established names; match nearby files.
- Service classes: PascalCase for class names, for example `PlanService`.
- Some existing service class identifiers start lowercase, such as `studentService`; preserve existing public names unless a broader refactor is requested.
- Local variables and functions: camelCase.
- Constants: UPPER_SNAKE_CASE when they are true constants.
- CSS class names: kebab-case.
- Route paths must match entries in `src/pages.json`.
### Error Handling
- Use `Service.Msg()` for toast messages
- Use `Service.Alert()` for modal dialogs
- API requests through `Service.Request()` handle 401 (token expired) automatically
- Return `ResultData` objects from service methods
- Clean up intervals in `onUnmounted()` lifecycle hook
## Formatting Expectations
- Repository convention is tabs for indentation in source files.
- Existing project code mostly uses single quotes in application TypeScript, though some files contain double quotes; prefer the dominant local style in the file you touch.
- Semicolons are used frequently enough that new changes should stay consistent within the edited file.
- Keep line endings as CRLF on Windows-oriented files when possible.
- Use nested SCSS selectors where that is already the local pattern.
- Avoid introducing broad formatting-only diffs.
### UI Components
- Use **uview-plus** as primary UI component library
- Use **ColorUI** for CSS framework and icons
- Component prefix: `u-` for uview-plus components (e.g., `<u-icon>`, `<u-button>`)
## Styling And UI
- Prefer `uview-plus` components where the project already uses them.
- ColorUI assets/components are also present; preserve established usage where relevant.
- Use `rpx` units for responsive uni-app layouts.
- Keep mobile-first layout assumptions.
- Match the visual language already present on the page you are editing rather than redesigning unrelated UI.
### Service Layer Pattern
- Extend `BaseConfig` for service classes
- Use static methods for utility functions
- `Service` class provides:
- API requests: `Service.Request()`
- Navigation: `Service.GoPage()`, `Service.GoPageTab()`, `Service.GoPageBack()`
- Storage: `Service.SetStorageCache()`, `Service.GetStorageCache()`
- Messages: `Service.Msg()`, `Service.Alert()`
- Loading: `Service.LoadIng()`, `Service.LoadClose()`
## Platform And Runtime Notes
- Use `uni.*` APIs for platform-specific behavior.
- Navigation typically goes through `Service.GoPage()`, `Service.GoPageTab()`, `Service.GoPageBack()`, or `Service.GoPageDelse()`.
- App state and auth token access are commonly wrapped by `Service.GetStorageCache()` and related helpers.
- Be careful when changing files inside `src/uni_modules/`; many are third-party modules and should only be edited when necessary.
### uni-app Specifics
- Use `uni.` API for platform-specific operations
- Pages registered in `src/pages.json`
- Tab bar configured in `src/pages.json`
- Use `rpx` units for responsive design
- Global styles in `src/App.vue` and `src/uni.scss`
## Agent Guidance
- Before changing code, inspect nearby files and follow their existing conventions.
- Keep edits focused and minimal; do not refactor unrelated areas opportunistically.
- Do not invent lint or test commands that are not actually configured.
- When describing validation, use real commands from `package.json`.
- If you add a test framework or lint setup later, update this file immediately.
- If you touch vendored `uni_modules`, call that out explicitly in your final summary.
### Git & Commit
- `.gitignore` includes `node_modules/`, `dist/`, `unpackage/`
- Commit messages should be descriptive (in Chinese or English)
### Key Dependencies
- Vue 3.4.21
- TypeScript 4.9.4
- Vite 5.2.8
- uni-app 3.0.0
- uview-plus 3.3.54
- dayjs (date manipulation)
- echarts (charts)
- vue-i18n (internationalization)
### No Existing Rules
- No `.cursor/rules/` or `.cursorrules` found
- No `.github/copilot-instructions.md` found
- No ESLint or Prettier configuration found
- Follow existing code patterns when making changes
## Current Gaps To Remember
- No lint pipeline is configured.
- No automated test pipeline is configured.
- No single-test command exists yet.
- No Cursor or Copilot repository instruction files exist.
- Agents should rely on local code patterns plus this file when making changes.