alwaysApply: true
Trae AI Coding Rules for Book-Hi
1. Project Context & Technology Stack
- Framework: uni-app + Vue 2
- UI Library: uView UI v1 (Prefix:
u-, no import needed for easycom components)
- CSS: SCSS with
scoped, use rpx for responsiveness.
- State Management: Vuex (
store/)
- Environment:
.env.js manages apiUrl.
2. Architecture & Directory Structure
- Main Package:
pages/ (Tabbar pages only: home, mine, sell, cart).
- Subpackages:
pages-sell: Mall/Selling features.
pages-car: Shopping cart & Order flow.
pages-mine: User center sub-pages.
pages-home: Home sub-pages.
- Static Assets:
- Global:
static/
- Subpackage-specific:
pages-xxx/static/
3. Development Guidelines
3.1 API Integration (Strict)
- Configuration:
api/config.js (Interceptor handles token & errors).
- Definition:
- Location:
api/modules/*.js (e.g., mall.js, user.js).
- Naming: Suffix with
Ajax (e.g., getGoodsListAjax).
- Format:
(params) => uni.$u.http.post('/path', params)
- Usage:
- Standard:
this.$u.api.methodName(params).then(res => ...)
- Direct:
uni.$u.http.post('/path', params).then(res => ...) (Allowed for simple/temp requests)
- Response Handling:
- Success:
res.code == 200
- Error: Handled globally by interceptor (Toast),
401 triggers silent login.
3.2 Component Development
- Global:
components/ (Register in main.js if generic).
- Local/Business:
pages-xxx/components/ (Import locally).
- uView Usage: Use
u- components directly (e.g., <u-button>, <u-cell-item>).
3.3 Routing
- Jump:
uni.navigateTo for subpages, uni.switchTab for tabbar.
- Path: ALWAYS use absolute paths (e.g.,
/pages-sell/pages/detail).
3.4 Styling
- Scoped:
<style lang="scss" scoped>
- Units:
rpx
- Colors: Use variables from
theme.scss if available, or project standard colors (Primary: #38C148 or similar based on pages.json).
4. Code Generation Instructions
- When creating pages: Check
pages.json subpackage structure first.
- When adding features:
- Define API in
api/modules/.
- Create/Update Component or Page.
- Ensure styles are scoped and responsive.
- Refactoring: Prefer uView components over native HTML tags for consistency.