artalk 2.4.2 → 2.4.3

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
@@ -236,18 +236,6 @@ class User {
236
236
  return !!this.data.nick && !!this.data.email;
237
237
  }
238
238
  }
239
- class Component {
240
- constructor(ctx) {
241
- __publicField(this, "$el");
242
- __publicField(this, "ctx");
243
- __publicField(this, "conf");
244
- this.ctx = ctx;
245
- this.conf = ctx.conf;
246
- }
247
- $t(key, args = {}) {
248
- return this.ctx.$t(key, args);
249
- }
250
- }
251
239
  function getDefaults() {
252
240
  return {
253
241
  baseUrl: null,
@@ -2855,7 +2843,12 @@ function marked(ctx, src) {
2855
2843
  }
2856
2844
  let dest = insane_1(markedContent, {
2857
2845
  allowedClasses: {},
2858
- allowedSchemes: ["http", "https", "mailto"],
2846
+ allowedSchemes: [
2847
+ "http",
2848
+ "https",
2849
+ "mailto",
2850
+ "data"
2851
+ ],
2859
2852
  allowedTags: [
2860
2853
  "a",
2861
2854
  "abbr",
@@ -2992,6 +2985,18 @@ function mergeDeep(target, source) {
2992
2985
  });
2993
2986
  return target;
2994
2987
  }
2988
+ class Component {
2989
+ constructor(ctx) {
2990
+ __publicField(this, "$el");
2991
+ __publicField(this, "ctx");
2992
+ __publicField(this, "conf");
2993
+ this.ctx = ctx;
2994
+ this.conf = ctx.conf;
2995
+ }
2996
+ $t(key, args = {}) {
2997
+ return this.ctx.$t(key, args);
2998
+ }
2999
+ }
2995
3000
  function showLoading(parentElem, conf) {
2996
3001
  let $loading = parentElem.querySelector(":scope > .atk-loading");
2997
3002
  if (!$loading) {
@@ -3909,7 +3914,7 @@ class UserApi extends ApiBase {
3909
3914
  if (this.ctx.conf.site)
3910
3915
  params.site_name = this.ctx.conf.site;
3911
3916
  const data = yield this.POST("/login", params);
3912
- return data.token;
3917
+ return data;
3913
3918
  });
3914
3919
  }
3915
3920
  userGet(name, email) {
@@ -3963,6 +3968,58 @@ class UserApi extends ApiBase {
3963
3968
  }
3964
3969
  return this.POST(`/mark-read`, params);
3965
3970
  }
3971
+ userList(offset, limit, type) {
3972
+ return __async(this, null, function* () {
3973
+ const params = {
3974
+ offset: offset || 0,
3975
+ limit: limit || 15
3976
+ };
3977
+ if (type)
3978
+ params.type = type;
3979
+ const d = yield this.POST("/admin/user-get", params);
3980
+ return d;
3981
+ });
3982
+ }
3983
+ userAdd(user, password) {
3984
+ return __async(this, null, function* () {
3985
+ const params = {
3986
+ name: user.name || "",
3987
+ email: user.email || "",
3988
+ password: password || "",
3989
+ link: user.link || "",
3990
+ is_admin: user.is_admin || false,
3991
+ site_names: user.site_names_raw || "",
3992
+ receive_email: user.receive_email || true,
3993
+ badge_name: user.badge_name || "",
3994
+ badge_color: user.badge_color || ""
3995
+ };
3996
+ const d = yield this.POST("/admin/user-add", params);
3997
+ return d.user;
3998
+ });
3999
+ }
4000
+ userEdit(user, password) {
4001
+ return __async(this, null, function* () {
4002
+ const params = {
4003
+ id: user.id,
4004
+ name: user.name || "",
4005
+ email: user.email || "",
4006
+ password: password || "",
4007
+ link: user.link || "",
4008
+ is_admin: user.is_admin || false,
4009
+ site_names: user.site_names_raw || "",
4010
+ receive_email: user.receive_email || true,
4011
+ badge_name: user.badge_name || "",
4012
+ badge_color: user.badge_color || ""
4013
+ };
4014
+ const d = yield this.POST("/admin/user-edit", params);
4015
+ return d.user;
4016
+ });
4017
+ }
4018
+ userDel(userID) {
4019
+ return this.POST("/admin/user-del", {
4020
+ id: String(userID)
4021
+ });
4022
+ }
3966
4023
  }
3967
4024
  class SystemApi extends ApiBase {
3968
4025
  conf() {
@@ -3994,6 +4051,13 @@ class SystemApi extends ApiBase {
3994
4051
  return data;
3995
4052
  });
3996
4053
  }
4054
+ version() {
4055
+ return __async(this, null, function* () {
4056
+ const resp = yield fetch(`${this.api.baseURL}/version`, { method: "POST" });
4057
+ const data = yield resp.json();
4058
+ return data;
4059
+ });
4060
+ }
3997
4061
  }
3998
4062
  class CaptchaApi extends ApiBase {
3999
4063
  captchaGet() {
@@ -4059,16 +4123,17 @@ const ApiComponents = {
4059
4123
  class Api {
4060
4124
  constructor(ctx) {
4061
4125
  __publicField(this, "ctx");
4062
- __publicField(this, "baseURL");
4063
4126
  this.ctx = ctx;
4064
- this.baseURL = `${ctx.conf.server}/api`;
4065
4127
  Object.entries(ApiComponents).forEach(([key, ApiComponent]) => {
4066
4128
  this[key] = new ApiComponent(this, this.ctx);
4067
4129
  });
4068
4130
  }
4131
+ get baseURL() {
4132
+ return `${this.ctx.conf.server}/api`;
4133
+ }
4069
4134
  }
4070
- const version = "2.4.2";
4071
- const backendMinVersion = "2.2.0";
4135
+ const version = "2.4.3";
4136
+ const backendMinVersion = "2.3.0";
4072
4137
  const ListHTML = '<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <div class="atk-text"></div>\n </div>\n <div class="atk-right-action">\n <span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show></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"></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';
4073
4138
  const win = window || {};
4074
4139
  const nav = navigator || {};
@@ -4427,7 +4492,8 @@ class CommentRender {
4427
4492
  renderAvatar() {
4428
4493
  const $avatar = this.$el.querySelector(".atk-avatar");
4429
4494
  const $avatarImg = createElement("<img />");
4430
- $avatarImg.src = this.comment.getGravatarURL();
4495
+ const avatarURLBuilder = this.ctx.conf.avatarURLBuilder;
4496
+ $avatarImg.src = avatarURLBuilder ? avatarURLBuilder(this.data) : this.comment.getGravatarURL();
4431
4497
  if (this.data.link) {
4432
4498
  const $avatarA = createElement('<a target="_blank" rel="noreferrer noopener nofollow"></a>');
4433
4499
  $avatarA.href = isValidURL(this.data.link) ? this.data.link : `https://${this.data.link}`;
@@ -5213,10 +5279,10 @@ class ListLite extends Component {
5213
5279
  __publicField(this, "data");
5214
5280
  __publicField(this, "isLoading", false);
5215
5281
  __publicField(this, "noCommentText");
5216
- __publicField(this, "flatMode", false);
5217
- __publicField(this, "nestSortBy");
5218
- __publicField(this, "pageMode", "pagination");
5219
- __publicField(this, "pageSize", 20);
5282
+ __publicField(this, "_nestSortBy");
5283
+ __publicField(this, "_flatMode");
5284
+ __publicField(this, "_pageMode");
5285
+ __publicField(this, "_pageSize");
5220
5286
  __publicField(this, "scrollListenerAt");
5221
5287
  __publicField(this, "repositionAt");
5222
5288
  __publicField(this, "pagination");
@@ -5227,20 +5293,53 @@ class ListLite extends Component {
5227
5293
  __publicField(this, "onAfterLoad");
5228
5294
  __publicField(this, "unread", []);
5229
5295
  __publicField(this, "unreadHighlight");
5296
+ __publicField(this, "confLoaded", false);
5230
5297
  this.$el = createElement(
5231
5298
  `<div class="atk-list-lite">
5232
5299
  <div class="atk-list-comments-wrap"></div>
5233
5300
  </div>`
5234
5301
  );
5235
5302
  this.$commentsWrap = this.$el.querySelector(".atk-list-comments-wrap");
5236
- this.noCommentText = ctx.conf.noComment || ctx.$t("noComment");
5237
- this.nestSortBy = this.ctx.conf.nestSort || "DATE_ASC";
5238
5303
  window.setInterval(() => {
5239
5304
  this.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
5240
5305
  const date = el.getAttribute("data-atk-comment-date");
5241
5306
  el.innerText = timeAgo(new Date(Number(date)), this.ctx);
5242
5307
  });
5243
5308
  }, 30 * 1e3);
5309
+ this.ctx.on("conf-loaded", () => {
5310
+ });
5311
+ }
5312
+ get nestSortBy() {
5313
+ if (this._nestSortBy !== void 0)
5314
+ return this._nestSortBy;
5315
+ return this.ctx.conf.nestSort || "DATE_ASC";
5316
+ }
5317
+ set nestSortBy(val) {
5318
+ this._nestSortBy = val;
5319
+ }
5320
+ get flatMode() {
5321
+ if (this._flatMode !== void 0)
5322
+ return this._flatMode;
5323
+ if (this.ctx.conf.flatMode === true || Number(this.ctx.conf.nestMax) <= 1)
5324
+ return true;
5325
+ if (this.ctx.conf.flatMode === "auto" && window.matchMedia("(max-width: 768px)").matches)
5326
+ return true;
5327
+ return false;
5328
+ }
5329
+ set flatMode(val) {
5330
+ this._flatMode = val;
5331
+ }
5332
+ get pageMode() {
5333
+ return this._pageMode || (this.conf.pagination.readMore ? "read-more" : "pagination");
5334
+ }
5335
+ set pageMode(val) {
5336
+ this._pageMode = val;
5337
+ }
5338
+ get pageSize() {
5339
+ return this._pageSize || this.conf.pagination.pageSize;
5340
+ }
5341
+ set pageSize(val) {
5342
+ this._pageSize = val;
5244
5343
  }
5245
5344
  getData() {
5246
5345
  return this.data;
@@ -5268,7 +5367,7 @@ class ListLite extends Component {
5268
5367
  const setLoading2 = (val) => this.setLoading(val, isFirstLoad);
5269
5368
  setLoading2(true);
5270
5369
  this.ctx.trigger("list-load");
5271
- if (isFirstLoad && this.pageMode === "read-more") {
5370
+ if (this.pageMode === "read-more" && isFirstLoad || this.pageMode === "pagination") {
5272
5371
  this.ctx.clearAllComments();
5273
5372
  }
5274
5373
  let listData;
@@ -5293,24 +5392,24 @@ class ListLite extends Component {
5293
5392
  }
5294
5393
  onLoad(data, offset) {
5295
5394
  var _a, _b;
5296
- if (this.pageMode === "pagination") {
5297
- this.ctx.clearAllComments();
5298
- }
5299
5395
  this.data = data;
5396
+ if (!this.confLoaded) {
5397
+ if (this.conf.useBackendConf)
5398
+ this.ctx.updateConf(data.conf.frontend_conf);
5399
+ else
5400
+ this.ctx.updateConf({});
5401
+ this.confLoaded = true;
5402
+ }
5300
5403
  const feMinVersion = ((_a = data.api_version) == null ? void 0 : _a.fe_min_version) || "0.0.0";
5301
5404
  if (this.ctx.conf.versionCheck && this.versionCheck("frontend", feMinVersion, version))
5302
5405
  return;
5303
5406
  if (this.ctx.conf.versionCheck && this.versionCheck("backend", backendMinVersion, (_b = data.api_version) == null ? void 0 : _b.version))
5304
5407
  return;
5305
- if (data.conf && typeof data.conf.img_upload === "boolean") {
5306
- this.ctx.conf.imgUpload = data.conf.img_upload;
5307
- }
5308
5408
  this.importComments(data.comments);
5309
5409
  this.refreshPagination(offset, this.flatMode ? data.total : data.total_roots);
5310
5410
  this.refreshUI();
5311
5411
  this.ctx.updateNotifies(data.unread || []);
5312
5412
  this.ctx.trigger("list-loaded");
5313
- this.ctx.trigger("conf-updated");
5314
5413
  if (this.onAfterLoad)
5315
5414
  this.onAfterLoad(data);
5316
5415
  }
@@ -5374,6 +5473,9 @@ class ListLite extends Component {
5374
5473
  }
5375
5474
  onError(msg, offset, errData) {
5376
5475
  var _a;
5476
+ if (!this.confLoaded) {
5477
+ this.ctx.updateConf({});
5478
+ }
5377
5479
  msg = String(msg);
5378
5480
  console.error(msg);
5379
5481
  if (offset !== 0 && this.pageMode === "read-more") {
@@ -5407,7 +5509,7 @@ class ListLite extends Component {
5407
5509
  if (isNoComment) {
5408
5510
  if (!$noComment) {
5409
5511
  $noComment = createElement('<div class="atk-list-no-comment"></div>');
5410
- $noComment.innerHTML = this.noCommentText;
5512
+ $noComment.innerHTML = this.noCommentText || this.ctx.conf.noComment || this.ctx.$t("noComment");
5411
5513
  this.$commentsWrap.appendChild($noComment);
5412
5514
  }
5413
5515
  } else {
@@ -5537,7 +5639,6 @@ class ListLite extends Component {
5537
5639
  ignoreBtn.onclick = () => {
5538
5640
  setError(this.$el.parentElement, null);
5539
5641
  this.ctx.conf.versionCheck = false;
5540
- this.ctx.trigger("conf-updated");
5541
5642
  this.fetchComments(0);
5542
5643
  };
5543
5644
  errEl.append(ignoreBtn);
@@ -5558,18 +5659,9 @@ class List extends ListLite {
5558
5659
  __publicField(this, "$dropdownWrap");
5559
5660
  __publicField(this, "goToCommentFounded", false);
5560
5661
  __publicField(this, "goToCommentDelay", true);
5662
+ __publicField(this, "dropdownLoaded", false);
5561
5663
  el.querySelector(".atk-list-body").append(this.$el);
5562
5664
  this.$el = el;
5563
- if (this.ctx.conf.flatMode === true) {
5564
- this.flatMode = true;
5565
- } else if (this.conf.nestMax && this.conf.nestMax <= 1) {
5566
- this.flatMode = true;
5567
- } else if (this.ctx.conf.flatMode === "auto") {
5568
- if (window.matchMedia("(max-width: 768px)").matches)
5569
- this.flatMode = true;
5570
- }
5571
- this.pageMode = this.conf.pagination.readMore ? "read-more" : "pagination";
5572
- this.pageSize = this.conf.pagination.pageSize || 20;
5573
5665
  this.repositionAt = this.$el;
5574
5666
  this.initListActionBtn();
5575
5667
  this.$commentCount = this.$el.querySelector(".atk-comment-count");
@@ -5577,9 +5669,6 @@ class List extends ListLite {
5577
5669
  count: '<span class="atk-comment-count-num">0</span>'
5578
5670
  });
5579
5671
  this.$commentCountNum = this.$commentCount.querySelector(".atk-comment-count-num");
5580
- if (this.ctx.conf.listSort) {
5581
- this.initDropdown();
5582
- }
5583
5672
  this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${version}">Artalk</a>`;
5584
5673
  }
5585
5674
  initListActionBtn() {
@@ -5614,6 +5703,9 @@ class List extends ListLite {
5614
5703
  this.ctx.editorOpen();
5615
5704
  this.$closeCommentBtn.innerHTML = this.$t("closeComment");
5616
5705
  }
5706
+ if (this.ctx.conf.listSort) {
5707
+ this.initDropdown();
5708
+ }
5617
5709
  }
5618
5710
  onLoad(data, offset) {
5619
5711
  super.onLoad(data, offset);
@@ -5687,6 +5779,9 @@ class List extends ListLite {
5687
5779
  }
5688
5780
  }
5689
5781
  initDropdown() {
5782
+ if (this.dropdownLoaded)
5783
+ return;
5784
+ this.dropdownLoaded = true;
5690
5785
  this.$dropdownWrap = this.$commentCount;
5691
5786
  this.$commentCount.classList.add("atk-dropdown-wrap");
5692
5787
  this.$dropdownWrap.append(createElement(`<span class="atk-arrow-down-icon"></span>`));
@@ -5767,6 +5862,8 @@ class Context {
5767
5862
  __publicField(this, "markedReplacers", []);
5768
5863
  __publicField(this, "commentList", []);
5769
5864
  __publicField(this, "eventList", []);
5865
+ __publicField(this, "darkModeMedia", window.matchMedia("(prefers-color-scheme: dark)"));
5866
+ __publicField(this, "darkModeAutoFunc");
5770
5867
  this.cid = +new Date();
5771
5868
  this.conf = conf;
5772
5869
  this.user = new User(this);
@@ -5775,6 +5872,9 @@ class Context {
5775
5872
  this.$root.classList.add("artalk");
5776
5873
  this.$root.innerHTML = "";
5777
5874
  this.api = new Api(this);
5875
+ this.on("conf-loaded", () => {
5876
+ this.refreshDarkModeConf();
5877
+ });
5778
5878
  }
5779
5879
  setApi(api) {
5780
5880
  this.api = api;
@@ -5936,21 +6036,42 @@ class Context {
5936
6036
  return getI18n(this.conf.locale, key, args);
5937
6037
  }
5938
6038
  setDarkMode(darkMode) {
6039
+ if (this.conf.darkMode === darkMode)
6040
+ return;
5939
6041
  const darkModeClassName = "atk-dark-mode";
5940
6042
  this.conf.darkMode = darkMode;
5941
- this.trigger("conf-updated");
5942
- if (this.conf.darkMode)
6043
+ if (darkMode)
5943
6044
  this.$root.classList.add(darkModeClassName);
5944
6045
  else
5945
6046
  this.$root.classList.remove(darkModeClassName);
5946
6047
  const { $wrap: $layerWrap } = GetLayerWrap(this);
5947
6048
  if ($layerWrap) {
5948
- if (this.conf.darkMode)
6049
+ if (darkMode)
5949
6050
  $layerWrap.classList.add(darkModeClassName);
5950
6051
  else
5951
6052
  $layerWrap.classList.remove(darkModeClassName);
5952
6053
  }
5953
6054
  }
6055
+ refreshDarkModeConf() {
6056
+ if (this.conf.darkMode === "auto") {
6057
+ this.setDarkMode(this.darkModeMedia.matches);
6058
+ if (!this.darkModeAutoFunc) {
6059
+ this.darkModeAutoFunc = (evt) => {
6060
+ this.setDarkMode(evt.matches);
6061
+ };
6062
+ this.darkModeMedia.addEventListener("change", this.darkModeAutoFunc);
6063
+ }
6064
+ } else {
6065
+ if (this.darkModeAutoFunc) {
6066
+ this.darkModeMedia.removeEventListener("change", this.darkModeAutoFunc);
6067
+ }
6068
+ this.setDarkMode(this.conf.darkMode || false);
6069
+ }
6070
+ }
6071
+ updateConf(conf) {
6072
+ this.conf = mergeDeep(this.conf, conf);
6073
+ this.trigger("conf-loaded");
6074
+ }
5954
6075
  }
5955
6076
  const defaults = {
5956
6077
  el: "",
@@ -5976,7 +6097,7 @@ const defaults = {
5976
6097
  pvEl: "#ArtalkPV",
5977
6098
  gravatar: {
5978
6099
  default: "mp",
5979
- mirror: "https://sdn.geekzu.org/avatar/"
6100
+ mirror: "https://cravatar.cn/avatar/"
5980
6101
  },
5981
6102
  pagination: {
5982
6103
  pageSize: 20,
@@ -5990,7 +6111,7 @@ const defaults = {
5990
6111
  imgUpload: true,
5991
6112
  reqTimeout: 15e3,
5992
6113
  versionCheck: true,
5993
- useBackendConf: false,
6114
+ useBackendConf: true,
5994
6115
  locale: "zh-CN"
5995
6116
  };
5996
6117
  class Dialog {
@@ -6106,6 +6227,7 @@ const CaptchaChecker = {
6106
6227
  },
6107
6228
  onError(that, ctx, err, inputVal, formEl) {
6108
6229
  formEl.querySelector(".atk-captcha-img").click();
6230
+ formEl.querySelector('input[type="text"]').value = "";
6109
6231
  }
6110
6232
  };
6111
6233
  const AdminChecker = {
@@ -6116,7 +6238,10 @@ const AdminChecker = {
6116
6238
  email: that.ctx.user.data.email,
6117
6239
  password: inputVal
6118
6240
  };
6119
- return that.ctx.getApi().user.login(data.name, data.email, data.password);
6241
+ return (() => __async(this, null, function* () {
6242
+ const resp = yield that.ctx.getApi().user.login(data.name, data.email, data.password);
6243
+ return resp.token;
6244
+ }))();
6120
6245
  },
6121
6246
  body(that, ctx) {
6122
6247
  return createElement(`<span>${that.ctx.$t("adminCheck")}</span>`);
@@ -6530,7 +6655,7 @@ class UploadPlug extends EditorPlug {
6530
6655
  };
6531
6656
  $input.click();
6532
6657
  };
6533
- this.ctx.on("conf-updated", () => {
6658
+ this.ctx.on("conf-loaded", () => {
6534
6659
  if (!this.ctx.conf.imgUpload) {
6535
6660
  this.getBtn().setAttribute("atk-only-admin-show", "");
6536
6661
  this.ctx.checkAdminShowEl();
@@ -6725,12 +6850,12 @@ class Editor extends Component {
6725
6850
  this.$notifyWrap = this.$el.querySelector(".atk-notify-wrap");
6726
6851
  this.$plugBtnWrap = this.$el.querySelector(".atk-plug-btn-wrap");
6727
6852
  this.$plugPanelWrap = this.$el.querySelector(".atk-plug-panel-wrap");
6728
- this.initLocalStorage();
6729
- this.initHeader();
6730
- this.initTextarea();
6731
- this.initPlugs();
6732
- this.initSubmitBtn();
6733
- this.ctx.on("conf-updated", () => {
6853
+ this.ctx.on("conf-loaded", () => {
6854
+ this.initLocalStorage();
6855
+ this.initHeader();
6856
+ this.initTextarea();
6857
+ this.initSubmitBtn();
6858
+ this.initPlugs();
6734
6859
  });
6735
6860
  }
6736
6861
  get user() {
@@ -7120,9 +7245,6 @@ class SidebarLayer extends Component {
7120
7245
  };
7121
7246
  }
7122
7247
  this.layer.show();
7123
- setTimeout(() => {
7124
- this.$el.style.transform = "translate(0, 0)";
7125
- }, 20);
7126
7248
  (() => __async(this, null, function* () {
7127
7249
  var _a;
7128
7250
  const resp = yield this.ctx.getApi().user.loginStatus();
@@ -7140,7 +7262,6 @@ class SidebarLayer extends Component {
7140
7262
  });
7141
7263
  }
7142
7264
  }))();
7143
- this.ctx.updateNotifies([]);
7144
7265
  if (this.firstShow) {
7145
7266
  this.$iframeWrap.innerHTML = "";
7146
7267
  this.$iframe = createElement("<iframe></iframe>");
@@ -7166,6 +7287,12 @@ class SidebarLayer extends Component {
7166
7287
  if (!this.conf.darkMode && isIframeSrcDarkMode)
7167
7288
  this.iframeLoad(this.$iframe.src.replace("&darkMode=1", ""));
7168
7289
  }
7290
+ setTimeout(() => {
7291
+ this.$el.style.transform = "translate(0, 0)";
7292
+ }, 100);
7293
+ setTimeout(() => {
7294
+ this.ctx.updateNotifies([]);
7295
+ }, 0);
7169
7296
  this.ctx.trigger("sidebar-show");
7170
7297
  });
7171
7298
  }
@@ -7186,7 +7313,13 @@ class SidebarLayer extends Component {
7186
7313
  }
7187
7314
  }
7188
7315
  const PvCountWidget = (ctx) => {
7189
- initCountWidget({ ctx, pvAdd: true });
7316
+ if (!ctx.conf.useBackendConf) {
7317
+ initCountWidget({ ctx, pvAdd: true });
7318
+ } else {
7319
+ ctx.on("list-loaded", () => {
7320
+ initCountWidget({ ctx, pvAdd: true });
7321
+ });
7322
+ }
7190
7323
  };
7191
7324
  function initCountWidget(p) {
7192
7325
  return __async(this, null, function* () {
@@ -7233,14 +7366,11 @@ const _Artalk = class {
7233
7366
  if (this.conf.el instanceof HTMLElement)
7234
7367
  this.$root = this.conf.el;
7235
7368
  this.ctx = new Context(this.conf, this.$root);
7236
- if (this.conf.useBackendConf)
7237
- return this.loadConfRemoteAndInitComponents();
7238
7369
  this.initComponents();
7239
7370
  }
7240
7371
  initComponents() {
7241
7372
  this.initLocale();
7242
7373
  this.initLayer();
7243
- this.initDarkMode();
7244
7374
  initMarked(this.ctx);
7245
7375
  const Components = {
7246
7376
  checkerLauncher: () => {
@@ -7261,7 +7391,6 @@ const _Artalk = class {
7261
7391
  sidebarLayer: () => {
7262
7392
  const sidebarLayer = new SidebarLayer(this.ctx);
7263
7393
  this.ctx.setSidebarLayer(sidebarLayer);
7264
- this.$root.appendChild(sidebarLayer.$el);
7265
7394
  },
7266
7395
  eventsDefault: () => {
7267
7396
  this.initEventBind();
@@ -7299,26 +7428,6 @@ const _Artalk = class {
7299
7428
  }
7300
7429
  return conf;
7301
7430
  }
7302
- loadConfRemoteAndInitComponents() {
7303
- return __async(this, null, function* () {
7304
- yield this.loadConfRemote();
7305
- this.initComponents();
7306
- return this;
7307
- });
7308
- }
7309
- loadConfRemote() {
7310
- return __async(this, null, function* () {
7311
- showLoading(this.$root);
7312
- let backendConf = {};
7313
- try {
7314
- backendConf = yield this.ctx.getApi().system.conf();
7315
- } catch (err) {
7316
- console.error("Load config from remote err", err);
7317
- }
7318
- this.ctx.conf = mergeDeep(this.ctx.conf, backendConf);
7319
- hideLoading(this.$root);
7320
- });
7321
- }
7322
7431
  initEventBind() {
7323
7432
  window.addEventListener("hashchange", () => {
7324
7433
  this.ctx.listHashGotoCheck();
@@ -7337,17 +7446,6 @@ const _Artalk = class {
7337
7446
  Layer.BodyOrgOverflow = document.body.style.overflow;
7338
7447
  Layer.BodyOrgPaddingRight = document.body.style.paddingRight;
7339
7448
  }
7340
- initDarkMode() {
7341
- if (this.conf.darkMode === "auto") {
7342
- const darkModeMedia = window.matchMedia("(prefers-color-scheme: dark)");
7343
- darkModeMedia.addEventListener("change", (e) => {
7344
- this.setDarkMode(e.matches);
7345
- });
7346
- this.setDarkMode(darkModeMedia.matches);
7347
- } else {
7348
- this.setDarkMode(this.conf.darkMode || false);
7349
- }
7350
- }
7351
7449
  on(name, handler) {
7352
7450
  this.ctx.on(name, handler, "external");
7353
7451
  }