artalk 2.8.5 → 2.8.6
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/dist/Artalk.cjs +1 -1
- package/dist/Artalk.cjs.map +1 -1
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.iife.js.map +1 -1
- package/dist/Artalk.js +1 -1
- package/dist/Artalk.js.map +1 -1
- package/dist/Artalk.mjs +281 -86
- package/dist/Artalk.mjs.map +1 -1
- package/dist/ArtalkLite.cjs +1 -1
- package/dist/ArtalkLite.cjs.map +1 -1
- package/dist/ArtalkLite.iife.js +1 -1
- package/dist/ArtalkLite.iife.js.map +1 -1
- package/dist/ArtalkLite.js +1 -1
- package/dist/ArtalkLite.js.map +1 -1
- package/dist/ArtalkLite.mjs +279 -85
- package/dist/ArtalkLite.mjs.map +1 -1
- package/dist/i18n/jp.cjs +1 -1
- package/dist/i18n/jp.js +1 -1
- package/dist/i18n/jp.mjs +21 -0
- package/dist/i18n/zh-TW.cjs +1 -1
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/i18n/zh-TW.mjs +21 -4
- package/dist/main.d.cts +199 -0
- package/dist/main.d.ts +199 -0
- package/package.json +2 -2
package/dist/ArtalkLite.mjs
CHANGED
|
@@ -142,11 +142,14 @@ class HttpClient {
|
|
|
142
142
|
/* Json */
|
|
143
143
|
];
|
|
144
144
|
const responseFormat = format || requestParams.format;
|
|
145
|
-
return this.customFetch(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
return this.customFetch(
|
|
146
|
+
`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`,
|
|
147
|
+
__spreadProps(__spreadValues({}, requestParams), {
|
|
148
|
+
headers: __spreadValues(__spreadValues({}, requestParams.headers || {}), type && type !== "multipart/form-data" ? { "Content-Type": type } : {}),
|
|
149
|
+
signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null,
|
|
150
|
+
body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
|
|
151
|
+
})
|
|
152
|
+
).then((response) => __async(this, null, function* () {
|
|
150
153
|
const r = response;
|
|
151
154
|
r.data = null;
|
|
152
155
|
r.error = null;
|
|
@@ -185,7 +188,9 @@ class HttpClient {
|
|
|
185
188
|
toQueryString(rawQuery) {
|
|
186
189
|
const query = rawQuery || {};
|
|
187
190
|
const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
|
|
188
|
-
return keys.map(
|
|
191
|
+
return keys.map(
|
|
192
|
+
(key) => Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)
|
|
193
|
+
).join("&");
|
|
189
194
|
}
|
|
190
195
|
addQueryParams(rawQuery) {
|
|
191
196
|
const queryString = this.toQueryString(rawQuery);
|
|
@@ -209,6 +214,133 @@ class HttpClient {
|
|
|
209
214
|
let Api$1 = class Api extends HttpClient {
|
|
210
215
|
constructor() {
|
|
211
216
|
super(...arguments);
|
|
217
|
+
__publicField(this, "auth", {
|
|
218
|
+
/**
|
|
219
|
+
* @description Login by email with verify code (Need send email verify code first) or password
|
|
220
|
+
*
|
|
221
|
+
* @tags Auth
|
|
222
|
+
* @name LoginByEmail
|
|
223
|
+
* @summary Login by email
|
|
224
|
+
* @request POST:/auth/email/login
|
|
225
|
+
* @response `200` `HandlerResponseUserLogin` OK
|
|
226
|
+
* @response `400` `(HandlerMap & {
|
|
227
|
+
msg?: string,
|
|
228
|
+
|
|
229
|
+
})` Bad Request
|
|
230
|
+
* @response `500` `(HandlerMap & {
|
|
231
|
+
msg?: string,
|
|
232
|
+
|
|
233
|
+
})` Internal Server Error
|
|
234
|
+
*/
|
|
235
|
+
loginByEmail: (data, params = {}) => this.request(__spreadValues({
|
|
236
|
+
path: `/auth/email/login`,
|
|
237
|
+
method: "POST",
|
|
238
|
+
body: data,
|
|
239
|
+
type: "application/json",
|
|
240
|
+
format: "json"
|
|
241
|
+
}, params)),
|
|
242
|
+
/**
|
|
243
|
+
* @description Register by email and verify code (if user exists, will update user, like forget password. Need send email verify code first)
|
|
244
|
+
*
|
|
245
|
+
* @tags Auth
|
|
246
|
+
* @name RegisterByEmail
|
|
247
|
+
* @summary Register by email
|
|
248
|
+
* @request POST:/auth/email/register
|
|
249
|
+
* @response `200` `HandlerResponseUserLogin` OK
|
|
250
|
+
* @response `400` `(HandlerMap & {
|
|
251
|
+
msg?: string,
|
|
252
|
+
|
|
253
|
+
})` Bad Request
|
|
254
|
+
* @response `500` `(HandlerMap & {
|
|
255
|
+
msg?: string,
|
|
256
|
+
|
|
257
|
+
})` Internal Server Error
|
|
258
|
+
*/
|
|
259
|
+
registerByEmail: (data, params = {}) => this.request(__spreadValues({
|
|
260
|
+
path: `/auth/email/register`,
|
|
261
|
+
method: "POST",
|
|
262
|
+
body: data,
|
|
263
|
+
type: "application/json",
|
|
264
|
+
format: "json"
|
|
265
|
+
}, params)),
|
|
266
|
+
/**
|
|
267
|
+
* @description Send email including verify code to user
|
|
268
|
+
*
|
|
269
|
+
* @tags Auth
|
|
270
|
+
* @name SendVerifyEmail
|
|
271
|
+
* @summary Send verify email
|
|
272
|
+
* @request POST:/auth/email/send
|
|
273
|
+
* @response `200` `(HandlerMap & {
|
|
274
|
+
msg?: string,
|
|
275
|
+
|
|
276
|
+
})` OK
|
|
277
|
+
* @response `400` `(HandlerMap & {
|
|
278
|
+
msg?: string,
|
|
279
|
+
|
|
280
|
+
})` Bad Request
|
|
281
|
+
* @response `500` `(HandlerMap & {
|
|
282
|
+
msg?: string,
|
|
283
|
+
|
|
284
|
+
})` Internal Server Error
|
|
285
|
+
*/
|
|
286
|
+
sendVerifyEmail: (data, params = {}) => this.request(__spreadValues({
|
|
287
|
+
path: `/auth/email/send`,
|
|
288
|
+
method: "POST",
|
|
289
|
+
body: data,
|
|
290
|
+
type: "application/json",
|
|
291
|
+
format: "json"
|
|
292
|
+
}, params)),
|
|
293
|
+
/**
|
|
294
|
+
* @description Get all users with same email, if there are more than one user with same email, need merge
|
|
295
|
+
*
|
|
296
|
+
* @tags Auth
|
|
297
|
+
* @name CheckDataMerge
|
|
298
|
+
* @summary Check data merge
|
|
299
|
+
* @request GET:/auth/merge
|
|
300
|
+
* @secure
|
|
301
|
+
* @response `200` `HandlerResponseAuthDataMergeCheck` OK
|
|
302
|
+
* @response `400` `(HandlerMap & {
|
|
303
|
+
msg?: string,
|
|
304
|
+
|
|
305
|
+
})` Bad Request
|
|
306
|
+
* @response `500` `(HandlerMap & {
|
|
307
|
+
msg?: string,
|
|
308
|
+
|
|
309
|
+
})` Internal Server Error
|
|
310
|
+
*/
|
|
311
|
+
checkDataMerge: (params = {}) => this.request(__spreadValues({
|
|
312
|
+
path: `/auth/merge`,
|
|
313
|
+
method: "GET",
|
|
314
|
+
secure: true,
|
|
315
|
+
format: "json"
|
|
316
|
+
}, params)),
|
|
317
|
+
/**
|
|
318
|
+
* @description This function is to solve the problem of multiple users with the same email address, should be called after user login and then check, and perform data merge.
|
|
319
|
+
*
|
|
320
|
+
* @tags Auth
|
|
321
|
+
* @name ApplyDataMerge
|
|
322
|
+
* @summary Apply data merge
|
|
323
|
+
* @request POST:/auth/merge
|
|
324
|
+
* @secure
|
|
325
|
+
* @response `200` `HandlerResponseAuthDataMergeApply` OK
|
|
326
|
+
* @response `400` `(HandlerMap & {
|
|
327
|
+
msg?: string,
|
|
328
|
+
|
|
329
|
+
})` Bad Request
|
|
330
|
+
* @response `500` `(HandlerMap & {
|
|
331
|
+
msg?: string,
|
|
332
|
+
|
|
333
|
+
})` Internal Server Error
|
|
334
|
+
*/
|
|
335
|
+
applyDataMerge: (data, params = {}) => this.request(__spreadValues({
|
|
336
|
+
path: `/auth/merge`,
|
|
337
|
+
method: "POST",
|
|
338
|
+
body: data,
|
|
339
|
+
secure: true,
|
|
340
|
+
type: "application/json",
|
|
341
|
+
format: "json"
|
|
342
|
+
}, params))
|
|
343
|
+
});
|
|
212
344
|
__publicField(this, "cache", {
|
|
213
345
|
/**
|
|
214
346
|
* @description Flush all cache on the server
|
|
@@ -469,6 +601,24 @@ let Api$1 = class Api extends HttpClient {
|
|
|
469
601
|
method: "GET",
|
|
470
602
|
format: "json"
|
|
471
603
|
}, params)),
|
|
604
|
+
/**
|
|
605
|
+
* @description Get social login providers
|
|
606
|
+
*
|
|
607
|
+
* @tags System
|
|
608
|
+
* @name GetSocialLoginProviders
|
|
609
|
+
* @summary Get Social Login Providers
|
|
610
|
+
* @request GET:/conf/auth/providers
|
|
611
|
+
* @response `200` `HandlerResponseConfAuthProviders` OK
|
|
612
|
+
* @response `404` `(HandlerMap & {
|
|
613
|
+
msg?: string,
|
|
614
|
+
|
|
615
|
+
})` Not Found
|
|
616
|
+
*/
|
|
617
|
+
getSocialLoginProviders: (params = {}) => this.request(__spreadValues({
|
|
618
|
+
path: `/conf/auth/providers`,
|
|
619
|
+
method: "GET",
|
|
620
|
+
format: "json"
|
|
621
|
+
}, params)),
|
|
472
622
|
/**
|
|
473
623
|
* @description Get Domain Info
|
|
474
624
|
*
|
|
@@ -1328,8 +1478,6 @@ function getDefaultExportFromCjs(x) {
|
|
|
1328
1478
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
1329
1479
|
if (protoProps)
|
|
1330
1480
|
_defineProperties(Constructor.prototype, protoProps);
|
|
1331
|
-
if (staticProps)
|
|
1332
|
-
_defineProperties(Constructor, staticProps);
|
|
1333
1481
|
Object.defineProperty(Constructor, "prototype", {
|
|
1334
1482
|
writable: false
|
|
1335
1483
|
});
|
|
@@ -2228,7 +2376,7 @@ const insaneOptions = {
|
|
|
2228
2376
|
allowedAttributes: {
|
|
2229
2377
|
"*": ["title", "accesskey"],
|
|
2230
2378
|
a: ["href", "name", "target", "aria-label", "rel"],
|
|
2231
|
-
img: ["src", "alt", "title", "atk-emoticon", "aria-label"],
|
|
2379
|
+
img: ["src", "alt", "title", "atk-emoticon", "aria-label", "data-src", "class", "loading"],
|
|
2232
2380
|
// for code highlight
|
|
2233
2381
|
code: ["class"],
|
|
2234
2382
|
span: ["class", "style"]
|
|
@@ -2236,7 +2384,8 @@ const insaneOptions = {
|
|
|
2236
2384
|
filter: (node) => {
|
|
2237
2385
|
const allowed = [
|
|
2238
2386
|
["code", /^hljs\W+language-(.*)$/],
|
|
2239
|
-
["span", /^(hljs-.*)$/]
|
|
2387
|
+
["span", /^(hljs-.*)$/],
|
|
2388
|
+
["img", /^lazyload$/]
|
|
2240
2389
|
];
|
|
2241
2390
|
allowed.forEach(([tag, reg]) => {
|
|
2242
2391
|
if (node.tag === tag && !!node.attrs.class && !reg.test(node.attrs.class)) {
|
|
@@ -2313,18 +2462,26 @@ const hanabi = /* @__PURE__ */ getDefaultExportFromCjs(hanabiExports);
|
|
|
2313
2462
|
function renderCode(code) {
|
|
2314
2463
|
return hanabi(code);
|
|
2315
2464
|
}
|
|
2316
|
-
function getRenderer() {
|
|
2465
|
+
function getRenderer(options) {
|
|
2317
2466
|
const renderer = new marked$1.Renderer();
|
|
2318
2467
|
renderer.link = markedLinkRenderer(renderer, renderer.link);
|
|
2319
2468
|
renderer.code = markedCodeRenderer();
|
|
2469
|
+
renderer.image = markedImageRenderer(renderer, renderer.image, options);
|
|
2320
2470
|
return renderer;
|
|
2321
2471
|
}
|
|
2322
2472
|
const markedLinkRenderer = (renderer, orgLinkRenderer) => (href, title, text) => {
|
|
2323
|
-
const
|
|
2473
|
+
const getLinkOrigin = (link) => {
|
|
2474
|
+
try {
|
|
2475
|
+
return new URL(link).origin;
|
|
2476
|
+
} catch (e) {
|
|
2477
|
+
return "";
|
|
2478
|
+
}
|
|
2479
|
+
};
|
|
2480
|
+
const isSameOriginLink = getLinkOrigin(href) === window.location.origin;
|
|
2324
2481
|
const html = orgLinkRenderer.call(renderer, href, title, text);
|
|
2325
2482
|
return html.replace(
|
|
2326
2483
|
/^<a /,
|
|
2327
|
-
`<a target="_blank" ${!
|
|
2484
|
+
`<a target="_blank" ${!isSameOriginLink ? `rel="noreferrer noopener nofollow"` : ""} `
|
|
2328
2485
|
);
|
|
2329
2486
|
};
|
|
2330
2487
|
const markedCodeRenderer = () => (block, lang) => {
|
|
@@ -2341,6 +2498,16 @@ const markedCodeRenderer = () => (block, lang) => {
|
|
|
2341
2498
|
<code class="hljs language-${realLang}">${colorized.replace(/&/g, "&")}</code>
|
|
2342
2499
|
</pre>`;
|
|
2343
2500
|
};
|
|
2501
|
+
const markedImageRenderer = (renderer, orgImageRenderer, { imgLazyLoad }) => (href, title, text) => {
|
|
2502
|
+
const html = orgImageRenderer.call(renderer, href, title, text);
|
|
2503
|
+
if (!imgLazyLoad)
|
|
2504
|
+
return html;
|
|
2505
|
+
if (imgLazyLoad === "native" || imgLazyLoad === true)
|
|
2506
|
+
return html.replace(/^<img /, '<img class="lazyload" loading="lazy" ');
|
|
2507
|
+
if (imgLazyLoad === "data-src")
|
|
2508
|
+
return html.replace(/^<img /, '<img class="lazyload" ').replace("src=", "data-src=");
|
|
2509
|
+
return html;
|
|
2510
|
+
};
|
|
2344
2511
|
let instance;
|
|
2345
2512
|
let replacers = [];
|
|
2346
2513
|
const markedOptions = {
|
|
@@ -2354,16 +2521,18 @@ function getInstance() {
|
|
|
2354
2521
|
function setReplacers(arr) {
|
|
2355
2522
|
replacers = arr;
|
|
2356
2523
|
}
|
|
2357
|
-
function initMarked() {
|
|
2524
|
+
function initMarked(options) {
|
|
2358
2525
|
try {
|
|
2359
2526
|
if (!marked$1.name)
|
|
2360
2527
|
return;
|
|
2361
2528
|
} catch (e) {
|
|
2362
2529
|
return;
|
|
2363
2530
|
}
|
|
2364
|
-
marked$1.setOptions(__spreadValues({
|
|
2365
|
-
renderer: getRenderer(
|
|
2366
|
-
|
|
2531
|
+
marked$1.setOptions(__spreadValues(__spreadValues({
|
|
2532
|
+
renderer: getRenderer({
|
|
2533
|
+
imgLazyLoad: options.imgLazyLoad
|
|
2534
|
+
})
|
|
2535
|
+
}, markedOptions), options.markedOptions));
|
|
2367
2536
|
instance = marked$1;
|
|
2368
2537
|
}
|
|
2369
2538
|
function marked(src) {
|
|
@@ -2499,6 +2668,8 @@ const en = {
|
|
|
2499
2668
|
placeholder: "Leave a comment",
|
|
2500
2669
|
noComment: "No Comment",
|
|
2501
2670
|
send: "Send",
|
|
2671
|
+
signIn: "Sign in",
|
|
2672
|
+
signUp: "Sign up",
|
|
2502
2673
|
save: "Save",
|
|
2503
2674
|
nick: "Nickname",
|
|
2504
2675
|
email: "Email",
|
|
@@ -2557,7 +2728,26 @@ const en = {
|
|
|
2557
2728
|
/* Sidebar */
|
|
2558
2729
|
msgCenter: "Messages",
|
|
2559
2730
|
ctrlCenter: "Admin",
|
|
2731
|
+
/* Auth */
|
|
2732
|
+
noAccountPrompt: "Don't have an account?",
|
|
2733
|
+
haveAccountPrompt: "Already have an account?",
|
|
2734
|
+
forgetPassword: "Forget Password",
|
|
2735
|
+
resetPassword: "Reset Password",
|
|
2736
|
+
verificationCode: "Verification Code",
|
|
2737
|
+
verifySend: "Verify",
|
|
2738
|
+
verifyResend: "Resend",
|
|
2739
|
+
waitSeconds: "Wait {seconds}s",
|
|
2560
2740
|
emailVerified: "Email has been verified",
|
|
2741
|
+
password: "Password",
|
|
2742
|
+
username: "Username",
|
|
2743
|
+
nextStep: "Next Step",
|
|
2744
|
+
skipNotVerify: "Skip, do not verify",
|
|
2745
|
+
logoutConfirm: "Are you sure to logout?",
|
|
2746
|
+
accountMergeNotice: "Your email has multiple accounts with different id.",
|
|
2747
|
+
accountMergeSelectOne: "Please select one you want to merge all the data into it.",
|
|
2748
|
+
accountMergeConfirm: "All data will be merged into one account, the id is {id}.",
|
|
2749
|
+
dismiss: "Dismiss",
|
|
2750
|
+
merge: "Merge",
|
|
2561
2751
|
/* General */
|
|
2562
2752
|
frontend: "Frontend",
|
|
2563
2753
|
backend: "Backend",
|
|
@@ -2580,6 +2770,8 @@ const zhCN = {
|
|
|
2580
2770
|
placeholder: "键入内容...",
|
|
2581
2771
|
noComment: "「此时无声胜有声」",
|
|
2582
2772
|
send: "发送",
|
|
2773
|
+
signIn: "登录",
|
|
2774
|
+
signUp: "注册",
|
|
2583
2775
|
save: "保存",
|
|
2584
2776
|
nick: "昵称",
|
|
2585
2777
|
email: "邮箱",
|
|
@@ -2638,7 +2830,26 @@ const zhCN = {
|
|
|
2638
2830
|
/* Sidebar */
|
|
2639
2831
|
msgCenter: "通知中心",
|
|
2640
2832
|
ctrlCenter: "控制中心",
|
|
2833
|
+
/* Auth */
|
|
2834
|
+
noAccountPrompt: "没有账号?",
|
|
2835
|
+
haveAccountPrompt: "已有账号?",
|
|
2836
|
+
forgetPassword: "忘记密码",
|
|
2837
|
+
resetPassword: "重置密码",
|
|
2838
|
+
verificationCode: "验证码",
|
|
2839
|
+
verifySend: "发送验证码",
|
|
2840
|
+
verifyResend: "重新发送",
|
|
2841
|
+
waitSeconds: "等待 {seconds}秒",
|
|
2641
2842
|
emailVerified: "邮箱已验证",
|
|
2843
|
+
password: "密码",
|
|
2844
|
+
username: "用户名",
|
|
2845
|
+
nextStep: "下一步",
|
|
2846
|
+
skipNotVerify: "跳过,不验证",
|
|
2847
|
+
logoutConfirm: "确定要退出登录吗?",
|
|
2848
|
+
accountMergeNotice: "您的电子邮件下有多个不同 ID 的账户。",
|
|
2849
|
+
accountMergeSelectOne: "请选择将所有数据合并到其中的一个。",
|
|
2850
|
+
accountMergeConfirm: "所有数据将合并到 ID 为 {id} 的账户中。",
|
|
2851
|
+
dismiss: "忽略",
|
|
2852
|
+
merge: "合并",
|
|
2642
2853
|
/* General */
|
|
2643
2854
|
frontend: "前端",
|
|
2644
2855
|
backend: "后端",
|
|
@@ -2741,27 +2952,6 @@ function timeAgo(date, $t = (n) => n) {
|
|
|
2741
2952
|
return " - ";
|
|
2742
2953
|
}
|
|
2743
2954
|
}
|
|
2744
|
-
function onImagesLoaded($container, event) {
|
|
2745
|
-
if (!$container)
|
|
2746
|
-
return;
|
|
2747
|
-
const images = $container.getElementsByTagName("img");
|
|
2748
|
-
if (!images.length)
|
|
2749
|
-
return;
|
|
2750
|
-
let loaded = images.length;
|
|
2751
|
-
for (let i = 0; i < images.length; i++) {
|
|
2752
|
-
if (images[i].complete) {
|
|
2753
|
-
loaded--;
|
|
2754
|
-
} else {
|
|
2755
|
-
images[i].addEventListener("load", () => {
|
|
2756
|
-
loaded--;
|
|
2757
|
-
if (loaded === 0)
|
|
2758
|
-
event();
|
|
2759
|
-
});
|
|
2760
|
-
}
|
|
2761
|
-
if (loaded === 0)
|
|
2762
|
-
event();
|
|
2763
|
-
}
|
|
2764
|
-
}
|
|
2765
2955
|
function getGravatarURL(opts) {
|
|
2766
2956
|
return `${opts.mirror.replace(/\/$/, "")}/${opts.emailMD5}?${opts.params.replace(/^\?/, "")}`;
|
|
2767
2957
|
}
|
|
@@ -2961,17 +3151,12 @@ function handelCustomConf(customConf, full = false) {
|
|
|
2961
3151
|
return conf;
|
|
2962
3152
|
}
|
|
2963
3153
|
function handleConfFormServer(conf) {
|
|
2964
|
-
const DisabledKeys = [
|
|
2965
|
-
"el",
|
|
2966
|
-
"pageKey",
|
|
2967
|
-
"pageTitle",
|
|
2968
|
-
"server",
|
|
2969
|
-
"site",
|
|
2970
|
-
"darkMode"
|
|
2971
|
-
];
|
|
3154
|
+
const DisabledKeys = ["el", "pageKey", "pageTitle", "server", "site"];
|
|
2972
3155
|
Object.keys(conf).forEach((k) => {
|
|
2973
3156
|
if (DisabledKeys.includes(k))
|
|
2974
3157
|
delete conf[k];
|
|
3158
|
+
if (k === "darkMode" && conf[k] !== "auto")
|
|
3159
|
+
delete conf[k];
|
|
2975
3160
|
});
|
|
2976
3161
|
if (conf.emoticons && typeof conf.emoticons === "string") {
|
|
2977
3162
|
conf.emoticons = conf.emoticons.trim();
|
|
@@ -3279,8 +3464,6 @@ function playFadeAnim(elem, after, type = "in") {
|
|
|
3279
3464
|
const onAnimEnded = () => {
|
|
3280
3465
|
elem.classList.remove(`atk-fade-${type}`);
|
|
3281
3466
|
elem.removeEventListener("animationend", onAnimEnded);
|
|
3282
|
-
if (after)
|
|
3283
|
-
after();
|
|
3284
3467
|
};
|
|
3285
3468
|
elem.addEventListener("animationend", onAnimEnded);
|
|
3286
3469
|
}
|
|
@@ -3831,10 +4014,10 @@ class SidebarLayer extends Component {
|
|
|
3831
4014
|
} else {
|
|
3832
4015
|
const $iframe = this.$iframe;
|
|
3833
4016
|
const iFrameSrc = $iframe.src;
|
|
3834
|
-
if (this.
|
|
4017
|
+
if (this.getDarkMode() !== iFrameSrc.includes("&darkMode=1")) {
|
|
3835
4018
|
this.iframeLoad(
|
|
3836
4019
|
$iframe,
|
|
3837
|
-
this.
|
|
4020
|
+
this.getDarkMode() ? iFrameSrc.concat("&darkMode=1") : iFrameSrc.replace("&darkMode=1", "")
|
|
3838
4021
|
);
|
|
3839
4022
|
}
|
|
3840
4023
|
}
|
|
@@ -3904,12 +4087,15 @@ class SidebarLayer extends Component {
|
|
|
3904
4087
|
};
|
|
3905
4088
|
if (view)
|
|
3906
4089
|
query.view = view;
|
|
3907
|
-
if (this.
|
|
4090
|
+
if (this.getDarkMode())
|
|
3908
4091
|
query.darkMode = "1";
|
|
3909
4092
|
const urlParams = new URLSearchParams(query);
|
|
3910
4093
|
this.iframeLoad($iframe, `${baseURL}?${urlParams.toString()}`);
|
|
3911
4094
|
return $iframe;
|
|
3912
4095
|
}
|
|
4096
|
+
getDarkMode() {
|
|
4097
|
+
return this.conf.darkMode === "auto" ? window.matchMedia("(prefers-color-scheme: dark)").matches : this.conf.darkMode;
|
|
4098
|
+
}
|
|
3913
4099
|
iframeLoad($iframe, src) {
|
|
3914
4100
|
$iframe.src = src;
|
|
3915
4101
|
showLoading(this.$iframeWrap);
|
|
@@ -4244,38 +4430,42 @@ function Detect(userAgent) {
|
|
|
4244
4430
|
return dest;
|
|
4245
4431
|
}
|
|
4246
4432
|
function check(conf, rules) {
|
|
4247
|
-
rules.forEach(({ el, max
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
el,
|
|
4254
|
-
maxHeight,
|
|
4255
|
-
postBtnClick: conf.postExpandBtnClick
|
|
4256
|
-
});
|
|
4257
|
-
else
|
|
4258
|
-
applyScrollableHeightLimit({ el, maxHeight });
|
|
4259
|
-
};
|
|
4433
|
+
rules.forEach(({ el, max, imgCheck }) => {
|
|
4434
|
+
if (!el)
|
|
4435
|
+
return;
|
|
4436
|
+
if (imgCheck)
|
|
4437
|
+
el.style.maxHeight = `${max + 1}px`;
|
|
4438
|
+
let lock = false;
|
|
4260
4439
|
const _check = () => {
|
|
4261
|
-
if (
|
|
4262
|
-
|
|
4440
|
+
if (lock)
|
|
4441
|
+
return;
|
|
4442
|
+
if (getHeight(el) <= max)
|
|
4443
|
+
return;
|
|
4444
|
+
const afterExpandBtnClick = () => {
|
|
4445
|
+
var _a;
|
|
4446
|
+
lock = true;
|
|
4447
|
+
(_a = conf.afterExpandBtnClick) == null ? void 0 : _a.call(conf);
|
|
4448
|
+
};
|
|
4449
|
+
!conf.scrollable ? applyHeightLimit({ el, max, afterExpandBtnClick }) : applyScrollableHeightLimit({ el, max });
|
|
4263
4450
|
};
|
|
4264
4451
|
_check();
|
|
4265
|
-
if (
|
|
4266
|
-
|
|
4452
|
+
if (imgCheck) {
|
|
4453
|
+
el.querySelectorAll(".atk-content img").forEach((img) => {
|
|
4454
|
+
img.onload = () => _check();
|
|
4455
|
+
});
|
|
4456
|
+
}
|
|
4267
4457
|
});
|
|
4268
4458
|
}
|
|
4269
4459
|
const HEIGHT_LIMIT_CSS = "atk-height-limit";
|
|
4270
4460
|
function applyHeightLimit(obj) {
|
|
4271
4461
|
if (!obj.el)
|
|
4272
4462
|
return;
|
|
4273
|
-
if (!obj.
|
|
4463
|
+
if (!obj.max)
|
|
4274
4464
|
return;
|
|
4275
4465
|
if (obj.el.classList.contains(HEIGHT_LIMIT_CSS))
|
|
4276
4466
|
return;
|
|
4277
4467
|
obj.el.classList.add(HEIGHT_LIMIT_CSS);
|
|
4278
|
-
obj.el.style.height = `${obj.
|
|
4468
|
+
obj.el.style.height = `${obj.max}px`;
|
|
4279
4469
|
obj.el.style.overflow = "hidden";
|
|
4280
4470
|
const $expandBtn = createElement(
|
|
4281
4471
|
`<div class="atk-height-limit-btn">${t("readMore")}</span>`
|
|
@@ -4283,8 +4473,8 @@ function applyHeightLimit(obj) {
|
|
|
4283
4473
|
$expandBtn.onclick = (e) => {
|
|
4284
4474
|
e.stopPropagation();
|
|
4285
4475
|
disposeHeightLimit(obj.el);
|
|
4286
|
-
if (obj.
|
|
4287
|
-
obj.
|
|
4476
|
+
if (obj.afterExpandBtnClick)
|
|
4477
|
+
obj.afterExpandBtnClick(e);
|
|
4288
4478
|
};
|
|
4289
4479
|
obj.el.append($expandBtn);
|
|
4290
4480
|
}
|
|
@@ -4299,16 +4489,17 @@ function disposeHeightLimit($el) {
|
|
|
4299
4489
|
e.remove();
|
|
4300
4490
|
});
|
|
4301
4491
|
$el.style.height = "";
|
|
4492
|
+
$el.style.maxHeight = "";
|
|
4302
4493
|
$el.style.overflow = "";
|
|
4303
4494
|
}
|
|
4304
4495
|
const HEIGHT_LIMIT_SCROLL_CSS = "atk-height-limit-scroll";
|
|
4305
|
-
function applyScrollableHeightLimit(
|
|
4306
|
-
if (!
|
|
4496
|
+
function applyScrollableHeightLimit(opt) {
|
|
4497
|
+
if (!opt.el)
|
|
4307
4498
|
return;
|
|
4308
|
-
if (
|
|
4499
|
+
if (opt.el.classList.contains(HEIGHT_LIMIT_SCROLL_CSS))
|
|
4309
4500
|
return;
|
|
4310
|
-
|
|
4311
|
-
|
|
4501
|
+
opt.el.classList.add(HEIGHT_LIMIT_SCROLL_CSS);
|
|
4502
|
+
opt.el.style.height = `${opt.max}px`;
|
|
4312
4503
|
}
|
|
4313
4504
|
const CommentHTML = '<div class="atk-comment-wrap">\n <div class="atk-comment">\n <div class="atk-avatar"></div>\n <div class="atk-main">\n <div class="atk-header">\n <span class="atk-item atk-nick"></span>\n <span class="atk-badge-wrap"></span>\n <span class="atk-item atk-date"></span>\n </div>\n <div class="atk-body">\n <div class="atk-content"></div>\n </div>\n <div class="atk-footer">\n <div class="atk-actions"></div>\n </div>\n </div>\n </div>\n</div>\n';
|
|
4314
4505
|
function renderAvatar(r) {
|
|
@@ -4772,7 +4963,7 @@ class Render {
|
|
|
4772
4963
|
const childrenMaxH = conf.children;
|
|
4773
4964
|
check(
|
|
4774
4965
|
{
|
|
4775
|
-
|
|
4966
|
+
afterExpandBtnClick: () => {
|
|
4776
4967
|
const children = this.comment.getChildren();
|
|
4777
4968
|
if (children.length === 1)
|
|
4778
4969
|
disposeHeightLimit(children[0].getRender().$content);
|
|
@@ -4781,10 +4972,10 @@ class Render {
|
|
|
4781
4972
|
},
|
|
4782
4973
|
[
|
|
4783
4974
|
// 评论内容限高
|
|
4784
|
-
{ el: this.$content, max: contentMaxH,
|
|
4785
|
-
{ el: this.$replyTo, max: contentMaxH,
|
|
4975
|
+
{ el: this.$content, max: contentMaxH, imgCheck: true },
|
|
4976
|
+
{ el: this.$replyTo, max: contentMaxH, imgCheck: true },
|
|
4786
4977
|
// 子评论区域限高(仅嵌套模式)
|
|
4787
|
-
{ el: this.$childrenWrap, max: childrenMaxH,
|
|
4978
|
+
{ el: this.$childrenWrap, max: childrenMaxH, imgCheck: false }
|
|
4788
4979
|
]
|
|
4789
4980
|
);
|
|
4790
4981
|
}
|
|
@@ -4873,7 +5064,7 @@ class CommentActions {
|
|
|
4873
5064
|
(_b = this.comment.getRender().voteBtnDown) == null ? void 0 : _b.updateText();
|
|
4874
5065
|
}).catch((err) => {
|
|
4875
5066
|
actionBtn == null ? void 0 : actionBtn.setError(t("voteFail"));
|
|
4876
|
-
console.
|
|
5067
|
+
console.error(err);
|
|
4877
5068
|
});
|
|
4878
5069
|
}
|
|
4879
5070
|
/** 管理员 - 评论状态修改 */
|
|
@@ -5828,8 +6019,11 @@ ${opts.errMsg}`;
|
|
|
5828
6019
|
setError(opts.$err, errEl);
|
|
5829
6020
|
}
|
|
5830
6021
|
const Markdown = (ctx) => {
|
|
5831
|
-
|
|
5832
|
-
|
|
6022
|
+
ctx.watchConf(["markedReplacers", "imgLazyLoad", "markedOptions"], (conf) => {
|
|
6023
|
+
initMarked({
|
|
6024
|
+
markedOptions: ctx.getConf().markedOptions,
|
|
6025
|
+
imgLazyLoad: ctx.getConf().imgLazyLoad
|
|
6026
|
+
});
|
|
5833
6027
|
if (conf.markedReplacers)
|
|
5834
6028
|
setReplacers(conf.markedReplacers);
|
|
5835
6029
|
});
|
|
@@ -7068,7 +7262,7 @@ const GotoFocus = (ctx) => {
|
|
|
7068
7262
|
comment.focus();
|
|
7069
7263
|
}));
|
|
7070
7264
|
};
|
|
7071
|
-
const version = "2.8.
|
|
7265
|
+
const version = "2.8.6";
|
|
7072
7266
|
const Copyright = (ctx) => {
|
|
7073
7267
|
ctx.on("mounted", () => {
|
|
7074
7268
|
const list = ctx.get("list");
|