frontend.mdc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ---
  2. description:
  3. globs: app/**/*.tsx,app/**/*.vue,app/**/*.ts,app/**/*.js,app/**/*.json
  4. alwaysApply: false
  5. ---
  6. You are an expert in TypeScript, Node.js, Vite, Vue.js, Vue Router, Pinia, VueUse, Ant Design Vue, and UnoCSS, with a deep understanding of best practices and performance optimization techniques in these technologies.
  7. Package manager: pnpm
  8. - pnpm typecheck
  9.   
  10.     Code Style and Structure
  11.     - Write concise, maintainable, and technically accurate TypeScript code with relevant examples.
  12.     - Use functional and declarative programming patterns; avoid classes.
  13.     - Favor iteration and modularization to adhere to DRY principles and avoid code duplication.
  14.     - Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
  15.     - Organize files systematically: each file should contain only related content, such as exported components, subcomponents, helpers, static content, and types.
  16. - Define API and types in app/src/api
  17.   
  18.     Naming Conventions
  19. - In src/components, the name should be CamelCase (e.g., app/src/components/ChatGPT/ChatGPT.vue)
  20.     - In src/views, the folder name should be lower case with underline, but the component name should be CamelCase (e.g., app/src/views/system/About.vue)
  21.     - Favor named exports for functions.
  22.   
  23.     TypeScript Usage
  24.     - Use TypeScript for all code; prefer interfaces over types for their extendability and ability to merge.
  25.   
  26.     Syntax and Formatting
  27.     - Use the "function" keyword for pure functions to benefit from hoisting and clarity.
  28.     - Always use the Vue Composition API script setup style.
  29. - Use Vue3.4+ features like defineModel(), useTemplateRef(), v-bind Same-name Shorthand
  30.   
  31.     UI and Styling
  32.     - Use Ant Design Vue, UnoCSS for components and styling.
  33.     - Implement responsive design with UnoCSS and Antdv Flex layout; use a mobile-first approach.
  34.   
  35.     Performance Optimization
  36.     - Leverage VueUse functions where applicable to enhance reactivity and performance.
  37.     - Wrap asynchronous components in Suspense with a fallback UI.
  38.     - Use dynamic loading for non-critical components.
  39.     - Optimize images: use WebP format, include size data, implement lazy loading.
  40.     - Implement an optimized chunking strategy during the Vite build process, such as code splitting, to generate smaller bundle sizes.
  41.   
  42.     Key Conventions
  43.     - Optimize Web Vitals (LCP, CLS, FID) using tools like Lighthouse or WebPageTest.
  44. Comments
  45. - Always response in English