You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.1 KiB
3.1 KiB
AGENTS.md
Project
WeChat Mini Program (微信小程序) — school campus app. Source root is src/ (set via miniprogramRoot in project.config.json).
Commands
- Lint:
pnpm run lint:fix(eslint only; no separate typecheck or test commands exist) - npm build: Must use WeChat DevTools → "Build npm" menu. Output goes to
src/miniprogram_npm/(gitignored). Do not editminiprogram_npm/manually. - JSX compile:
pnpm run beforeCompile— Babel-transforms.jsxfiles undersrc/pages/using@babel/plugin-transform-react-jsx(automatic runtime). WeChat DevTools runs this automatically viaproject.config.jsonscripts before compile/preview/upload. No.jsxfiles currently exist, but the pipeline is wired.
Architecture
- Custom Page wrapper (
src/utils/page.ts): The globalPageconstructor is replaced inapp.tsonLaunch. Every page automatically gets navbar setup, image params, scroll-based nav background, and a defaultonShareAppMessage. When adding page lifecycle hooks, be aware these wrappers run before your own handlers. wx.ajax: Custom property added towxinapp.tsonLaunch. It is a curried version ofsrc/api/request.tswith the base URL baked in. Usewx.ajax(...)for network requests — do not callrequestdirectly from pages.- Login flow: Managed in
AppviaglobalData.loginState/globalData.initLoginInfo. Pages callgetApp().waitLogin()before making authenticated requests. - Custom tabbar:
app.jsonhas"custom": true; the tabbar UI is implemented in components.
Path Aliases
@/*→src/*(configured in bothtsconfig.jsonpaths andapp.jsonresolveAlias)
Style & Lint
- ESLint:
@antfu/eslint-config+eslint-config-prettier(stylistic rules off). Globalswx,App,Page,Component,getApp,getCurrentPages,requirePlugin,requireMiniProgramare declared. - Prettier: no semicolons, single quotes, trailing commas, printWidth 120. Uses
htmlparser for.wxml,cssfor.wxss,babelfor.wxs. - TypeScript: strict mode (but
noImplicitAny: false), target ES5, CommonJS modules. Typings intypings/index.d.tsdeclareIAppOption,IAgaxParams, and extendWechatMiniprogram.Wxwithajax.
File Structure
Each page/component follows the standard miniprogram quad: .ts, .wxml, .scss, .json.
src/
app.ts / app.json / app.scss # App entry
api/request.ts # HTTP request wrapper
utils/
page.ts # Custom Page wrapper (global)
util.ts # Helpers
dayjs/ # Manually bundled dayjs plugins (not from npm)
pages/{name}/index.{ts,wxml,scss,json}
components/{name}/index.{ts,wxml,scss,json}
Gotchas
src/utils/dayjs/contains hand-copied dayjs locale/plugin files, not npm imports. Do not replace with npm imports without testing.src/miniprogram_npm/is build output — never edit directly.- The
beforeCompileBabel step only processessrc/pages/**/*.jsx. If you add JSX outsidepages/, the script won't catch it. - No test framework is configured.