artalk 2.2.3 → 2.2.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.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;
@@ -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 linkRenderer = renderer.link;
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 = linkRenderer.call(renderer, href, title, text);
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
- return insane_1(ctx.markedInstance.parse(src), {
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
- const uaData = navigator.userAgentData;
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 (majorPlatformVersion >= 13) {
2786
- return uaRaw.replace(/Windows\W+NT\W+10.0/, "Windows NT 11.0");
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 `${ctx.conf.server.replace(/\/api\/?$/, "")}/${path.replace(/^\//, "")}`;
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)
@@ -2939,8 +2952,6 @@ const _Layer = class extends Component {
2939
2952
  __publicField(this, "$wrap");
2940
2953
  __publicField(this, "$mask");
2941
2954
  __publicField(this, "maskClickHideEnable", true);
2942
- __publicField(this, "bodyStyleOrgOverflow", "");
2943
- __publicField(this, "bodyStyleOrgPaddingRight", "");
2944
2955
  __publicField(this, "afterHide");
2945
2956
  this.name = name;
2946
2957
  const { $wrap, $mask } = GetLayerWrap(ctx);
@@ -2985,9 +2996,9 @@ const _Layer = class extends Component {
2985
2996
  this.afterHide();
2986
2997
  this.$wrap.classList.add("atk-fade-out");
2987
2998
  this.$el.style.display = "none";
2999
+ this.pageBodyScrollBarShow();
2988
3000
  this.newActionTimer(() => {
2989
3001
  this.$wrap.style.display = "none";
2990
- this.pageBodyScrollBarShow();
2991
3002
  this.checkCleanLayer();
2992
3003
  }, 450);
2993
3004
  this.newActionTimer(() => {
@@ -2999,15 +3010,13 @@ const _Layer = class extends Component {
2999
3010
  this.maskClickHideEnable = enable;
3000
3011
  }
3001
3012
  pageBodyScrollBarHide() {
3002
- this.bodyStyleOrgOverflow = document.body.style.overflow;
3003
- this.bodyStyleOrgPaddingRight = document.body.style.paddingRight;
3004
3013
  document.body.style.overflow = "hidden";
3005
3014
  const bpr = parseInt(window.getComputedStyle(document.body, null).getPropertyValue("padding-right"), 10);
3006
3015
  document.body.style.paddingRight = `${getScrollBarWidth() + bpr || 0}px`;
3007
3016
  }
3008
3017
  pageBodyScrollBarShow() {
3009
- document.body.style.overflow = this.bodyStyleOrgOverflow;
3010
- document.body.style.paddingRight = this.bodyStyleOrgPaddingRight;
3018
+ document.body.style.overflow = _Layer.BodyOrgOverflow;
3019
+ document.body.style.paddingRight = _Layer.BodyOrgPaddingRight;
3011
3020
  }
3012
3021
  newActionTimer(func, delay) {
3013
3022
  const act = () => {
@@ -3024,7 +3033,6 @@ const _Layer = class extends Component {
3024
3033
  });
3025
3034
  }
3026
3035
  disposeNow() {
3027
- document.body.style.overflow = "";
3028
3036
  this.$el.remove();
3029
3037
  this.pageBodyScrollBarShow();
3030
3038
  this.checkCleanLayer();
@@ -3041,6 +3049,8 @@ const _Layer = class extends Component {
3041
3049
  }
3042
3050
  };
3043
3051
  let Layer = _Layer;
3052
+ __publicField(Layer, "BodyOrgOverflow");
3053
+ __publicField(Layer, "BodyOrgPaddingRight");
3044
3054
  __publicField(Layer, "actionTimers", []);
3045
3055
  function GetLayerWrap(ctx) {
3046
3056
  let $wrap = document.querySelector(`.atk-layer-wrap#ctx-${ctx.cid}`);
@@ -3184,7 +3194,7 @@ class Api {
3184
3194
  __publicField(this, "ctx");
3185
3195
  __publicField(this, "baseURL");
3186
3196
  this.ctx = ctx;
3187
- this.baseURL = ctx.conf.server;
3197
+ this.baseURL = `${ctx.conf.server}/api`;
3188
3198
  }
3189
3199
  get(offset, pageSize, flatMode, paramsEditor) {
3190
3200
  const params = {
@@ -3276,8 +3286,11 @@ class Api {
3276
3286
  }
3277
3287
  loginStatus() {
3278
3288
  return __async(this, null, function* () {
3279
- const data = yield POST(this.ctx, `${this.baseURL}/login-status`);
3280
- return data || { is_login: false };
3289
+ const data = yield POST(this.ctx, `${this.baseURL}/login-status`, {
3290
+ name: this.ctx.user.data.nick,
3291
+ email: this.ctx.user.data.email
3292
+ });
3293
+ return data || { is_login: false, is_admin: false };
3281
3294
  });
3282
3295
  }
3283
3296
  pageGet(siteName, offset, limit) {
@@ -3311,13 +3324,17 @@ class Api {
3311
3324
  };
3312
3325
  return POST(this.ctx, `${this.baseURL}/admin/page-del`, params);
3313
3326
  }
3314
- pageFetch(id) {
3327
+ pageFetch(id, siteName, getStatus) {
3315
3328
  return __async(this, null, function* () {
3316
- const params = {
3317
- id
3318
- };
3329
+ const params = {};
3330
+ if (id)
3331
+ params.id = id;
3332
+ if (siteName)
3333
+ params.site_name = siteName;
3334
+ if (getStatus)
3335
+ params.get_status = getStatus;
3319
3336
  const d = yield POST(this.ctx, `${this.baseURL}/admin/page-fetch`, params);
3320
- return d.page;
3337
+ return d;
3321
3338
  });
3322
3339
  }
3323
3340
  siteGet() {
@@ -3446,7 +3463,7 @@ const CaptchaChecker = {
3446
3463
  const $iframe = createElement(`<iframe class="atk-fade-in"></iframe>`);
3447
3464
  $iframe.style.display = "none";
3448
3465
  showLoading($iframeWrap, { transparentBg: true });
3449
- $iframe.src = `${that.ctx.conf.server}/captcha/get`;
3466
+ $iframe.src = `${that.ctx.conf.server}/api/captcha/get?t=${+new Date()}`;
3450
3467
  $iframe.onload = () => {
3451
3468
  $iframe.style.display = "";
3452
3469
  hideLoading($iframeWrap);
@@ -3656,16 +3673,28 @@ class EmoticonsPlug extends EditorPlug {
3656
3673
  __publicField(this, "emoticons", []);
3657
3674
  __publicField(this, "$grpWrap");
3658
3675
  __publicField(this, "$grpSwitcher");
3676
+ __publicField(this, "loadingTask", null);
3677
+ __publicField(this, "isListLoaded", false);
3678
+ __publicField(this, "isImgLoaded", false);
3659
3679
  this.editor = editor2;
3660
3680
  this.$el = createElement(`<div class="atk-editor-plug-emoticons"></div>`);
3661
- this.init();
3662
3681
  }
3663
- init() {
3682
+ loadEmoticonsData() {
3664
3683
  return __async(this, null, function* () {
3665
- showLoading(this.$el);
3666
- this.emoticons = yield this.handleData(this.ctx.conf.emoticons);
3667
- hideLoading(this.$el);
3668
- this.initEmoticonsList();
3684
+ if (this.isListLoaded)
3685
+ return;
3686
+ if (this.loadingTask !== null) {
3687
+ yield this.loadingTask;
3688
+ return;
3689
+ }
3690
+ this.loadingTask = (() => __async(this, null, function* () {
3691
+ showLoading(this.$el);
3692
+ this.emoticons = yield this.handleData(this.ctx.conf.emoticons);
3693
+ hideLoading(this.$el);
3694
+ this.loadingTask = null;
3695
+ this.isListLoaded = true;
3696
+ }))();
3697
+ yield this.loadingTask;
3669
3698
  });
3670
3699
  }
3671
3700
  handleData(data) {
@@ -3714,7 +3743,6 @@ class EmoticonsPlug extends EditorPlug {
3714
3743
  }
3715
3744
  });
3716
3745
  data = data.filter((item) => typeof item === "object" && !Array.isArray(item) && !!item && !!item.name);
3717
- console.log(data);
3718
3746
  this.solveNullKey(data);
3719
3747
  this.solveSameKey(data);
3720
3748
  return data;
@@ -3845,9 +3873,16 @@ class EmoticonsPlug extends EditorPlug {
3845
3873
  changeListHeight() {
3846
3874
  }
3847
3875
  onShow() {
3848
- setTimeout(() => {
3849
- this.changeListHeight();
3850
- }, 30);
3876
+ (() => __async(this, null, function* () {
3877
+ yield this.loadEmoticonsData();
3878
+ if (!this.isImgLoaded) {
3879
+ this.initEmoticonsList();
3880
+ this.isImgLoaded = true;
3881
+ }
3882
+ setTimeout(() => {
3883
+ this.changeListHeight();
3884
+ }, 30);
3885
+ }))();
3851
3886
  }
3852
3887
  onHide() {
3853
3888
  this.$el.parentElement.style.height = "";
@@ -3915,6 +3950,7 @@ class Editor extends Component {
3915
3950
  __publicField(this, "$bottom");
3916
3951
  __publicField(this, "$plugBtnWrap");
3917
3952
  __publicField(this, "$imgUploadBtn");
3953
+ __publicField(this, "$imgUploadInput");
3918
3954
  __publicField(this, "$submitBtn");
3919
3955
  __publicField(this, "$notifyWrap");
3920
3956
  __publicField(this, "replyComment", null);
@@ -4050,6 +4086,13 @@ class Editor extends Component {
4050
4086
  this.LOADABLE_PLUG_LIST.forEach((PlugObj) => {
4051
4087
  const btnElem = createElement(`<span class="atk-plug-btn" data-plug-name="${PlugObj.Name}">${PlugObj.BtnHTML}</span>`);
4052
4088
  this.$plugBtnWrap.appendChild(btnElem);
4089
+ if (PlugObj.Name === "emoticons") {
4090
+ const emoPlug = new PlugObj(this);
4091
+ this.plugList[PlugObj.Name] = emoPlug;
4092
+ window.setTimeout(() => {
4093
+ emoPlug.loadEmoticonsData();
4094
+ }, 1e3);
4095
+ }
4053
4096
  btnElem.addEventListener("click", () => {
4054
4097
  let plug = this.plugList[PlugObj.Name];
4055
4098
  if (!plug) {
@@ -4094,10 +4137,13 @@ class Editor extends Component {
4094
4137
  initImgUpload() {
4095
4138
  this.$imgUploadBtn = createElement(`<span class="atk-plug-btn">\u56FE\u7247</span>`);
4096
4139
  this.$plugBtnWrap.querySelector('[data-plug-name="preview"]').before(this.$imgUploadBtn);
4140
+ this.$imgUploadInput = document.createElement("input");
4141
+ this.$imgUploadInput.type = "file";
4142
+ this.$imgUploadInput.style.display = "none";
4143
+ this.$imgUploadInput.accept = this.allowImgExts.map((o) => `.${o}`).join(",");
4144
+ this.$imgUploadBtn.after(this.$imgUploadInput);
4097
4145
  this.$imgUploadBtn.onclick = () => {
4098
- const $input = document.createElement("input");
4099
- $input.type = "file";
4100
- $input.accept = this.allowImgExts.map((o) => `.${o}`).join(",");
4146
+ const $input = this.$imgUploadInput;
4101
4147
  $input.onchange = () => {
4102
4148
  (() => __async(this, null, function* () {
4103
4149
  if (!$input.files || $input.files.length === 0)
@@ -4201,7 +4247,9 @@ class Editor extends Component {
4201
4247
  if (!!this.plugList && !!this.plugList.preview) {
4202
4248
  this.plugList.preview.updateContent();
4203
4249
  }
4204
- this.adjustTextareaHeight();
4250
+ window.setTimeout(() => {
4251
+ this.adjustTextareaHeight();
4252
+ }, 80);
4205
4253
  }
4206
4254
  clearEditor() {
4207
4255
  this.setContent("");
@@ -4286,7 +4334,7 @@ class Editor extends Component {
4286
4334
  site_name: this.replyComment === null ? this.ctx.conf.site : this.replyComment.site_name
4287
4335
  });
4288
4336
  if (this.replyComment !== null && this.replyComment.page_key !== this.ctx.conf.pageKey) {
4289
- window.open(`${this.replyComment.page_key}#atk-comment-${nComment.id}`);
4337
+ window.open(`${this.replyComment.page_url}#atk-comment-${nComment.id}`);
4290
4338
  }
4291
4339
  this.ctx.trigger("list-insert", nComment);
4292
4340
  this.clearEditor();
@@ -4340,252 +4388,201 @@ class Editor extends Component {
4340
4388
  if (this.replyComment !== null)
4341
4389
  this.cancelReply();
4342
4390
  }
4391
+ initRemoteEmoticons() {
4392
+ }
4343
4393
  }
4344
4394
  var list = "";
4345
4395
  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';
4346
4396
  var comment = "";
4347
- var win = window || {};
4348
- var nav = navigator || {};
4397
+ const win = window || {};
4398
+ const nav = navigator || {};
4349
4399
  function Detect(userAgent) {
4350
- var u = userAgent || nav.userAgent;
4351
- var _this = this;
4352
- var match = {
4353
- Trident: u.indexOf("Trident") > -1 || u.indexOf("NET CLR") > -1,
4354
- Presto: u.indexOf("Presto") > -1,
4355
- WebKit: u.indexOf("AppleWebKit") > -1,
4356
- Gecko: u.indexOf("Gecko/") > -1,
4357
- Safari: u.indexOf("Safari") > -1,
4358
- Chrome: u.indexOf("Chrome") > -1 || u.indexOf("CriOS") > -1,
4359
- IE: u.indexOf("MSIE") > -1 || u.indexOf("Trident") > -1,
4360
- Edge: u.indexOf("Edge") > -1,
4361
- Firefox: u.indexOf("Firefox") > -1 || u.indexOf("FxiOS") > -1,
4362
- "Firefox Focus": u.indexOf("Focus") > -1,
4363
- Chromium: u.indexOf("Chromium") > -1,
4364
- Opera: u.indexOf("Opera") > -1 || u.indexOf("OPR") > -1,
4365
- Vivaldi: u.indexOf("Vivaldi") > -1,
4366
- Yandex: u.indexOf("YaBrowser") > -1,
4367
- Kindle: u.indexOf("Kindle") > -1 || u.indexOf("Silk/") > -1,
4368
- 360: u.indexOf("360EE") > -1 || u.indexOf("360SE") > -1,
4369
- UC: u.indexOf("UC") > -1 || u.indexOf(" UBrowser") > -1,
4370
- QQBrowser: u.indexOf("QQBrowser") > -1,
4371
- QQ: u.indexOf("QQ/") > -1,
4372
- Baidu: u.indexOf("Baidu") > -1 || u.indexOf("BIDUBrowser") > -1,
4373
- Maxthon: u.indexOf("Maxthon") > -1,
4374
- Sogou: u.indexOf("MetaSr") > -1 || u.indexOf("Sogou") > -1,
4375
- LBBROWSER: u.indexOf("LBBROWSER") > -1,
4376
- "2345Explorer": u.indexOf("2345Explorer") > -1,
4377
- TheWorld: u.indexOf("TheWorld") > -1,
4378
- XiaoMi: u.indexOf("MiuiBrowser") > -1,
4379
- Quark: u.indexOf("Quark") > -1,
4380
- Qiyu: u.indexOf("Qiyu") > -1,
4381
- Wechat: u.indexOf("MicroMessenger") > -1,
4382
- Taobao: u.indexOf("AliApp(TB") > -1,
4383
- Alipay: u.indexOf("AliApp(AP") > -1,
4384
- Weibo: u.indexOf("Weibo") > -1,
4385
- Douban: u.indexOf("com.douban.frodo") > -1,
4386
- Suning: u.indexOf("SNEBUY-APP") > -1,
4387
- iQiYi: u.indexOf("IqiyiApp") > -1,
4388
- Windows: u.indexOf("Windows") > -1,
4389
- Linux: u.indexOf("Linux") > -1 || u.indexOf("X11") > -1,
4390
- "Mac OS": u.indexOf("Macintosh") > -1,
4391
- Android: u.indexOf("Android") > -1 || u.indexOf("Adr") > -1,
4392
- Ubuntu: u.indexOf("Ubuntu") > -1,
4393
- FreeBSD: u.indexOf("FreeBSD") > -1,
4394
- Debian: u.indexOf("Debian") > -1,
4395
- "Windows Phone": u.indexOf("IEMobile") > -1 || u.indexOf("Windows Phone") > -1,
4396
- BlackBerry: u.indexOf("BlackBerry") > -1 || u.indexOf("RIM") > -1,
4397
- MeeGo: u.indexOf("MeeGo") > -1,
4398
- Symbian: u.indexOf("Symbian") > -1,
4399
- iOS: u.indexOf("like Mac OS X") > -1,
4400
- "Chrome OS": u.indexOf("CrOS") > -1,
4401
- WebOS: u.indexOf("hpwOS") > -1,
4402
- Mobile: u.indexOf("Mobi") > -1 || u.indexOf("iPh") > -1 || u.indexOf("480") > -1,
4403
- Tablet: u.indexOf("Tablet") > -1 || u.indexOf("Pad") > -1 || u.indexOf("Nexus 7") > -1
4400
+ const u = String(userAgent || nav.userAgent);
4401
+ const dest = {
4402
+ os: "",
4403
+ osVersion: "",
4404
+ engine: "",
4405
+ browser: "",
4406
+ device: "",
4407
+ language: "",
4408
+ version: ""
4404
4409
  };
4405
- if (match.Mobile) {
4406
- match.Mobile = !(u.indexOf("iPad") > -1);
4407
- } else if (win.showModalDialog && win.chrome) {
4408
- match["360"] = true;
4409
- }
4410
- var hash = {
4411
- engine: ["WebKit", "Trident", "Gecko", "Presto"],
4412
- browser: ["Safari", "Chrome", "Edge", "IE", "Firefox", "Firefox Focus", "Chromium", "Opera", "Vivaldi", "Yandex", "Kindle", "360", "UC", "QQBrowser", "QQ", "Baidu", "Maxthon", "Sogou", "LBBROWSER", "2345Explorer", "TheWorld", "XiaoMi", "Quark", "Qiyu", "Wechat", "Taobao", "Alipay", "Weibo", "Douban", "Suning", "iQiYi"],
4413
- os: ["Windows", "Linux", "Mac OS", "Android", "Ubuntu", "FreeBSD", "Debian", "iOS", "Windows Phone", "BlackBerry", "MeeGo", "Symbian", "Chrome OS", "WebOS"],
4414
- device: ["Mobile", "Tablet"]
4410
+ const engineMatch = {
4411
+ Trident: u.includes("Trident") || u.includes("NET CLR"),
4412
+ Presto: u.includes("Presto"),
4413
+ WebKit: u.includes("AppleWebKit"),
4414
+ Gecko: u.includes("Gecko/")
4415
+ };
4416
+ const browserMatch = {
4417
+ Safari: u.includes("Safari"),
4418
+ Chrome: u.includes("Chrome") || u.includes("CriOS"),
4419
+ IE: u.includes("MSIE") || u.includes("Trident"),
4420
+ Edge: u.includes("Edge") || u.includes("Edg"),
4421
+ Firefox: u.includes("Firefox") || u.includes("FxiOS"),
4422
+ "Firefox Focus": u.includes("Focus"),
4423
+ Chromium: u.includes("Chromium"),
4424
+ Opera: u.includes("Opera") || u.includes("OPR"),
4425
+ Vivaldi: u.includes("Vivaldi"),
4426
+ Yandex: u.includes("YaBrowser"),
4427
+ Kindle: u.includes("Kindle") || u.includes("Silk/"),
4428
+ 360: u.includes("360EE") || u.includes("360SE"),
4429
+ UC: u.includes("UC") || u.includes(" UBrowser"),
4430
+ QQBrowser: u.includes("QQBrowser"),
4431
+ QQ: u.includes("QQ/"),
4432
+ Baidu: u.includes("Baidu") || u.includes("BIDUBrowser"),
4433
+ Maxthon: u.includes("Maxthon"),
4434
+ Sogou: u.includes("MetaSr") || u.includes("Sogou"),
4435
+ LBBROWSER: u.includes("LBBROWSER"),
4436
+ "2345Explorer": u.includes("2345Explorer"),
4437
+ TheWorld: u.includes("TheWorld"),
4438
+ MIUI: u.includes("MiuiBrowser"),
4439
+ Quark: u.includes("Quark"),
4440
+ Qiyu: u.includes("Qiyu"),
4441
+ Wechat: u.includes("MicroMessenger"),
4442
+ Taobao: u.includes("AliApp(TB"),
4443
+ Alipay: u.includes("AliApp(AP"),
4444
+ Weibo: u.includes("Weibo"),
4445
+ Douban: u.includes("com.douban.frodo"),
4446
+ Suning: u.includes("SNEBUY-APP"),
4447
+ iQiYi: u.includes("IqiyiApp")
4448
+ };
4449
+ const osMatch = {
4450
+ Windows: u.includes("Windows"),
4451
+ Linux: u.includes("Linux") || u.includes("X11"),
4452
+ "macOS": u.includes("Macintosh"),
4453
+ Android: u.includes("Android") || u.includes("Adr"),
4454
+ Ubuntu: u.includes("Ubuntu"),
4455
+ FreeBSD: u.includes("FreeBSD"),
4456
+ Debian: u.includes("Debian"),
4457
+ "Windows Phone": u.includes("IEMobile") || u.includes("Windows Phone"),
4458
+ BlackBerry: u.includes("BlackBerry") || u.includes("RIM"),
4459
+ MeeGo: u.includes("MeeGo"),
4460
+ Symbian: u.includes("Symbian"),
4461
+ iOS: u.includes("like Mac OS X"),
4462
+ "Chrome OS": u.includes("CrOS"),
4463
+ WebOS: u.includes("hpwOS")
4464
+ };
4465
+ const deviceMatch = {
4466
+ Mobile: u.includes("Mobi") || u.includes("iPh") || u.includes("480"),
4467
+ Tablet: u.includes("Tablet") || u.includes("Pad") || u.includes("Nexus 7")
4415
4468
  };
4416
- _this.device = "PC";
4417
- _this.language = function() {
4418
- var g = nav.browserLanguage || nav.language;
4419
- var arr = g.split("-");
4420
- if (arr[1]) {
4469
+ if (deviceMatch.Mobile) {
4470
+ deviceMatch.Mobile = !u.includes("iPad");
4471
+ } else if (browserMatch.Chrome && u.includes("Edg")) {
4472
+ browserMatch.Chrome = false;
4473
+ browserMatch.Edge = true;
4474
+ } else if (win.showModalDialog && win.chrome) {
4475
+ browserMatch.Chrome = false;
4476
+ browserMatch["360"] = true;
4477
+ }
4478
+ dest.device = "PC";
4479
+ dest.language = (() => {
4480
+ const g = nav.browserLanguage || nav.language;
4481
+ const arr = g.split("-");
4482
+ if (arr[1])
4421
4483
  arr[1] = arr[1].toUpperCase();
4422
- }
4423
4484
  return arr.join("_");
4424
- }();
4425
- for (var s in hash) {
4426
- for (var i = 0; i < hash[s].length; i++) {
4427
- var value = hash[s][i];
4428
- if (match[value]) {
4429
- _this[s] = value;
4430
- }
4431
- }
4432
- }
4433
- var osVersion = {
4434
- Windows: function() {
4435
- var v = u.replace(/^.*Windows NT ([\d.]+);.*$/, "$1");
4436
- var hash2 = {
4437
- 6.4: "10",
4438
- 6.3: "8.1",
4439
- 6.2: "8",
4440
- 6.1: "7",
4485
+ })();
4486
+ const hash = {
4487
+ engine: engineMatch,
4488
+ browser: browserMatch,
4489
+ os: osMatch,
4490
+ device: deviceMatch
4491
+ };
4492
+ Object.entries(hash).forEach(([type, match]) => {
4493
+ Object.entries(match).forEach(([name, result]) => {
4494
+ if (result === true)
4495
+ dest[type] = name;
4496
+ });
4497
+ });
4498
+ const osVersion = {
4499
+ Windows: () => {
4500
+ const v = u.replace(/^.*Windows NT ([\d.]+);.*$/, "$1");
4501
+ const wvHash = {
4502
+ "6.4": "10",
4503
+ "6.3": "8.1",
4504
+ "6.2": "8",
4505
+ "6.1": "7",
4441
4506
  "6.0": "Vista",
4442
- 5.2: "XP",
4443
- 5.1: "XP",
4507
+ "5.2": "XP",
4508
+ "5.1": "XP",
4444
4509
  "5.0": "2000",
4445
4510
  "10.0": "10",
4446
4511
  "11.0": "11"
4447
4512
  };
4448
- return hash2[v] || v;
4449
- },
4450
- Android: function() {
4451
- return u.replace(/^.*Android ([\d.]+);.*$/, "$1");
4452
- },
4453
- iOS: function() {
4454
- return u.replace(/^.*OS ([\d_]+) like.*$/, "$1").replace(/_/g, ".");
4513
+ return wvHash[v] || v;
4455
4514
  },
4456
- Debian: function() {
4457
- return u.replace(/^.*Debian\/([\d.]+).*$/, "$1");
4458
- },
4459
- "Windows Phone": function() {
4460
- return u.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/, "$2");
4461
- },
4462
- "Mac OS": function() {
4463
- return u.replace(/^.*Mac OS X ([\d_]+).*$/, "$1").replace(/_/g, ".");
4464
- },
4465
- WebOS: function() {
4466
- return u.replace(/^.*hpwOS\/([\d.]+);.*$/, "$1");
4467
- }
4515
+ Android: () => u.replace(/^.*Android ([\d.]+);.*$/, "$1"),
4516
+ iOS: () => u.replace(/^.*OS ([\d_]+) like.*$/, "$1").replace(/_/g, "."),
4517
+ Debian: () => u.replace(/^.*Debian\/([\d.]+).*$/, "$1"),
4518
+ "Windows Phone": () => u.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/, "$2"),
4519
+ "macOS": () => u.replace(/^.*Mac OS X ([\d_]+).*$/, "$1").replace(/_/g, "."),
4520
+ WebOS: () => u.replace(/^.*hpwOS\/([\d.]+);.*$/, "$1")
4468
4521
  };
4469
- _this.osVersion = "";
4470
- if (osVersion[_this.os]) {
4471
- _this.osVersion = osVersion[_this.os]();
4472
- if (_this.osVersion === u) {
4473
- _this.osVersion = "";
4474
- }
4475
- }
4476
- var version = {
4477
- Safari: function() {
4478
- return u.replace(/^.*Version\/([\d.]+).*$/, "$1");
4479
- },
4480
- Chrome: function() {
4481
- return u.replace(/^.*Chrome\/([\d.]+).*$/, "$1").replace(/^.*CriOS\/([\d.]+).*$/, "$1");
4482
- },
4483
- IE: function() {
4484
- return u.replace(/^.*MSIE ([\d.]+).*$/, "$1").replace(/^.*rv:([\d.]+).*$/, "$1");
4485
- },
4486
- Edge: function() {
4487
- return u.replace(/^.*Edge\/([\d.]+).*$/, "$1");
4488
- },
4489
- Firefox: function() {
4490
- return u.replace(/^.*Firefox\/([\d.]+).*$/, "$1").replace(/^.*FxiOS\/([\d.]+).*$/, "$1");
4491
- },
4492
- "Firefox Focus": function() {
4493
- return u.replace(/^.*Focus\/([\d.]+).*$/, "$1");
4494
- },
4495
- Chromium: function() {
4496
- return u.replace(/^.*Chromium\/([\d.]+).*$/, "$1");
4497
- },
4498
- Opera: function() {
4499
- return u.replace(/^.*Opera\/([\d.]+).*$/, "$1").replace(/^.*OPR\/([\d.]+).*$/, "$1");
4500
- },
4501
- Vivaldi: function() {
4502
- return u.replace(/^.*Vivaldi\/([\d.]+).*$/, "$1");
4503
- },
4504
- Yandex: function() {
4505
- return u.replace(/^.*YaBrowser\/([\d.]+).*$/, "$1");
4506
- },
4507
- Kindle: function() {
4508
- return u.replace(/^.*Version\/([\d.]+).*$/, "$1");
4509
- },
4510
- Maxthon: function() {
4511
- return u.replace(/^.*Maxthon\/([\d.]+).*$/, "$1");
4512
- },
4513
- QQBrowser: function() {
4514
- return u.replace(/^.*QQBrowser\/([\d.]+).*$/, "$1");
4515
- },
4516
- QQ: function() {
4517
- return u.replace(/^.*QQ\/([\d.]+).*$/, "$1");
4518
- },
4519
- Baidu: function() {
4520
- return u.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/, "$1");
4521
- },
4522
- UC: function() {
4523
- return u.replace(/^.*UC?Browser\/([\d.]+).*$/, "$1");
4524
- },
4525
- Sogou: function() {
4526
- return u.replace(/^.*SE ([\d.X]+).*$/, "$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/, "$1");
4527
- },
4528
- "2345Explorer": function() {
4529
- return u.replace(/^.*2345Explorer\/([\d.]+).*$/, "$1");
4530
- },
4531
- TheWorld: function() {
4532
- return u.replace(/^.*TheWorld ([\d.]+).*$/, "$1");
4533
- },
4534
- XiaoMi: function() {
4535
- return u.replace(/^.*MiuiBrowser\/([\d.]+).*$/, "$1");
4536
- },
4537
- Quark: function() {
4538
- return u.replace(/^.*Quark\/([\d.]+).*$/, "$1");
4539
- },
4540
- Qiyu: function() {
4541
- return u.replace(/^.*Qiyu\/([\d.]+).*$/, "$1");
4542
- },
4543
- Wechat: function() {
4544
- return u.replace(/^.*MicroMessenger\/([\d.]+).*$/, "$1");
4545
- },
4546
- Taobao: function() {
4547
- return u.replace(/^.*AliApp\(TB\/([\d.]+).*$/, "$1");
4548
- },
4549
- Alipay: function() {
4550
- return u.replace(/^.*AliApp\(AP\/([\d.]+).*$/, "$1");
4551
- },
4552
- Weibo: function() {
4553
- return u.replace(/^.*weibo__([\d.]+).*$/, "$1");
4554
- },
4555
- Douban: function() {
4556
- return u.replace(/^.*com.douban.frodo\/([\d.]+).*$/, "$1");
4557
- },
4558
- Suning: function() {
4559
- return u.replace(/^.*SNEBUY-APP([\d.]+).*$/, "$1");
4560
- },
4561
- iQiYi: function() {
4562
- return u.replace(/^.*IqiyiVersion\/([\d.]+).*$/, "$1");
4563
- }
4522
+ dest.osVersion = "";
4523
+ if (osVersion[dest.os]) {
4524
+ dest.osVersion = osVersion[dest.os]();
4525
+ if (dest.osVersion === u) {
4526
+ dest.osVersion = "";
4527
+ }
4528
+ }
4529
+ const version = {
4530
+ Safari: () => u.replace(/^.*Version\/([\d.]+).*$/, "$1"),
4531
+ Chrome: () => u.replace(/^.*Chrome\/([\d.]+).*$/, "$1").replace(/^.*CriOS\/([\d.]+).*$/, "$1"),
4532
+ IE: () => u.replace(/^.*MSIE ([\d.]+).*$/, "$1").replace(/^.*rv:([\d.]+).*$/, "$1"),
4533
+ Edge: () => u.replace(/^.*(Edge|Edg|Edg[A-Z]{1})\/([\d.]+).*$/, "$2"),
4534
+ Firefox: () => u.replace(/^.*Firefox\/([\d.]+).*$/, "$1").replace(/^.*FxiOS\/([\d.]+).*$/, "$1"),
4535
+ "Firefox Focus": () => u.replace(/^.*Focus\/([\d.]+).*$/, "$1"),
4536
+ Chromium: () => u.replace(/^.*Chromium\/([\d.]+).*$/, "$1"),
4537
+ Opera: () => u.replace(/^.*Opera\/([\d.]+).*$/, "$1").replace(/^.*OPR\/([\d.]+).*$/, "$1"),
4538
+ Vivaldi: () => u.replace(/^.*Vivaldi\/([\d.]+).*$/, "$1"),
4539
+ Yandex: () => u.replace(/^.*YaBrowser\/([\d.]+).*$/, "$1"),
4540
+ Kindle: () => u.replace(/^.*Version\/([\d.]+).*$/, "$1"),
4541
+ Maxthon: () => u.replace(/^.*Maxthon\/([\d.]+).*$/, "$1"),
4542
+ QQBrowser: () => u.replace(/^.*QQBrowser\/([\d.]+).*$/, "$1"),
4543
+ QQ: () => u.replace(/^.*QQ\/([\d.]+).*$/, "$1"),
4544
+ Baidu: () => u.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/, "$1"),
4545
+ UC: () => u.replace(/^.*UC?Browser\/([\d.]+).*$/, "$1"),
4546
+ Sogou: () => u.replace(/^.*SE ([\d.X]+).*$/, "$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/, "$1"),
4547
+ "2345Explorer": () => u.replace(/^.*2345Explorer\/([\d.]+).*$/, "$1"),
4548
+ TheWorld: () => u.replace(/^.*TheWorld ([\d.]+).*$/, "$1"),
4549
+ MIUI: () => u.replace(/^.*MiuiBrowser\/([\d.]+).*$/, "$1"),
4550
+ Quark: () => u.replace(/^.*Quark\/([\d.]+).*$/, "$1"),
4551
+ Qiyu: () => u.replace(/^.*Qiyu\/([\d.]+).*$/, "$1"),
4552
+ Wechat: () => u.replace(/^.*MicroMessenger\/([\d.]+).*$/, "$1"),
4553
+ Taobao: () => u.replace(/^.*AliApp\(TB\/([\d.]+).*$/, "$1"),
4554
+ Alipay: () => u.replace(/^.*AliApp\(AP\/([\d.]+).*$/, "$1"),
4555
+ Weibo: () => u.replace(/^.*weibo__([\d.]+).*$/, "$1"),
4556
+ Douban: () => u.replace(/^.*com.douban.frodo\/([\d.]+).*$/, "$1"),
4557
+ Suning: () => u.replace(/^.*SNEBUY-APP([\d.]+).*$/, "$1"),
4558
+ iQiYi: () => u.replace(/^.*IqiyiVersion\/([\d.]+).*$/, "$1")
4564
4559
  };
4565
- _this.version = "";
4566
- if (version[_this.browser]) {
4567
- _this.version = version[_this.browser]();
4568
- if (_this.version === u) {
4569
- _this.version = "";
4570
- }
4571
- }
4572
- if (_this.version.indexOf(".")) {
4573
- _this.version = _this.version.substring(0, _this.version.indexOf("."));
4574
- }
4575
- if (_this.browser === "Edge") {
4576
- _this.engine = "EdgeHTML";
4577
- } else if (_this.browser === "Chrome" && parseInt(_this.version) > 27) {
4578
- _this.engine = "Blink";
4579
- } else if (_this.browser === "Opera" && parseInt(_this.version) > 12) {
4580
- _this.engine = "Blink";
4581
- } else if (_this.browser === "Yandex") {
4582
- _this.engine = "Blink";
4583
- } else if (_this.browser === void 0) {
4584
- _this.browser = "Unknow App";
4585
- }
4586
- }
4587
- function detectFactory(u) {
4588
- return new Detect(u);
4560
+ dest.version = "";
4561
+ if (version[dest.browser]) {
4562
+ dest.version = version[dest.browser]();
4563
+ if (dest.version === u) {
4564
+ dest.version = "";
4565
+ }
4566
+ }
4567
+ if (dest.version.indexOf(".")) {
4568
+ dest.version = dest.version.substring(0, dest.version.indexOf("."));
4569
+ }
4570
+ if (dest.os === "iOS" && u.includes("iPad")) {
4571
+ dest.os = "iPadOS";
4572
+ } else if (dest.browser === "Edge" && !u.includes("Edg")) {
4573
+ dest.engine = "EdgeHTML";
4574
+ } else if (dest.browser === "MIUI") {
4575
+ dest.os = "Android";
4576
+ } else if (dest.browser === "Chrome" && Number(dest.version) > 27) {
4577
+ dest.engine = "Blink";
4578
+ } else if (dest.browser === "Opera" && Number(dest.version) > 12) {
4579
+ dest.engine = "Blink";
4580
+ } else if (dest.browser === "Yandex") {
4581
+ dest.engine = "Blink";
4582
+ } else if (dest.browser === void 0) {
4583
+ dest.browser = "Unknow App";
4584
+ }
4585
+ return dest;
4589
4586
  }
4590
4587
  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';
4591
4588
  class ActionBtn {
@@ -5011,11 +5008,11 @@ class Comment extends Component {
5011
5008
  return timeAgo(new Date(this.data.date));
5012
5009
  }
5013
5010
  getUserUaBrowser() {
5014
- const info = detectFactory(this.data.ua);
5011
+ const info = Detect(this.data.ua);
5015
5012
  return `${info.browser} ${info.version}`;
5016
5013
  }
5017
5014
  getUserUaOS() {
5018
- const info = detectFactory(this.data.ua);
5015
+ const info = Detect(this.data.ua);
5019
5016
  return `${info.os} ${info.osVersion}`;
5020
5017
  }
5021
5018
  playFadeInAnim() {
@@ -5352,7 +5349,7 @@ class ReadMoreBtn {
5352
5349
  this.hide();
5353
5350
  }
5354
5351
  }
5355
- const backendMinVersion = "2.1.1";
5352
+ const backendMinVersion = "2.1.2";
5356
5353
  class ListLite extends Component {
5357
5354
  constructor(ctx) {
5358
5355
  super(ctx);
@@ -5417,7 +5414,7 @@ class ListLite extends Component {
5417
5414
  try {
5418
5415
  listData = yield new Api(this.ctx).get(offset, this.pageSize, this.flatMode, this.paramsEditor);
5419
5416
  } catch (e) {
5420
- this.onError(e.msg || String(e), offset);
5417
+ this.onError(e.msg || String(e), offset, e.data);
5421
5418
  throw e;
5422
5419
  } finally {
5423
5420
  hideLoading$1();
@@ -5440,7 +5437,7 @@ class ListLite extends Component {
5440
5437
  }
5441
5438
  this.data = data;
5442
5439
  const feMinVersion = ((_a = data.api_version) == null ? void 0 : _a.fe_min_version) || "0.0.0";
5443
- if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.3"))
5440
+ if (this.ctx.conf.versionCheck && this.versionCheck("\u524D\u7AEF", feMinVersion, "2.2.6"))
5444
5441
  return;
5445
5442
  if (this.ctx.conf.versionCheck && this.versionCheck("\u540E\u7AEF", backendMinVersion, (_b = data.api_version) == null ? void 0 : _b.version))
5446
5443
  return;
@@ -5521,7 +5518,7 @@ class ListLite extends Component {
5521
5518
  this.$el.append(this.pagination.$el);
5522
5519
  }
5523
5520
  }
5524
- onError(msg, offset) {
5521
+ onError(msg, offset, errData) {
5525
5522
  var _a;
5526
5523
  msg = String(msg);
5527
5524
  console.error(msg);
@@ -5534,10 +5531,20 @@ class ListLite extends Component {
5534
5531
  $retryBtn.onclick = () => this.fetchComments(0);
5535
5532
  $err.appendChild($retryBtn);
5536
5533
  const adminBtn = createElement('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');
5537
- adminBtn.onclick = () => this.ctx.trigger("sidebar-show");
5534
+ $err.appendChild(adminBtn);
5538
5535
  if (!this.ctx.user.data.isAdmin)
5539
5536
  adminBtn.classList.add("atk-hide");
5540
- $err.appendChild(adminBtn);
5537
+ let sidebarView = "";
5538
+ if (errData == null ? void 0 : errData.err_no_site) {
5539
+ const viewLoadParam = {
5540
+ create_name: this.ctx.conf.site,
5541
+ create_urls: `${window.location.protocol}//${window.location.host}`
5542
+ };
5543
+ sidebarView = `sites|${JSON.stringify(viewLoadParam)}`;
5544
+ }
5545
+ adminBtn.onclick = () => this.ctx.trigger("sidebar-show", {
5546
+ view: sidebarView
5547
+ });
5541
5548
  setError(this.$el, $err);
5542
5549
  }
5543
5550
  refreshUI() {
@@ -5762,7 +5769,7 @@ class List extends ListLite {
5762
5769
  if (this.ctx.conf.listSort) {
5763
5770
  this.initDropdown();
5764
5771
  }
5765
- this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.2.3"}">Artalk</a>`;
5772
+ this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.2.6"}">Artalk</a>`;
5766
5773
  this.ctx.on("list-reload", () => this.fetchComments(0));
5767
5774
  this.ctx.on("list-refresh-ui", () => this.refreshUI());
5768
5775
  this.ctx.on("list-import", (data) => this.importComments(data));
@@ -5946,13 +5953,13 @@ class SidebarLayer extends Component {
5946
5953
  this.$closeBtn.onclick = () => {
5947
5954
  this.hide();
5948
5955
  };
5949
- this.ctx.on("sidebar-show", () => this.show());
5956
+ this.ctx.on("sidebar-show", (conf) => this.show(conf || {}));
5950
5957
  this.ctx.on("sidebar-hide", () => this.hide());
5951
5958
  this.ctx.on("user-changed", () => {
5952
5959
  this.firstShow = true;
5953
5960
  });
5954
5961
  }
5955
- show() {
5962
+ show(conf) {
5956
5963
  return __async(this, null, function* () {
5957
5964
  this.$el.style.transform = "";
5958
5965
  if (this.layer == null) {
@@ -5967,41 +5974,48 @@ class SidebarLayer extends Component {
5967
5974
  setTimeout(() => {
5968
5975
  this.$el.style.transform = "translate(0, 0)";
5969
5976
  }, 20);
5970
- if (this.firstShow) {
5971
- if (this.ctx.user.data.isAdmin) {
5972
- const resp = yield new Api(this.ctx).loginStatus();
5973
- if (!resp.is_login) {
5974
- yield new Promise((resolve, reject) => {
5975
- this.ctx.trigger("checker-admin", {
5976
- onSuccess: () => {
5977
- resolve(null);
5978
- setTimeout(() => {
5979
- this.show();
5980
- }, 500);
5981
- },
5982
- onCancel: () => {
5983
- var _a;
5984
- (_a = this.layer) == null ? void 0 : _a.hide();
5985
- }
5986
- });
5987
- });
5988
- }
5977
+ (() => __async(this, null, function* () {
5978
+ var _a;
5979
+ const resp = yield new Api(this.ctx).loginStatus();
5980
+ if (resp.is_admin && !resp.is_login) {
5981
+ (_a = this.layer) == null ? void 0 : _a.hide();
5982
+ this.firstShow = true;
5983
+ this.ctx.trigger("checker-admin", {
5984
+ onSuccess: () => {
5985
+ setTimeout(() => {
5986
+ this.show(conf);
5987
+ }, 500);
5988
+ },
5989
+ onCancel: () => {
5990
+ }
5991
+ });
5989
5992
  }
5993
+ }))();
5994
+ this.ctx.trigger("unread-update", { notifies: [] });
5995
+ if (this.firstShow) {
5990
5996
  this.$iframeWrap.innerHTML = "";
5991
5997
  this.$iframe = createElement("<iframe></iframe>");
5992
- const baseURL = getURLBasedOnApi(this.ctx, "sidebar/");
5993
- const userData = encodeURIComponent(JSON.stringify(this.ctx.user.data));
5994
- const location = window.location;
5995
- this.iframeLoad(`${baseURL}?pageKey=${encodeURIComponent(this.conf.pageKey)}&site=${encodeURIComponent(this.conf.site || "")}&user=${userData}&time=${+new Date()}&referer=${encodeURIComponent(`${location.protocol}//${location.host}${location.pathname}`)}${this.conf.darkMode ? `&darkMode=1` : ``}`);
5998
+ const baseURL = getURLBasedOnApi(this.ctx, "/sidebar/");
5999
+ const query = {
6000
+ pageKey: this.conf.pageKey,
6001
+ site: this.conf.site || "",
6002
+ user: JSON.stringify(this.ctx.user.data),
6003
+ time: +new Date()
6004
+ };
6005
+ if (conf.view)
6006
+ query.view = conf.view;
6007
+ if (this.conf.darkMode)
6008
+ query.darkMode = "1";
6009
+ const urlParams = new URLSearchParams(query);
6010
+ this.iframeLoad(`${baseURL}?${urlParams.toString()}`);
5996
6011
  this.$iframeWrap.append(this.$iframe);
5997
6012
  this.firstShow = false;
5998
6013
  } else {
5999
- if (this.conf.darkMode && !this.$iframe.src.match(/darkMode=1$/)) {
6014
+ const isIframeSrcDarkMode = this.$iframe.src.includes("darkMode=1");
6015
+ if (this.conf.darkMode && !isIframeSrcDarkMode)
6000
6016
  this.iframeLoad(`${this.$iframe.src}&darkMode=1`);
6001
- }
6002
- if (!this.conf.darkMode && this.$iframe.src.match(/darkMode=1$/)) {
6003
- this.iframeLoad(this.$iframe.src.replace(/&darkMode=1$/, ""));
6004
- }
6017
+ if (!this.conf.darkMode && isIframeSrcDarkMode)
6018
+ this.iframeLoad(this.$iframe.src.replace("&darkMode=1", ""));
6005
6019
  }
6006
6020
  });
6007
6021
  }
@@ -6054,22 +6068,30 @@ const _Artalk = class {
6054
6068
  __publicField(this, "list");
6055
6069
  __publicField(this, "sidebarLayer");
6056
6070
  this.conf = __spreadValues(__spreadValues({}, _Artalk.defaults), customConf);
6057
- this.conf.server = this.conf.server.replace(/\/$/, "");
6071
+ this.conf.server = this.conf.server.replace(/\/$/, "").replace(/\/api\/?$/, "");
6058
6072
  if (!this.conf.pageKey) {
6059
- this.conf.pageKey = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
6073
+ this.conf.pageKey = `${window.location.pathname}`;
6060
6074
  }
6061
- try {
6062
- const $root = document.querySelector(this.conf.el);
6063
- if (!$root)
6064
- throw Error(`Sorry, target element "${this.conf.el}" was not found.`);
6065
- this.$root = $root;
6066
- } catch (e) {
6067
- console.error(e);
6068
- throw new Error("Please check your Artalk `el` config.");
6075
+ if (!this.conf.pageTitle) {
6076
+ this.conf.pageTitle = `${document.title}`;
6077
+ }
6078
+ if (!!this.conf.el && this.conf.el instanceof HTMLElement) {
6079
+ this.$root = this.conf.el;
6080
+ } else {
6081
+ try {
6082
+ const $root = document.querySelector(this.conf.el);
6083
+ if (!$root)
6084
+ throw Error(`Sorry, target element "${this.conf.el}" was not found.`);
6085
+ this.$root = $root;
6086
+ } catch (e) {
6087
+ console.error(e);
6088
+ throw new Error("Please check your Artalk `el` config.");
6089
+ }
6069
6090
  }
6070
6091
  this.ctx = new Context(this.$root, this.conf);
6071
6092
  this.$root.classList.add("artalk");
6072
6093
  this.$root.innerHTML = "";
6094
+ this.initLayer();
6073
6095
  this.initDarkMode();
6074
6096
  this.checkerLauncher = new CheckerLauncher(this.ctx);
6075
6097
  initMarked(this.ctx);
@@ -6116,6 +6138,10 @@ const _Artalk = class {
6116
6138
  reload() {
6117
6139
  this.list.fetchComments(0);
6118
6140
  }
6141
+ initLayer() {
6142
+ Layer.BodyOrgOverflow = document.body.style.overflow;
6143
+ Layer.BodyOrgPaddingRight = document.body.style.paddingRight;
6144
+ }
6119
6145
  initDarkMode() {
6120
6146
  const darkModeClassName = "atk-dark-mode";
6121
6147
  if (this.conf.darkMode) {
@@ -6139,12 +6165,12 @@ const _Artalk = class {
6139
6165
  }
6140
6166
  initPV() {
6141
6167
  return __async(this, null, function* () {
6142
- if (!this.conf.pvEl || !document.querySelector(this.conf.pvEl))
6143
- return;
6144
- const $pv = document.querySelector(this.conf.pvEl);
6145
6168
  const pvNum = yield new Api(this.ctx).pv();
6146
6169
  if (Number.isNaN(Number(pvNum)))
6147
6170
  return;
6171
+ if (!this.conf.pvEl || !document.querySelector(this.conf.pvEl))
6172
+ return;
6173
+ const $pv = document.querySelector(this.conf.pvEl);
6148
6174
  $pv.innerText = String(pvNum);
6149
6175
  });
6150
6176
  }