artalk 2.2.4 → 2.2.7
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.es.js +276 -270
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/src/api/index.ts +19 -3
- package/src/artalk.ts +20 -11
- package/src/components/comment.ts +1 -1
- package/src/components/editor-plugs/emoticons-plug.ts +37 -16
- package/src/components/editor-plugs/preview-plug.ts +1 -1
- package/src/components/editor.ts +21 -2
- package/src/components/list-lite.ts +4 -1
- package/src/components/list.ts +1 -1
- package/src/components/sidebar-layer.ts +3 -3
- package/src/context.ts +2 -1
- package/src/lib/checker/captcha-checker.ts +1 -1
- package/src/lib/checker/index.ts +1 -1
- package/src/lib/detect.ts +222 -0
- package/src/lib/utils.ts +32 -14
- package/types/artalk-config.d.ts +1 -1
- package/src/lib/detect.js +0 -263
package/dist/Artalk.es.js
CHANGED
|
@@ -66,6 +66,7 @@ class Context {
|
|
|
66
66
|
__publicField(this, "user");
|
|
67
67
|
__publicField(this, "eventList", []);
|
|
68
68
|
__publicField(this, "markedInstance");
|
|
69
|
+
__publicField(this, "markedReplacers", []);
|
|
69
70
|
this.cid = +new Date();
|
|
70
71
|
this.$root = rootEl;
|
|
71
72
|
this.conf = conf;
|
|
@@ -1122,7 +1123,7 @@ function mangle(text) {
|
|
|
1122
1123
|
class Lexer {
|
|
1123
1124
|
constructor(options) {
|
|
1124
1125
|
this.tokens = [];
|
|
1125
|
-
this.tokens.links = Object.create(null);
|
|
1126
|
+
this.tokens.links = /* @__PURE__ */ Object.create(null);
|
|
1126
1127
|
this.options = options || defaults$2;
|
|
1127
1128
|
this.options.tokenizer = this.options.tokenizer || new Tokenizer();
|
|
1128
1129
|
this.tokenizer = this.options.tokenizer;
|
|
@@ -2656,10 +2657,10 @@ function versionCompare(a, b) {
|
|
|
2656
2657
|
}
|
|
2657
2658
|
function initMarked(ctx) {
|
|
2658
2659
|
const renderer = new marked$1.Renderer();
|
|
2659
|
-
const
|
|
2660
|
+
const orgLinkRenderer = renderer.link;
|
|
2660
2661
|
renderer.link = (href, title, text) => {
|
|
2661
2662
|
const localLink = href == null ? void 0 : href.startsWith(`${window.location.protocol}//${window.location.hostname}`);
|
|
2662
|
-
const html =
|
|
2663
|
+
const html = orgLinkRenderer.call(renderer, href, title, text);
|
|
2663
2664
|
return html.replace(/^<a /, `<a target="_blank" ${!localLink ? `rel="noreferrer noopener nofollow"` : ""} `);
|
|
2664
2665
|
};
|
|
2665
2666
|
renderer.code = (block2, lang) => {
|
|
@@ -2691,7 +2692,7 @@ function initMarked(ctx) {
|
|
|
2691
2692
|
ctx.markedInstance = nMarked;
|
|
2692
2693
|
}
|
|
2693
2694
|
function marked(ctx, src) {
|
|
2694
|
-
|
|
2695
|
+
let dest = insane_1(ctx.markedInstance.parse(src), {
|
|
2695
2696
|
allowedClasses: {},
|
|
2696
2697
|
allowedSchemes: ["http", "https", "mailto"],
|
|
2697
2698
|
allowedTags: [
|
|
@@ -2742,7 +2743,7 @@ function marked(ctx, src) {
|
|
|
2742
2743
|
],
|
|
2743
2744
|
allowedAttributes: {
|
|
2744
2745
|
"*": ["title", "accesskey"],
|
|
2745
|
-
a: ["href", "name", "target", "aria-label"],
|
|
2746
|
+
a: ["href", "name", "target", "aria-label", "rel"],
|
|
2746
2747
|
img: ["src", "alt", "title", "atk-emoticon", "aria-label"],
|
|
2747
2748
|
code: ["class"],
|
|
2748
2749
|
span: ["class", "style"]
|
|
@@ -2763,14 +2764,19 @@ function marked(ctx, src) {
|
|
|
2763
2764
|
return true;
|
|
2764
2765
|
}
|
|
2765
2766
|
});
|
|
2767
|
+
ctx.markedReplacers.forEach((replacer) => {
|
|
2768
|
+
if (typeof replacer === "function")
|
|
2769
|
+
dest = replacer(dest);
|
|
2770
|
+
});
|
|
2771
|
+
return dest;
|
|
2766
2772
|
}
|
|
2767
2773
|
function getCorrectUserAgent() {
|
|
2768
2774
|
return __async(this, null, function* () {
|
|
2769
2775
|
const uaRaw = navigator.userAgent;
|
|
2770
|
-
|
|
2771
|
-
if (!uaData || !uaData.getHighEntropyValues) {
|
|
2776
|
+
if (!navigator.userAgentData || !navigator.userAgentData.getHighEntropyValues) {
|
|
2772
2777
|
return uaRaw;
|
|
2773
2778
|
}
|
|
2779
|
+
const uaData = navigator.userAgentData;
|
|
2774
2780
|
let uaGot = null;
|
|
2775
2781
|
try {
|
|
2776
2782
|
uaGot = yield uaData.getHighEntropyValues(["platformVersion"]);
|
|
@@ -2778,12 +2784,16 @@ function getCorrectUserAgent() {
|
|
|
2778
2784
|
console.error(err);
|
|
2779
2785
|
return uaRaw;
|
|
2780
2786
|
}
|
|
2781
|
-
if (uaData.platform !== "Windows") {
|
|
2782
|
-
return uaRaw;
|
|
2783
|
-
}
|
|
2784
2787
|
const majorPlatformVersion = Number(uaGot.platformVersion.split(".")[0]);
|
|
2785
|
-
if (
|
|
2786
|
-
|
|
2788
|
+
if (uaData.platform === "Windows") {
|
|
2789
|
+
if (majorPlatformVersion >= 13) {
|
|
2790
|
+
return uaRaw.replace(/Windows NT 10.0/, "Windows NT 11.0");
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
if (uaData.platform === "macOS") {
|
|
2794
|
+
if (majorPlatformVersion >= 11) {
|
|
2795
|
+
return uaRaw.replace(/(Mac OS X \d+_\d+_\d+|Mac OS X)/, `Mac OS X ${uaGot.platformVersion.replace(/\./g, "_")}`);
|
|
2796
|
+
}
|
|
2787
2797
|
}
|
|
2788
2798
|
return uaRaw;
|
|
2789
2799
|
});
|
|
@@ -2798,7 +2808,10 @@ function isValidURL(urlRaw) {
|
|
|
2798
2808
|
return url.protocol === "http:" || url.protocol === "https:";
|
|
2799
2809
|
}
|
|
2800
2810
|
function getURLBasedOnApi(ctx, path) {
|
|
2801
|
-
return
|
|
2811
|
+
return getURLBasedOn(ctx.conf.server, path);
|
|
2812
|
+
}
|
|
2813
|
+
function getURLBasedOn(baseURL, path) {
|
|
2814
|
+
return `${baseURL.replace(/\/$/, "")}/${path.replace(/^\//, "")}`;
|
|
2802
2815
|
}
|
|
2803
2816
|
function showLoading(parentElem, conf) {
|
|
2804
2817
|
if (parentElem instanceof Context)
|
|
@@ -3181,7 +3194,7 @@ class Api {
|
|
|
3181
3194
|
__publicField(this, "ctx");
|
|
3182
3195
|
__publicField(this, "baseURL");
|
|
3183
3196
|
this.ctx = ctx;
|
|
3184
|
-
this.baseURL = ctx.conf.server
|
|
3197
|
+
this.baseURL = `${ctx.conf.server}/api`;
|
|
3185
3198
|
}
|
|
3186
3199
|
get(offset, pageSize, flatMode, paramsEditor) {
|
|
3187
3200
|
const params = {
|
|
@@ -3439,6 +3452,14 @@ class Api {
|
|
|
3439
3452
|
return data || { is_pass: false };
|
|
3440
3453
|
});
|
|
3441
3454
|
}
|
|
3455
|
+
cacheFlushAll() {
|
|
3456
|
+
const params = { flush_all: true };
|
|
3457
|
+
return POST(this.ctx, `${this.baseURL}/admin/cache-flush`, params);
|
|
3458
|
+
}
|
|
3459
|
+
cacheWarmUp() {
|
|
3460
|
+
const params = {};
|
|
3461
|
+
return POST(this.ctx, `${this.baseURL}/admin/cache-warm`, params);
|
|
3462
|
+
}
|
|
3442
3463
|
}
|
|
3443
3464
|
const CaptchaChecker = {
|
|
3444
3465
|
request(that, ctx, inputVal) {
|
|
@@ -3450,7 +3471,7 @@ const CaptchaChecker = {
|
|
|
3450
3471
|
const $iframe = createElement(`<iframe class="atk-fade-in"></iframe>`);
|
|
3451
3472
|
$iframe.style.display = "none";
|
|
3452
3473
|
showLoading($iframeWrap, { transparentBg: true });
|
|
3453
|
-
$iframe.src = `${that.ctx.conf.server}/captcha/get?t=${+new Date()}`;
|
|
3474
|
+
$iframe.src = `${that.ctx.conf.server}/api/captcha/get?t=${+new Date()}`;
|
|
3454
3475
|
$iframe.onload = () => {
|
|
3455
3476
|
$iframe.style.display = "";
|
|
3456
3477
|
hideLoading($iframeWrap);
|
|
@@ -3660,16 +3681,28 @@ class EmoticonsPlug extends EditorPlug {
|
|
|
3660
3681
|
__publicField(this, "emoticons", []);
|
|
3661
3682
|
__publicField(this, "$grpWrap");
|
|
3662
3683
|
__publicField(this, "$grpSwitcher");
|
|
3684
|
+
__publicField(this, "loadingTask", null);
|
|
3685
|
+
__publicField(this, "isListLoaded", false);
|
|
3686
|
+
__publicField(this, "isImgLoaded", false);
|
|
3663
3687
|
this.editor = editor2;
|
|
3664
3688
|
this.$el = createElement(`<div class="atk-editor-plug-emoticons"></div>`);
|
|
3665
|
-
this.init();
|
|
3666
3689
|
}
|
|
3667
|
-
|
|
3690
|
+
loadEmoticonsData() {
|
|
3668
3691
|
return __async(this, null, function* () {
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3692
|
+
if (this.isListLoaded)
|
|
3693
|
+
return;
|
|
3694
|
+
if (this.loadingTask !== null) {
|
|
3695
|
+
yield this.loadingTask;
|
|
3696
|
+
return;
|
|
3697
|
+
}
|
|
3698
|
+
this.loadingTask = (() => __async(this, null, function* () {
|
|
3699
|
+
showLoading(this.$el);
|
|
3700
|
+
this.emoticons = yield this.handleData(this.ctx.conf.emoticons);
|
|
3701
|
+
hideLoading(this.$el);
|
|
3702
|
+
this.loadingTask = null;
|
|
3703
|
+
this.isListLoaded = true;
|
|
3704
|
+
}))();
|
|
3705
|
+
yield this.loadingTask;
|
|
3673
3706
|
});
|
|
3674
3707
|
}
|
|
3675
3708
|
handleData(data) {
|
|
@@ -3718,7 +3751,6 @@ class EmoticonsPlug extends EditorPlug {
|
|
|
3718
3751
|
}
|
|
3719
3752
|
});
|
|
3720
3753
|
data = data.filter((item) => typeof item === "object" && !Array.isArray(item) && !!item && !!item.name);
|
|
3721
|
-
console.log(data);
|
|
3722
3754
|
this.solveNullKey(data);
|
|
3723
3755
|
this.solveSameKey(data);
|
|
3724
3756
|
return data;
|
|
@@ -3849,9 +3881,16 @@ class EmoticonsPlug extends EditorPlug {
|
|
|
3849
3881
|
changeListHeight() {
|
|
3850
3882
|
}
|
|
3851
3883
|
onShow() {
|
|
3852
|
-
|
|
3853
|
-
this.
|
|
3854
|
-
|
|
3884
|
+
(() => __async(this, null, function* () {
|
|
3885
|
+
yield this.loadEmoticonsData();
|
|
3886
|
+
if (!this.isImgLoaded) {
|
|
3887
|
+
this.initEmoticonsList();
|
|
3888
|
+
this.isImgLoaded = true;
|
|
3889
|
+
}
|
|
3890
|
+
setTimeout(() => {
|
|
3891
|
+
this.changeListHeight();
|
|
3892
|
+
}, 30);
|
|
3893
|
+
}))();
|
|
3855
3894
|
}
|
|
3856
3895
|
onHide() {
|
|
3857
3896
|
this.$el.parentElement.style.height = "";
|
|
@@ -4055,6 +4094,13 @@ class Editor extends Component {
|
|
|
4055
4094
|
this.LOADABLE_PLUG_LIST.forEach((PlugObj) => {
|
|
4056
4095
|
const btnElem = createElement(`<span class="atk-plug-btn" data-plug-name="${PlugObj.Name}">${PlugObj.BtnHTML}</span>`);
|
|
4057
4096
|
this.$plugBtnWrap.appendChild(btnElem);
|
|
4097
|
+
if (PlugObj.Name === "emoticons") {
|
|
4098
|
+
const emoPlug = new PlugObj(this);
|
|
4099
|
+
this.plugList[PlugObj.Name] = emoPlug;
|
|
4100
|
+
window.setTimeout(() => {
|
|
4101
|
+
emoPlug.loadEmoticonsData();
|
|
4102
|
+
}, 1e3);
|
|
4103
|
+
}
|
|
4058
4104
|
btnElem.addEventListener("click", () => {
|
|
4059
4105
|
let plug = this.plugList[PlugObj.Name];
|
|
4060
4106
|
if (!plug) {
|
|
@@ -4209,7 +4255,9 @@ class Editor extends Component {
|
|
|
4209
4255
|
if (!!this.plugList && !!this.plugList.preview) {
|
|
4210
4256
|
this.plugList.preview.updateContent();
|
|
4211
4257
|
}
|
|
4212
|
-
|
|
4258
|
+
window.setTimeout(() => {
|
|
4259
|
+
this.adjustTextareaHeight();
|
|
4260
|
+
}, 80);
|
|
4213
4261
|
}
|
|
4214
4262
|
clearEditor() {
|
|
4215
4263
|
this.setContent("");
|
|
@@ -4348,252 +4396,201 @@ class Editor extends Component {
|
|
|
4348
4396
|
if (this.replyComment !== null)
|
|
4349
4397
|
this.cancelReply();
|
|
4350
4398
|
}
|
|
4399
|
+
initRemoteEmoticons() {
|
|
4400
|
+
}
|
|
4351
4401
|
}
|
|
4352
4402
|
var list = "";
|
|
4353
4403
|
var ListHTML = '<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <div class="atk-text">\n <span class="atk-comment-count-num">0</span>\n \u6761\u8BC4\u8BBA\n </div>\n </div>\n <div class="atk-right-action">\n <span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show>\u5173\u95ED\u8BC4\u8BBA</span>\n <span data-action="open-sidebar" class="atk-hide atk-on">\n <span class="atk-unread-badge" style="display: none;"></span>\n <div class="atk-text">\u901A\u77E5\u4E2D\u5FC3</div>\n </span>\n </div>\n </div>\n <div class="atk-list-body"></div>\n <div class="atk-list-footer">\n <div class="atk-copyright"></div>\n </div>\n</div>\n';
|
|
4354
4404
|
var comment = "";
|
|
4355
|
-
|
|
4356
|
-
|
|
4405
|
+
const win = window || {};
|
|
4406
|
+
const nav = navigator || {};
|
|
4357
4407
|
function Detect(userAgent) {
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
IE: u.indexOf("MSIE") > -1 || u.indexOf("Trident") > -1,
|
|
4368
|
-
Edge: u.indexOf("Edge") > -1,
|
|
4369
|
-
Firefox: u.indexOf("Firefox") > -1 || u.indexOf("FxiOS") > -1,
|
|
4370
|
-
"Firefox Focus": u.indexOf("Focus") > -1,
|
|
4371
|
-
Chromium: u.indexOf("Chromium") > -1,
|
|
4372
|
-
Opera: u.indexOf("Opera") > -1 || u.indexOf("OPR") > -1,
|
|
4373
|
-
Vivaldi: u.indexOf("Vivaldi") > -1,
|
|
4374
|
-
Yandex: u.indexOf("YaBrowser") > -1,
|
|
4375
|
-
Kindle: u.indexOf("Kindle") > -1 || u.indexOf("Silk/") > -1,
|
|
4376
|
-
360: u.indexOf("360EE") > -1 || u.indexOf("360SE") > -1,
|
|
4377
|
-
UC: u.indexOf("UC") > -1 || u.indexOf(" UBrowser") > -1,
|
|
4378
|
-
QQBrowser: u.indexOf("QQBrowser") > -1,
|
|
4379
|
-
QQ: u.indexOf("QQ/") > -1,
|
|
4380
|
-
Baidu: u.indexOf("Baidu") > -1 || u.indexOf("BIDUBrowser") > -1,
|
|
4381
|
-
Maxthon: u.indexOf("Maxthon") > -1,
|
|
4382
|
-
Sogou: u.indexOf("MetaSr") > -1 || u.indexOf("Sogou") > -1,
|
|
4383
|
-
LBBROWSER: u.indexOf("LBBROWSER") > -1,
|
|
4384
|
-
"2345Explorer": u.indexOf("2345Explorer") > -1,
|
|
4385
|
-
TheWorld: u.indexOf("TheWorld") > -1,
|
|
4386
|
-
XiaoMi: u.indexOf("MiuiBrowser") > -1,
|
|
4387
|
-
Quark: u.indexOf("Quark") > -1,
|
|
4388
|
-
Qiyu: u.indexOf("Qiyu") > -1,
|
|
4389
|
-
Wechat: u.indexOf("MicroMessenger") > -1,
|
|
4390
|
-
Taobao: u.indexOf("AliApp(TB") > -1,
|
|
4391
|
-
Alipay: u.indexOf("AliApp(AP") > -1,
|
|
4392
|
-
Weibo: u.indexOf("Weibo") > -1,
|
|
4393
|
-
Douban: u.indexOf("com.douban.frodo") > -1,
|
|
4394
|
-
Suning: u.indexOf("SNEBUY-APP") > -1,
|
|
4395
|
-
iQiYi: u.indexOf("IqiyiApp") > -1,
|
|
4396
|
-
Windows: u.indexOf("Windows") > -1,
|
|
4397
|
-
Linux: u.indexOf("Linux") > -1 || u.indexOf("X11") > -1,
|
|
4398
|
-
"Mac OS": u.indexOf("Macintosh") > -1,
|
|
4399
|
-
Android: u.indexOf("Android") > -1 || u.indexOf("Adr") > -1,
|
|
4400
|
-
Ubuntu: u.indexOf("Ubuntu") > -1,
|
|
4401
|
-
FreeBSD: u.indexOf("FreeBSD") > -1,
|
|
4402
|
-
Debian: u.indexOf("Debian") > -1,
|
|
4403
|
-
"Windows Phone": u.indexOf("IEMobile") > -1 || u.indexOf("Windows Phone") > -1,
|
|
4404
|
-
BlackBerry: u.indexOf("BlackBerry") > -1 || u.indexOf("RIM") > -1,
|
|
4405
|
-
MeeGo: u.indexOf("MeeGo") > -1,
|
|
4406
|
-
Symbian: u.indexOf("Symbian") > -1,
|
|
4407
|
-
iOS: u.indexOf("like Mac OS X") > -1,
|
|
4408
|
-
"Chrome OS": u.indexOf("CrOS") > -1,
|
|
4409
|
-
WebOS: u.indexOf("hpwOS") > -1,
|
|
4410
|
-
Mobile: u.indexOf("Mobi") > -1 || u.indexOf("iPh") > -1 || u.indexOf("480") > -1,
|
|
4411
|
-
Tablet: u.indexOf("Tablet") > -1 || u.indexOf("Pad") > -1 || u.indexOf("Nexus 7") > -1
|
|
4408
|
+
const u = String(userAgent || nav.userAgent);
|
|
4409
|
+
const dest = {
|
|
4410
|
+
os: "",
|
|
4411
|
+
osVersion: "",
|
|
4412
|
+
engine: "",
|
|
4413
|
+
browser: "",
|
|
4414
|
+
device: "",
|
|
4415
|
+
language: "",
|
|
4416
|
+
version: ""
|
|
4412
4417
|
};
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4418
|
+
const engineMatch = {
|
|
4419
|
+
Trident: u.includes("Trident") || u.includes("NET CLR"),
|
|
4420
|
+
Presto: u.includes("Presto"),
|
|
4421
|
+
WebKit: u.includes("AppleWebKit"),
|
|
4422
|
+
Gecko: u.includes("Gecko/")
|
|
4423
|
+
};
|
|
4424
|
+
const browserMatch = {
|
|
4425
|
+
Safari: u.includes("Safari"),
|
|
4426
|
+
Chrome: u.includes("Chrome") || u.includes("CriOS"),
|
|
4427
|
+
IE: u.includes("MSIE") || u.includes("Trident"),
|
|
4428
|
+
Edge: u.includes("Edge") || u.includes("Edg"),
|
|
4429
|
+
Firefox: u.includes("Firefox") || u.includes("FxiOS"),
|
|
4430
|
+
"Firefox Focus": u.includes("Focus"),
|
|
4431
|
+
Chromium: u.includes("Chromium"),
|
|
4432
|
+
Opera: u.includes("Opera") || u.includes("OPR"),
|
|
4433
|
+
Vivaldi: u.includes("Vivaldi"),
|
|
4434
|
+
Yandex: u.includes("YaBrowser"),
|
|
4435
|
+
Kindle: u.includes("Kindle") || u.includes("Silk/"),
|
|
4436
|
+
360: u.includes("360EE") || u.includes("360SE"),
|
|
4437
|
+
UC: u.includes("UC") || u.includes(" UBrowser"),
|
|
4438
|
+
QQBrowser: u.includes("QQBrowser"),
|
|
4439
|
+
QQ: u.includes("QQ/"),
|
|
4440
|
+
Baidu: u.includes("Baidu") || u.includes("BIDUBrowser"),
|
|
4441
|
+
Maxthon: u.includes("Maxthon"),
|
|
4442
|
+
Sogou: u.includes("MetaSr") || u.includes("Sogou"),
|
|
4443
|
+
LBBROWSER: u.includes("LBBROWSER"),
|
|
4444
|
+
"2345Explorer": u.includes("2345Explorer"),
|
|
4445
|
+
TheWorld: u.includes("TheWorld"),
|
|
4446
|
+
MIUI: u.includes("MiuiBrowser"),
|
|
4447
|
+
Quark: u.includes("Quark"),
|
|
4448
|
+
Qiyu: u.includes("Qiyu"),
|
|
4449
|
+
Wechat: u.includes("MicroMessenger"),
|
|
4450
|
+
Taobao: u.includes("AliApp(TB"),
|
|
4451
|
+
Alipay: u.includes("AliApp(AP"),
|
|
4452
|
+
Weibo: u.includes("Weibo"),
|
|
4453
|
+
Douban: u.includes("com.douban.frodo"),
|
|
4454
|
+
Suning: u.includes("SNEBUY-APP"),
|
|
4455
|
+
iQiYi: u.includes("IqiyiApp")
|
|
4456
|
+
};
|
|
4457
|
+
const osMatch = {
|
|
4458
|
+
Windows: u.includes("Windows"),
|
|
4459
|
+
Linux: u.includes("Linux") || u.includes("X11"),
|
|
4460
|
+
"macOS": u.includes("Macintosh"),
|
|
4461
|
+
Android: u.includes("Android") || u.includes("Adr"),
|
|
4462
|
+
Ubuntu: u.includes("Ubuntu"),
|
|
4463
|
+
FreeBSD: u.includes("FreeBSD"),
|
|
4464
|
+
Debian: u.includes("Debian"),
|
|
4465
|
+
"Windows Phone": u.includes("IEMobile") || u.includes("Windows Phone"),
|
|
4466
|
+
BlackBerry: u.includes("BlackBerry") || u.includes("RIM"),
|
|
4467
|
+
MeeGo: u.includes("MeeGo"),
|
|
4468
|
+
Symbian: u.includes("Symbian"),
|
|
4469
|
+
iOS: u.includes("like Mac OS X"),
|
|
4470
|
+
"Chrome OS": u.includes("CrOS"),
|
|
4471
|
+
WebOS: u.includes("hpwOS")
|
|
4423
4472
|
};
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4473
|
+
const deviceMatch = {
|
|
4474
|
+
Mobile: u.includes("Mobi") || u.includes("iPh") || u.includes("480"),
|
|
4475
|
+
Tablet: u.includes("Tablet") || u.includes("Pad") || u.includes("Nexus 7")
|
|
4476
|
+
};
|
|
4477
|
+
if (deviceMatch.Mobile) {
|
|
4478
|
+
deviceMatch.Mobile = !u.includes("iPad");
|
|
4479
|
+
} else if (browserMatch.Chrome && u.includes("Edg")) {
|
|
4480
|
+
browserMatch.Chrome = false;
|
|
4481
|
+
browserMatch.Edge = true;
|
|
4482
|
+
} else if (win.showModalDialog && win.chrome) {
|
|
4483
|
+
browserMatch.Chrome = false;
|
|
4484
|
+
browserMatch["360"] = true;
|
|
4485
|
+
}
|
|
4486
|
+
dest.device = "PC";
|
|
4487
|
+
dest.language = (() => {
|
|
4488
|
+
const g = nav.browserLanguage || nav.language;
|
|
4489
|
+
const arr = g.split("-");
|
|
4490
|
+
if (arr[1])
|
|
4429
4491
|
arr[1] = arr[1].toUpperCase();
|
|
4430
|
-
}
|
|
4431
4492
|
return arr.join("_");
|
|
4432
|
-
}();
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4493
|
+
})();
|
|
4494
|
+
const hash = {
|
|
4495
|
+
engine: engineMatch,
|
|
4496
|
+
browser: browserMatch,
|
|
4497
|
+
os: osMatch,
|
|
4498
|
+
device: deviceMatch
|
|
4499
|
+
};
|
|
4500
|
+
Object.entries(hash).forEach(([type, match]) => {
|
|
4501
|
+
Object.entries(match).forEach(([name, result]) => {
|
|
4502
|
+
if (result === true)
|
|
4503
|
+
dest[type] = name;
|
|
4504
|
+
});
|
|
4505
|
+
});
|
|
4506
|
+
const osVersion = {
|
|
4507
|
+
Windows: () => {
|
|
4508
|
+
const v = u.replace(/^.*Windows NT ([\d.]+);.*$/, "$1");
|
|
4509
|
+
const wvHash = {
|
|
4510
|
+
"6.4": "10",
|
|
4511
|
+
"6.3": "8.1",
|
|
4512
|
+
"6.2": "8",
|
|
4513
|
+
"6.1": "7",
|
|
4449
4514
|
"6.0": "Vista",
|
|
4450
|
-
5.2: "XP",
|
|
4451
|
-
5.1: "XP",
|
|
4515
|
+
"5.2": "XP",
|
|
4516
|
+
"5.1": "XP",
|
|
4452
4517
|
"5.0": "2000",
|
|
4453
4518
|
"10.0": "10",
|
|
4454
4519
|
"11.0": "11"
|
|
4455
4520
|
};
|
|
4456
|
-
return
|
|
4457
|
-
},
|
|
4458
|
-
Android: function() {
|
|
4459
|
-
return u.replace(/^.*Android ([\d.]+);.*$/, "$1");
|
|
4521
|
+
return wvHash[v] || v;
|
|
4460
4522
|
},
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
"Windows Phone": function() {
|
|
4468
|
-
return u.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/, "$2");
|
|
4469
|
-
},
|
|
4470
|
-
"Mac OS": function() {
|
|
4471
|
-
return u.replace(/^.*Mac OS X ([\d_]+).*$/, "$1").replace(/_/g, ".");
|
|
4472
|
-
},
|
|
4473
|
-
WebOS: function() {
|
|
4474
|
-
return u.replace(/^.*hpwOS\/([\d.]+);.*$/, "$1");
|
|
4475
|
-
}
|
|
4523
|
+
Android: () => u.replace(/^.*Android ([\d.]+);.*$/, "$1"),
|
|
4524
|
+
iOS: () => u.replace(/^.*OS ([\d_]+) like.*$/, "$1").replace(/_/g, "."),
|
|
4525
|
+
Debian: () => u.replace(/^.*Debian\/([\d.]+).*$/, "$1"),
|
|
4526
|
+
"Windows Phone": () => u.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/, "$2"),
|
|
4527
|
+
"macOS": () => u.replace(/^.*Mac OS X ([\d_]+).*$/, "$1").replace(/_/g, "."),
|
|
4528
|
+
WebOS: () => u.replace(/^.*hpwOS\/([\d.]+);.*$/, "$1")
|
|
4476
4529
|
};
|
|
4477
|
-
|
|
4478
|
-
if (osVersion[
|
|
4479
|
-
|
|
4480
|
-
if (
|
|
4481
|
-
|
|
4482
|
-
}
|
|
4483
|
-
}
|
|
4484
|
-
|
|
4485
|
-
Safari:
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
},
|
|
4515
|
-
Kindle: function() {
|
|
4516
|
-
return u.replace(/^.*Version\/([\d.]+).*$/, "$1");
|
|
4517
|
-
},
|
|
4518
|
-
Maxthon: function() {
|
|
4519
|
-
return u.replace(/^.*Maxthon\/([\d.]+).*$/, "$1");
|
|
4520
|
-
},
|
|
4521
|
-
QQBrowser: function() {
|
|
4522
|
-
return u.replace(/^.*QQBrowser\/([\d.]+).*$/, "$1");
|
|
4523
|
-
},
|
|
4524
|
-
QQ: function() {
|
|
4525
|
-
return u.replace(/^.*QQ\/([\d.]+).*$/, "$1");
|
|
4526
|
-
},
|
|
4527
|
-
Baidu: function() {
|
|
4528
|
-
return u.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/, "$1");
|
|
4529
|
-
},
|
|
4530
|
-
UC: function() {
|
|
4531
|
-
return u.replace(/^.*UC?Browser\/([\d.]+).*$/, "$1");
|
|
4532
|
-
},
|
|
4533
|
-
Sogou: function() {
|
|
4534
|
-
return u.replace(/^.*SE ([\d.X]+).*$/, "$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/, "$1");
|
|
4535
|
-
},
|
|
4536
|
-
"2345Explorer": function() {
|
|
4537
|
-
return u.replace(/^.*2345Explorer\/([\d.]+).*$/, "$1");
|
|
4538
|
-
},
|
|
4539
|
-
TheWorld: function() {
|
|
4540
|
-
return u.replace(/^.*TheWorld ([\d.]+).*$/, "$1");
|
|
4541
|
-
},
|
|
4542
|
-
XiaoMi: function() {
|
|
4543
|
-
return u.replace(/^.*MiuiBrowser\/([\d.]+).*$/, "$1");
|
|
4544
|
-
},
|
|
4545
|
-
Quark: function() {
|
|
4546
|
-
return u.replace(/^.*Quark\/([\d.]+).*$/, "$1");
|
|
4547
|
-
},
|
|
4548
|
-
Qiyu: function() {
|
|
4549
|
-
return u.replace(/^.*Qiyu\/([\d.]+).*$/, "$1");
|
|
4550
|
-
},
|
|
4551
|
-
Wechat: function() {
|
|
4552
|
-
return u.replace(/^.*MicroMessenger\/([\d.]+).*$/, "$1");
|
|
4553
|
-
},
|
|
4554
|
-
Taobao: function() {
|
|
4555
|
-
return u.replace(/^.*AliApp\(TB\/([\d.]+).*$/, "$1");
|
|
4556
|
-
},
|
|
4557
|
-
Alipay: function() {
|
|
4558
|
-
return u.replace(/^.*AliApp\(AP\/([\d.]+).*$/, "$1");
|
|
4559
|
-
},
|
|
4560
|
-
Weibo: function() {
|
|
4561
|
-
return u.replace(/^.*weibo__([\d.]+).*$/, "$1");
|
|
4562
|
-
},
|
|
4563
|
-
Douban: function() {
|
|
4564
|
-
return u.replace(/^.*com.douban.frodo\/([\d.]+).*$/, "$1");
|
|
4565
|
-
},
|
|
4566
|
-
Suning: function() {
|
|
4567
|
-
return u.replace(/^.*SNEBUY-APP([\d.]+).*$/, "$1");
|
|
4568
|
-
},
|
|
4569
|
-
iQiYi: function() {
|
|
4570
|
-
return u.replace(/^.*IqiyiVersion\/([\d.]+).*$/, "$1");
|
|
4571
|
-
}
|
|
4530
|
+
dest.osVersion = "";
|
|
4531
|
+
if (osVersion[dest.os]) {
|
|
4532
|
+
dest.osVersion = osVersion[dest.os]();
|
|
4533
|
+
if (dest.osVersion === u) {
|
|
4534
|
+
dest.osVersion = "";
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
const version = {
|
|
4538
|
+
Safari: () => u.replace(/^.*Version\/([\d.]+).*$/, "$1"),
|
|
4539
|
+
Chrome: () => u.replace(/^.*Chrome\/([\d.]+).*$/, "$1").replace(/^.*CriOS\/([\d.]+).*$/, "$1"),
|
|
4540
|
+
IE: () => u.replace(/^.*MSIE ([\d.]+).*$/, "$1").replace(/^.*rv:([\d.]+).*$/, "$1"),
|
|
4541
|
+
Edge: () => u.replace(/^.*(Edge|Edg|Edg[A-Z]{1})\/([\d.]+).*$/, "$2"),
|
|
4542
|
+
Firefox: () => u.replace(/^.*Firefox\/([\d.]+).*$/, "$1").replace(/^.*FxiOS\/([\d.]+).*$/, "$1"),
|
|
4543
|
+
"Firefox Focus": () => u.replace(/^.*Focus\/([\d.]+).*$/, "$1"),
|
|
4544
|
+
Chromium: () => u.replace(/^.*Chromium\/([\d.]+).*$/, "$1"),
|
|
4545
|
+
Opera: () => u.replace(/^.*Opera\/([\d.]+).*$/, "$1").replace(/^.*OPR\/([\d.]+).*$/, "$1"),
|
|
4546
|
+
Vivaldi: () => u.replace(/^.*Vivaldi\/([\d.]+).*$/, "$1"),
|
|
4547
|
+
Yandex: () => u.replace(/^.*YaBrowser\/([\d.]+).*$/, "$1"),
|
|
4548
|
+
Kindle: () => u.replace(/^.*Version\/([\d.]+).*$/, "$1"),
|
|
4549
|
+
Maxthon: () => u.replace(/^.*Maxthon\/([\d.]+).*$/, "$1"),
|
|
4550
|
+
QQBrowser: () => u.replace(/^.*QQBrowser\/([\d.]+).*$/, "$1"),
|
|
4551
|
+
QQ: () => u.replace(/^.*QQ\/([\d.]+).*$/, "$1"),
|
|
4552
|
+
Baidu: () => u.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/, "$1"),
|
|
4553
|
+
UC: () => u.replace(/^.*UC?Browser\/([\d.]+).*$/, "$1"),
|
|
4554
|
+
Sogou: () => u.replace(/^.*SE ([\d.X]+).*$/, "$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/, "$1"),
|
|
4555
|
+
"2345Explorer": () => u.replace(/^.*2345Explorer\/([\d.]+).*$/, "$1"),
|
|
4556
|
+
TheWorld: () => u.replace(/^.*TheWorld ([\d.]+).*$/, "$1"),
|
|
4557
|
+
MIUI: () => u.replace(/^.*MiuiBrowser\/([\d.]+).*$/, "$1"),
|
|
4558
|
+
Quark: () => u.replace(/^.*Quark\/([\d.]+).*$/, "$1"),
|
|
4559
|
+
Qiyu: () => u.replace(/^.*Qiyu\/([\d.]+).*$/, "$1"),
|
|
4560
|
+
Wechat: () => u.replace(/^.*MicroMessenger\/([\d.]+).*$/, "$1"),
|
|
4561
|
+
Taobao: () => u.replace(/^.*AliApp\(TB\/([\d.]+).*$/, "$1"),
|
|
4562
|
+
Alipay: () => u.replace(/^.*AliApp\(AP\/([\d.]+).*$/, "$1"),
|
|
4563
|
+
Weibo: () => u.replace(/^.*weibo__([\d.]+).*$/, "$1"),
|
|
4564
|
+
Douban: () => u.replace(/^.*com.douban.frodo\/([\d.]+).*$/, "$1"),
|
|
4565
|
+
Suning: () => u.replace(/^.*SNEBUY-APP([\d.]+).*$/, "$1"),
|
|
4566
|
+
iQiYi: () => u.replace(/^.*IqiyiVersion\/([\d.]+).*$/, "$1")
|
|
4572
4567
|
};
|
|
4573
|
-
|
|
4574
|
-
if (version[
|
|
4575
|
-
|
|
4576
|
-
if (
|
|
4577
|
-
|
|
4578
|
-
}
|
|
4579
|
-
}
|
|
4580
|
-
if (
|
|
4581
|
-
|
|
4582
|
-
}
|
|
4583
|
-
if (
|
|
4584
|
-
|
|
4585
|
-
} else if (
|
|
4586
|
-
|
|
4587
|
-
} else if (
|
|
4588
|
-
|
|
4589
|
-
} else if (
|
|
4590
|
-
|
|
4591
|
-
} else if (
|
|
4592
|
-
|
|
4593
|
-
}
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4568
|
+
dest.version = "";
|
|
4569
|
+
if (version[dest.browser]) {
|
|
4570
|
+
dest.version = version[dest.browser]();
|
|
4571
|
+
if (dest.version === u) {
|
|
4572
|
+
dest.version = "";
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
if (dest.version.indexOf(".")) {
|
|
4576
|
+
dest.version = dest.version.substring(0, dest.version.indexOf("."));
|
|
4577
|
+
}
|
|
4578
|
+
if (dest.os === "iOS" && u.includes("iPad")) {
|
|
4579
|
+
dest.os = "iPadOS";
|
|
4580
|
+
} else if (dest.browser === "Edge" && !u.includes("Edg")) {
|
|
4581
|
+
dest.engine = "EdgeHTML";
|
|
4582
|
+
} else if (dest.browser === "MIUI") {
|
|
4583
|
+
dest.os = "Android";
|
|
4584
|
+
} else if (dest.browser === "Chrome" && Number(dest.version) > 27) {
|
|
4585
|
+
dest.engine = "Blink";
|
|
4586
|
+
} else if (dest.browser === "Opera" && Number(dest.version) > 12) {
|
|
4587
|
+
dest.engine = "Blink";
|
|
4588
|
+
} else if (dest.browser === "Yandex") {
|
|
4589
|
+
dest.engine = "Blink";
|
|
4590
|
+
} else if (dest.browser === void 0) {
|
|
4591
|
+
dest.browser = "Unknow App";
|
|
4592
|
+
}
|
|
4593
|
+
return dest;
|
|
4597
4594
|
}
|
|
4598
4595
|
var 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-item atk-badge"></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';
|
|
4599
4596
|
class ActionBtn {
|
|
@@ -5019,11 +5016,11 @@ class Comment extends Component {
|
|
|
5019
5016
|
return timeAgo(new Date(this.data.date));
|
|
5020
5017
|
}
|
|
5021
5018
|
getUserUaBrowser() {
|
|
5022
|
-
const info =
|
|
5019
|
+
const info = Detect(this.data.ua);
|
|
5023
5020
|
return `${info.browser} ${info.version}`;
|
|
5024
5021
|
}
|
|
5025
5022
|
getUserUaOS() {
|
|
5026
|
-
const info =
|
|
5023
|
+
const info = Detect(this.data.ua);
|
|
5027
5024
|
return `${info.os} ${info.osVersion}`;
|
|
5028
5025
|
}
|
|
5029
5026
|
playFadeInAnim() {
|
|
@@ -5386,6 +5383,8 @@ class ListLite extends Component {
|
|
|
5386
5383
|
<div class="atk-list-comments-wrap"></div>
|
|
5387
5384
|
</div>`);
|
|
5388
5385
|
this.$commentsWrap = this.$el.querySelector(".atk-list-comments-wrap");
|
|
5386
|
+
if (ctx.conf.noComment)
|
|
5387
|
+
this.noCommentText = ctx.conf.noComment;
|
|
5389
5388
|
window.setInterval(() => {
|
|
5390
5389
|
this.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
|
|
5391
5390
|
const date = el.getAttribute("data-atk-comment-date");
|
|
@@ -5448,7 +5447,7 @@ class ListLite extends Component {
|
|
|
5448
5447
|
}
|
|
5449
5448
|
this.data = data;
|
|
5450
5449
|
const feMinVersion = ((_a = data.api_version) == null ? void 0 : _a.fe_min_version) || "0.0.0";
|
|
5451
|
-
if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.
|
|
5450
|
+
if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.7"))
|
|
5452
5451
|
return;
|
|
5453
5452
|
if (this.ctx.conf.versionCheck && this.versionCheck("\u540E\u7AEF", backendMinVersion, (_b = data.api_version) == null ? void 0 : _b.version))
|
|
5454
5453
|
return;
|
|
@@ -5780,7 +5779,7 @@ class List extends ListLite {
|
|
|
5780
5779
|
if (this.ctx.conf.listSort) {
|
|
5781
5780
|
this.initDropdown();
|
|
5782
5781
|
}
|
|
5783
|
-
this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.2.
|
|
5782
|
+
this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.2.7"}">Artalk</a>`;
|
|
5784
5783
|
this.ctx.on("list-reload", () => this.fetchComments(0));
|
|
5785
5784
|
this.ctx.on("list-refresh-ui", () => this.refreshUI());
|
|
5786
5785
|
this.ctx.on("list-import", (data) => this.importComments(data));
|
|
@@ -6006,7 +6005,7 @@ class SidebarLayer extends Component {
|
|
|
6006
6005
|
if (this.firstShow) {
|
|
6007
6006
|
this.$iframeWrap.innerHTML = "";
|
|
6008
6007
|
this.$iframe = createElement("<iframe></iframe>");
|
|
6009
|
-
const baseURL = getURLBasedOnApi(this.ctx, "sidebar/");
|
|
6008
|
+
const baseURL = getURLBasedOnApi(this.ctx, "/sidebar/");
|
|
6010
6009
|
const query = {
|
|
6011
6010
|
pageKey: this.conf.pageKey,
|
|
6012
6011
|
site: this.conf.site || "",
|
|
@@ -6079,18 +6078,25 @@ const _Artalk = class {
|
|
|
6079
6078
|
__publicField(this, "list");
|
|
6080
6079
|
__publicField(this, "sidebarLayer");
|
|
6081
6080
|
this.conf = __spreadValues(__spreadValues({}, _Artalk.defaults), customConf);
|
|
6082
|
-
this.conf.server = this.conf.server.replace(/\/$/, "");
|
|
6081
|
+
this.conf.server = this.conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
|
|
6083
6082
|
if (!this.conf.pageKey) {
|
|
6084
|
-
this.conf.pageKey = `${window.location.
|
|
6083
|
+
this.conf.pageKey = `${window.location.pathname}`;
|
|
6085
6084
|
}
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
this.$root =
|
|
6091
|
-
}
|
|
6092
|
-
|
|
6093
|
-
|
|
6085
|
+
if (!this.conf.pageTitle) {
|
|
6086
|
+
this.conf.pageTitle = `${document.title}`;
|
|
6087
|
+
}
|
|
6088
|
+
if (!!this.conf.el && this.conf.el instanceof HTMLElement) {
|
|
6089
|
+
this.$root = this.conf.el;
|
|
6090
|
+
} else {
|
|
6091
|
+
try {
|
|
6092
|
+
const $root = document.querySelector(this.conf.el);
|
|
6093
|
+
if (!$root)
|
|
6094
|
+
throw Error(`Sorry, target element "${this.conf.el}" was not found.`);
|
|
6095
|
+
this.$root = $root;
|
|
6096
|
+
} catch (e) {
|
|
6097
|
+
console.error(e);
|
|
6098
|
+
throw new Error("Please check your Artalk `el` config.");
|
|
6099
|
+
}
|
|
6094
6100
|
}
|
|
6095
6101
|
this.ctx = new Context(this.$root, this.conf);
|
|
6096
6102
|
this.$root.classList.add("artalk");
|