md icon indicating copy to clipboard operation
md copied to clipboard

feat: support publish articles to wxmp draft

Open simonzhangs opened this issue 3 months ago • 7 comments

feat: 新增微信公众号草稿发布功能,支持将Markdown编辑器中的内容直接发布到微信公众号后台作为草稿。

✨ 主要功能如下: 📝 内容发布

  • 草稿发布:支持将编辑器的HTML内容发布到微信公众号后台作为草稿
  • 智能标题提取:优先获取文章标题,无标题时自动提取内容中的第一个标题(h1-h6)
  • 摘要生成:自动提取内容第一段作为摘要,支持手动编辑
  • 样式内联:HTML内容自动内联CSS样式,确保在公众号中正常显示

🖼️ 封面图处理

  • 自动提取:从内容中自动提取第一张图片作为封面
  • 多种上传方式:支持手动输入图片链接,支持本地上传图片文件,自动过滤无效格式

⚙️ 配置管理

  • 配置检测:自动检测公众号图床配置(appID、appsecret)
  • 代理支持:支持开发环境和CF Pages环境的代理配置

🎨 用户体验

  • 发布状态:实时显示发布进度和状态
  • 成功跳转:发布成功后提供直接跳转到微信公众号管理后台的链接
  • 表单验证:发布前验证必填字段和配置状态
  • 评论设置:支持设置是否开启评论和仅粉丝可评论

🎯 使用场景 适用于需要将Markdown内容快速发布到微信公众号的场景,特别是:技术博客作者、内容创作者、自媒体运营者

⚠️ 注意事项

  • 需要先配置微信公众号的appID和appsecret
  • 封面图必须提供,否则无法发布

使用流程:

  1. 点击发布公众号,弹窗 image
  2. 等待自动上传公众号封面后,点击确认 image
  3. 发布成功后,可以直接跳转公众号后台

如果没有公众号图床配置(appID、appsecret),点击发布时会提醒 image 点击打开配置,会自动弹出图床配置弹窗 image

simonzhangs avatar Sep 27 '25 14:09 simonzhangs

🎊 PR Preview has been successfully built and deployed to https://doocs-md-preview-pr-1016.surge.sh

github-actions[bot] avatar Sep 27 '25 14:09 github-actions[bot]

这个 build 报错了,需要检查一下:

vite v6.3.6 building for production...
transforming...
Error: src/utils/file.ts(324,62): error TS2304: Cannot find name 'chrome'.
Error: src/utils/wechat-publish.ts(49,62): error TS2304: Cannot find name 'chrome'.
Error: src/utils/wechat-publish.ts(89,62): error TS2304: Cannot find name 'chrome'.
 ELIFECYCLE  Command failed with exit code 2.
 ELIFECYCLE  Command failed.
ERROR: "type-check" exited with 2.
/home/runner/work/md/md/apps/web:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @md/web@ build:h5-netlify: `run-p type-check "build:h5-netlify:only {@}" --`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

yanglbme avatar Sep 27 '25 15:09 yanglbme

这个 build 报错了,需要检查一下:

vite v6.3.6 building for production...
transforming...
Error: src/utils/file.ts(324,62): error TS2304: Cannot find name 'chrome'.
Error: src/utils/wechat-publish.ts(49,62): error TS2304: Cannot find name 'chrome'.
Error: src/utils/wechat-publish.ts(89,62): error TS2304: Cannot find name 'chrome'.
 ELIFECYCLE  Command failed with exit code 2.
 ELIFECYCLE  Command failed.
ERROR: "type-check" exited with 2.
/home/runner/work/md/md/apps/web:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @md/web@ build:h5-netlify: `run-p type-check "build:h5-netlify:only {@}" --`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

好的我看下,pr 先转成 draft pr了

simonzhangs avatar Sep 27 '25 15:09 simonzhangs

移动端可以改成悬浮按钮,而不是简单隐藏

zeevenn avatar Sep 28 '25 03:09 zeevenn

移动端可以改成悬浮按钮,而不是简单隐藏

很好的建议,国庆后再贡献趴。

simonzhangs avatar Sep 28 '25 16:09 simonzhangs

这个 build 报错了,需要检查一下:

vite v6.3.6 building for production...
transforming...
Error: src/utils/file.ts(324,62): error TS2304: Cannot find name 'chrome'.
Error: src/utils/wechat-publish.ts(49,62): error TS2304: Cannot find name 'chrome'.
Error: src/utils/wechat-publish.ts(89,62): error TS2304: Cannot find name 'chrome'.
 ELIFECYCLE  Command failed with exit code 2.
 ELIFECYCLE  Command failed.
ERROR: "type-check" exited with 2.
/home/runner/work/md/md/apps/web:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @md/web@ build:h5-netlify: `run-p type-check "build:h5-netlify:only {@}" --`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

这个 build 报错了,需要检查一下:

vite v6.3.6 building for production...
transforming...
Error: src/utils/file.ts(324,62): error TS2304: Cannot find name 'chrome'.
Error: src/utils/wechat-publish.ts(49,62): error TS2304: Cannot find name 'chrome'.
Error: src/utils/wechat-publish.ts(89,62): error TS2304: Cannot find name 'chrome'.
 ELIFECYCLE  Command failed with exit code 2.
 ELIFECYCLE  Command failed.
ERROR: "type-check" exited with 2.
/home/runner/work/md/md/apps/web:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @md/web@ build:h5-netlify: `run-p type-check "build:h5-netlify:only {@}" --`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

好的我看下,pr 先转成 draft pr了

已处理

simonzhangs avatar Sep 28 '25 16:09 simonzhangs

虽然现在公众号开发者账号密钥 只在图床中使用,但是如果加上发布草稿这个功能, 我觉得可以两边都支持账号密钥配置,配置内容同步起来。

或者考虑简化理解,增加一个tips,增加一个说明文档。~ 建议建议

honwhy avatar Oct 01 '25 13:10 honwhy