fix: 更新代码注释规范,强调注释应解释复杂逻辑而非重复代码
This commit is contained in:
7
.github/copilot-instructions.md
vendored
7
.github/copilot-instructions.md
vendored
@ -11,7 +11,7 @@ This document outlines the core technical choices, coding conventions, and confi
|
||||
1. `<script setup lang="ts">` (Imports, logic, composables, etc.)
|
||||
2. `<template>` (HTML structure)
|
||||
3. `<style>` (Preferably `<style scoped>`)
|
||||
* **Code Comments:** All comments within the codebase **must be written in Chinese**. (代码中的所有注释**必须使用中文**。)
|
||||
* **Code Comments:** All comments within the codebase **must be written in Chinese**. (代码中的所有注释**必须使用中文**。) **注释应解释代码的“为什么”或复杂逻辑,而不是解释“是什么”或重复代码/配置本身。**
|
||||
|
||||
## 📦 UI Libraries & Components
|
||||
|
||||
@ -21,6 +21,7 @@ This document outlines the core technical choices, coding conventions, and confi
|
||||
* **PrimeVue:** Use components directly with their standard names (e.g., `<Button>`, `<InputText>`, `<DataTable>`).
|
||||
* **Custom Components:** Local components (e.g., `<MyCustomComponent />` defined in `src/components/MyCustomComponent.vue`) should be used directly in templates without explicit imports in `<script setup>`.
|
||||
* **Custom Icons:** Custom SVG icons are available via `unplugin-icons` with the prefix `icon-`. Usage: `<icon-your-svg-file-name />`.
|
||||
* **No Auto-Import Comments for Components:** When using auto-imported components (UI libraries, local components), **do not** add comments indicating they are auto-imported. Assume this behavior is known.
|
||||
|
||||
## ✨ API Auto-Import (unplugin-auto-import)
|
||||
|
||||
@ -34,14 +35,16 @@ This document outlines the core technical choices, coding conventions, and confi
|
||||
* **Auto-Imported Directories:** All exports from files within `src/stores/**` and `src/utils/**` are also auto-imported globally. Functions, variables, or stores defined and exported in these directories can be used directly without explicit import statements.
|
||||
* **Template Usage:** Auto-import functionality also applies within the `<template>` block where appropriate (e.g., accessing store state or using certain utility functions directly).
|
||||
* **Important:** Rely on the auto-import mechanism for the specified libraries and directories. Explicitly importing these APIs clutters the code unnecessarily.
|
||||
* **No Auto-Import Explanation Comments:** When using auto-imported APIs (from libraries like Vue, Pinia, VueUse, or custom directories like `src/utils`, `src/stores`), simply use them directly. **Absolutely avoid adding comments that merely state an item is auto-imported** (e.g., DO NOT add comments like "// xxx is auto-imported from src/utils"). Focus comments on explaining complex logic or intent.
|
||||
|
||||
## ✅ Summary of Key Rules & Conventions
|
||||
|
||||
* **Always** use `<script setup lang="ts">`.
|
||||
* Composition API is the **only** accepted style.
|
||||
* Code comments **must be in Chinese**.
|
||||
* Code comments **must be in Chinese** and explain **why/how**, not what or the build system.
|
||||
* Vue 3 Composition API, Pinia, Vue Router (auto), VueUse functions, `consola`, and exports from `src/stores` & `src/utils` are globally available via auto-import; **do not** import them explicitly.
|
||||
* Ant Design Vue, PrimeVue, and local `src/components` components are auto-imported; use them directly in templates without explicit imports.
|
||||
* **Crucially: Do not add comments solely to explain that an API or component is auto-imported.** Trust the auto-import setup.
|
||||
* Use custom SVG icons via the `<icon-name />` syntax.
|
||||
* Maintain the specified SFC structure: `<script setup>`, `<template>`, `<style>`.
|
||||
|
||||
|
Reference in New Issue
Block a user