Wechat Game Club
Overview
Add a WeChat mini-game Game Club entry from a single MP backend openlink. Keep the integration local to the mini-game: no backend, no cloud development, no third-party engine.
Workflow
- Read the target project's
AGENTS.mdor equivalent rules first. - Confirm the project is a WeChat mini-game, usually with
game.js,game.json,project.config.json, and native Canvas JavaScript. - Ask for the Game Club in-game jump link only if the user did not provide it. Treat it as the MP backend
openlink. - Add or update a bridge module for
wx.createPageManager. Prefer copyingassets/game-club-bridge.jsand replacing__GAME_CLUB_OPENLINK__. - Wire one visible game UI entry to
bridge.open(). Use the existing renderer/input/menu pattern; do not introduce a DOM button in Canvas games. - Make repeated taps idempotent with a
loadingflag and reuse the page manager instance. - Validate with syntax checks and a small search pass for placeholders.
Code Pattern
Use this shape unless the project already has an equivalent abstraction:
const { GameClubBridge } = require('./js/game-club');
const gameClub = new GameClubBridge(typeof wx !== 'undefined' ? wx : null, {
openlink: 'OPENLINK_FROM_MP_BACKEND'
});
// In an existing click handler:
gameClub.open();
Copy assets/game-club-bridge.js when a bridge does not exist. If a bridge exists, patch it instead of creating a second one.
UI Wiring Rules
- Put the entry where the project already places social/community actions, usually the home screen, pause menu, or side action rail.
- In Canvas games, draw the button in the renderer and add hit detection in the existing input handler or game state click router.
- Keep the button hidden or disabled only if the surrounding UI already has such states; do not silently remove the action when unsupported.
- On unsupported WeChat versions/devices, call
wx.showToast({ icon: 'none' })or the project's toast helper.
Error Handling
Map common load failures to user-readable messages:
| Code | Meaning | Suggested message |
|---|---|---|
-1 |
invalid openlink |
tell the user the Game Club openlink is invalid |
-2 |
WeChat version unsupported | tell the user the current WeChat version is unsupported |
-3 |
device unsupported | tell the user the current device is unsupported |
-6 |
network issue | ask the user to retry later |
-7 |
too frequent | ask the user to retry later |
-8 |
version mismatch | tell the user the openlink does not match the current version |
Validation
Run the project's normal JavaScript syntax checks. For no-build mini-games, this is commonly:
node --check game.js
Get-ChildItem js -Filter *.js | ForEach-Object { node --check $_.FullName }
rg -n "__GAME_CLUB_OPENLINK__|TODO|createPageManager|GameClubBridge" .
Also verify in WeChat Developer Tools on a real mini-game compile target, because wx.createPageManager behavior is runtime-specific.
Common Mistakes
- Do not hard-code another project's
openlink. - Do not add backend, cloud storage, or npm/build tooling only for Game Club.
- Do not create a second
game-club.jsif the project already has one. - Do not treat
openlinkas a web URL; pass it directly topageManager.load({ openlink }). - Do not call
show()beforeload()resolves.