# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview uni-app (Vue 3) WeChat Miniprogram for **愈心谷 (YuXinGu)**, a mental health and wellness platform. Built with Vite and targets `mp-weixin`. The `UI/` directory is a separate, incomplete React Native experiment — ignore it for miniprogram work. ## Build & Development This project has **no npm scripts** in root `package.json`. It is designed for the HBuilderX IDE: - **Dev build:** HBuilderX runs the uni-app Vite plugin automatically. Output goes to `unpackage/dist/dev/mp-weixin/`. - **Manual build:** `npx vite build` (uses `@dcloudio/vite-plugin-uni` from `vite.config.js`) - **WeChat DevTools:** Open `unpackage/dist/dev/mp-weixin/` to preview and debug. Dependencies are minimal: `unplugin-auto-import`, `sass`, `sass-loader`. ## Architecture ### Routing & Navigation - **Page routing** is defined in `pages.json`, NOT in Vue Router. All 26 routes are listed there. - **Tab bar** (4 tabs): 首页 (`pages/index/index`), 心理咨询 (`pages/consult/consult`), 心理测评 (`pages/test-list/test-list`), 我的 (`pages/personal-center/personal-center`) - **Global style** uses `navigationStyle: "custom"` — every page is responsible for its own navigation bar via the `` component. - New pages must be registered in `pages.json` and use `` for the custom nav bar. ### Auto-Imports `unplugin-auto-import` is configured in `vite.config.js` to auto-import Vue and uni-app APIs (`ref`, `reactive`, `computed`, `onLoad`, etc.) — do NOT manually import these in `.vue` files. ### HTTP Request Layer (`util/`) - **`util/requestConfig.js`** exports a pre-configured `$http` instance (base URL: `https://miniapp.yuxingu.com.cn`). Always use this for API calls. - **`util/apiUrl.js`** exports all API endpoint paths as a `urls` object. All miniprogram endpoints are prefixed `/app-api/psychic/`. - **Auth:** The request interceptor reads `token` from `uni.getStorageSync('token')` and attaches it as `Authorization: Bearer `. - **Error handling:** 401/1001/1100 response codes trigger token removal and storage cleanup in `dataFactory`. Other errors auto-display toast messages when `isPrompt` is true. - **Loading states:** Requests with `load: true` show/hide `uni.showLoading` via a request counter. Usage pattern in pages: ```js import $http from '@/util/requestConfig.js' import { urls } from '@/util/apiUrl.js' const res = await $http.get(urls.getDoctorInfo, { id: doctorId }) ``` ### Shared Components (`components/`) - **`my-nav.vue`** — Custom navigation bar; used on every page since `navigationStyle: "custom"`. - **`ShareMixin.ts`** — TypeScript mixin providing `onShareAppMessage` and `onShareTimeline` hooks. - **`show-pop/`** — Reusable popup dialog. - **`show-remind/`** — Reusable reminder/toast. ### Key Patterns - **Fonts:** Three custom fonts are loaded globally in `App.vue` from CDN: `SourceHanSans`, `SourceHanSansBold`, `GenYoMinJP`. The default body font is `SourceHanSans`. - **Share menu:** Enabled globally in `App.vue` for both `shareAppMessage` and `shareTimeline`. - **Assets:** Static images are organized by feature in `static/`. Tab bar icons use the `n-menu/` subdirectory. - **Platform config:** `manifest.json` contains WeChat appid (`wx6782dd88e655f1a7`) and per-platform settings for mp-weixin, mp-alipay, mp-baidu, mp-toutiao. - **uni_modules/:** Standard uni-app plugins (uni-icons, uni-popup, etc.) — treat these as third-party code.