May 20, 2021 WeChat Mini Program Development Document
The developer tool provides both the command line and the HTTP service interface for external calls, and developers can sign in, preview, upload, and more through the command line or HTTP request indication tool.
The http service is automatically turned on after the tool is started, and the HTTP service port number is recorded in the user directory, which can be determined by checking the user directory, checking for port files in the user directory, and trying to connect.
Port number file location:
macOS : s/Library/Application Support/WeChat Web Developer Tool/Default/.ide
Windows: s/AppData/Local/WeChat Web Developer Tools/User Data/Default/.ide
Interface definition:
URL: /open
HTTP Method: GET
URL parameters | Required | Description |
---|---|---|
projectpath | Whether | Open the item in the specified path. I f the project is open, the item is automatically refreshed. If the project is not created, the project is automatically created and opened |
Example:
# 打开工具
http://127.0.0.1:端口号/open
# 打开/刷新项目
http://127.0.0.1:端口号/open?projectpath=项目全路径
Attention:
Interface definition:
URL:/login
HTTP Method: GET
URL parameters | Required | Description |
---|---|---|
format | Whether | Specify the login QR code return format, optional values are image, base64, terminal, default image. The picture format is png |
qroutput | Whether | Specify the file path to write QR code data to the file. If specified, the QR code will be written to the file of the specified path, and if not specified, the QR code will be returned as the request body |
Example:
# 登录,返回图片格式的二维码
http://127.0.0.1:端口号/login
# 登录,取 base64 格式二维码
http://127.0.0.1:端口号/login?format=base64
# 登录,取 base64 格式二维码,并写入 /Users/username/logincode.txt
http://127.0.0.1:端口号/login?format=base64&qroutput=%2FUsers%2Fusername%2Flogincode.txt
Interface definition:
URL:/preview
HTTP Method: GET
URL parameters | Required | Description |
---|---|---|
projectpath | Is | Preview the items in the specified path. I f the project is open, the item is automatically refreshed. If the project is not created, the project is automatically created and previewed |
format | Whether | Specify the login QR code return format, optional values are image, base64, terminal, default image. The picture format is png |
qroutput | Whether | Specify the file path to write QR code data to the file. If specified, the QR code will be written to the file of the specified path, and if not specified, the QR code will be returned as the request body |
Example:
# 预览路径为 /Users/username/demo 的项目,返回图片格式的二维码
http://127.0.0.1:端口号/preview?projectpath=%2FUsers%2Fusername%2Fdemo
# 预览路径为 /Users/username/demo 的项目,返回 base64 格式的二维码
http://127.0.0.1:端口号/preview?projectpath=%2FUsers%2Fusername%2Fdemo&format=base64
# 预览路径为 /Users/username/demo 的项目,返回 base64 格式的二维码,并写入 /Users/username/logincode.txt
http://127.0.0.1:端口号/preview?projectpath=%2FUsers%2Fusername%2Fdemo&format=base64&qroutput=%2FUsers%2Fusername%2Flogincode.txt
Interface definition:
URL:/upload
HTTP Method: GET
URL parameters | Required | Description |
---|---|---|
projectpath | Is | Upload the items in the specified path |
version | Is | Version number |
desc | Whether | This uploaded version notes |
Example:
# 上传路径为 /Users/username/demo 的项目,指定版本号为 v1.0.0
http://127.0.0.1:端口号/upload?projectpath=%2FUsers%2Fusername%2Fdemo&version=v1.0.0
# 上传路径为 /Users/username/demo 的项目,指定版本号为 v1.0.0,并带上备注
http://127.0.0.1:端口号/upload?projectpath=%2FUsers%2Fusername%2Fdemo&version=v1.0.0&desc=test
Interface definition:
URL:/test
HTTP Method: GET
URL parameters | Required | Description |
---|---|---|
projectpath | Is | Test the items in the specified path |
Example:
# 提交路径为 /Users/username/demo 的项目进行测试
http://127.0.0.1:端口号/test?projectpath=%2FUsers%2Fusername%2Fdemo
Normally, http has a status code of 200 and, in error 400, returns a JSON string in the following format:
{
"code": 40000,
"error": "原因"
}