wechat-publisher
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese微信公众号文章发布工具
WeChat Official Account Article Publishing Tool
功能概述
Feature Overview
将本地 Markdown 文章一键发布到微信公众号草稿箱。
One-click publish local Markdown articles to the WeChat Official Account draft box.
如何获取微信开发者平台的 AppID 和 AppSecret(可选)
How to Get AppID and AppSecret from WeChat Developer Platform (Optional)
如果默认配置发布失败,或用户想使用自己的公众号,指导用户按以下步骤获取:
- 登录微信开发者平台(首页/公众号) https://developers.weixin.qq.com/platform
- 点击
前往使用 - 点击
我的业务/公众号 - 公众号页面的下方就能看到"AppID"
基础信息 - 公众号页面的下方就能看到"AppSecret"
开发秘钥
If the default configuration fails to publish, or users want to use their own Official Account, guide them to follow these steps to get the information:
- Log in to the WeChat Developer Platform (Home/Official Account) https://developers.weixin.qq.com/platform
- Click
Go to Use - Click
My Business/Official Account - You can find "AppID" under on the Official Account page
Basic Information - You can find "AppSecret" under on the Official Account page
Development Secret
工作流程
Workflow
根据用户需求执行不同的操作流程:
Execute different operation processes according to user needs:
场景一:预览主题效果
Scenario 1: Preview Theme Effects
当用户说"我要预览主题"或类似表达时:
- 直接提供预览链接:https://5g6pxtj3zg.coze.site/
- 简单说明:告知用户该网站提供了一个固定包含各种元素的markdown文章,用于展示不同主题的实际效果
- 无需执行任何本地操作
When users say "I want to preview themes" or similar expressions:
- Directly provide the preview link: https://5g6pxtj3zg.coze.site/
- Brief explanation: Inform users that this website provides a fixed Markdown article containing various elements to display the actual effects of different themes
- No local operations required
场景二:发布文章到公众号
Scenario 2: Publish Articles to Official Account
当用户需要将 Markdown 文章发布到微信公众号时,按以下步骤执行:
When users need to publish Markdown articles to WeChat Official Account, follow these steps:
1. 环境检查与准备
1. Environment Check and Preparation
确保环境满足要求:
- Node.js >= 24.13.0
- 安装依赖(已安装时会快速跳过)
bash
undefinedEnsure the environment meets the requirements:
- Node.js >= 24.13.0
- Install dependencies (will skip quickly if already installed)
bash
undefinedWindows 示例
Windows example
npm install --prefix "C:\Users\YourName.qoder\skills\wechat-publisher-skill"
npm install --prefix "C:\Users\YourName.qoder\skills\wechat-publisher-skill"
Mac/Linux 示例
Mac/Linux example
npm install --prefix "/Users/yourname/.qoder/skills/wechat-publisher-skill"
undefinednpm install --prefix "/Users/yourname/.qoder/skills/wechat-publisher-skill"
undefined2. 收集必要信息
2. Collect Necessary Information
向用户确认以下信息:
| 参数 | 必填 | 说明 |
|---|---|---|
| Markdown 文件路径 | 是 | 要发布的文章文件位置 |
| APP_ID | 否 | 微信开发者平台的 AppID |
| APP_SECRET | 否 | 微信开发者平台的 AppSecret |
| 文章作者名称 | 否 | 公众号显示的作者名 |
| 封面图片路径 | 否 | 文章封面图片 |
| 文章标题 | 否 | 发布的文章标题,未指定时使用文件名作为标题 |
| 主题 | 否 | 文章渲染主题,使用 themes 目录下的主题文件(默认使用蓝色主题) |
| 文章前缀 | 否 | 显示在正文开头的内容 |
| 文章后缀 | 否 | 显示在正文结尾的内容 |
所有可选参数均有默认值(来自),用户不提供时自动使用默认值。config.default.json
Confirm the following information with users:
| Parameter | Required | Description |
|---|---|---|
| Markdown File Path | Yes | The location of the article file to be published |
| APP_ID | No | AppID from WeChat Developer Platform |
| APP_SECRET | No | AppSecret from WeChat Developer Platform |
| Article Author Name | No | Author name displayed on the Official Account |
| Cover Image Path | No | Article cover image |
| Article Title | No | Title of the published article; if not specified, the file name will be used as the title |
| Theme | No | Article rendering theme, use theme files in the themes directory (blue theme is used by default) |
| Article Prefix | No | Content displayed at the beginning of the main text |
| Article Suffix | No | Content displayed at the end of the main text |
All optional parameters have default values (from), which will be used automatically if users do not provide them.config.default.json
3. 配置生成
3. Configuration Generation
生成逻辑:
- 复制 为
config.default.jsonconfig.json - 更新 为用户提供的文章路径
markdownFilePath - 用户提供了其他参数时,覆盖对应的默认值
- 将 中的相对路径转换为绝对路径(
config.default.json+ 文件名,如<技能目录绝对路径>→./cover.jpg)<技能目录绝对路径>/cover.jpg
config.json 字段说明:
json
{
"markdownFilePath": "用户提供的markdown文章路径",
"title": "文章标题,未指定时使用文件名作为标题",
"theme": "文章渲染主题,使用themes目录下的主题文件名(默认使用蓝色主题)",
"AUTHOR": "文章作者名称",
"prefix": "文章前缀",
"suffix": "文章后缀",
"APP_ID": "微信开发者平台的APP_ID",
"APP_SECRET": "微信开发者平台的APP_SECRET",
"coverFilePath": "文章的封面路径"
}config.json 示例:
json
{
"markdownFilePath": "D:\\Documents\\公众号教程\\文章.md",
"title": "文章标题",
"theme": "blue",
"AUTHOR": "牙叔教程",
"prefix": "本文由AI创作\n",
"suffix": "## 扣子智能体教程\nhttps://space.bilibili.com/26079586",
"APP_ID": "wxc2afxxxxxxxxxx",
"APP_SECRET": "8c05bc67131xxxxxxxxxx",
"coverFilePath": "C:\\Users\\YourName\\.qoder\\skills\\wechat-publisher-skill\\cover.jpg"
}注意:Mac/Linux 系统将路径中的替换为\,如//Users/yourname/Documents/公众号教程/文章.md
发布失败时的配置处理:
如果发布返回 或 错误,提示用户提供正确的 APP_ID 和 APP_SECRET,更新 后重新发布。
invalid appidinvalid appsecretconfig.json重要提示:
- 无需读取 Markdown 文件内容,发布脚本会自动处理文章中的所有内容(包括图片、格式等)
- 无需验证图片文件是否存在,只需确保 指向的文件路径正确即可
markdownFilePath
Generation Logic:
- Copy to
config.default.jsonconfig.json - Update to the article path provided by the user
markdownFilePath - Override the corresponding default values if users provide other parameters
- Convert relative paths in to absolute paths (
config.default.json+ file name, e.g.,<Skill Directory Absolute Path>→./cover.jpg)<Skill Directory Absolute Path>/cover.jpg
config.json Field Description:
json
{
"markdownFilePath": "Path of the markdown article provided by the user",
"title": "Article title; if not specified, the file name will be used as the title",
"theme": "Article rendering theme, use theme file names in the themes directory (blue theme is used by default)",
"AUTHOR": "Article author name",
"prefix": "Article prefix",
"suffix": "Article suffix",
"APP_ID": "APP_ID from WeChat Developer Platform",
"APP_SECRET": "APP_SECRET from WeChat Developer Platform",
"coverFilePath": "Path of the article cover"
}config.json Example:
json
{
"markdownFilePath": "D:\\Documents\\Official Account Tutorial\\Article.md",
"title": "Article Title",
"theme": "blue",
"AUTHOR": "Yashu Tutorial",
"prefix": "This article is created by AI\n",
"suffix": "## Kouzi Agent Tutorial\nhttps://space.bilibili.com/26079586",
"APP_ID": "wxc2afxxxxxxxxxx",
"APP_SECRET": "8c05bc67131xxxxxxxxxx",
"coverFilePath": "C:\\Users\\YourName\\.qoder\\skills\\wechat-publisher-skill\\cover.jpg"
}Note: Replacewith\for Mac/Linux systems, e.g.,//Users/yourname/Documents/Official Account Tutorial/Article.md
Configuration Handling When Publishing Fails:
If the publish returns or errors, prompt users to provide the correct APP_ID and APP_SECRET, then republish after updating .
invalid appidinvalid appsecretconfig.jsonImportant Notes:
- No need to read the Markdown file content, the publish script will automatically handle all content in the article (including images, formatting, etc.)
- No need to verify whether image files exist, just ensure the path pointed to by is correct
markdownFilePath
4. 执行发布文章到公众号的脚本
4. Execute the Script to Publish Articles to Official Account
⚠️ 重要:必须通过 config.json 文件传递参数,不要直接在命令行传递 --file/--app-id/--app-secret 等参数!
注意:终端只传递 参数,指向生成的 文件。
--configconfig.json⚠️ 必须使用绝对路径执行命令(避免 Windows 跨盘符切换目录失败):
bash
undefined⚠️ Important: Must pass parameters via the config.json file, do not directly pass parameters like --file/--app-id/--app-secret in the command line!
Note: The terminal only passes the parameter, pointing to the generated file.
--configconfig.json⚠️ Must use absolute paths to execute commands (to avoid cross-directory switching failures on Windows):
bash
undefined将 <技能目录> 替换为实际路径
Replace <Skill Directory> with the actual path
node "<技能目录>/index.js" --config "<技能目录>/config.json"
node "<Skill Directory>/index.js" --config "<Skill Directory>/config.json"
Windows 示例
Windows example
node "C:\Users\YourName.qoder\skills\wechat-publisher-skill\index.js" --config "C:\Users\YourName.qoder\skills\wechat-publisher-skill\config.json"
node "C:\Users\YourName.qoder\skills\wechat-publisher-skill\index.js" --config "C:\Users\YourName.qoder\skills\wechat-publisher-skill\config.json"
Mac/Linux 示例
Mac/Linux example
node "/Users/yourname/.qoder/skills/wechat-publisher-skill/index.js" --config "/Users/yourname/.qoder/skills/wechat-publisher-skill/config.json"
❌ 错误示例(不要这样做):
```bashnode "/Users/yourname/.qoder/skills/wechat-publisher-skill/index.js" --config "/Users/yourname/.qoder/skills/wechat-publisher-skill/config.json"
❌ Wrong Example (Do NOT do this):
```bash相对路径在 Windows 跨盘符时可能失败
Relative paths may fail when cross-disk on Windows
node index.js --config ./config.json
node index.js --config ./config.json
不要直接传递参数
Do not pass parameters directly
node index.js --file xxx.md --app-id xxx --app-secret xxx
undefinednode index.js --file xxx.md --app-id xxx --app-secret xxx
undefined5. 结果反馈
5. Result Feedback
向用户报告发布结果:
- 发布成功:提供草稿链接,告知用户在微信公众平台查看
- 发布失败:根据错误码提供具体的解决建议
Report the publish result to users:
- Publish Success: Provide the draft link and inform users to check it on the WeChat Official Account Platform
- Publish Failure: Provide specific solutions based on the error code
发布失败的原因及解决
Reasons for Publish Failure and Solutions
-
电脑 IP 不在公众号 IP 白名单中
- 解决:登录微信开发者平台 https://developers.weixin.qq.com/platform → 前往使用 → 我的业务/公众号 → 开发秘钥 → IP 白名单 → 编辑添加电脑 IP
- 获取电脑 IP:百度搜索
ip
-
:AppSecret 已被重置或输入错误
invalid appsecret -
:AppID 输入错误
invalid appid
-
Computer IP is not in the Official Account IP whitelist
- Solution: Log in to WeChat Developer Platform https://developers.weixin.qq.com/platform → Go to Use → My Business/Official Account → Development Secret → IP Whitelist → Edit and add the computer IP
- Get computer IP: Search on Baidu
ip
-
: AppSecret has been reset or entered incorrectly
invalid appsecret -
: AppID is entered incorrectly
invalid appid
注意事项
Notes
-
图片格式:支持 JPG、PNG
-
图片位置:markdown 文章中的图片必须与 markdown 文件在同一目录
-
图片引用格式:支持标准 markdown 图片语法,如
 -
