frontend.mdc 2.5 KB

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