commit a00eaadfef2ce27cef41a61d830a2a5f6a1abfda Author: manpengan Date: Sat Mar 28 21:56:45 2026 +0800 init: 微信小游戏项目初始化 基础工程骨架:game.js 入口、Canvas 渲染、DevTools 项目配置。 包含 CLAUDE.md / AGENTS.md 及 KB 知识库接入。 Co-Authored-By: Claude Opus 4.6 (1M context) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f470d54 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# macOS +.DS_Store + +# IDE +.idea/ +.vscode/ + +# WeChat DevTools +node_modules/ +miniprogram_npm/ +*.wasm + +# Build +dist/ + +# Environment +.env +.env.local diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..321459b --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,30 @@ + +## Project State +- **Project**: wechat-minigame — 微信小游戏 +- **Stage**: 初始化 +- **Last action**: project init +- **Next task**: 讨论游戏类型、玩法设计和技术方案,制定开发计划 +- **Hard constraints**: Canvas rendering | 4MB first package | No DOM/BOM | 60fps target +- **KB**: ~/pro/kb/projects/wechat-minigame/ + + +## Project Structure + +``` +game.js # Entry point +game.json # Global config +project.config.json # DevTools project config +js/ # Game logic +images/ # Image assets +audio/ # Audio assets +``` + +## Build & Dev Commands + +No CLI build/test commands. Use WeChat DevTools for preview and debugging. + +## Coding Style + +- ES6+ modules (import/export) +- Canvas-based rendering, no DOM +- Data files use JS module wrapping (no JSON require) diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..79865fe --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,36 @@ +# wechat-minigame + + +## 项目速览 +- **项目**:wechat-minigame — 微信小游戏 +- **阶段**:初始化 +- **上次结论**:项目初始化 +- **下一步**:与 Codex 讨论游戏类型、玩法设计和技术方案 +- **关键约束**:Canvas 渲染 | 首包 4MB | 无 DOM/BOM | 60fps 目标 +- **KB 指针**:~/pro/kb/projects/wechat-minigame/ + + +## 开发环境 + +- 平台:微信小游戏(非小程序) +- 渲染:Canvas 2D / WebGL +- 调试工具:微信开发者工具 +- 无 npm/build/test CLI,在 DevTools 中模拟器验证 + +## 项目结构 + +``` +game.js # 入口 +game.json # 全局配置 +project.config.json # DevTools 项目配置 +js/ # 游戏逻辑 +images/ # 图片素材 +audio/ # 音频素材 +``` + +## 平台约束 + +- `require()` 不支持 JSON,数据用 JS module 包装 +- 首包 ≤ 4MB,分包总计 ≤ 20MB +- 不支持 DOM/BOM,仅微信 API 子集 +- Canvas 是全局单例,通过 `wx.createCanvas()` 获取 diff --git a/audio/.gitkeep b/audio/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/game.js b/game.js new file mode 100644 index 0000000..7b727cd --- /dev/null +++ b/game.js @@ -0,0 +1 @@ +import './js/main' diff --git a/game.json b/game.json new file mode 100644 index 0000000..c7d4915 --- /dev/null +++ b/game.json @@ -0,0 +1,10 @@ +{ + "deviceOrientation": "portrait", + "showStatusBar": false, + "networkTimeout": { + "request": 5000, + "connectSocket": 5000, + "uploadFile": 5000, + "downloadFile": 5000 + } +} diff --git a/images/.gitkeep b/images/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/js/main.js b/js/main.js new file mode 100644 index 0000000..28f0e24 --- /dev/null +++ b/js/main.js @@ -0,0 +1,12 @@ +const { windowWidth, windowHeight } = wx.getSystemInfoSync() + +const canvas = wx.createCanvas() +const ctx = canvas.getContext('2d') + +ctx.fillStyle = '#ffffff' +ctx.fillRect(0, 0, windowWidth, windowHeight) + +ctx.fillStyle = '#333333' +ctx.font = '24px sans-serif' +ctx.textAlign = 'center' +ctx.fillText('微信小游戏', windowWidth / 2, windowHeight / 2) diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..41644b1 --- /dev/null +++ b/project.config.json @@ -0,0 +1,41 @@ +{ + "miniprogramRoot": "./", + "setting": { + "urlCheck": true, + "es6": true, + "enhance": true, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": false, + "coverView": true, + "nodeModules": false, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "uglifyFileName": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "compileHotReLoad": false, + "lazyloadPlaceholderEnable": false, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "useIsolateContext": true, + "userConfirmedBundleSwitch": false, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "showES6CompileOption": false + }, + "compileType": "game", + "appid": "", + "projectname": "wechat-minigame", + "condition": {} +}