wxgzh
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesewxgzh
wxgzh
封装 命令行工具,用于微信公众号文章发布。
@lyhue1991/wxgzhWrapper for the command-line tool, used for publishing articles to WeChat Official Accounts.
@lyhue1991/wxgzh核心能力
Core Capabilities
- 一键发布文章 - Markdown → 公众号草稿箱
- 配置管理 - AppID/AppSecret 配置
- 封面生成 - 自动生成或自定义封面图
- 格式转换 - Markdown → 公众号 HTML
- One-click Article Publishing - Markdown → Official Account Draft Box
- Configuration Management - AppID/AppSecret configuration
- Cover Generation - Auto-generate or customize cover images
- Format Conversion - Markdown → Official Account HTML
工作流程
Workflow
📝 发布文章到公众号
📝 Publish Article to Official Account
当用户表达发布文章意图时,按以下流程执行:
1. 检查安装 → 2. 检查配置 → 3. 发布文章Step 1: 检查是否安装 wxgzh
bash
command -v wxgzh如果未安装,执行:
bash
npm install -g @lyhue1991/wxgzhStep 2: 检查配置
bash
wxgzh config --list如果未配置,询问用户提供:
- (公众号开发接口管理中的 AppID)
AppID - (公众号开发接口管理中的 AppSecret)
AppSecret
然后执行:
bash
wxgzh config --appid 你的AppID --appsecret 你的AppSecret⚠️ 提醒用户:需要把本机公网 IP 加入公众号后台的 IP 白名单 查看公网 IP:访问 https://ip.sb/
Step 3: 发布文章
bash
wxgzh article.md --author "文章作者姓名"支持参数:
- - 作者名
--author <name> - - 主题样式(default/blue/green/red/yellow/brown/black/orange)
--theme <theme> - - 指定封面图
--cover <path> - - 文章摘要
--digest <text> - - 开启评论
--enable-comment
When users express the intention to publish an article, follow this process:
1. Check Installation → 2. Check Configuration → 3. Publish ArticleStep 1: Check if wxgzh is installed
bash
command -v wxgzhIf not installed, execute:
bash
npm install -g @lyhue1991/wxgzhStep 2: Check Configuration
bash
wxgzh config --listIf not configured, ask the user to provide:
- (AppID from the official account development interface management)
AppID - (AppSecret from the official account development interface management)
AppSecret
Then execute:
bash
wxgzh config --appid YourAppID --appsecret YourAppSecret⚠️ Remind users: You must add your local public IP to the IP whitelist in the official account backend Check public IP: Visit https://ip.sb/
Step 3: Publish Article
bash
wxgzh article.md --author "Author Name"Supported parameters:
- - Author name
--author <name> - - Theme style (default/blue/green/red/yellow/brown/black/orange)
--theme <theme> - - Specify cover image path
--cover <path> - - Article abstract
--digest <text> - - Enable comments
--enable-comment
⚙️ 配置公众号
⚙️ Configure Official Account
当用户只需配置 AppID/AppSecret 时:
bash
wxgzh config --appid 你的AppID --appsecret 你的AppSecretWhen users only need to configure AppID/AppSecret:
bash
wxgzh config --appid YourAppID --appsecret YourAppSecret🖼️ 生成封面图
🖼️ Generate Cover Image
当用户需要生成封面时:
bash
wxgzh cover --title "我的文章" --to .wxgzh/cover.jpg生成后立即预览结果(macOS):
bash
wxgzh cover --title "我的文章" --to .wxgzh/cover.jpg && open .wxgzh/cover.jpg查看内置背景:
bash
wxgzh cover --listWhen users need to generate a cover image:
bash
wxgzh cover --title "My Article" --to .wxgzh/cover.jpgPreview the result immediately after generation (macOS):
bash
wxgzh cover --title "My Article" --to .wxgzh/cover.jpg && open .wxgzh/cover.jpgView built-in backgrounds:
bash
wxgzh cover --list📄 Markdown 转 HTML
📄 Markdown to HTML
当用户只需转换格式时:
bash
wxgzh md2html --from article.md --to .wxgzh/article.htmlWhen users only need format conversion:
bash
wxgzh md2html --from article.md --to .wxgzh/article.html注意事项
Notes
- IP 白名单 - 调用微信接口前,必须把本机公网 IP 加入公众号后台白名单
- 配置文件位置 -
~/.config/wxgzh/wxgzh.json - 中间产物 - 默认输出到文章同级目录的 文件夹
.wxgzh/
- IP Whitelist - Before calling WeChat APIs, you must add your local public IP to the official account backend whitelist
- Configuration File Location -
~/.config/wxgzh/wxgzh.json - Intermediate Products - Default output to the folder in the same directory as the article
.wxgzh/
快速参考
Quick Reference
bash
undefinedbash
undefined查看帮助
View help
wxgzh --help
wxgzh --help
查看配置
View configuration
wxgzh config --list
wxgzh config --list
查看主题
View themes
wxgzh config --list-themes
wxgzh config --list-themes
一键发布
One-click publishing
wxgzh article.md --author 你的名字 --theme blue
wxgzh article.md --author YourName --theme blue
分步执行
Step-by-step execution
wxgzh md2html --from article.md --to .wxgzh/article.html
wxgzh fix .wxgzh/article.html
wxgzh cover --title "标题" --to .wxgzh/cover.jpg
wxgzh publish --article .wxgzh/article.html --cover .wxgzh/cover.jpg
undefinedwxgzh md2html --from article.md --to .wxgzh/article.html
wxgzh fix .wxgzh/article.html
wxgzh cover --title "Title" --to .wxgzh/cover.jpg
wxgzh publish --article .wxgzh/article.html --cover .wxgzh/cover.jpg
undefined