聊天格式:支持一左一右的气泡对话格式示例:
>L: 左侧对话内容 >R: 右侧对话内容 >L: 又一句左侧内容 >R: 又一句右侧内容 -
禁止行为:
- 严禁读取 目录下的
wechat-publisher-skill文件(约 79KB),该代码已经加密混淆index.js - 严禁从文章内容中自动提取图片作为封面
- 严禁读取
-
Image Format: JPG, PNG are supported
-
Image Location: Images in the markdown article must be in the same directory as the markdown file
-
Image Reference Format: Standard markdown image syntax is supported, e.g.,
 -
Chat Format: Supports left-right bubble dialogue formatExample:
>L: Left dialogue content >R: Right dialogue content >L: Another left content >R: Another right content -
Prohibited Behaviors:
- It is strictly forbidden to read the file (about 79KB) in the
index.jsdirectory, as this code has been encrypted and obfuscatedwechat-publisher-skill - It is strictly forbidden to automatically extract images from the article content as the cover
- It is strictly forbidden to read the
主题预览
Theme Preview
当用户需要预览主题效果时,请直接提供在线预览链接:
🔗 主题预览地址:https://5g6pxtj3zg.coze.site/
该网站使用一个固定的包含各种元素的markdown文章来展示不同主题的实际效果,方便用户选择合适的文章渲染风格。
When users need to preview theme effects, directly provide the online preview link:
🔗 Theme Preview URL: https://5g6pxtj3zg.coze.site/
This website uses a fixed markdown article containing various elements to display the actual effects of different themes, making it convenient for users to choose a suitable article rendering style.
支持的主题风格
Supported Theme Styles
系统提供 17 种文章渲染主题,每种主题都有独特的视觉风格:
- sakura(樱花主题):日系樱花主题,柔和少女风格
- minimal(极简主题):极简灰色主题,素雅简洁风格
- amber(琥珀主题):温暖琥珀主题,金色阳光风格
- blue(蓝色主题):清新蓝色主题,专业稳重风格
- cyan(青色主题):清爽青色主题,科技现代风格
- green(绿色主题):自然绿色主题,清新环保风格
- indigo(靛蓝主题):深邃靛蓝主题,优雅高贵风格
- lavender(薰衣草主题):淡雅薰衣草主题,浪漫温馨风格
- mint(薄荷主题):清新薄荷主题,简约时尚风格
- orange(橙色主题):活力橙色主题,热情积极风格
- pink(粉色主题):甜美粉色主题,可爱温柔风格
- purple(紫色主题):神秘紫色主题,高贵典雅风格
- red(红色主题):经典红色主题,醒目有力风格
- rose(玫瑰主题):浪漫玫瑰主题,优雅华丽风格
- sky(天空主题):明亮天空主题,开阔清新风格
- teal(青绿主题):优雅青绿主题,平衡和谐风格
- vintage(复古主题):怀旧复古主题,经典文艺风格
The system provides 17 article rendering themes, each with a unique visual style:
- sakura (Sakura Theme): Japanese-style sakura theme, soft and girly style
- minimal (Minimalist Theme): Minimalist gray theme, elegant and concise style
- amber (Amber Theme): Warm amber theme, golden sunshine style
- blue (Blue Theme): Fresh blue theme, professional and steady style
- cyan (Cyan Theme): Refreshing cyan theme, technological and modern style
- green (Green Theme): Natural green theme, fresh and eco-friendly style
- indigo (Indigo Theme): Deep indigo theme, elegant and noble style
- lavender (Lavender Theme): Light lavender theme, romantic and warm style
- mint (Mint Theme): Fresh mint theme, simple and fashionable style
- orange (Orange Theme): Vibrant orange theme, enthusiastic and positive style
- pink (Pink Theme): Sweet pink theme, cute and gentle style
- purple (Purple Theme): Mysterious purple theme, noble and elegant style
- red (Red Theme): Classic red theme, eye-catching and powerful style
- rose (Rose Theme): Romantic rose theme, elegant and luxurious style
- sky (Sky Theme): Bright sky theme, open and fresh style
- teal (Teal Theme): Elegant teal theme, balanced and harmonious style
- vintage (Vintage Theme): Nostalgic vintage theme, classic and literary style
文章发布成功后的下一步操作
Next Steps After Successful Article Publication
- 登录你的 微信公众号
- 点击 内容管理 → 草稿箱
- 点击草稿箱中文章的 编辑按钮,打开文章编辑页面
- 请审核校对 文章与封面
- Log in to your WeChat Official Account
- Click Content Management → Draft Box
- Click the Edit Button of the article in the draft box to open the article editing page
- Please review and proofread the article and cover