3.3 KiB
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).
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. Acceptsphone,link_id/linkId, or/h/<id>inscene.pages/resubmit/index: A5 business information and document uploads.pages/complaint/index: A5 order complaints.pages/map/index: native map selection returning GCJ-02lng,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: developmenthttps://ag-test.batiao8.com, productionhttps://ag.batiao8.com.TARO_APP_TIANDITU_KEY: reverse geocoding againstapi.tianditu.gov.cn.- Orders use
GET/PUT /h5/order, configuration usesGET /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 usepages/index/index. - See
docs/a5-integration.mdfor 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>/withindex.tsx+index.scss+index.config.ts. New pages must be added to thepagesarray insrc/app.config.tsor they won't route. - Lifecycle: use Taro hooks —
useLoadfor page init (reads route params viaTaro.getCurrentInstance().router?.params),useLaunchfor app init — not bareuseEffect. - Native API calls must be env-guarded: wrap
weapp-only APIs (e.g.Taro.requestPayment) inif (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 is750, so author dimensions inpx— Taro converts torpx/remat compile time. - Imports:
@/*is aliased tosrc/*(seetsconfig.json). strictNullChecks,noUnusedLocals, andnoUnusedParametersare on;noImplicitAnyis off.