multi-publisher 1.0.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.
- package/LICENSE +21 -0
- package/README.md +370 -0
- package/dist/adapters/baijiahao.d.ts +14 -0
- package/dist/adapters/baijiahao.js +77 -0
- package/dist/adapters/base-adapter.d.ts +41 -0
- package/dist/adapters/base-adapter.js +84 -0
- package/dist/adapters/bilibili.d.ts +14 -0
- package/dist/adapters/bilibili.js +86 -0
- package/dist/adapters/cnblogs.d.ts +14 -0
- package/dist/adapters/cnblogs.js +90 -0
- package/dist/adapters/csdn.d.ts +29 -0
- package/dist/adapters/csdn.js +174 -0
- package/dist/adapters/cto51.d.ts +14 -0
- package/dist/adapters/cto51.js +72 -0
- package/dist/adapters/douban.d.ts +14 -0
- package/dist/adapters/douban.js +49 -0
- package/dist/adapters/eastmoney.d.ts +14 -0
- package/dist/adapters/eastmoney.js +47 -0
- package/dist/adapters/imooc.d.ts +14 -0
- package/dist/adapters/imooc.js +78 -0
- package/dist/adapters/index.d.ts +26 -0
- package/dist/adapters/index.js +22 -0
- package/dist/adapters/interface.d.ts +44 -0
- package/dist/adapters/interface.js +1 -0
- package/dist/adapters/juejin.d.ts +23 -0
- package/dist/adapters/juejin.js +166 -0
- package/dist/adapters/oschina.d.ts +14 -0
- package/dist/adapters/oschina.js +77 -0
- package/dist/adapters/registry.d.ts +61 -0
- package/dist/adapters/registry.js +146 -0
- package/dist/adapters/segmentfault.d.ts +14 -0
- package/dist/adapters/segmentfault.js +73 -0
- package/dist/adapters/sohu.d.ts +14 -0
- package/dist/adapters/sohu.js +72 -0
- package/dist/adapters/toutiao.d.ts +9 -0
- package/dist/adapters/toutiao.js +199 -0
- package/dist/adapters/wechat-publisher.d.ts +55 -0
- package/dist/adapters/wechat-publisher.js +210 -0
- package/dist/adapters/weibo.d.ts +14 -0
- package/dist/adapters/weibo.js +99 -0
- package/dist/adapters/weixin.d.ts +14 -0
- package/dist/adapters/weixin.js +63 -0
- package/dist/adapters/woshipm.d.ts +14 -0
- package/dist/adapters/woshipm.js +72 -0
- package/dist/adapters/xiaohongshu.d.ts +9 -0
- package/dist/adapters/xiaohongshu.js +199 -0
- package/dist/adapters/xueqiu.d.ts +14 -0
- package/dist/adapters/xueqiu.js +74 -0
- package/dist/adapters/yuque.d.ts +13 -0
- package/dist/adapters/yuque.js +25 -0
- package/dist/adapters/zhihu.d.ts +23 -0
- package/dist/adapters/zhihu.js +142 -0
- package/dist/cli/cookie.d.ts +5 -0
- package/dist/cli/cookie.js +80 -0
- package/dist/cli/credential.d.ts +6 -0
- package/dist/cli/credential.js +32 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +72 -0
- package/dist/cli/login.d.ts +3 -0
- package/dist/cli/login.js +101 -0
- package/dist/cli/platforms.d.ts +1 -0
- package/dist/cli/platforms.js +35 -0
- package/dist/cli/publish-all.d.ts +6 -0
- package/dist/cli/publish-all.js +101 -0
- package/dist/cli/publish.d.ts +7 -0
- package/dist/cli/publish.js +78 -0
- package/dist/cli/render.d.ts +9 -0
- package/dist/cli/render.js +40 -0
- package/dist/commands/login.d.ts +43 -0
- package/dist/commands/login.js +248 -0
- package/dist/commands/publish.d.ts +19 -0
- package/dist/commands/publish.js +275 -0
- package/dist/config.d.ts +177 -0
- package/dist/config.js +333 -0
- package/dist/core/mathjax.d.ts +4 -0
- package/dist/core/mathjax.js +33 -0
- package/dist/core/parser.d.ts +17 -0
- package/dist/core/parser.js +42 -0
- package/dist/core/renderer.d.ts +18 -0
- package/dist/core/renderer.js +30 -0
- package/dist/core/styler.d.ts +8 -0
- package/dist/core/styler.js +11 -0
- package/dist/core/theme.d.ts +9 -0
- package/dist/core/theme.js +420 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +7 -0
- package/dist/runtime/browser-runtime.d.ts +79 -0
- package/dist/runtime/browser-runtime.js +501 -0
- package/dist/runtime/index.d.ts +12 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/node-runtime.d.ts +5 -0
- package/dist/runtime/node-runtime.js +25 -0
- package/dist/tools/xiaohongshu-sniffer.d.ts +1 -0
- package/dist/tools/xiaohongshu-sniffer.js +54 -0
- package/package.json +62 -0
- package/themes/all-themes-preview.html +522 -0
- package/themes/previews/cyberpunk.png +0 -0
- package/themes/previews/minimal.png +0 -0
- package/themes/previews/nord.png +0 -0
- package/themes/previews/wechat.png +0 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* publish 命令
|
|
3
|
+
*
|
|
4
|
+
* 工作流程:
|
|
5
|
+
* 1. 解析 MD 文件(frontmatter + 内容)
|
|
6
|
+
* 2. 构建 Article 对象
|
|
7
|
+
* 3. 为每个目标平台选择适配器
|
|
8
|
+
* 4. 调用适配器发布
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
11
|
+
import { extname, basename } from 'node:path';
|
|
12
|
+
import { NodeRuntime } from '../runtime/node-runtime.js';
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Frontmatter 解析(简易版,不依赖 gray-matter)
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
function parseFrontmatter(content) {
|
|
17
|
+
const lines = content.split('\n');
|
|
18
|
+
if (lines[0]?.trim() !== '---') {
|
|
19
|
+
return { data: {}, body: content };
|
|
20
|
+
}
|
|
21
|
+
const fenceIdx = lines.findIndex((l, i) => i > 0 && l.trim() === '---');
|
|
22
|
+
if (fenceIdx === -1) {
|
|
23
|
+
return { data: {}, body: content };
|
|
24
|
+
}
|
|
25
|
+
const yamlLines = lines.slice(1, fenceIdx);
|
|
26
|
+
const body = lines.slice(fenceIdx + 1).join('\n').trim();
|
|
27
|
+
// 简单 YAML 解析(支持 key: value)
|
|
28
|
+
const data = {};
|
|
29
|
+
for (const line of yamlLines) {
|
|
30
|
+
const colonIdx = line.indexOf(':');
|
|
31
|
+
if (colonIdx === -1)
|
|
32
|
+
continue;
|
|
33
|
+
const key = line.slice(0, colonIdx).trim();
|
|
34
|
+
const value = line.slice(colonIdx + 1).trim();
|
|
35
|
+
data[key] = value.replace(/^["']|["']$/g, '');
|
|
36
|
+
}
|
|
37
|
+
return { data, body };
|
|
38
|
+
}
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// MD 文件解析
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
function parseMarkdownFile(filePath) {
|
|
43
|
+
if (!existsSync(filePath)) {
|
|
44
|
+
throw new Error(`文件不存在: ${filePath}`);
|
|
45
|
+
}
|
|
46
|
+
const raw = readFileSync(filePath, 'utf-8');
|
|
47
|
+
const { data: frontmatter, body } = parseFrontmatter(raw);
|
|
48
|
+
// 提取标题:优先 frontmatter.title,其次文件第一个 # 标题
|
|
49
|
+
const title = frontmatter.title
|
|
50
|
+
|| extractFirstHeading(body)
|
|
51
|
+
|| basename(filePath, extname(filePath));
|
|
52
|
+
// 提取标签(支持 yaml 数组和逗号分隔字符串)
|
|
53
|
+
let tags = [];
|
|
54
|
+
if (frontmatter.tags) {
|
|
55
|
+
if (Array.isArray(frontmatter.tags)) {
|
|
56
|
+
tags = frontmatter.tags.map(String);
|
|
57
|
+
}
|
|
58
|
+
else if (typeof frontmatter.tags === 'string') {
|
|
59
|
+
tags = frontmatter.tags.split(/[,,]/).map(t => t.trim()).filter(Boolean);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// 摘要:优先 frontmatter.summary,其次取正文前 200 字
|
|
63
|
+
const summary = frontmatter.summary
|
|
64
|
+
|| body.replace(/[#*`\[\]]/g, '').slice(0, 200).trim() + '...';
|
|
65
|
+
const article = {
|
|
66
|
+
title,
|
|
67
|
+
markdown: body,
|
|
68
|
+
summary,
|
|
69
|
+
tags,
|
|
70
|
+
cover: frontmatter.cover,
|
|
71
|
+
};
|
|
72
|
+
return article;
|
|
73
|
+
}
|
|
74
|
+
function extractFirstHeading(md) {
|
|
75
|
+
for (const line of md.split('\n')) {
|
|
76
|
+
const m = line.match(/^#{1,6}\s+(.+)/);
|
|
77
|
+
if (m)
|
|
78
|
+
return m[1].trim();
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// 微信公众号渲染(复用 wenyan-cli 的核心逻辑)
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
async function renderForWeixin(article, theme) {
|
|
86
|
+
// 延迟导入,避免 @wenyan-md/core 未安装时整个 CLI 无法启动
|
|
87
|
+
let render;
|
|
88
|
+
try {
|
|
89
|
+
// @wenyan-md/core 导出的是渲染好的 HTML
|
|
90
|
+
// 这里我们直接模拟一个简化版渲染(实际项目应 import 真实模块)
|
|
91
|
+
const { prepareRenderContext } = await import('@wenyan-md/core').catch(() => null);
|
|
92
|
+
if (prepareRenderContext) {
|
|
93
|
+
// 实际使用需要 getInputContent 等回调
|
|
94
|
+
// 简化:用 marked + juice 代替
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// core 未安装,使用内置简化渲染
|
|
99
|
+
}
|
|
100
|
+
// 内置简化渲染(fallback)
|
|
101
|
+
return renderMarkdownFallback(article.markdown);
|
|
102
|
+
}
|
|
103
|
+
function renderMarkdownFallback(md) {
|
|
104
|
+
// 使用 Node 内置的高版本 String.prototype 用replaceAll + 简易转义
|
|
105
|
+
// 实际项目建议用 marked + highlight.js
|
|
106
|
+
let html = md
|
|
107
|
+
// 标题
|
|
108
|
+
.replace(/^### (.+)$/gm, '<h3>$1</h3>')
|
|
109
|
+
.replace(/^## (.+)$/gm, '<h2>$1</h2>')
|
|
110
|
+
.replace(/^# (.+)$/gm, '<h1>$1</h1>')
|
|
111
|
+
// 粗体斜体
|
|
112
|
+
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
|
|
113
|
+
.replace(/\*(.+?)\*/g, '<em>$1</em>')
|
|
114
|
+
// 代码块
|
|
115
|
+
.replace(/```[\s\S]*?```/g, (m) => {
|
|
116
|
+
const code = m.replace(/```\w*\n?/, '').replace(/```$/, '');
|
|
117
|
+
return `<pre><code>${code.replace(/</g, '<').replace(/>/g, '>')}</code></pre>`;
|
|
118
|
+
})
|
|
119
|
+
// 行内代码
|
|
120
|
+
.replace(/`([^`]+)`/g, '<code>$1</code>')
|
|
121
|
+
// 链接
|
|
122
|
+
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>')
|
|
123
|
+
// 图片
|
|
124
|
+
.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1"/>')
|
|
125
|
+
// 换行
|
|
126
|
+
.replace(/\n\n/g, '</p><p>');
|
|
127
|
+
// 段落包装
|
|
128
|
+
return `<p>${html}</p>`;
|
|
129
|
+
}
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
// 发布到微信公众号(AppID + AppSecret)
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
async function publishWeixin(article, appId, appSecret, draft) {
|
|
134
|
+
console.log('[Weixin] 开始发布到微信公众号...');
|
|
135
|
+
// 1. 获取 Access Token
|
|
136
|
+
const tokenUrl = `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appId}&secret=${appSecret}`;
|
|
137
|
+
const tokenResp = await fetch(tokenUrl);
|
|
138
|
+
const tokenData = await tokenResp.json();
|
|
139
|
+
if (!tokenData.access_token) {
|
|
140
|
+
throw new Error(`获取 Access Token 失败: ${JSON.stringify(tokenData)}`);
|
|
141
|
+
}
|
|
142
|
+
const accessToken = tokenData.access_token;
|
|
143
|
+
console.log('[Weixin] ✓ Access Token 获取成功');
|
|
144
|
+
// 2. 渲染 HTML
|
|
145
|
+
const content = await renderForWeixin(article, 'default');
|
|
146
|
+
// 3. 新建草稿(微信不支持直接发布,只能先创建草稿)
|
|
147
|
+
const draftReq = await fetch(`https://api.weixin.qq.com/cgi-bin/draft/add?access_token=${accessToken}`, {
|
|
148
|
+
method: 'POST',
|
|
149
|
+
headers: { 'Content-Type': 'application/json' },
|
|
150
|
+
body: JSON.stringify({
|
|
151
|
+
articles: [
|
|
152
|
+
{
|
|
153
|
+
title: article.title,
|
|
154
|
+
author: '',
|
|
155
|
+
digest: article.summary?.slice(0, 54) ?? '',
|
|
156
|
+
content: content,
|
|
157
|
+
content_source_url: '',
|
|
158
|
+
thumb_media_id: '',
|
|
159
|
+
need_open_comment: 1,
|
|
160
|
+
only_fans_can_comment: 0,
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
}),
|
|
164
|
+
});
|
|
165
|
+
const draftData = await draftReq.json();
|
|
166
|
+
if (draftData.media_id) {
|
|
167
|
+
console.log(`[Weixin] ✓ 草稿创建成功,Media ID: ${draftData.media_id}`);
|
|
168
|
+
if (!draft) {
|
|
169
|
+
console.log('[Weixin] 注意:微信平台只能保存草稿,请在手机端预览并发布');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
throw new Error(`创建草稿失败: ${JSON.stringify(draftData)}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
// 发布到其他平台(Cookie 认证)
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
async function publishWithCookies(article, platformId) {
|
|
180
|
+
console.log(`[${platformId}] 开始发布...`);
|
|
181
|
+
// 1. 创建 Node Runtime
|
|
182
|
+
const runtime = new NodeRuntime({ timeout: 30000 });
|
|
183
|
+
// 2. 获取适配器
|
|
184
|
+
let AdapterClass;
|
|
185
|
+
try {
|
|
186
|
+
const { getAdapter } = await import('@wechatsync/core').catch(() => ({ getAdapter: null }));
|
|
187
|
+
if (!getAdapter)
|
|
188
|
+
throw new Error('wechatsync core 未安装');
|
|
189
|
+
AdapterClass = getAdapter(platformId);
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
throw new Error(`不支持的平台: ${platformId},请确认已安装 @wechatsync/core 且平台可用`);
|
|
193
|
+
}
|
|
194
|
+
if (!AdapterClass) {
|
|
195
|
+
throw new Error(`不支持的平台: ${platformId}`);
|
|
196
|
+
}
|
|
197
|
+
// 3. 实例化并发布
|
|
198
|
+
const adapter = new AdapterClass();
|
|
199
|
+
await adapter.init(runtime);
|
|
200
|
+
// 4. 检查认证
|
|
201
|
+
const auth = await adapter.checkAuth();
|
|
202
|
+
if (!auth.isAuthenticated) {
|
|
203
|
+
throw new Error(`[${platformId}] 未登录或 Cookie 已过期,请运行: mpub login --platform ${platformId}`);
|
|
204
|
+
}
|
|
205
|
+
console.log(`[${platformId}] ✓ 已认证: ${auth.username ?? auth.userId}`);
|
|
206
|
+
// 5. 发布
|
|
207
|
+
const result = await adapter.publish(article, { draftOnly: false });
|
|
208
|
+
if (result.success) {
|
|
209
|
+
console.log(`[${platformId}] ✓ 发布成功: ${result.postUrl ?? result.postId}`);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
throw new Error(`[${platformId}] 发布失败: ${result.error}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// ---------------------------------------------------------------------------
|
|
216
|
+
// 主命令
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
export async function publishCommand(opts) {
|
|
219
|
+
const platforms = opts.platforms.split(',').map(p => p.trim()).filter(Boolean);
|
|
220
|
+
console.log(`\n=== multi-publisher ===`);
|
|
221
|
+
console.log(`文件: ${opts.file}`);
|
|
222
|
+
console.log(`平台: ${platforms.join(', ')}`);
|
|
223
|
+
console.log(`Dry Run: ${opts.dryRun ?? false}`);
|
|
224
|
+
console.log();
|
|
225
|
+
// 解析 MD
|
|
226
|
+
let article;
|
|
227
|
+
try {
|
|
228
|
+
article = parseMarkdownFile(opts.file);
|
|
229
|
+
console.log(`标题: ${article.title}`);
|
|
230
|
+
console.log(`标签: ${article.tags?.join(', ') ?? '无'}`);
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
console.error(`解析 Markdown 文件失败: ${err}`);
|
|
234
|
+
process.exit(1);
|
|
235
|
+
}
|
|
236
|
+
if (opts.dryRun) {
|
|
237
|
+
console.log('\n[Dry Run] 渲染结果预览:');
|
|
238
|
+
const html = renderMarkdownFallback(article.markdown);
|
|
239
|
+
console.log(html.slice(0, 500));
|
|
240
|
+
console.log('\n(dry-run 模式,未实际发布)');
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
// 发布到各平台
|
|
244
|
+
const results = [];
|
|
245
|
+
for (const platformId of platforms) {
|
|
246
|
+
try {
|
|
247
|
+
if (platformId === 'weixin') {
|
|
248
|
+
if (!opts.appId || !opts.appSecret) {
|
|
249
|
+
console.log('[Weixin] 提示:使用 --app-id 和 --app-secret 指定微信公众号凭据');
|
|
250
|
+
console.log(' 或设置环境变量 WX_APP_ID, WX_APP_SECRET');
|
|
251
|
+
}
|
|
252
|
+
const appId = opts.appId ?? process.env.WX_APP_ID ?? '';
|
|
253
|
+
const appSecret = opts.appSecret ?? process.env.WX_APP_SECRET ?? '';
|
|
254
|
+
await publishWeixin(article, appId, appSecret, opts.draft ?? false);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
await publishWithCookies(article, platformId);
|
|
258
|
+
}
|
|
259
|
+
results.push({ platform: platformId, success: true });
|
|
260
|
+
}
|
|
261
|
+
catch (err) {
|
|
262
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
263
|
+
console.error(`[${platformId}] ✗ 失败: ${msg}`);
|
|
264
|
+
results.push({ platform: platformId, success: false, error: msg });
|
|
265
|
+
}
|
|
266
|
+
console.log();
|
|
267
|
+
}
|
|
268
|
+
// 汇总
|
|
269
|
+
const ok = results.filter(r => r.success).length;
|
|
270
|
+
const fail = results.filter(r => !r.success).length;
|
|
271
|
+
console.log(`=== 发布完成: ${ok} 成功,${fail} 失败 ===`);
|
|
272
|
+
if (fail > 0) {
|
|
273
|
+
process.exit(1);
|
|
274
|
+
}
|
|
275
|
+
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
export interface WeixinConfig {
|
|
2
|
+
appId?: string;
|
|
3
|
+
appSecret?: string;
|
|
4
|
+
access_token?: string;
|
|
5
|
+
token_expires_at?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ZhihuConfig {
|
|
8
|
+
cookies?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface JuejinConfig {
|
|
11
|
+
cookies?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export interface CSDNConfig {
|
|
14
|
+
cookies?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
export interface ToutiaoConfig {
|
|
17
|
+
cookies?: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
export interface JianshuConfig {
|
|
20
|
+
cookies?: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
export interface WeiboConfig {
|
|
23
|
+
cookies?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
export interface XiaohongshuConfig {
|
|
26
|
+
cookies?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface BaijiahaoConfig {
|
|
29
|
+
cookies?: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
export interface BilibiliConfig {
|
|
32
|
+
cookies?: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
export interface SegmentfaultConfig {
|
|
35
|
+
cookies?: Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
export interface CnblogsConfig {
|
|
38
|
+
cookies?: Record<string, string>;
|
|
39
|
+
}
|
|
40
|
+
export interface OschinaConfig {
|
|
41
|
+
cookies?: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
export interface ImoocConfig {
|
|
44
|
+
cookies?: Record<string, string>;
|
|
45
|
+
}
|
|
46
|
+
export interface Cto51Config {
|
|
47
|
+
cookies?: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
export interface YueqiuConfig {
|
|
50
|
+
cookies?: Record<string, string>;
|
|
51
|
+
}
|
|
52
|
+
export interface WoshipmConfig {
|
|
53
|
+
cookies?: Record<string, string>;
|
|
54
|
+
}
|
|
55
|
+
export interface DoubanConfig {
|
|
56
|
+
cookies?: Record<string, string>;
|
|
57
|
+
}
|
|
58
|
+
export interface SohuConfig {
|
|
59
|
+
cookies?: Record<string, string>;
|
|
60
|
+
}
|
|
61
|
+
export interface EastmoneyConfig {
|
|
62
|
+
cookies?: Record<string, string>;
|
|
63
|
+
}
|
|
64
|
+
export interface GlobalConfig {
|
|
65
|
+
version: number;
|
|
66
|
+
weixin?: WeixinConfig;
|
|
67
|
+
zhihu?: ZhihuConfig;
|
|
68
|
+
juejin?: JuejinConfig;
|
|
69
|
+
csdn?: CSDNConfig;
|
|
70
|
+
toutiao?: ToutiaoConfig;
|
|
71
|
+
jianshu?: JianshuConfig;
|
|
72
|
+
weibo?: WeiboConfig;
|
|
73
|
+
xiaohongshu?: XiaohongshuConfig;
|
|
74
|
+
baijiahao?: BaijiahaoConfig;
|
|
75
|
+
bilibili?: BilibiliConfig;
|
|
76
|
+
segmentfault?: SegmentfaultConfig;
|
|
77
|
+
cnblogs?: CnblogsConfig;
|
|
78
|
+
oschina?: OschinaConfig;
|
|
79
|
+
imooc?: ImoocConfig;
|
|
80
|
+
cto51?: Cto51Config;
|
|
81
|
+
yueqiu?: YueqiuConfig;
|
|
82
|
+
woshipm?: WoshipmConfig;
|
|
83
|
+
douban?: DoubanConfig;
|
|
84
|
+
sohu?: SohuConfig;
|
|
85
|
+
eastmoney?: EastmoneyConfig;
|
|
86
|
+
}
|
|
87
|
+
/** 读取配置(带缓存) */
|
|
88
|
+
export declare function loadConfig(): Promise<GlobalConfig>;
|
|
89
|
+
/** 原子更新配置(读取-修改-写入) */
|
|
90
|
+
export declare function updateConfig(updater: (c: GlobalConfig) => void): Promise<void>;
|
|
91
|
+
/** 迁移旧版分散文件到 config.json */
|
|
92
|
+
export declare function migrateLegacyConfig(): Promise<boolean>;
|
|
93
|
+
/** 统一配置管理器(各平台 publisher 内部使用) */
|
|
94
|
+
export declare class ConfigStore {
|
|
95
|
+
/** 获取微信配置 */
|
|
96
|
+
static getWeixin(): Promise<WeixinConfig>;
|
|
97
|
+
/** 更新微信配置 */
|
|
98
|
+
static setWeixin(update: Partial<WeixinConfig>): Promise<void>;
|
|
99
|
+
/** 获取知乎 Cookie */
|
|
100
|
+
static getZhihuCookies(): Promise<Record<string, string> | null>;
|
|
101
|
+
/** 设置知乎 Cookie */
|
|
102
|
+
static setZhihuCookies(cookies: Record<string, string>): Promise<void>;
|
|
103
|
+
/** 获取掘金 Cookie */
|
|
104
|
+
static getJuejinCookies(): Promise<Record<string, string> | null>;
|
|
105
|
+
/** 设置掘金 Cookie */
|
|
106
|
+
static setJuejinCookies(cookies: Record<string, string>): Promise<void>;
|
|
107
|
+
/** 获取 CSDN Cookie */
|
|
108
|
+
static getCSDNCookies(): Promise<Record<string, string> | null>;
|
|
109
|
+
/** 设置 CSDN Cookie */
|
|
110
|
+
static setCSDNCookies(cookies: Record<string, string>): Promise<void>;
|
|
111
|
+
/** 获取头条号 Cookie */
|
|
112
|
+
static getToutiaoCookies(): Promise<Record<string, string> | null>;
|
|
113
|
+
/** 设置头条号 Cookie */
|
|
114
|
+
static setToutiaoCookies(cookies: Record<string, string>): Promise<void>;
|
|
115
|
+
/** 获取简书 Cookie */
|
|
116
|
+
static getJianshuCookies(): Promise<Record<string, string> | null>;
|
|
117
|
+
/** 设置简书 Cookie */
|
|
118
|
+
static setJianshuCookies(cookies: Record<string, string>): Promise<void>;
|
|
119
|
+
/** 获取微博 Cookie */
|
|
120
|
+
static getWeiboCookies(): Promise<Record<string, string> | null>;
|
|
121
|
+
/** 设置微博 Cookie */
|
|
122
|
+
static setWeiboCookies(cookies: Record<string, string>): Promise<void>;
|
|
123
|
+
/** 获取小红书 Cookie */
|
|
124
|
+
static getXiaohongshuCookies(): Promise<Record<string, string> | null>;
|
|
125
|
+
/** 设置小红书 Cookie */
|
|
126
|
+
static setXiaohongshuCookies(cookies: Record<string, string>): Promise<void>;
|
|
127
|
+
/** 获取百家号 Cookie */
|
|
128
|
+
static getBaijiahaoCookies(): Promise<Record<string, string> | null>;
|
|
129
|
+
/** 设置百家号 Cookie */
|
|
130
|
+
static setBaijiahaoCookies(cookies: Record<string, string>): Promise<void>;
|
|
131
|
+
/** 获取B站 Cookie */
|
|
132
|
+
static getBilibiliCookies(): Promise<Record<string, string> | null>;
|
|
133
|
+
/** 设置B站 Cookie */
|
|
134
|
+
static setBilibiliCookies(cookies: Record<string, string>): Promise<void>;
|
|
135
|
+
/** 获取思否 Cookie */
|
|
136
|
+
static getSegmentfaultCookies(): Promise<Record<string, string> | null>;
|
|
137
|
+
/** 设置思否 Cookie */
|
|
138
|
+
static setSegmentfaultCookies(cookies: Record<string, string>): Promise<void>;
|
|
139
|
+
/** 获取博客园 Cookie */
|
|
140
|
+
static getCnblogsCookies(): Promise<Record<string, string> | null>;
|
|
141
|
+
/** 设置博客园 Cookie */
|
|
142
|
+
static setCnblogsCookies(cookies: Record<string, string>): Promise<void>;
|
|
143
|
+
/** 获取开源中国 Cookie */
|
|
144
|
+
static getOschinaCookies(): Promise<Record<string, string> | null>;
|
|
145
|
+
/** 设置开源中国 Cookie */
|
|
146
|
+
static setOschinaCookies(cookies: Record<string, string>): Promise<void>;
|
|
147
|
+
/** 获取慕课网 Cookie */
|
|
148
|
+
static getImoocCookies(): Promise<Record<string, string> | null>;
|
|
149
|
+
/** 设置慕课网 Cookie */
|
|
150
|
+
static setImoocCookies(cookies: Record<string, string>): Promise<void>;
|
|
151
|
+
/** 获取 51CTO Cookie */
|
|
152
|
+
static getCto51Cookies(): Promise<Record<string, string> | null>;
|
|
153
|
+
/** 设置 51CTO Cookie */
|
|
154
|
+
static setCto51Cookies(cookies: Record<string, string>): Promise<void>;
|
|
155
|
+
/** 获取雪球 Cookie */
|
|
156
|
+
static getYueqiuCookies(): Promise<Record<string, string> | null>;
|
|
157
|
+
/** 设置雪球 Cookie */
|
|
158
|
+
static setYueqiuCookies(cookies: Record<string, string>): Promise<void>;
|
|
159
|
+
/** 获取人人都是产品经理 Cookie */
|
|
160
|
+
static getWoshipmCookies(): Promise<Record<string, string> | null>;
|
|
161
|
+
/** 设置人人都是产品经理 Cookie */
|
|
162
|
+
static setWoshipmCookies(cookies: Record<string, string>): Promise<void>;
|
|
163
|
+
/** 获取豆瓣 Cookie */
|
|
164
|
+
static getDoubanCookies(): Promise<Record<string, string> | null>;
|
|
165
|
+
/** 设置豆瓣 Cookie */
|
|
166
|
+
static setDoubanCookies(cookies: Record<string, string>): Promise<void>;
|
|
167
|
+
/** 获取搜狐 Cookie */
|
|
168
|
+
static getSohuCookies(): Promise<Record<string, string> | null>;
|
|
169
|
+
/** 设置搜狐 Cookie */
|
|
170
|
+
static setSohuCookies(cookies: Record<string, string>): Promise<void>;
|
|
171
|
+
/** 获取东方财富 Cookie */
|
|
172
|
+
static getEastmoneyCookies(): Promise<Record<string, string> | null>;
|
|
173
|
+
/** 设置东方财富 Cookie */
|
|
174
|
+
static setEastmoneyCookies(cookies: Record<string, string>): Promise<void>;
|
|
175
|
+
/** 获取配置目录路径 */
|
|
176
|
+
static getDir(): string;
|
|
177
|
+
}
|