Skip to content

Conversation

simonzhangs
Copy link
Contributor

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

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

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

🖼️ 封面图处理

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

⚙️ 配置管理

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

🎨 用户体验

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

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

⚠️ 注意事项

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

使用流程:

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

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

Copy link

github-actions bot commented Sep 27, 2025

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

@yanglbme
Copy link
Member

这个 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.

@simonzhangs
Copy link
Contributor Author

simonzhangs commented Sep 27, 2025

这个 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 simonzhangs marked this pull request as draft September 27, 2025 15:53
@zeevenn
Copy link
Member

zeevenn commented Sep 28, 2025

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

@simonzhangs
Copy link
Contributor Author

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

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

@simonzhangs simonzhangs marked this pull request as ready for review September 28, 2025 16:41
@simonzhangs
Copy link
Contributor Author

这个 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了

已处理

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果缺少参数是不是才应该切换 tab,配置了参数就不需要切换了吧,同理其他几个 tab 也是一样

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以放到 packages/core 下,新增 publish 文件夹,为其他平台增加口子

}

export async function addMpArticleDraft(params: MpArticleDraft) {
let { appID, appsecret, proxyOrigin } = JSON.parse(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以作为参数传入

@honwhy
Copy link
Contributor

honwhy commented Oct 1, 2025

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants