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)

如果默认配置发布失败,或用户想使用自己的公众号,指导用户按以下步骤获取:
  1. 登录微信开发者平台(首页/公众号) https://developers.weixin.qq.com/platform
  2. 点击
    前往使用
  3. 点击
    我的业务/公众号
  4. 公众号页面的
    基础信息
    下方就能看到"AppID"
  5. 公众号页面的
    开发秘钥
    下方就能看到"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:
  1. Log in to the WeChat Developer Platform (Home/Official Account) https://developers.weixin.qq.com/platform
  2. Click
    Go to Use
  3. Click
    My Business/Official Account
  4. You can find "AppID" under
    Basic Information
    on the Official Account page
  5. You can find "AppSecret" under
    Development Secret
    on the Official Account page

工作流程

Workflow

根据用户需求执行不同的操作流程:
Execute different operation processes according to user needs:

场景一:预览主题效果

Scenario 1: Preview Theme Effects

当用户说"我要预览主题"或类似表达时:
  1. 直接提供预览链接https://5g6pxtj3zg.coze.site/
  2. 简单说明:告知用户该网站提供了一个固定包含各种元素的markdown文章,用于展示不同主题的实际效果
  3. 无需执行任何本地操作
When users say "I want to preview themes" or similar expressions:
  1. Directly provide the preview link: https://5g6pxtj3zg.coze.site/
  2. Brief explanation: Inform users that this website provides a fixed Markdown article containing various elements to display the actual effects of different themes
  3. 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
undefined
Ensure the environment meets the requirements:
  • Node.js >= 24.13.0
  • Install dependencies (will skip quickly if already installed)
bash
undefined

Windows 示例

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"
undefined
npm install --prefix "/Users/yourname/.qoder/skills/wechat-publisher-skill"
undefined

2. 收集必要信息

2. Collect Necessary Information

向用户确认以下信息:
参数必填说明
Markdown 文件路径要发布的文章文件位置
APP_ID微信开发者平台的 AppID
APP_SECRET微信开发者平台的 AppSecret
文章作者名称公众号显示的作者名
封面图片路径文章封面图片
文章标题发布的文章标题,未指定时使用文件名作为标题
主题文章渲染主题,使用 themes 目录下的主题文件(默认使用蓝色主题)
文章前缀显示在正文开头的内容
文章后缀显示在正文结尾的内容
所有可选参数均有默认值(来自
config.default.json
),用户不提供时自动使用默认值。
Confirm the following information with users:
ParameterRequiredDescription
Markdown File PathYesThe location of the article file to be published
APP_IDNoAppID from WeChat Developer Platform
APP_SECRETNoAppSecret from WeChat Developer Platform
Article Author NameNoAuthor name displayed on the Official Account
Cover Image PathNoArticle cover image
Article TitleNoTitle of the published article; if not specified, the file name will be used as the title
ThemeNoArticle rendering theme, use theme files in the themes directory (blue theme is used by default)
Article PrefixNoContent displayed at the beginning of the main text
Article SuffixNoContent displayed at the end of the main text
All optional parameters have default values (from
config.default.json
), which will be used automatically if users do not provide them.

3. 配置生成

3. Configuration Generation

生成逻辑:
  1. 复制
    config.default.json
    config.json
  2. 更新
    markdownFilePath
    为用户提供的文章路径
  3. 用户提供了其他参数时,覆盖对应的默认值
  4. 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
发布失败时的配置处理:
如果发布返回
invalid appid
invalid appsecret
错误,提示用户提供正确的 APP_ID 和 APP_SECRET,更新
config.json
后重新发布。
重要提示:
  • 无需读取 Markdown 文件内容,发布脚本会自动处理文章中的所有内容(包括图片、格式等)
  • 无需验证图片文件是否存在,只需确保
    markdownFilePath
    指向的文件路径正确即可
Generation Logic:
  1. Copy
    config.default.json
    to
    config.json
  2. Update
    markdownFilePath
    to the article path provided by the user
  3. Override the corresponding default values if users provide other parameters
  4. Convert relative paths in
    config.default.json
    to absolute paths (
    <Skill Directory Absolute Path>
    + file name, e.g.,
    ./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: Replace
\
with
/
for Mac/Linux systems, e.g.,
/Users/yourname/Documents/Official Account Tutorial/Article.md
Configuration Handling When Publishing Fails:
If the publish returns
invalid appid
or
invalid appsecret
errors, prompt users to provide the correct APP_ID and APP_SECRET, then republish after updating
config.json
.
Important 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
    markdownFilePath
    is correct

4. 执行发布文章到公众号的脚本

4. Execute the Script to Publish Articles to Official Account

⚠️ 重要:必须通过 config.json 文件传递参数,不要直接在命令行传递 --file/--app-id/--app-secret 等参数!
注意:终端只传递
--config
参数,指向生成的
config.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
--config
parameter, pointing to the generated
config.json
file.
⚠️ 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"

❌ 错误示例(不要这样做):

```bash
node "/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
undefined
node index.js --file xxx.md --app-id xxx --app-secret xxx
undefined

5. 结果反馈

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
  • invalid appsecret
    :AppSecret 已被重置或输入错误
  • invalid appid
    :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
      ip
      on Baidu
  • invalid appsecret
    : AppSecret has been reset or entered incorrectly
  • invalid appid
    : AppID is entered incorrectly

注意事项

Notes

  1. 图片格式:支持 JPG、PNG
  2. 图片位置:markdown 文章中的图片必须与 markdown 文件在同一目录
  3. 图片引用格式:支持标准 markdown 图片语法,如
    ![](图片文件名.png)
  4. 聊天格式:支持一左一右的气泡对话格式
    示例:
    >L: 左侧对话内容
    >R: 右侧对话内容
    >L: 又一句左侧内容
    >R: 又一句右侧内容
  5. 禁止行为
    • 严禁读取
      wechat-publisher-skill
      目录下的
      index.js
      文件(约 79KB),该代码已经加密混淆
    • 严禁从文章内容中自动提取图片作为封面
  1. Image Format: JPG, PNG are supported
  2. Image Location: Images in the markdown article must be in the same directory as the markdown file
  3. Image Reference Format: Standard markdown image syntax is supported, e.g.,
    ![](image-filename.png)
  4. Chat Format: Supports left-right bubble dialogue format
    Example:
    >L: Left dialogue content
    >R: Right dialogue content
    >L: Another left content
    >R: Another right content
  5. Prohibited Behaviors:
    • It is strictly forbidden to read the
      index.js
      file (about 79KB) in the
      wechat-publisher-skill
      directory, as this code has been encrypted and obfuscated
    • It is strictly forbidden to automatically extract images from the article content as the cover

主题预览

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

  1. 登录你的 微信公众号
  2. 点击 内容管理草稿箱
  3. 点击草稿箱中文章的 编辑按钮,打开文章编辑页面
  4. 请审核校对 文章与封面
  1. Log in to your WeChat Official Account
  2. Click Content ManagementDraft Box
  3. Click the Edit Button of the article in the draft box to open the article editing page
  4. Please review and proofread the article and cover