corp-mp/AGENTS.md

54 lines
3.3 KiB
Markdown

# AGENTS.md
This file provides guidance to Codex (Codex.ai/code) when working with code in this repository.
`corp-mp` is a **Taro 4.2** cross-platform app (React 18 + TypeScript + SCSS, compiled with **Vite**). The primary target is the WeChat mini-program (`weapp`); Taro also compiles it to H5, Alipay, Swan, TT, QQ, JD, RN, and Harmony.
## Commands
Package manager is **pnpm** (a `pnpm-lock.yaml` is committed).
```bash
pnpm install # install deps
pnpm dev:weapp # WeChat mini-program dev build with --watch → ./dist
pnpm build:weapp # production mini-program build → ./dist
pnpm dev:h5 / build:h5 # H5 target
```
Other targets follow `pnpm dev:<platform>` / `pnpm build:<platform>` (`alipay`, `swan`, `tt`, `qq`, `jd`, `rn`, `harmony-hybrid`).
**Running the mini-program:** builds output to `./dist`. Open `./dist` in WeChat DevTools (`project.config.json` already points `miniprogramRoot` there; appId `wxf8a8961f30396c19`).
**Tests:** `pnpm test` runs Vitest. There is no lint script; ESLint (`taro/react`) and Stylelint run manually. The Husky `commit-msg` hook runs **commitlint** (Conventional Commits).
## Architecture
Native A5 mini-program for map-label progress query. Pages in `src/app.config.ts`:
- `pages/index/index`: A5 progress query, order details and customer service. Accepts `phone`, `link_id` / `linkId`, or `/h/<id>` in `scene`.
- `pages/resubmit/index`: A5 business information and document uploads.
- `pages/complaint/index`: A5 order complaints.
- `pages/map/index`: native map selection returning GCJ-02 `lng,lat`.
- `pages/agreement/index`: service and privacy agreements.
### Request and configuration
- A5 client and draft storage: `src/lib/a5/api.ts`; data adapters: `src/lib/a5/data.ts`.
- `TARO_APP_API_A5`: development `https://ag-test.batiao8.com`, production `https://ag.batiao8.com`.
- `TARO_APP_TIANDITU_KEY`: reverse geocoding against `api.tianditu.gov.cn`.
- Orders use `GET/PUT /h5/order`, configuration uses `GET /h5/link`, files use `/h5/file`.
- No corp token bootstrap, x-host, default launch scheme, signing/decryption or presigned Qiniu upload.
- Only A5 business behavior is supported. The former `pages/a5/*` routes are removed; external entries must use `pages/index/index`.
- See `docs/a5-integration.md` for API details, legal domains and the existing complaint HTTP 404 fallback.
Do not reintroduce a business H5 WebView unless explicitly requested.
## Conventions
- **Page = folder** under `src/pages/<name>/` with `index.tsx` + `index.scss` + `index.config.ts`. New pages **must** be added to the `pages` array in `src/app.config.ts` or they won't route.
- **Lifecycle:** use Taro hooks — `useLoad` for page init (reads route params via `Taro.getCurrentInstance().router?.params`), `useLaunch` for app init — not bare `useEffect`.
- **Native API calls must be env-guarded:** wrap `weapp`-only APIs (e.g. `Taro.requestPayment`) in `if (Taro.getEnv() === Taro.ENV_TYPE.WEAPP)` with a fallback branch for other targets.
- **Styling:** SCSS with BEM (`block__element--modifier`); CSS Modules are disabled. Design width is `750`, so author dimensions in `px` — Taro converts to `rpx`/`rem` at compile time.
- **Imports:** `@/*` is aliased to `src/*` (see `tsconfig.json`).
- `strictNullChecks`, `noUnusedLocals`, and `noUnusedParameters` are on; `noImplicitAny` is off.