corp-mp/AGENTS.md

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 wx6d4f6f29c41aff93).

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.developmenthttp://corp-test.batiao8.com, .env.productionhttps://nb.zuom8.cn.
  • x-host prefers the H5 jump host, then TARO_APP_API_HOST.
  • Map reverse geocode uses TARO_APP_TIANDITU_KEY against api.tianditu.gov.cn (add this request domain in WeChat admin).
  • Missing launch query fields fall back to DEFAULT_LAUNCH_SCHEME in src/lib/launch.ts (scene=/h/KZ9Q, host=nb.batiao8.com, package=10044, phone=13800138000).
  • No token: GET /api/user/config then keep the returned guest token. Then GET /api/h5/corp for package/config.
  • Shared client: src/lib/request.ts (same MD5 sign + AES decrypt as H5). Platform header is wx-mp.

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.

A more verbose Chinese-language version of these notes lives in GEMINI.md.