去掉协会 WebView 和魔方账密页,微信登录与咨询接口共用同一 token 和拦截器。 Co-authored-by: Cursor <cursoragent@cursor.com>
3.5 KiB
3.5 KiB
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-unifromvite.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<my-nav>component. - New pages must be registered in
pages.jsonand use<my-nav>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.jsexports a pre-configured$httpinstance (base URL:https://miniapp.yuxingu.com.cn). Always use this for API calls.util/apiUrl.jsexports all API endpoint paths as aurlsobject. All miniprogram endpoints are prefixed/app-api/psychic/.- Auth: The request interceptor reads
tokenfromuni.getStorageSync('token')and attaches it asAuthorization: Bearer <token>. - Error handling: 401/1001/1100 response codes trigger token removal and storage cleanup in
dataFactory. Other errors auto-display toast messages whenisPromptis true. - Loading states: Requests with
load: trueshow/hideuni.showLoadingvia a request counter.
Usage pattern in pages:
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 sincenavigationStyle: "custom".ShareMixin.ts— TypeScript mixin providingonShareAppMessageandonShareTimelinehooks.show-pop/— Reusable popup dialog.show-remind/— Reusable reminder/toast.
Key Patterns
- Fonts: Three custom fonts are loaded globally in
App.vuefrom CDN:SourceHanSans,SourceHanSansBold,GenYoMinJP. The default body font isSourceHanSans. - Share menu: Enabled globally in
App.vuefor bothshareAppMessageandshareTimeline. - Assets: Static images are organized by feature in
static/. Tab bar icons use then-menu/subdirectory. - Platform config:
manifest.jsoncontains 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.