docs: 更新项目文档,增加AI辅助开发指南和通用指令,明确代码风格、组件架构、状态管理、API交互及测试要求
This commit is contained in:
parent
c03df200ab
commit
77e71fb489
@ -10,9 +10,6 @@
|
|||||||
"Bash(npx react-native start --reset-cache)",
|
"Bash(npx react-native start --reset-cache)",
|
||||||
"Bash(npm run lint)"
|
"Bash(npm run lint)"
|
||||||
],
|
],
|
||||||
"deny": [
|
"deny": ["WebSearch"]
|
||||||
"WebSearch"
|
|
||||||
],
|
|
||||||
"defaultMode": "bypassPermissions"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
gemini.md
40
gemini.md
@ -2,15 +2,33 @@
|
|||||||
|
|
||||||
This is a React Native application built with TypeScript.
|
This is a React Native application built with TypeScript.
|
||||||
|
|
||||||
## Project Structure
|
## General Instructions
|
||||||
|
|
||||||
- `src/`: Contains the main source code for the application.
|
- Always use Chinese to answer.
|
||||||
- `components/`: Reusable React components.
|
- Check for potential errors in the user's prompt and try to fix them.
|
||||||
- `context/`: React context for state management.
|
- If the proposed changes are significant or alter the core logic, ask the user for confirmation before proceeding. Otherwise, you can make the changes directly.
|
||||||
- `hooks/`: Custom React hooks.
|
|
||||||
- `navigation/`: Navigation logic using React Navigation.
|
## AI-Assisted Development Guidelines
|
||||||
- `screens/`: Application screens.
|
|
||||||
- `services/`: Services for API calls and other business logic.
|
### 1. Code Style & Conventions
|
||||||
- `types/`: TypeScript type definitions.
|
- **Adherence:** Strictly follow the existing code style, formatting (Prettier), and linting rules (ESLint) of the project.
|
||||||
- `android/`: Android specific code.
|
- **Consistency:** When adding new features, first analyze the surrounding code to ensure new code matches the existing patterns in terms of naming, structure, and architecture.
|
||||||
- `ios/`: iOS specific code.
|
|
||||||
|
### 2. Component-Based Architecture
|
||||||
|
- **Modularity:** Prioritize creating modular, reusable, and single-purpose components. Place all reusable components in the `src/components/` directory.
|
||||||
|
- **Props:** Define explicit TypeScript interfaces for all component props in the `src/types/` directory or co-located with the component file.
|
||||||
|
|
||||||
|
### 3. State Management
|
||||||
|
- **React Context:** For global or shared state, utilize the existing React Context API structure located in `src/context/`.
|
||||||
|
- **Local State:** For component-specific state that doesn't need to be shared, use the `useState` and `useReducer` hooks.
|
||||||
|
|
||||||
|
### 4. API & Data Fetching
|
||||||
|
- **Service Layer:** All interactions with external APIs must be encapsulated within the service layer (`src/services/`). Do not make direct API calls (e.g., using `fetch` or `axios`) from within UI components.
|
||||||
|
- **Type Safety:** Define clear TypeScript types for all API request payloads and responses in the `src/types/` directory.
|
||||||
|
|
||||||
|
### 5. Navigation
|
||||||
|
- **Centralized Logic:** All screen navigation logic should be managed within the `src/navigation/` directory, using the established React Navigation setup.
|
||||||
|
|
||||||
|
### 6. Testing
|
||||||
|
- **Unit Tests:** When creating new components or services, please also create corresponding unit tests in the `__tests__` directory.
|
||||||
|
- **Existing Tests:** When modifying existing code, ensure all related tests are updated and continue to pass.
|
Loading…
x
Reference in New Issue
Block a user