wechat-md-publisher 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +392 -0
  3. package/dist/Logger-ZfwNA932.js +741 -0
  4. package/dist/Logger-ZfwNA932.js.map +1 -0
  5. package/dist/cli/commands/account.d.ts +3 -0
  6. package/dist/cli/commands/account.d.ts.map +1 -0
  7. package/dist/cli/commands/account.js +96 -0
  8. package/dist/cli/commands/account.js.map +1 -0
  9. package/dist/cli/commands/draft.d.ts +3 -0
  10. package/dist/cli/commands/draft.d.ts.map +1 -0
  11. package/dist/cli/commands/draft.js +103 -0
  12. package/dist/cli/commands/draft.js.map +1 -0
  13. package/dist/cli/commands/publish.d.ts +3 -0
  14. package/dist/cli/commands/publish.d.ts.map +1 -0
  15. package/dist/cli/commands/publish.js +130 -0
  16. package/dist/cli/commands/publish.js.map +1 -0
  17. package/dist/cli/commands/theme.d.ts +3 -0
  18. package/dist/cli/commands/theme.d.ts.map +1 -0
  19. package/dist/cli/commands/theme.js +95 -0
  20. package/dist/cli/commands/theme.js.map +1 -0
  21. package/dist/cli/index.d.ts +3 -0
  22. package/dist/cli/index.d.ts.map +1 -0
  23. package/dist/cli/index.js +23 -0
  24. package/dist/cli/index.js.map +1 -0
  25. package/dist/cli.js +1037 -0
  26. package/dist/cli.js.map +1 -0
  27. package/dist/container.d.ts +27 -0
  28. package/dist/container.d.ts.map +1 -0
  29. package/dist/container.js +66 -0
  30. package/dist/container.js.map +1 -0
  31. package/dist/core/renderer/ImageProcessor.d.ts +20 -0
  32. package/dist/core/renderer/ImageProcessor.d.ts.map +1 -0
  33. package/dist/core/renderer/ImageProcessor.js +82 -0
  34. package/dist/core/renderer/ImageProcessor.js.map +1 -0
  35. package/dist/core/renderer/MarkdownRenderer.d.ts +13 -0
  36. package/dist/core/renderer/MarkdownRenderer.d.ts.map +1 -0
  37. package/dist/core/renderer/MarkdownRenderer.js +37 -0
  38. package/dist/core/renderer/MarkdownRenderer.js.map +1 -0
  39. package/dist/core/theme/ThemeEngine.d.ts +16 -0
  40. package/dist/core/theme/ThemeEngine.d.ts.map +1 -0
  41. package/dist/core/theme/ThemeEngine.js +57 -0
  42. package/dist/core/theme/ThemeEngine.js.map +1 -0
  43. package/dist/core/theme/loaders/BuiltinLoader.d.ts +5 -0
  44. package/dist/core/theme/loaders/BuiltinLoader.d.ts.map +1 -0
  45. package/dist/core/theme/loaders/BuiltinLoader.js +37 -0
  46. package/dist/core/theme/loaders/BuiltinLoader.js.map +1 -0
  47. package/dist/core/theme/loaders/LocalLoader.d.ts +5 -0
  48. package/dist/core/theme/loaders/LocalLoader.d.ts.map +1 -0
  49. package/dist/core/theme/loaders/LocalLoader.js +20 -0
  50. package/dist/core/theme/loaders/LocalLoader.js.map +1 -0
  51. package/dist/core/theme/loaders/RemoteLoader.d.ts +11 -0
  52. package/dist/core/theme/loaders/RemoteLoader.d.ts.map +1 -0
  53. package/dist/core/theme/loaders/RemoteLoader.js +87 -0
  54. package/dist/core/theme/loaders/RemoteLoader.js.map +1 -0
  55. package/dist/core/theme/registry.d.ts +12 -0
  56. package/dist/core/theme/registry.d.ts.map +1 -0
  57. package/dist/core/theme/registry.js +30 -0
  58. package/dist/core/theme/registry.js.map +1 -0
  59. package/dist/core/wechat/WechatClient.d.ts +19 -0
  60. package/dist/core/wechat/WechatClient.d.ts.map +1 -0
  61. package/dist/core/wechat/WechatClient.js +29 -0
  62. package/dist/core/wechat/WechatClient.js.map +1 -0
  63. package/dist/core/wechat/api/DraftAPI.d.ts +18 -0
  64. package/dist/core/wechat/api/DraftAPI.d.ts.map +1 -0
  65. package/dist/core/wechat/api/DraftAPI.js +94 -0
  66. package/dist/core/wechat/api/DraftAPI.js.map +1 -0
  67. package/dist/core/wechat/api/MaterialAPI.d.ts +21 -0
  68. package/dist/core/wechat/api/MaterialAPI.d.ts.map +1 -0
  69. package/dist/core/wechat/api/MaterialAPI.js +74 -0
  70. package/dist/core/wechat/api/MaterialAPI.js.map +1 -0
  71. package/dist/core/wechat/api/PublishAPI.d.ts +15 -0
  72. package/dist/core/wechat/api/PublishAPI.d.ts.map +1 -0
  73. package/dist/core/wechat/api/PublishAPI.js +85 -0
  74. package/dist/core/wechat/api/PublishAPI.js.map +1 -0
  75. package/dist/core/wechat/api/TokenAPI.d.ts +14 -0
  76. package/dist/core/wechat/api/TokenAPI.d.ts.map +1 -0
  77. package/dist/core/wechat/api/TokenAPI.js +46 -0
  78. package/dist/core/wechat/api/TokenAPI.js.map +1 -0
  79. package/dist/core/wechat/constants.d.ts +28 -0
  80. package/dist/core/wechat/constants.d.ts.map +1 -0
  81. package/dist/core/wechat/constants.js +28 -0
  82. package/dist/core/wechat/constants.js.map +1 -0
  83. package/dist/errors/BaseError.d.ts +14 -0
  84. package/dist/errors/BaseError.d.ts.map +1 -0
  85. package/dist/errors/BaseError.js +23 -0
  86. package/dist/errors/BaseError.js.map +1 -0
  87. package/dist/errors/ThemeError.d.ts +11 -0
  88. package/dist/errors/ThemeError.d.ts.map +1 -0
  89. package/dist/errors/ThemeError.js +17 -0
  90. package/dist/errors/ThemeError.js.map +1 -0
  91. package/dist/errors/WechatError.d.ts +17 -0
  92. package/dist/errors/WechatError.d.ts.map +1 -0
  93. package/dist/errors/WechatError.js +24 -0
  94. package/dist/errors/WechatError.js.map +1 -0
  95. package/dist/index.d.ts +14 -0
  96. package/dist/index.d.ts.map +1 -0
  97. package/dist/index.js +14 -0
  98. package/dist/index.js.map +1 -0
  99. package/dist/infrastructure/cache/CacheStore.d.ts +16 -0
  100. package/dist/infrastructure/cache/CacheStore.d.ts.map +1 -0
  101. package/dist/infrastructure/cache/CacheStore.js +44 -0
  102. package/dist/infrastructure/cache/CacheStore.js.map +1 -0
  103. package/dist/infrastructure/cache/ImageCache.d.ts +11 -0
  104. package/dist/infrastructure/cache/ImageCache.d.ts.map +1 -0
  105. package/dist/infrastructure/cache/ImageCache.js +17 -0
  106. package/dist/infrastructure/cache/ImageCache.js.map +1 -0
  107. package/dist/infrastructure/cache/ThemeCache.d.ts +7 -0
  108. package/dist/infrastructure/cache/ThemeCache.d.ts.map +1 -0
  109. package/dist/infrastructure/cache/ThemeCache.js +13 -0
  110. package/dist/infrastructure/cache/ThemeCache.js.map +1 -0
  111. package/dist/infrastructure/cache/TokenCache.d.ts +11 -0
  112. package/dist/infrastructure/cache/TokenCache.d.ts.map +1 -0
  113. package/dist/infrastructure/cache/TokenCache.js +17 -0
  114. package/dist/infrastructure/cache/TokenCache.js.map +1 -0
  115. package/dist/infrastructure/config/ConfigStore.d.ts +14 -0
  116. package/dist/infrastructure/config/ConfigStore.d.ts.map +1 -0
  117. package/dist/infrastructure/config/ConfigStore.js +69 -0
  118. package/dist/infrastructure/config/ConfigStore.js.map +1 -0
  119. package/dist/infrastructure/http/HttpClient.d.ts +13 -0
  120. package/dist/infrastructure/http/HttpClient.d.ts.map +1 -0
  121. package/dist/infrastructure/http/HttpClient.js +53 -0
  122. package/dist/infrastructure/http/HttpClient.js.map +1 -0
  123. package/dist/infrastructure/logger/Logger.d.ts +9 -0
  124. package/dist/infrastructure/logger/Logger.d.ts.map +1 -0
  125. package/dist/infrastructure/logger/Logger.js +31 -0
  126. package/dist/infrastructure/logger/Logger.js.map +1 -0
  127. package/dist/services/AccountService.d.ts +16 -0
  128. package/dist/services/AccountService.d.ts.map +1 -0
  129. package/dist/services/AccountService.js +94 -0
  130. package/dist/services/AccountService.js.map +1 -0
  131. package/dist/services/DraftService.d.ts +21 -0
  132. package/dist/services/DraftService.d.ts.map +1 -0
  133. package/dist/services/DraftService.js +60 -0
  134. package/dist/services/DraftService.js.map +1 -0
  135. package/dist/services/PublishService.d.ts +18 -0
  136. package/dist/services/PublishService.d.ts.map +1 -0
  137. package/dist/services/PublishService.js +38 -0
  138. package/dist/services/PublishService.js.map +1 -0
  139. package/dist/services/RenderService.d.ts +17 -0
  140. package/dist/services/RenderService.d.ts.map +1 -0
  141. package/dist/services/RenderService.js +37 -0
  142. package/dist/services/RenderService.js.map +1 -0
  143. package/dist/services/ThemeService.d.ts +19 -0
  144. package/dist/services/ThemeService.d.ts.map +1 -0
  145. package/dist/services/ThemeService.js +104 -0
  146. package/dist/services/ThemeService.js.map +1 -0
  147. package/dist/types/account.d.ts +22 -0
  148. package/dist/types/account.d.ts.map +1 -0
  149. package/dist/types/account.js +2 -0
  150. package/dist/types/account.js.map +1 -0
  151. package/dist/types/common.d.ts +22 -0
  152. package/dist/types/common.d.ts.map +1 -0
  153. package/dist/types/common.js +2 -0
  154. package/dist/types/common.js.map +1 -0
  155. package/dist/types/config.d.ts +31 -0
  156. package/dist/types/config.d.ts.map +1 -0
  157. package/dist/types/config.js +2 -0
  158. package/dist/types/config.js.map +1 -0
  159. package/dist/types/draft.d.ts +40 -0
  160. package/dist/types/draft.d.ts.map +1 -0
  161. package/dist/types/draft.js +2 -0
  162. package/dist/types/draft.js.map +1 -0
  163. package/dist/types/publish.d.ts +40 -0
  164. package/dist/types/publish.d.ts.map +1 -0
  165. package/dist/types/publish.js +2 -0
  166. package/dist/types/publish.js.map +1 -0
  167. package/dist/types/theme.d.ts +29 -0
  168. package/dist/types/theme.d.ts.map +1 -0
  169. package/dist/types/theme.js +2 -0
  170. package/dist/types/theme.js.map +1 -0
  171. package/dist/utils/crypto.d.ts +5 -0
  172. package/dist/utils/crypto.d.ts.map +1 -0
  173. package/dist/utils/crypto.js +18 -0
  174. package/dist/utils/crypto.js.map +1 -0
  175. package/dist/utils/file.d.ts +7 -0
  176. package/dist/utils/file.d.ts.map +1 -0
  177. package/dist/utils/file.js +48 -0
  178. package/dist/utils/file.js.map +1 -0
  179. package/dist/utils/image.d.ts +6 -0
  180. package/dist/utils/image.d.ts.map +1 -0
  181. package/dist/utils/image.js +46 -0
  182. package/dist/utils/image.js.map +1 -0
  183. package/package.json +80 -0
  184. package/themes/builtin/default.css +128 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,392 @@
