@wenyan-md/core 1.0.12 → 1.0.13
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/README.md +17 -2
- package/dist/browser/wenyan-core.js +26 -26
- package/dist/core.js +187 -180
- package/dist/{juejin_default-CnUAGV72.js → juejin_default-13x4lhT9.js} +1 -6
- package/dist/{lapis-dRySN5pK.js → lapis-BUlsdDG6.js} +1 -1
- package/dist/math/wenyan-math.js +1 -1
- package/dist/{medium_default-BXHGUKdY.js → medium_default-Zyy9RBMn.js} +1 -1
- package/dist/{phycat-C5ES4IMt.js → phycat-CATVZm-R.js} +0 -4
- package/dist/{pie-DUYodGli.js → pie-Q9UMu3CB.js} +1 -1
- package/dist/publish.js +103 -102
- package/dist/{rainbow-BtrbZco6.js → rainbow-Bv0kNhYA.js} +2 -1
- package/dist/styles/wenyan-styles.js +21 -40
- package/dist/theme.js +8 -8
- package/dist/{toutiao_default-DthFV93V.js → toutiao_default-CLGOaI2x.js} +7 -13
- package/dist/types/publish.d.ts +1 -1
- package/dist/types/wechatApi.d.ts +1 -1
- package/dist/types/wrapper.d.ts +3 -3
- package/dist/wrapper.js +4 -4
- package/dist/{zhihu_default-7uVAZjKn.js → zhihu_default-Cz8bIkGO.js} +1 -6
- package/package.json +2 -2
package/dist/publish.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { JSDOM as W } from "jsdom";
|
|
2
2
|
import { createReadStream as L } from "fs";
|
|
3
3
|
import { stat as F } from "fs/promises";
|
|
4
|
-
import
|
|
4
|
+
import _, { basename as N } from "path";
|
|
5
5
|
import { FormData as j, Blob as R } from "formdata-node";
|
|
6
6
|
var I = (t, e, r) => {
|
|
7
7
|
if (!e.has(t))
|
|
8
8
|
throw TypeError("Cannot " + r);
|
|
9
|
-
},
|
|
9
|
+
}, f = (t, e, r) => (I(t, e, "read from private field"), r ? r.call(t) : e.get(t)), w = (t, e, r) => {
|
|
10
10
|
if (e.has(t))
|
|
11
11
|
throw TypeError("Cannot add the same private member more than once");
|
|
12
12
|
e instanceof WeakSet ? e.add(t) : e.set(t, r);
|
|
13
|
-
},
|
|
13
|
+
}, p = (t, e, r, a) => (I(t, e, "write to private field"), e.set(t, r), r), P = (t) => typeof t == "object" && t != null && !Array.isArray(t), h = (t) => typeof t == "function", C = (t) => P(t) && h(t[Symbol.asyncIterator]), A = 65536;
|
|
14
14
|
async function* z(t) {
|
|
15
|
-
if (t.byteLength <=
|
|
15
|
+
if (t.byteLength <= A) {
|
|
16
16
|
yield t;
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
let e = 0;
|
|
20
20
|
for (; e < t.byteLength; ) {
|
|
21
|
-
const r = Math.min(t.byteLength - e,
|
|
21
|
+
const r = Math.min(t.byteLength - e, A), a = t.buffer.slice(e, e + r);
|
|
22
22
|
e += a.byteLength, yield new Uint8Array(a);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -49,33 +49,33 @@ async function* O(t) {
|
|
|
49
49
|
for (; e !== t.size; ) {
|
|
50
50
|
const a = await t.slice(
|
|
51
51
|
e,
|
|
52
|
-
Math.min(t.size, e +
|
|
52
|
+
Math.min(t.size, e + A)
|
|
53
53
|
).arrayBuffer();
|
|
54
54
|
e += a.byteLength, yield new Uint8Array(a);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
async function*
|
|
57
|
+
async function* T(t, e = !1) {
|
|
58
58
|
for (const r of t)
|
|
59
59
|
ArrayBuffer.isView(r) ? e ? yield* z(r) : yield r : h(r.stream) ? yield* H(r.stream()) : yield* O(r);
|
|
60
60
|
}
|
|
61
61
|
function* U(t, e, r = 0, a) {
|
|
62
62
|
a ??= e;
|
|
63
|
-
let
|
|
64
|
-
const
|
|
63
|
+
let s = r < 0 ? Math.max(e + r, 0) : Math.min(r, e), i = a < 0 ? Math.max(e + a, 0) : Math.min(a, e);
|
|
64
|
+
const n = Math.max(i - s, 0);
|
|
65
65
|
let o = 0;
|
|
66
|
-
for (const
|
|
67
|
-
if (o >=
|
|
66
|
+
for (const d of t) {
|
|
67
|
+
if (o >= n)
|
|
68
68
|
break;
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
|
|
69
|
+
const c = ArrayBuffer.isView(d) ? d.byteLength : d.size;
|
|
70
|
+
if (s && c <= s)
|
|
71
|
+
s -= c, i -= c;
|
|
72
72
|
else {
|
|
73
|
-
let
|
|
74
|
-
ArrayBuffer.isView(
|
|
73
|
+
let l;
|
|
74
|
+
ArrayBuffer.isView(d) ? (l = d.subarray(s, Math.min(c, i)), o += l.byteLength) : (l = d.slice(s, Math.min(c, i)), o += l.size), i -= c, s = 0, yield l;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
var u,
|
|
78
|
+
var u, k, g, V = class E {
|
|
79
79
|
/**
|
|
80
80
|
* Returns a new [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object.
|
|
81
81
|
* The content of the blob consists of the concatenation of the values given in the parameter array.
|
|
@@ -84,7 +84,7 @@ var u, _, g, V = class v {
|
|
|
84
84
|
* @param options An optional object of type `BlobPropertyBag`.
|
|
85
85
|
*/
|
|
86
86
|
constructor(e = [], r = {}) {
|
|
87
|
-
if (
|
|
87
|
+
if (w(this, u, []), w(this, k, ""), w(this, g, 0), r ??= {}, typeof e != "object" || e === null)
|
|
88
88
|
throw new TypeError(
|
|
89
89
|
"Failed to construct 'Blob': The provided value cannot be converted to a sequence."
|
|
90
90
|
);
|
|
@@ -98,14 +98,14 @@ var u, _, g, V = class v {
|
|
|
98
98
|
);
|
|
99
99
|
const a = new TextEncoder();
|
|
100
100
|
for (const i of e) {
|
|
101
|
-
let
|
|
102
|
-
ArrayBuffer.isView(i) ?
|
|
101
|
+
let n;
|
|
102
|
+
ArrayBuffer.isView(i) ? n = new Uint8Array(i.buffer.slice(
|
|
103
103
|
i.byteOffset,
|
|
104
104
|
i.byteOffset + i.byteLength
|
|
105
|
-
)) : i instanceof ArrayBuffer ?
|
|
105
|
+
)) : i instanceof ArrayBuffer ? n = new Uint8Array(i.slice(0)) : i instanceof E ? n = i : n = a.encode(String(i)), p(this, g, f(this, g) + (ArrayBuffer.isView(n) ? n.byteLength : n.size)), f(this, u).push(n);
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
|
|
107
|
+
const s = r.type === void 0 ? "" : String(r.type);
|
|
108
|
+
p(this, k, /^[\x20-\x7E]*$/.test(s) ? s : "");
|
|
109
109
|
}
|
|
110
110
|
static [Symbol.hasInstance](e) {
|
|
111
111
|
return !!(e && typeof e == "object" && h(e.constructor) && (h(e.stream) || h(e.arrayBuffer)) && /^(Blob|File)$/.test(e[Symbol.toStringTag]));
|
|
@@ -114,13 +114,13 @@ var u, _, g, V = class v {
|
|
|
114
114
|
* Returns the [`MIME type`](https://developer.mozilla.org/en-US/docs/Glossary/MIME_type) of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).
|
|
115
115
|
*/
|
|
116
116
|
get type() {
|
|
117
|
-
return
|
|
117
|
+
return f(this, k);
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* Returns the size of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in bytes.
|
|
121
121
|
*/
|
|
122
122
|
get size() {
|
|
123
|
-
return
|
|
123
|
+
return f(this, g);
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Creates and returns a new [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object which contains data from a subset of the blob on which it's called.
|
|
@@ -130,7 +130,7 @@ var u, _, g, V = class v {
|
|
|
130
130
|
* @param contentType The content type to assign to the new Blob; this will be the value of its type property. The default value is an empty string.
|
|
131
131
|
*/
|
|
132
132
|
slice(e, r, a) {
|
|
133
|
-
return new
|
|
133
|
+
return new E(U(f(this, u), this.size, e, r), {
|
|
134
134
|
type: a
|
|
135
135
|
});
|
|
136
136
|
}
|
|
@@ -140,7 +140,7 @@ var u, _, g, V = class v {
|
|
|
140
140
|
async text() {
|
|
141
141
|
const e = new TextDecoder();
|
|
142
142
|
let r = "";
|
|
143
|
-
for await (const a of
|
|
143
|
+
for await (const a of T(f(this, u)))
|
|
144
144
|
r += e.decode(a, { stream: !0 });
|
|
145
145
|
return r += e.decode(), r;
|
|
146
146
|
}
|
|
@@ -150,7 +150,7 @@ var u, _, g, V = class v {
|
|
|
150
150
|
async arrayBuffer() {
|
|
151
151
|
const e = new Uint8Array(this.size);
|
|
152
152
|
let r = 0;
|
|
153
|
-
for await (const a of
|
|
153
|
+
for await (const a of T(f(this, u)))
|
|
154
154
|
e.set(a, r), r += a.length;
|
|
155
155
|
return e.buffer;
|
|
156
156
|
}
|
|
@@ -158,11 +158,11 @@ var u, _, g, V = class v {
|
|
|
158
158
|
* Returns a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) which upon reading returns the data contained within the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
|
|
159
159
|
*/
|
|
160
160
|
stream() {
|
|
161
|
-
const e =
|
|
161
|
+
const e = T(f(this, u), !0);
|
|
162
162
|
return new ReadableStream({
|
|
163
163
|
async pull(r) {
|
|
164
|
-
const { value: a, done:
|
|
165
|
-
if (
|
|
164
|
+
const { value: a, done: s } = await e.next();
|
|
165
|
+
if (s)
|
|
166
166
|
return queueMicrotask(() => r.close());
|
|
167
167
|
r.enqueue(a);
|
|
168
168
|
},
|
|
@@ -176,10 +176,10 @@ var u, _, g, V = class v {
|
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
178
|
u = /* @__PURE__ */ new WeakMap();
|
|
179
|
-
|
|
179
|
+
k = /* @__PURE__ */ new WeakMap();
|
|
180
180
|
g = /* @__PURE__ */ new WeakMap();
|
|
181
|
-
var
|
|
182
|
-
Object.defineProperties(
|
|
181
|
+
var S = V;
|
|
182
|
+
Object.defineProperties(S.prototype, {
|
|
183
183
|
type: { enumerable: !0 },
|
|
184
184
|
size: { enumerable: !0 },
|
|
185
185
|
slice: { enumerable: !0 },
|
|
@@ -187,7 +187,7 @@ Object.defineProperties(A.prototype, {
|
|
|
187
187
|
text: { enumerable: !0 },
|
|
188
188
|
arrayBuffer: { enumerable: !0 }
|
|
189
189
|
});
|
|
190
|
-
var
|
|
190
|
+
var M, v, G = class extends S {
|
|
191
191
|
/**
|
|
192
192
|
* Creates a new File instance.
|
|
193
193
|
*
|
|
@@ -196,22 +196,22 @@ var k, M, G = class extends A {
|
|
|
196
196
|
* @param options An options object containing optional attributes for the file.
|
|
197
197
|
*/
|
|
198
198
|
constructor(t, e, r = {}) {
|
|
199
|
-
if (super(t, r),
|
|
199
|
+
if (super(t, r), w(this, M, void 0), w(this, v, 0), arguments.length < 2)
|
|
200
200
|
throw new TypeError(
|
|
201
201
|
`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`
|
|
202
202
|
);
|
|
203
|
-
|
|
203
|
+
p(this, M, String(e));
|
|
204
204
|
const a = r.lastModified === void 0 ? Date.now() : Number(r.lastModified);
|
|
205
|
-
Number.isNaN(a) ||
|
|
205
|
+
Number.isNaN(a) || p(this, v, a);
|
|
206
206
|
}
|
|
207
207
|
static [Symbol.hasInstance](t) {
|
|
208
|
-
return t instanceof
|
|
208
|
+
return t instanceof S && t[Symbol.toStringTag] === "File" && typeof t.name == "string";
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
211
211
|
* Name of the file referenced by the File object.
|
|
212
212
|
*/
|
|
213
213
|
get name() {
|
|
214
|
-
return
|
|
214
|
+
return f(this, M);
|
|
215
215
|
}
|
|
216
216
|
/* c8 ignore next 3 */
|
|
217
217
|
get webkitRelativePath() {
|
|
@@ -221,36 +221,36 @@ var k, M, G = class extends A {
|
|
|
221
221
|
* The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
|
|
222
222
|
*/
|
|
223
223
|
get lastModified() {
|
|
224
|
-
return
|
|
224
|
+
return f(this, v);
|
|
225
225
|
}
|
|
226
226
|
get [Symbol.toStringTag]() {
|
|
227
227
|
return "File";
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
k = /* @__PURE__ */ new WeakMap();
|
|
231
230
|
M = /* @__PURE__ */ new WeakMap();
|
|
232
|
-
|
|
231
|
+
v = /* @__PURE__ */ new WeakMap();
|
|
232
|
+
var m, y, J = class q {
|
|
233
233
|
constructor(e) {
|
|
234
|
-
|
|
234
|
+
w(this, m, void 0), w(this, y, void 0), p(this, m, e.path), p(this, y, e.start || 0), this.name = N(f(this, m)), this.size = e.size, this.lastModified = e.lastModified;
|
|
235
235
|
}
|
|
236
236
|
slice(e, r) {
|
|
237
237
|
return new q({
|
|
238
|
-
path:
|
|
238
|
+
path: f(this, m),
|
|
239
239
|
lastModified: this.lastModified,
|
|
240
|
-
start:
|
|
240
|
+
start: f(this, y) + e,
|
|
241
241
|
size: r - e
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
async *stream() {
|
|
245
|
-
const { mtimeMs: e } = await F(
|
|
245
|
+
const { mtimeMs: e } = await F(f(this, m));
|
|
246
246
|
if (e > this.lastModified)
|
|
247
247
|
throw new DOMException(
|
|
248
248
|
"The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.",
|
|
249
249
|
"NotReadableError"
|
|
250
250
|
);
|
|
251
|
-
this.size && (yield* L(
|
|
252
|
-
start:
|
|
253
|
-
end:
|
|
251
|
+
this.size && (yield* L(f(this, m), {
|
|
252
|
+
start: f(this, y),
|
|
253
|
+
end: f(this, y) + this.size - 1
|
|
254
254
|
}));
|
|
255
255
|
}
|
|
256
256
|
get [Symbol.toStringTag]() {
|
|
@@ -258,15 +258,15 @@ var m, w, J = class q {
|
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
m = /* @__PURE__ */ new WeakMap();
|
|
261
|
-
|
|
261
|
+
y = /* @__PURE__ */ new WeakMap();
|
|
262
262
|
var K = J;
|
|
263
|
-
function X(t, { mtimeMs: e, size: r }, a,
|
|
263
|
+
function X(t, { mtimeMs: e, size: r }, a, s = {}) {
|
|
264
264
|
let i;
|
|
265
|
-
P(a) ? [
|
|
266
|
-
const
|
|
267
|
-
return i || (i =
|
|
268
|
-
...
|
|
269
|
-
lastModified:
|
|
265
|
+
P(a) ? [s, i] = [a, void 0] : i = a;
|
|
266
|
+
const n = new K({ path: t, size: r, lastModified: e });
|
|
267
|
+
return i || (i = n.name), new G([n], i, {
|
|
268
|
+
...s,
|
|
269
|
+
lastModified: n.lastModified
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
272
|
async function Z(t, e, r) {
|
|
@@ -275,30 +275,31 @@ async function Z(t, e, r) {
|
|
|
275
275
|
}
|
|
276
276
|
/*! Based on fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> & David Frank */
|
|
277
277
|
const Q = "https://api.weixin.qq.com/cgi-bin/token", Y = "https://api.weixin.qq.com/cgi-bin/draft/add", ee = "https://api.weixin.qq.com/cgi-bin/material/add_material", te = process.env.WECHAT_APP_ID || "", re = process.env.WECHAT_APP_SECRET || "";
|
|
278
|
-
async function ae() {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
async function ae(t, e) {
|
|
279
|
+
t = t ?? te, e = e ?? re;
|
|
280
|
+
const r = await fetch(`${Q}?grant_type=client_credential&appid=${t}&secret=${e}`);
|
|
281
|
+
if (!r.ok) {
|
|
282
|
+
const a = await r.text();
|
|
283
|
+
throw new Error(`获取AccessToken失败: ${r.status} ${a}`);
|
|
283
284
|
}
|
|
284
|
-
return await
|
|
285
|
+
return await r.json();
|
|
285
286
|
}
|
|
286
287
|
async function ie(t, e, r, a) {
|
|
287
|
-
const
|
|
288
|
-
|
|
288
|
+
const s = new j();
|
|
289
|
+
s.append("media", e, r);
|
|
289
290
|
const i = await fetch(`${ee}?access_token=${a}&type=${t}`, {
|
|
290
291
|
method: "POST",
|
|
291
|
-
body:
|
|
292
|
+
body: s
|
|
292
293
|
});
|
|
293
294
|
if (!i.ok) {
|
|
294
295
|
const o = await i.text();
|
|
295
296
|
throw new Error(`上传素材失败: ${i.status} ${o}`);
|
|
296
297
|
}
|
|
297
|
-
const
|
|
298
|
-
return
|
|
298
|
+
const n = await i.json();
|
|
299
|
+
return n.url && n.url.startsWith("http://") && (n.url = n.url.replace("http://", "https://")), n;
|
|
299
300
|
}
|
|
300
301
|
async function se(t, e, r, a) {
|
|
301
|
-
const
|
|
302
|
+
const s = await fetch(`${Y}?access_token=${a}`, {
|
|
302
303
|
method: "POST",
|
|
303
304
|
body: JSON.stringify({
|
|
304
305
|
articles: [
|
|
@@ -310,28 +311,28 @@ async function se(t, e, r, a) {
|
|
|
310
311
|
]
|
|
311
312
|
})
|
|
312
313
|
});
|
|
313
|
-
if (!
|
|
314
|
-
const i = await
|
|
315
|
-
throw new Error(`发布失败: ${
|
|
314
|
+
if (!s.ok) {
|
|
315
|
+
const i = await s.text();
|
|
316
|
+
throw new Error(`发布失败: ${s.status} ${i}`);
|
|
316
317
|
}
|
|
317
|
-
return await
|
|
318
|
+
return await s.json();
|
|
318
319
|
}
|
|
319
320
|
const B = process.env.HOST_IMAGE_PATH || "", ne = "/mnt/host-downloads";
|
|
320
|
-
async function
|
|
321
|
-
let a,
|
|
321
|
+
async function $(t, e, r) {
|
|
322
|
+
let a, s;
|
|
322
323
|
if (t.startsWith("http")) {
|
|
323
|
-
const
|
|
324
|
-
if (!
|
|
324
|
+
const n = await fetch(t);
|
|
325
|
+
if (!n.ok || !n.body)
|
|
325
326
|
throw new Error(`Failed to download image from URL: ${t}`);
|
|
326
|
-
const o =
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
a = new R([
|
|
327
|
+
const o = _.basename(t.split("?")[0]), d = _.extname(o);
|
|
328
|
+
s = r ?? (d === "" ? `${o}.jpg` : o);
|
|
329
|
+
const c = await n.arrayBuffer();
|
|
330
|
+
a = new R([c]);
|
|
330
331
|
} else {
|
|
331
|
-
const
|
|
332
|
-
|
|
332
|
+
const n = B ? t.replace(B, ne) : t, o = _.basename(n), d = _.extname(o);
|
|
333
|
+
s = r ?? (d === "" ? `${o}.jpg` : o), a = await Z(t);
|
|
333
334
|
}
|
|
334
|
-
const i = await ie("image", a,
|
|
335
|
+
const i = await ie("image", a, s, e);
|
|
335
336
|
if (i.errcode)
|
|
336
337
|
throw new Error(`上传失败,错误码:${i.errcode},错误信息:${i.errmsg}`);
|
|
337
338
|
return i;
|
|
@@ -339,32 +340,32 @@ async function E(t, e, r) {
|
|
|
339
340
|
async function oe(t, e) {
|
|
340
341
|
if (!t.includes("<img"))
|
|
341
342
|
return { html: t, firstImageId: "" };
|
|
342
|
-
const r = new W(t), a = r.window.document, i = Array.from(a.querySelectorAll("img")).map(async (
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
if (
|
|
346
|
-
return
|
|
343
|
+
const r = new W(t), a = r.window.document, i = Array.from(a.querySelectorAll("img")).map(async (c) => {
|
|
344
|
+
const l = c.getAttribute("src");
|
|
345
|
+
if (l) {
|
|
346
|
+
if (l.startsWith("https://mmbiz.qpic.cn"))
|
|
347
|
+
return l;
|
|
347
348
|
{
|
|
348
|
-
const
|
|
349
|
-
return
|
|
349
|
+
const b = await $(l, e);
|
|
350
|
+
return c.setAttribute("src", b.url), b.media_id;
|
|
350
351
|
}
|
|
351
352
|
}
|
|
352
353
|
return null;
|
|
353
354
|
}), o = (await Promise.all(i)).filter(Boolean)[0] || "";
|
|
354
355
|
return { html: r.serialize(), firstImageId: o };
|
|
355
356
|
}
|
|
356
|
-
async function ue(t, e, r) {
|
|
357
|
-
const
|
|
358
|
-
if (!
|
|
359
|
-
throw
|
|
360
|
-
const n = e.replace(/\n<li/g, "<li").replace(/<\/li>\n/g, "</li>"), { html:
|
|
361
|
-
let
|
|
362
|
-
if (r ?
|
|
357
|
+
async function ue(t, e, r, a, s) {
|
|
358
|
+
const i = await ae(a, s);
|
|
359
|
+
if (!i.access_token)
|
|
360
|
+
throw i.errcode ? new Error(`获取 Access Token 失败,错误码:${i.errcode},${i.errmsg}`) : new Error(`获取 Access Token 失败: ${i}`);
|
|
361
|
+
const n = e.replace(/\n<li/g, "<li").replace(/<\/li>\n/g, "</li>"), { html: o, firstImageId: d } = await oe(n, i.access_token);
|
|
362
|
+
let c = "";
|
|
363
|
+
if (r ? c = (await $(r, i.access_token, "cover.jpg")).media_id : d.startsWith("https://mmbiz.qpic.cn") ? c = (await $(d, i.access_token, "cover.jpg")).media_id : c = d, !c)
|
|
363
364
|
throw new Error("你必须指定一张封面图或者在正文中至少出现一张图片。");
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
366
|
-
return
|
|
367
|
-
throw
|
|
365
|
+
const l = await se(t, o, c, i.access_token);
|
|
366
|
+
if (l.media_id)
|
|
367
|
+
return l;
|
|
368
|
+
throw l.errcode ? new Error(`上传到公众号草稿失败,错误码:${l.errcode},${l.errmsg}`) : new Error(`上传到公众号草稿失败: ${l}`);
|
|
368
369
|
}
|
|
369
370
|
export {
|
|
370
371
|
ue as publishToDraft
|
|
@@ -19,7 +19,7 @@ const n = `/*
|
|
|
19
19
|
}
|
|
20
20
|
#wenyan p,
|
|
21
21
|
#wenyan pre {
|
|
22
|
-
margin: 1em 0
|
|
22
|
+
margin: 1em 0;
|
|
23
23
|
}
|
|
24
24
|
#wenyan h1,
|
|
25
25
|
#wenyan h2,
|
|
@@ -43,6 +43,7 @@ const n = `/*
|
|
|
43
43
|
padding-right: 1em;
|
|
44
44
|
border-left: 0.5em solid var(--h-border-color);
|
|
45
45
|
border-radius: 0.4em;
|
|
46
|
+
display: inline-block;
|
|
46
47
|
}
|
|
47
48
|
#wenyan h3 {
|
|
48
49
|
font-size: 1.3em;
|