3.5 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).
There is no test runner and no lint script in package.json. ESLint (taro/react) and Stylelint are configured but run manually. The only enforced gate is a Husky commit-msg hook running commitlint (Conventional Commits) — non-conforming commit messages are rejected.
Architecture
Native mini-program for map-label progress query. Pages in src/app.config.ts:
pages/index/index — 进度查询. Accepts H5 jump query token / host / package / scene (see corp-h5 weixinMiniProgram.ts). Queries GET /api/h5/order/phone, resubmits with PUT /api/h5/order, uploads via GET /api/presign + Qiniu.
pages/map/index — 微信原生地图选点. Tap / locate / chooseLocation search, returns GCJ-02 lng,lat.
Session and request
- API origin comes from
TARO_APP_API_ORIGIN:.env.development→http://corp-test.batiao8.com,.env.production→https://nb.zuom8.cn. x-hostprefers the H5 jumphost, thenTARO_APP_API_HOST.- Map reverse geocode uses
TARO_APP_TIANDITU_KEYagainstapi.tianditu.gov.cn(add this request domain in WeChat admin). - Missing launch query fields fall back to
DEFAULT_LAUNCH_SCHEMEinsrc/lib/launch.ts(scene=/h/KZ9Q,host=nb.batiao8.com,package=10044,phone=17316703138). - No token:
GET /api/user/configthen keep the returned guest token. ThenGET /api/h5/corpfor package/config. - Shared client:
src/lib/request.ts(same MD5 sign + AES decrypt as H5). Platform header iswx-mp.
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.
A more verbose Chinese-language version of these notes lives in GEMINI.md.