1
+ # Wechat-MD-Publisher
2
+
3
+ > 全功能微信公众号 Markdown 发布工具 - 让内容创作更简单
4
+
5
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)](https://www.typescriptlang.org/)
7
+ [![Node](https://img.shields.io/badge/Node-%3E%3D18-green.svg)](https://nodejs.org/)
8
+
9
+ ## ✨ 简介
10
+
11
+ `wechat-md-publisher` 是一个强大的微信公众号 Markdown 发布工具,让你用最熟悉的 Markdown 格式创作,一键发布到微信公众号。
12
+
13
+ **为什么选择它?**
14
+ - 🚀 **完整功能** - 草稿管理、发布管理、多账号支持,一应俱全
15
+ - 🎨 **精美主题** - 8 个内置主题,支持本地和远程自定义主题
16
+ - 🖼️ **智能处理** - 自动上传图片,MD5 缓存避免重复上传
17
+ - 💻 **双重接口** - CLI 命令行工具 + 完整编程 API
18
+ - ⚡ **高性能** - 多级缓存系统,Token、图片、主题全缓存
19
+ - 📦 **开箱即用** - 零配置启动,5 分钟上手
20
+
21
+ ## 🎯 核心特性
22
+
23
+ ### 完整的草稿管理
24
+ - 创建草稿(支持本地图片、网络图片)
25
+ - 列出草稿(分页查询)
26
+ - 删除草稿(单个/批量)
27
+ - 获取草稿总数
28
+
29
+ ### 完整的发布管理
30
+ - 发布草稿到微信公众号
31
+ - 创建并发布(一步到位)
32
+ - 列出已发布文章
33
+ - 删除已发布文章
34
+ - 查询发布状态
35
+
36
+ ### 8 个精美内置主题
37
+
38
+ 基于 [@wenyan-md/core](https://github.com/caol64/wenyan-core) 提供的精美主题:
39
+
40
+ | 主题 | 风格 | 适用场景 |
41
+ |------|------|----------|
42
+ | **default** | 简洁经典 | 通用、正式文章 |
43
+ | **orangeheart** | 温暖优雅 | 情感、生活类 |
44
+ | **rainbow** | 活泼清爽 | 轻松、趣味内容 |
45
+ | **lapis** | 清新极简 | 技术、专业内容 |
46
+ | **pie** | 现代锐利 | 产品、设计类 |
47
+ | **maize** | 柔和舒适 | 教育、知识分享 |
48
+ | **purple** | 简约文艺 | 个人博客、文艺 |
49
+ | **phycat** | 薄荷清新 | 科普、教程类 |
50
+
51
+ ### 智能图片处理
52
+ - 自动上传本地图片到微信素材库
53
+ - 自动下载并上传网络图片
54
+ - MD5 缓存机制,避免重复上传
55
+ - 自动选择封面图
56
+ - 支持微信图片 URL
57
+
58
+ ### 多账号管理
59
+ - 支持管理多个微信公众号
60
+ - 快速切换默认账号
61
+ - 账号信息安全存储
62
+
63
+ ## 🚀 快速开始
64
+
65
+ ### 1. 安装
66
+
67
+ ```bash
68
+ # 克隆项目
69
+ git clone https://github.com/sipingme/wechat-md-publisher.git
70
+ cd wechat-md-publisher
71
+
72
+ # 安装依赖
73
+ pnpm install
74
+
75
+ # 构建项目
76
+ pnpm build
77
+ ```
78
+
79
+ ### 2. 配置账号
80
+
81
+ ```bash
82
+ node dist/cli.js account add \
83
+ --name "我的公众号" \
84
+ --app-id wx_your_app_id \
85
+ --app-secret your_app_secret \
86
+ --default
87
+ ```
88
+
89
+ > 💡 **获取 AppID 和 AppSecret**:登录[微信公众平台](https://mp.weixin.qq.com/) → 设置与开发 → 基本配置
90
+
91
+ ### 3. 创建第一篇文章
92
+
93
+ 创建 `article.md`:
94
+
95
+ ```markdown
96
+ ---
97
+ title: 我的第一篇文章
98
+ author: 作者名
99
+ cover: ./cover.jpg
100
+ ---
101
+
102
+ # 欢迎使用 wechat-md-publisher
103
+
104
+ 这是一个全功能的微信公众号 Markdown 发布工具。
105
+
106
+ ## 主要特性
107
+
108
+ - 完整的草稿管理
109
+ - 完整的发布管理
110
+ - 8 个精美内置主题
111
+
112
+ ![示例图片](./example.jpg)
113
+ ```
114
+
115
+ ### 4. 发布文章
116
+
117
+ ```bash
118
+ # 方式一:创建草稿
119
+ node dist/cli.js draft create --file article.md --theme orangeheart
120
+
121
+ # 方式二:直接发布
122
+ node dist/cli.js publish create --file article.md --theme lapis
123
+ ```
124
+
125
+ ## 使用指南
126
+
127
+ ### CLI 命令
128
+
129
+ #### 账号管理
130
+
131
+ ```bash
132
+ # 添加账号
133
+ node dist/cli.js account add --name "公众号名" --app-id xxx --app-secret xxx --default
134
+
135
+ # 列出所有账号
136
+ node dist/cli.js account list
137
+
138
+ # 切换默认账号
139
+ node dist/cli.js account switch <account-id>
140
+
141
+ # 删除账号
142
+ node dist/cli.js account remove <account-id>
143
+ ```
144
+
145
+ #### 主题管理
146
+
147
+ ```bash
148
+ # 列出所有主题
149
+ node dist/cli.js theme list
150
+
151
+ # 添加本地主题
152
+ node dist/cli.js theme add-local --name my-theme --path ./my-theme.css
153
+
154
+ # 添加远程主题 API
155
+ node dist/cli.js theme add-remote --name md2wechat --url https://api.md2wechat.cn --key xxx
156
+
157
+ # 删除主题
158
+ node dist/cli.js theme remove <theme-id>
159
+ ```
160
+
161
+ #### 草稿管理
162
+
163
+ ```bash
164
+ # 创建草稿
165
+ node dist/cli.js draft create --file article.md --theme orangeheart
166
+
167
+ # 列出草稿
168
+ node dist/cli.js draft list --page 1 --size 20
169
+
170
+ # 删除草稿
171
+ node dist/cli.js draft delete <media-id>
172
+
173
+ # 查看草稿总数
174
+ node dist/cli.js draft count
175
+ ```
176
+
177
+ #### 发布管理
178
+
179
+ ```bash
180
+ # 发布草稿
181
+ node dist/cli.js publish submit <media-id>
182
+
183
+ # 创建并发布(一步到位)
184
+ node dist/cli.js publish create --file article.md --theme lapis
185
+
186
+ # 列出已发布文章
187
+ node dist/cli.js publish list
188
+
189
+ # 删除已发布文章
190
+ node dist/cli.js publish delete <article-id>
191
+
192
+ # 查询发布状态
193
+ node dist/cli.js publish status <publish-id>
194
+ ```
195
+
196
+ ### 编程 API
197
+
198
+ ```typescript
199
+ import { container } from 'wechat-md-publisher';
200
+
201
+ // 初始化
202
+ await container.initialize();
203
+
204
+ // 添加账号
205
+ const accountService = container.getAccountService();
206
+ await accountService.addAccount({
207
+ name: '我的公众号',
208
+ appId: 'wx123',
209
+ appSecret: 'secret',
210
+ isDefault: true,
211
+ });
212
+
213
+ // 创建并发布
214
+ const publishService = await container.getPublishService();
215
+ const result = await publishService.createAndPublish({
216
+ file: './article.md',
217
+ theme: 'orangeheart',
218
+ });
219
+
220
+ console.log('发布成功:', result.publish_id);
221
+ ```
222
+
223
+ ### 自定义主题
224
+
225
+ 创建 `my-theme.css`:
226
+
227
+ ```css
228
+ :root {
229
+ --primary-color: #ff6b6b;
230
+ --text-color: #2c3e50;
231
+ }
232
+
233
+ #wenyan {
234
+ font-size: 16px;
235
+ line-height: 1.8;
236
+ color: var(--text-color);
237
+ }
238
+
239
+ #wenyan h1 {
240
+ font-size: 24px;
241
+ color: var(--primary-color);
242
+ border-bottom: 3px solid var(--primary-color);
243
+ }
244
+
245
+ #wenyan h2 {
246
+ font-size: 20px;
247
+ padding-left: 10px;
248
+ border-left: 4px solid var(--primary-color);
249
+ }
250
+ ```
251
+
252
+ 添加主题:
253
+
254
+ ```bash
255
+ node dist/cli.js theme add-local --name my-theme --path ./my-theme.css
256
+ ```
257
+
258
+ 使用主题:
259
+
260
+ ```bash
261
+ node dist/cli.js draft create --file article.md --theme my-theme
262
+ ```
263
+
264
+ ## 🏗️ 项目架构
265
+
266
+ ```
267
+ ┌─────────────────────────────────────────┐
268
+ │ CLI Layer (CLI 层) │
269
+ │ Commander.js + Ora + Chalk + Table │
270
+ └─────────────────────────────────────────┘
271
+
272
+ ┌─────────────────────────────────────────┐
273
+ │ Service Layer (服务层) │
274
+ │ Account │ Theme │ Draft │ Publish │
275
+ └─────────────────────────────────────────┘
276
+
277
+ ┌─────────────────────────────────────────┐
278
+ │ Core Layer (核心层) │
279
+ │ WechatClient │ ThemeEngine │ Renderer │
280
+ └─────────────────────────────────────────┘
281
+
282
+ ┌─────────────────────────────────────────┐
283
+ │ Infrastructure (基础设施层) │
284
+ │ Config │ Cache │ Logger │ HttpClient │
285
+ └─────────────────────────────────────────┘
286
+ ```
287
+
288
+ **分层设计**:
289
+ - **CLI 层** - 用户交互界面
290
+ - **服务层** - 业务逻辑编排
291
+ - **核心层** - 核心功能实现
292
+ - **基础设施层** - 基础功能支持
293
+
294
+ ## 🛠️ 技术栈
295
+
296
+ - **语言**: TypeScript 5.0
297
+ - **构建**: Vite
298
+ - **CLI**: Commander.js + Ora + Chalk + cli-table3
299
+ - **配置**: Conf + Zod
300
+ - **HTTP**: Axios
301
+ - **日志**: Winston
302
+ - **渲染**: [@wenyan-md/core](https://github.com/caol64/wenyan-core)
303
+ - **测试**: Vitest
304
+
305
+ ## ⚙️ 配置说明
306
+
307
+ ### 配置文件位置
308
+
309
+ - **macOS**: `~/Library/Preferences/wechat-md-publisher-nodejs/config.json`
310
+ - **Linux**: `~/.config/wechat-md-publisher-nodejs/config.json`
311
+ - **Windows**: `%APPDATA%\wechat-md-publisher-nodejs\Config\config.json`
312
+
313
+ ### 微信公众号配置
314
+
315
+ 1. 登录[微信公众平台](https://mp.weixin.qq.com/)
316
+ 2. 进入「设置与开发」→「基本配置」
317
+ 3. 获取「开发者ID(AppID)」和「开发者密码(AppSecret)」
318
+ 4. 将服务器 IP 地址添加到「IP白名单」
319
+
320
+ > 📖 详细配置说明:https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Getting_Started_Guide.html
321
+
322
+ ## 🎨 主题说明
323
+
324
+ ### 内置主题来源
325
+
326
+ 本项目的 8 个精美内置主题来自 [@wenyan-md/core](https://github.com/caol64/wenyan-core),这是一个优秀的微信公众号 Markdown 渲染引擎。
327
+
328
+ ### 主题预览
329
+
330
+ 使用不同主题查看效果:
331
+
332
+ ```bash
333
+ # 测试所有主题
334
+ for theme in default orangeheart rainbow lapis pie maize purple phycat; do
335
+ echo "Testing theme: $theme"
336
+ node dist/cli.js draft create --file article.md --theme $theme
337
+ done
338
+ ```
339
+
340
+ ## 🐛 常见问题
341
+
342
+ ### 1. Token 过期
343
+
344
+ Token 会自动刷新,如遇问题请重新配置账号。
345
+
346
+ ### 2. 图片上传失败
347
+
348
+ - 检查图片路径是否正确
349
+ - 确保图片大小不为 0
350
+ - 检查服务器 IP 是否在白名单中
351
+
352
+ ### 3. 找不到主题
353
+
354
+ 使用 `node dist/cli.js theme list` 查看可用主题。
355
+
356
+ ### 4. 依赖安装失败
357
+
358
+ ```bash
359
+ # 清理缓存
360
+ rm -rf node_modules pnpm-lock.yaml
361
+
362
+ # 重新安装
363
+ pnpm install
364
+ ```
365
+
366
+ ## 🙏 致谢
367
+
368
+ 本项目的开发受到以下优秀项目的启发和支持:
369
+
370
+ - **[@wenyan-md/core](https://github.com/caol64/wenyan-core)** - 提供了强大的 Markdown 渲染引擎和 8 个精美的内置主题,是本项目的核心依赖
371
+ - **[wenyan-cli](https://github.com/caol64/wenyan-cli)** - 提供了优秀的 CLI 设计思路和用户体验参考
372
+
373
+
374
+ ## 📞 联系方式
375
+
376
+ - **作者**: sipingme@gmail.com
377
+ - **GitHub**: https://github.com/sipingme/wechat-md-publisher
378
+ - **Issues**: https://github.com/sipingme/wechat-md-publisher/issues
379
+
380
+ ## 📄 开源协议
381
+
382
+ Apache License 2.0
383
+
384
+ Copyright (c) 2026 sipingme@gmail.com
385
+
386
+ ## 🌟 Star History
387
+
388
+ 如果这个项目对你有帮助,欢迎 Star ⭐️
389
+
390
+ ---
391
+
392
+ **让 Markdown 写作更简单,让内容发布更高效!** 🚀