artalk 2.1.3 → 2.1.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.
Files changed (62) hide show
  1. package/CNAME +1 -0
  2. package/dist/Artalk.css +1 -1
  3. package/dist/Artalk.es.js +509 -1571
  4. package/dist/Artalk.iife.js +1 -1
  5. package/dist/Artalk.js +1 -1
  6. package/index.html +143 -0
  7. package/package.json +8 -32
  8. package/postcss.config.js +5 -0
  9. package/src/api/index.ts +16 -3
  10. package/src/api/request.ts +4 -2
  11. package/src/artalk.ts +30 -8
  12. package/src/components/action-btn.ts +1 -1
  13. package/src/components/comment.ts +88 -3
  14. package/src/components/editor-plugs/emoticons-plug.less +21 -11
  15. package/src/components/editor-plugs/emoticons-plug.ts +18 -18
  16. package/src/components/editor-plugs/preview-plug.less +1 -1
  17. package/src/components/editor.ts +15 -20
  18. package/src/components/html/comment.html +6 -13
  19. package/src/components/html/editor.html +8 -9
  20. package/src/components/html/list.html +1 -1
  21. package/src/components/html/sidebar-layer.html +8 -0
  22. package/src/components/list-lite.ts +203 -299
  23. package/src/components/list.ts +11 -9
  24. package/src/components/pagination.ts +2 -2
  25. package/src/components/read-more-btn.ts +27 -4
  26. package/src/components/sidebar-layer.ts +143 -0
  27. package/src/defaults.ts +2 -1
  28. package/src/lib/detect.js +3 -1
  29. package/src/lib/utils.ts +27 -1
  30. package/src/style/_color.less +19 -23
  31. package/src/style/_extend.less +0 -80
  32. package/src/style/_variables.less +0 -24
  33. package/src/style/comment.less +191 -197
  34. package/src/style/editor.less +69 -94
  35. package/src/style/list.less +13 -13
  36. package/src/style/main.less +32 -32
  37. package/src/style/pagination.less +6 -6
  38. package/src/style/sidebar-layer.less +92 -0
  39. package/types/artalk-config.d.ts +4 -1
  40. package/types/artalk-data.d.ts +2 -2
  41. package/vite-common.config.ts +15 -0
  42. package/vite-demo.config.ts +14 -0
  43. package/vite.config.ts +36 -0
  44. package/LICENSE +0 -674
  45. package/README.md +0 -84
  46. package/src/components/admin/page-list.ts +0 -194
  47. package/src/components/admin/site-list-floater.ts +0 -98
  48. package/src/components/admin/site-list.ts +0 -289
  49. package/src/components/html/sidebar.html +0 -22
  50. package/src/components/item-text-editor.ts +0 -136
  51. package/src/components/sidebar-view.ts +0 -26
  52. package/src/components/sidebar-views/comments-view.ts +0 -74
  53. package/src/components/sidebar-views/pages-view.ts +0 -61
  54. package/src/components/sidebar-views/setting-view.ts +0 -21
  55. package/src/components/sidebar-views/sites-view.ts +0 -36
  56. package/src/components/sidebar-views/transfer-view.ts +0 -218
  57. package/src/components/sidebar.ts +0 -293
  58. package/src/lib/md5.js +0 -6
  59. package/src/style/item-text-editor.less +0 -35
  60. package/src/style/page-list.less +0 -50
  61. package/src/style/sidebar.less +0 -420
  62. package/src/style/site-list.less +0 -208
package/dist/Artalk.es.js CHANGED
@@ -102,6 +102,7 @@ const defaults$3 = {
102
102
  vote: true,
103
103
  voteDown: false,
104
104
  uaBadge: true,
105
+ pvEl: "#ArtalkPV",
105
106
  flatMode: "auto",
106
107
  maxNesting: 3,
107
108
  gravatar: {
@@ -109,7 +110,7 @@ const defaults$3 = {
109
110
  mirror: "https://sdn.geekzu.org/avatar/"
110
111
  },
111
112
  pagination: {
112
- pageSize: 15,
113
+ pageSize: 20,
113
114
  readMore: true,
114
115
  autoLoad: true
115
116
  },
@@ -194,7 +195,7 @@ function unescape(html) {
194
195
  }
195
196
  const caret = /(^|[^\[])\^/g;
196
197
  function edit(regex, opt) {
197
- regex = regex.source || regex;
198
+ regex = typeof regex === "string" ? regex : regex.source;
198
199
  opt = opt || "";
199
200
  const obj = {
200
201
  replace: (name, val) => {
@@ -290,7 +291,7 @@ function splitCells(tableRow, count) {
290
291
  if (!cells[0].trim()) {
291
292
  cells.shift();
292
293
  }
293
- if (!cells[cells.length - 1].trim()) {
294
+ if (cells.length > 0 && !cells[cells.length - 1].trim()) {
294
295
  cells.pop();
295
296
  }
296
297
  if (cells.length > count) {
@@ -320,7 +321,7 @@ function rtrim(str, c, invert) {
320
321
  break;
321
322
  }
322
323
  }
323
- return str.substr(0, l - suffLen);
324
+ return str.slice(0, l - suffLen);
324
325
  }
325
326
  function findClosingBracket(str, b) {
326
327
  if (str.indexOf(b[1]) === -1) {
@@ -411,14 +412,11 @@ class Tokenizer {
411
412
  }
412
413
  space(src) {
413
414
  const cap = this.rules.block.newline.exec(src);
414
- if (cap) {
415
- if (cap[0].length > 1) {
416
- return {
417
- type: "space",
418
- raw: cap[0]
419
- };
420
- }
421
- return { raw: "\n" };
415
+ if (cap && cap[0].length > 0) {
416
+ return {
417
+ type: "space",
418
+ raw: cap[0]
419
+ };
422
420
  }
423
421
  }
424
422
  code(src) {
@@ -481,7 +479,7 @@ class Tokenizer {
481
479
  blockquote(src) {
482
480
  const cap = this.rules.block.blockquote.exec(src);
483
481
  if (cap) {
484
- const text = cap[0].replace(/^ *> ?/gm, "");
482
+ const text = cap[0].replace(/^ *>[ \t]?/gm, "");
485
483
  return {
486
484
  type: "blockquote",
487
485
  raw: cap[0],
@@ -493,7 +491,7 @@ class Tokenizer {
493
491
  list(src) {
494
492
  let cap = this.rules.block.list.exec(src);
495
493
  if (cap) {
496
- let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine, line, lines, itemContents;
494
+ let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine, line, nextLine, rawLine, itemContents, endEarly;
497
495
  let bull = cap[1].trim();
498
496
  const isordered = bull.length > 1;
499
497
  const list2 = {
@@ -508,57 +506,57 @@ class Tokenizer {
508
506
  if (this.options.pedantic) {
509
507
  bull = isordered ? bull : "[*+-]";
510
508
  }
511
- const itemRegex = new RegExp(`^( {0,3}${bull})((?: [^\\n]*| *)(?:\\n[^\\n]*)*(?:\\n|$))`);
509
+ const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
512
510
  while (src) {
513
- if (this.rules.block.hr.test(src)) {
511
+ endEarly = false;
512
+ if (!(cap = itemRegex.exec(src))) {
514
513
  break;
515
514
  }
516
- if (!(cap = itemRegex.exec(src))) {
515
+ if (this.rules.block.hr.test(src)) {
517
516
  break;
518
517
  }
519
- lines = cap[2].split("\n");
518
+ raw = cap[0];
519
+ src = src.substring(raw.length);
520
+ line = cap[2].split("\n", 1)[0];
521
+ nextLine = src.split("\n", 1)[0];
520
522
  if (this.options.pedantic) {
521
523
  indent = 2;
522
- itemContents = lines[0].trimLeft();
524
+ itemContents = line.trimLeft();
523
525
  } else {
524
526
  indent = cap[2].search(/[^ ]/);
525
- indent = cap[1].length + (indent > 4 ? 1 : indent);
526
- itemContents = lines[0].slice(indent - cap[1].length);
527
+ indent = indent > 4 ? 1 : indent;
528
+ itemContents = line.slice(indent);
529
+ indent += cap[1].length;
527
530
  }
528
531
  blankLine = false;
529
- raw = cap[0];
530
- if (!lines[0] && /^ *$/.test(lines[1])) {
531
- raw = cap[1] + lines.slice(0, 2).join("\n") + "\n";
532
- list2.loose = true;
533
- lines = [];
532
+ if (!line && /^ *$/.test(nextLine)) {
533
+ raw += nextLine + "\n";
534
+ src = src.substring(nextLine.length + 1);
535
+ endEarly = true;
534
536
  }
535
- const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])`);
536
- for (i = 1; i < lines.length; i++) {
537
- line = lines[i];
538
- if (this.options.pedantic) {
539
- line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
540
- }
541
- if (nextBulletRegex.test(line)) {
542
- raw = cap[1] + lines.slice(0, i).join("\n") + "\n";
543
- break;
544
- }
545
- if (!blankLine) {
546
- if (!line.trim()) {
547
- blankLine = true;
537
+ if (!endEarly) {
538
+ const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])`);
539
+ while (src) {
540
+ rawLine = src.split("\n", 1)[0];
541
+ line = rawLine;
542
+ if (this.options.pedantic) {
543
+ line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
544
+ }
545
+ if (nextBulletRegex.test(line)) {
546
+ break;
548
547
  }
549
- if (line.search(/[^ ]/) >= indent) {
548
+ if (line.search(/[^ ]/) >= indent || !line.trim()) {
550
549
  itemContents += "\n" + line.slice(indent);
551
- } else {
550
+ } else if (!blankLine) {
552
551
  itemContents += "\n" + line;
552
+ } else {
553
+ break;
553
554
  }
554
- continue;
555
- }
556
- if (line.search(/[^ ]/) >= indent || !line.trim()) {
557
- itemContents += "\n" + line.slice(indent);
558
- continue;
559
- } else {
560
- raw = cap[1] + lines.slice(0, i).join("\n") + "\n";
561
- break;
555
+ if (!blankLine && !line.trim()) {
556
+ blankLine = true;
557
+ }
558
+ raw += rawLine + "\n";
559
+ src = src.substring(rawLine.length + 1);
562
560
  }
563
561
  }
564
562
  if (!list2.loose) {
@@ -584,7 +582,6 @@ class Tokenizer {
584
582
  text: itemContents
585
583
  });
586
584
  list2.raw += raw;
587
- src = src.slice(raw.length);
588
585
  }
589
586
  list2.items[list2.items.length - 1].raw = raw.trimRight();
590
587
  list2.items[list2.items.length - 1].text = itemContents.trimRight();
@@ -593,7 +590,21 @@ class Tokenizer {
593
590
  for (i = 0; i < l; i++) {
594
591
  this.lexer.state.top = false;
595
592
  list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
596
- if (list2.items[i].tokens.some((t) => t.type === "space")) {
593
+ const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
594
+ const hasMultipleLineBreaks = spacers.every((t) => {
595
+ const chars = t.raw.split("");
596
+ let lineBreaks = 0;
597
+ for (const char of chars) {
598
+ if (char === "\n") {
599
+ lineBreaks += 1;
600
+ }
601
+ if (lineBreaks > 1) {
602
+ return true;
603
+ }
604
+ }
605
+ return false;
606
+ });
607
+ if (!list2.loose && spacers.length && hasMultipleLineBreaks) {
597
608
  list2.loose = true;
598
609
  list2.items[i].loose = true;
599
610
  }
@@ -643,7 +654,7 @@ class Tokenizer {
643
654
  return { text: c };
644
655
  }),
645
656
  align: cap[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
646
- rows: cap[3] ? cap[3].replace(/\n$/, "").split("\n") : []
657
+ rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : []
647
658
  };
648
659
  if (item.header.length === item.align.length) {
649
660
  item.raw = cap[0];
@@ -987,18 +998,18 @@ const block = {
987
998
  newline: /^(?: *(?:\n|$))+/,
988
999
  code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
989
1000
  fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
990
- hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
1001
+ hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
991
1002
  heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
992
1003
  blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
993
- list: /^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,
1004
+ list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
994
1005
  html: "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",
995
- def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
1006
+ def: /^ {0,3}\[(label)\]: *(?:\n *)?<?([^\s>]+)>?(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
996
1007
  table: noopTest,
997
1008
  lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
998
- _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,
1009
+ _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
999
1010
  text: /^[^\n]+/
1000
1011
  };
1001
- block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
1012
+ block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
1002
1013
  block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
1003
1014
  block.def = edit(block.def).replace("label", block._label).replace("title", block._title).getRegex();
1004
1015
  block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
@@ -1007,13 +1018,14 @@ block.list = edit(block.list).replace(/bull/g, block.bullet).replace("hr", "\\n+
1007
1018
  block._tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
1008
1019
  block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
1009
1020
  block.html = edit(block.html, "i").replace("comment", block._comment).replace("tag", block._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
1010
- block.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
1021
+ block.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
1011
1022
  block.blockquote = edit(block.blockquote).replace("paragraph", block.paragraph).getRegex();
1012
1023
  block.normal = merge({}, block);
1013
1024
  block.gfm = merge({}, block.normal, {
1014
1025
  table: "^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
1015
1026
  });
1016
1027
  block.gfm.table = edit(block.gfm.table).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
1028
+ block.gfm.paragraph = edit(block._paragraph).replace("hr", block.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("table", block.gfm.table).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", block._tag).getRegex();
1017
1029
  block.pedantic = merge({}, block.normal, {
1018
1030
  html: edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", block._comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
1019
1031
  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
@@ -1027,13 +1039,13 @@ const inline = {
1027
1039
  url: noopTest,
1028
1040
  tag: "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",
1029
1041
  link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
1030
- reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
1031
- nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
1042
+ reflink: /^!?\[(label)\]\[(ref)\]/,
1043
+ nolink: /^!?\[(ref)\](?:\[\])?/,
1032
1044
  reflinkSearch: "reflink|nolink(?!\\()",
1033
1045
  emStrong: {
1034
1046
  lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
1035
- rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
1036
- rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/
1047
+ rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
1048
+ rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/
1037
1049
  },
1038
1050
  code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
1039
1051
  br: /^( {2,}|\\)\n(?!\s*$)/,
@@ -1059,7 +1071,8 @@ inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
1059
1071
  inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
1060
1072
  inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
1061
1073
  inline.link = edit(inline.link).replace("label", inline._label).replace("href", inline._href).replace("title", inline._title).getRegex();
1062
- inline.reflink = edit(inline.reflink).replace("label", inline._label).getRegex();
1074
+ inline.reflink = edit(inline.reflink).replace("label", inline._label).replace("ref", block._label).getRegex();
1075
+ inline.nolink = edit(inline.nolink).replace("ref", block._label).getRegex();
1063
1076
  inline.reflinkSearch = edit(inline.reflinkSearch, "g").replace("reflink", inline.reflink).replace("nolink", inline.nolink).getRegex();
1064
1077
  inline.normal = merge({}, inline);
1065
1078
  inline.pedantic = merge({}, inline.normal, {
@@ -1153,7 +1166,7 @@ class Lexer {
1153
1166
  return lexer.inlineTokens(src);
1154
1167
  }
1155
1168
  lex(src) {
1156
- src = src.replace(/\r\n|\r/g, "\n").replace(/\t/g, " ");
1169
+ src = src.replace(/\r\n|\r/g, "\n");
1157
1170
  this.blockTokens(src, this.tokens);
1158
1171
  let next;
1159
1172
  while (next = this.inlineQueue.shift()) {
@@ -1163,7 +1176,11 @@ class Lexer {
1163
1176
  }
1164
1177
  blockTokens(src, tokens = []) {
1165
1178
  if (this.options.pedantic) {
1166
- src = src.replace(/^ +$/gm, "");
1179
+ src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
1180
+ } else {
1181
+ src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
1182
+ return leading + " ".repeat(tabs.length);
1183
+ });
1167
1184
  }
1168
1185
  let token, lastToken, cutSrc, lastParagraphClipped;
1169
1186
  while (src) {
@@ -1179,7 +1196,9 @@ class Lexer {
1179
1196
  }
1180
1197
  if (token = this.tokenizer.space(src)) {
1181
1198
  src = src.substring(token.raw.length);
1182
- if (token.type) {
1199
+ if (token.raw.length === 1 && tokens.length > 0) {
1200
+ tokens[tokens.length - 1].raw += "\n";
1201
+ } else {
1183
1202
  tokens.push(token);
1184
1203
  }
1185
1204
  continue;
@@ -1470,16 +1489,21 @@ class Renderer {
1470
1489
  return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
1471
1490
  }
1472
1491
  blockquote(quote) {
1473
- return "<blockquote>\n" + quote + "</blockquote>\n";
1492
+ return `<blockquote>
1493
+ ${quote}</blockquote>
1494
+ `;
1474
1495
  }
1475
1496
  html(html) {
1476
1497
  return html;
1477
1498
  }
1478
1499
  heading(text, level, raw, slugger) {
1479
1500
  if (this.options.headerIds) {
1480
- return "<h" + level + ' id="' + this.options.headerPrefix + slugger.slug(raw) + '">' + text + "</h" + level + ">\n";
1501
+ const id = this.options.headerPrefix + slugger.slug(raw);
1502
+ return `<h${level} id="${id}">${text}</h${level}>
1503
+ `;
1481
1504
  }
1482
- return "<h" + level + ">" + text + "</h" + level + ">\n";
1505
+ return `<h${level}>${text}</h${level}>
1506
+ `;
1483
1507
  }
1484
1508
  hr() {
1485
1509
  return this.options.xhtml ? "<hr/>\n" : "<hr>\n";
@@ -1489,41 +1513,46 @@ class Renderer {
1489
1513
  return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
1490
1514
  }
1491
1515
  listitem(text) {
1492
- return "<li>" + text + "</li>\n";
1516
+ return `<li>${text}</li>
1517
+ `;
1493
1518
  }
1494
1519
  checkbox(checked) {
1495
1520
  return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox"' + (this.options.xhtml ? " /" : "") + "> ";
1496
1521
  }
1497
1522
  paragraph(text) {
1498
- return "<p>" + text + "</p>\n";
1523
+ return `<p>${text}</p>
1524
+ `;
1499
1525
  }
1500
1526
  table(header, body) {
1501
1527
  if (body)
1502
- body = "<tbody>" + body + "</tbody>";
1528
+ body = `<tbody>${body}</tbody>`;
1503
1529
  return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
1504
1530
  }
1505
1531
  tablerow(content) {
1506
- return "<tr>\n" + content + "</tr>\n";
1532
+ return `<tr>
1533
+ ${content}</tr>
1534
+ `;
1507
1535
  }
1508
1536
  tablecell(content, flags) {
1509
1537
  const type = flags.header ? "th" : "td";
1510
- const tag = flags.align ? "<" + type + ' align="' + flags.align + '">' : "<" + type + ">";
1511
- return tag + content + "</" + type + ">\n";
1538
+ const tag = flags.align ? `<${type} align="${flags.align}">` : `<${type}>`;
1539
+ return tag + content + `</${type}>
1540
+ `;
1512
1541
  }
1513
1542
  strong(text) {
1514
- return "<strong>" + text + "</strong>";
1543
+ return `<strong>${text}</strong>`;
1515
1544
  }
1516
1545
  em(text) {
1517
- return "<em>" + text + "</em>";
1546
+ return `<em>${text}</em>`;
1518
1547
  }
1519
1548
  codespan(text) {
1520
- return "<code>" + text + "</code>";
1549
+ return `<code>${text}</code>`;
1521
1550
  }
1522
1551
  br() {
1523
1552
  return this.options.xhtml ? "<br/>" : "<br>";
1524
1553
  }
1525
1554
  del(text) {
1526
- return "<del>" + text + "</del>";
1555
+ return `<del>${text}</del>`;
1527
1556
  }
1528
1557
  link(href, title, text) {
1529
1558
  href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
@@ -1542,9 +1571,9 @@ class Renderer {
1542
1571
  if (href === null) {
1543
1572
  return text;
1544
1573
  }
1545
- let out = '<img src="' + href + '" alt="' + text + '"';
1574
+ let out = `<img src="${href}" alt="${text}"`;
1546
1575
  if (title) {
1547
- out += ' title="' + title + '"';
1576
+ out += ` title="${title}"`;
1548
1577
  }
1549
1578
  out += this.options.xhtml ? "/>" : ">";
1550
1579
  return out;
@@ -2584,6 +2613,8 @@ function timeAgo(date) {
2584
2613
  }
2585
2614
  }
2586
2615
  function onImagesLoaded($container, event) {
2616
+ if (!$container)
2617
+ return;
2587
2618
  const images = $container.getElementsByTagName("img");
2588
2619
  if (!images.length)
2589
2620
  return;
@@ -2655,6 +2686,30 @@ function marked(ctx, src) {
2655
2686
  }
2656
2687
  return markedInstance.parse(src);
2657
2688
  }
2689
+ function getCorrectUserAgent() {
2690
+ return __async(this, null, function* () {
2691
+ const uaRaw = navigator.userAgent;
2692
+ const uaData = navigator.userAgentData;
2693
+ if (!uaData || !uaData.getHighEntropyValues) {
2694
+ return uaRaw;
2695
+ }
2696
+ let uaGot = null;
2697
+ try {
2698
+ uaGot = yield uaData.getHighEntropyValues(["platformVersion"]);
2699
+ } catch (err) {
2700
+ console.error(err);
2701
+ return uaRaw;
2702
+ }
2703
+ if (uaData.platform !== "Windows") {
2704
+ return uaRaw;
2705
+ }
2706
+ const majorPlatformVersion = Number(uaGot.platformVersion.split(".")[0]);
2707
+ if (majorPlatformVersion >= 13) {
2708
+ return uaRaw.replace(/Windows\W+NT\W+10.0/, "Windows NT 11.0");
2709
+ }
2710
+ return uaRaw;
2711
+ });
2712
+ }
2658
2713
  function showLoading(parentElem) {
2659
2714
  if (parentElem instanceof Context)
2660
2715
  parentElem = parentElem.$root;
@@ -2948,7 +3003,8 @@ function Fetch(ctx, input, init, timeout) {
2948
3003
  } else {
2949
3004
  resp = yield timeoutPromise(timeout || ctx.conf.reqTimeout || 15e3, fetch(input, init));
2950
3005
  }
2951
- if (!resp.ok && resp.status !== 401)
3006
+ const noAccessCodes = [401, 400];
3007
+ if (!resp.ok && !noAccessCodes.includes(resp.status))
2952
3008
  throw new Error(`\u8BF7\u6C42\u54CD\u5E94 ${resp.status}`);
2953
3009
  let json = yield resp.json();
2954
3010
  const recall = (resolve, reject) => {
@@ -2970,7 +3026,7 @@ function Fetch(ctx, input, init, timeout) {
2970
3026
  }
2971
3027
  });
2972
3028
  });
2973
- } else if (json.data && json.data.need_login || resp.status === 401) {
3029
+ } else if (json.data && json.data.need_login || noAccessCodes.includes(resp.status)) {
2974
3030
  json = yield new Promise((resolve, reject) => {
2975
3031
  ctx.trigger("checker-admin", {
2976
3032
  onSuccess: () => {
@@ -3038,16 +3094,13 @@ class Api {
3038
3094
  this.ctx = ctx;
3039
3095
  this.baseURL = ctx.conf.server;
3040
3096
  }
3041
- get(offset, type, flatMode, paramsEditor) {
3042
- var _a;
3097
+ get(offset, pageSize, flatMode, paramsEditor) {
3043
3098
  const params = {
3044
3099
  page_key: this.ctx.conf.pageKey,
3045
3100
  site_name: this.ctx.conf.site || "",
3046
- limit: ((_a = this.ctx.conf.pagination) == null ? void 0 : _a.pageSize) || 15,
3101
+ limit: pageSize,
3047
3102
  offset
3048
3103
  };
3049
- if (type)
3050
- params.type = type;
3051
3104
  if (flatMode)
3052
3105
  params.flat_mode = flatMode;
3053
3106
  if (this.ctx.user.checkHasBasicUserInfo()) {
@@ -3066,7 +3119,8 @@ class Api {
3066
3119
  link: comment2.link,
3067
3120
  content: comment2.content,
3068
3121
  rid: comment2.rid,
3069
- page_key: comment2.page_key
3122
+ page_key: comment2.page_key,
3123
+ ua: yield getCorrectUserAgent()
3070
3124
  };
3071
3125
  if (comment2.page_title)
3072
3126
  params.page_title = comment2.page_title;
@@ -3235,6 +3289,17 @@ class Api {
3235
3289
  }
3236
3290
  return POST(this.ctx, `${this.baseURL}/mark-read`, params);
3237
3291
  }
3292
+ pv() {
3293
+ return __async(this, null, function* () {
3294
+ const params = {
3295
+ site_name: this.ctx.conf.site || "",
3296
+ page_key: this.ctx.conf.pageKey || "",
3297
+ page_title: this.ctx.conf.pageTitle || ""
3298
+ };
3299
+ const p = yield POST(this.ctx, `${this.baseURL}/pv`, params);
3300
+ return p.pv;
3301
+ });
3302
+ }
3238
3303
  captchaGet() {
3239
3304
  return __async(this, null, function* () {
3240
3305
  const data = yield GET(this.ctx, `${this.baseURL}/captcha/refresh`);
@@ -3381,7 +3446,7 @@ class CheckerLauncher {
3381
3446
  }
3382
3447
  }
3383
3448
  var editor = "";
3384
- var EditorHTML = '<div class="atk-main-editor">\n <div class="atk-editor-header">\n <input name="nick" placeholder="\u6635\u79F0" class="atk-nick" type="text" required="required">\n <input name="email" placeholder="\u90AE\u7BB1" class="atk-email" type="email" required="required">\n <input name="link" placeholder="\u7F51\u5740 (https://)" class="atk-link" type="url">\n </div>\n <div class="atk-editor-textarea-wrap">\n <div class="atk-close-comment" style="display: none;"><span>\u4EC5\u7BA1\u7406\u5458\u53EF\u8BC4\u8BBA</span></div>\n <textarea id="atk-editor-textarea" class="atk-editor-textarea" placeholder=""></textarea>\n </div>\n <div class="atk-editor-plug-wrap" style="display: none;"></div>\n <div class="atk-editor-bottom">\n <div class="atk-editor-bottom-part atk-left atk-editor-plug-switcher-wrap"></div>\n <div class="atk-editor-bottom-part atk-right">\n <button type="button" class="atk-send-btn"></button>\n </div>\n </div>\n <div class="atk-editor-notify-wrap"></div>\n</div>\n';
3449
+ var EditorHTML = '<div class="atk-main-editor">\n <div class="atk-header">\n <input name="nick" placeholder="\u6635\u79F0" class="atk-nick" type="text" required="required">\n <input name="email" placeholder="\u90AE\u7BB1" class="atk-email" type="email" required="required">\n <input name="link" placeholder="\u7F51\u5740 (https://)" class="atk-link" type="url">\n </div>\n <div class="atk-textarea-wrap">\n <textarea class="atk-textarea" placeholder=""></textarea>\n </div>\n <div class="atk-plug-wrap" style="display: none;"></div>\n <div class="atk-bottom">\n <div class="atk-item atk-plug-btn-wrap"></div>\n <div class="atk-item">\n <button type="button" class="atk-send-btn"></button>\n </div>\n </div>\n <div class="atk-notify-wrap"></div>\n</div>\n';
3385
3450
  var emoticonsPlug = "";
3386
3451
  class EditorPlug {
3387
3452
  constructor(editor2) {
@@ -3398,8 +3463,8 @@ class EmoticonsPlug extends EditorPlug {
3398
3463
  super(editor2);
3399
3464
  __publicField(this, "$el");
3400
3465
  __publicField(this, "emoticons", []);
3401
- __publicField(this, "$listWrap");
3402
- __publicField(this, "$types");
3466
+ __publicField(this, "$grpWrap");
3467
+ __publicField(this, "$grpSwitcher");
3403
3468
  this.editor = editor2;
3404
3469
  this.$el = createElement(`<div class="atk-editor-plug-emoticons"></div>`);
3405
3470
  this.init();
@@ -3527,17 +3592,17 @@ class EmoticonsPlug extends EditorPlug {
3527
3592
  return dest;
3528
3593
  }
3529
3594
  initEmoticonsList() {
3530
- this.$listWrap = createElement(`<div class="atk-emoticons-list-wrap"></div>`);
3531
- this.$el.append(this.$listWrap);
3595
+ this.$grpWrap = createElement(`<div class="atk-grp-wrap"></div>`);
3596
+ this.$el.append(this.$grpWrap);
3532
3597
  this.emoticons.forEach((grp, index) => {
3533
- const emoticonsEl = createElement(`<div class="atk-emoticons-list" style="display: none;"></div>`);
3534
- this.$listWrap.append(emoticonsEl);
3535
- emoticonsEl.setAttribute("data-index", String(index));
3536
- emoticonsEl.setAttribute("data-grp-name", grp.name);
3537
- emoticonsEl.setAttribute("data-type", grp.type);
3598
+ const $grp = createElement(`<div class="atk-grp" style="display: none;"></div>`);
3599
+ this.$grpWrap.append($grp);
3600
+ $grp.setAttribute("data-index", String(index));
3601
+ $grp.setAttribute("data-grp-name", grp.name);
3602
+ $grp.setAttribute("data-type", grp.type);
3538
3603
  grp.items.forEach((item) => {
3539
- const $item = createElement(`<span class="atk-emoticons-item"></span>`);
3540
- emoticonsEl.append($item);
3604
+ const $item = createElement(`<span class="atk-item"></span>`);
3605
+ $grp.append($item);
3541
3606
  if (!!item.key && !new RegExp(`^(${grp.name})?\\s?[0-9]+$`).test(item.key))
3542
3607
  $item.setAttribute("title", item.key);
3543
3608
  if (grp.type === "image") {
@@ -3557,21 +3622,21 @@ class EmoticonsPlug extends EditorPlug {
3557
3622
  };
3558
3623
  });
3559
3624
  });
3560
- this.$types = createElement(`<div class="atk-emoticons-types"></div>`);
3561
- this.$el.append(this.$types);
3625
+ this.$grpSwitcher = createElement(`<div class="atk-grp-switcher"></div>`);
3626
+ this.$el.append(this.$grpSwitcher);
3562
3627
  this.emoticons.forEach((grp, index) => {
3563
3628
  const $item = createElement("<span />");
3564
3629
  $item.innerText = grp.name;
3565
3630
  $item.setAttribute("data-index", String(index));
3566
3631
  $item.onclick = () => this.openGrp(index);
3567
- this.$types.append($item);
3632
+ this.$grpSwitcher.append($item);
3568
3633
  });
3569
3634
  if (this.emoticons.length > 0)
3570
3635
  this.openGrp(0);
3571
3636
  }
3572
3637
  openGrp(index) {
3573
3638
  var _a;
3574
- Array.from(this.$listWrap.children).forEach((item) => {
3639
+ Array.from(this.$grpWrap.children).forEach((item) => {
3575
3640
  const el = item;
3576
3641
  if (el.getAttribute("data-index") !== String(index)) {
3577
3642
  el.style.display = "none";
@@ -3579,8 +3644,8 @@ class EmoticonsPlug extends EditorPlug {
3579
3644
  el.style.display = "";
3580
3645
  }
3581
3646
  });
3582
- this.$types.querySelectorAll("span.active").forEach((item) => item.classList.remove("active"));
3583
- (_a = this.$types.querySelector(`span[data-index="${index}"]`)) == null ? void 0 : _a.classList.add("active");
3647
+ this.$grpSwitcher.querySelectorAll("span.active").forEach((item) => item.classList.remove("active"));
3648
+ (_a = this.$grpSwitcher.querySelector(`span[data-index="${index}"]`)) == null ? void 0 : _a.classList.add("active");
3584
3649
  this.changeListHeight();
3585
3650
  }
3586
3651
  getEl() {
@@ -3655,12 +3720,9 @@ class Editor extends Component {
3655
3720
  __publicField(this, "$header");
3656
3721
  __publicField(this, "$textareaWrap");
3657
3722
  __publicField(this, "$textarea");
3658
- __publicField(this, "$closeComment");
3659
3723
  __publicField(this, "$plugWrap");
3660
3724
  __publicField(this, "$bottom");
3661
- __publicField(this, "$bottomPartLeft");
3662
- __publicField(this, "$plugSwitcherWrap");
3663
- __publicField(this, "$bottomPartRight");
3725
+ __publicField(this, "$plugBtnWrap");
3664
3726
  __publicField(this, "$submitBtn");
3665
3727
  __publicField(this, "$notifyWrap");
3666
3728
  __publicField(this, "replyComment", null);
@@ -3672,17 +3734,14 @@ class Editor extends Component {
3672
3734
  });
3673
3735
  __publicField(this, "openedPlugName", null);
3674
3736
  this.$el = createElement(EditorHTML);
3675
- this.$header = this.$el.querySelector(".atk-editor-header");
3676
- this.$textareaWrap = this.$el.querySelector(".atk-editor-textarea-wrap");
3677
- this.$textarea = this.$el.querySelector(".atk-editor-textarea");
3678
- this.$closeComment = this.$el.querySelector(".atk-close-comment");
3679
- this.$plugWrap = this.$el.querySelector(".atk-editor-plug-wrap");
3680
- this.$bottom = this.$el.querySelector(".atk-editor-bottom");
3681
- this.$bottomPartLeft = this.$el.querySelector(".atk-editor-bottom-part.atk-left");
3682
- this.$plugSwitcherWrap = this.$el.querySelector(".atk-editor-plug-switcher-wrap");
3683
- this.$bottomPartRight = this.$el.querySelector(".atk-editor-bottom-part.atk-right");
3737
+ this.$header = this.$el.querySelector(".atk-header");
3738
+ this.$textareaWrap = this.$el.querySelector(".atk-textarea-wrap");
3739
+ this.$textarea = this.$el.querySelector(".atk-textarea");
3740
+ this.$plugWrap = this.$el.querySelector(".atk-plug-wrap");
3741
+ this.$bottom = this.$el.querySelector(".atk-bottom");
3742
+ this.$plugBtnWrap = this.$el.querySelector(".atk-plug-btn-wrap");
3684
3743
  this.$submitBtn = this.$el.querySelector(".atk-send-btn");
3685
- this.$notifyWrap = this.$el.querySelector(".atk-editor-notify-wrap");
3744
+ this.$notifyWrap = this.$el.querySelector(".atk-notify-wrap");
3686
3745
  this.initLocalStorage();
3687
3746
  this.initHeader();
3688
3747
  this.initTextarea();
@@ -3793,17 +3852,17 @@ class Editor extends Component {
3793
3852
  this.$plugWrap.innerHTML = "";
3794
3853
  this.$plugWrap.style.display = "none";
3795
3854
  this.openedPlugName = null;
3796
- this.$plugSwitcherWrap.innerHTML = "";
3855
+ this.$plugBtnWrap.innerHTML = "";
3797
3856
  this.LOADABLE_PLUG_LIST.forEach((PlugObj) => {
3798
- const btnElem = createElement(`<span class="atk-editor-action atk-editor-plug-switcher">${PlugObj.BtnHTML}</span>`);
3799
- this.$plugSwitcherWrap.appendChild(btnElem);
3857
+ const btnElem = createElement(`<span class="atk-plug-btn">${PlugObj.BtnHTML}</span>`);
3858
+ this.$plugBtnWrap.appendChild(btnElem);
3800
3859
  btnElem.addEventListener("click", () => {
3801
3860
  let plug = this.plugList[PlugObj.Name];
3802
3861
  if (!plug) {
3803
3862
  plug = new PlugObj(this);
3804
3863
  this.plugList[PlugObj.Name] = plug;
3805
3864
  }
3806
- this.$plugSwitcherWrap.querySelectorAll(".active").forEach((item) => item.classList.remove("active"));
3865
+ this.$plugBtnWrap.querySelectorAll(".active").forEach((item) => item.classList.remove("active"));
3807
3866
  if (PlugObj.Name === this.openedPlugName) {
3808
3867
  plug.onHide();
3809
3868
  this.$plugWrap.style.display = "none";
@@ -3965,7 +4024,8 @@ class Editor extends Component {
3965
4024
  showNotify(this.$notifyWrap, msg, type);
3966
4025
  }
3967
4026
  close() {
3968
- this.$closeComment.style.display = "";
4027
+ if (!this.$textareaWrap.querySelector(".atk-comment-closed"))
4028
+ this.$textareaWrap.prepend(createElement('<div class="atk-comment-closed">\u4EC5\u7BA1\u7406\u5458\u53EF\u8BC4\u8BBA</div>'));
3969
4029
  if (!this.user.data.isAdmin) {
3970
4030
  this.$textarea.style.display = "none";
3971
4031
  this.closePlug();
@@ -3976,7 +4036,8 @@ class Editor extends Component {
3976
4036
  }
3977
4037
  }
3978
4038
  open() {
3979
- this.$closeComment.style.display = "none";
4039
+ var _a;
4040
+ (_a = this.$textareaWrap.querySelector(".atk-comment-closed")) == null ? void 0 : _a.remove();
3980
4041
  this.$textarea.style.display = "";
3981
4042
  this.$bottom.style.display = "";
3982
4043
  }
@@ -4000,7 +4061,7 @@ class Editor extends Component {
4000
4061
  }
4001
4062
  }
4002
4063
  var list = "";
4003
- var ListHTML = '<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <span class="atk-comment-count-num">0</span>\n \u6761\u8BC4\u8BBA\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 \u901A\u77E5\u4E2D\u5FC3\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';
4064
+ var ListHTML = '<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <span class="atk-comment-count-num">0</span>\n \u6761\u8BC4\u8BBA\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';
4004
4065
  var comment = "";
4005
4066
  var win = window || {};
4006
4067
  var nav = navigator || {};
@@ -4099,7 +4160,9 @@ function Detect(userAgent) {
4099
4160
  "6.0": "Vista",
4100
4161
  5.2: "XP",
4101
4162
  5.1: "XP",
4102
- "5.0": "2000"
4163
+ "5.0": "2000",
4164
+ "10.0": "10",
4165
+ "11.0": "11"
4103
4166
  };
4104
4167
  return hash2[v] || v;
4105
4168
  },
@@ -4243,7 +4306,7 @@ function Detect(userAgent) {
4243
4306
  function detectFactory(u) {
4244
4307
  return new Detect(u);
4245
4308
  }
4246
- var CommentHTML = '<div class="atk-comment-wrap" data-comment-id="">\n <div class="atk-comment">\n\n <div class="atk-avatar"></div>\n\n <div class="atk-comment-main">\n\n <div class="atk-header">\n <span class="atk-nick"></span>\n <span class="atk-badge"></span>\n <span class="atk-date"></span>\n </div>\n\n <div class="atk-body">\n <div class="atk-content"></div>\n </div>\n\n <div class="atk-footer">\n <div class="atk-comment-actions"></div>\n </div>\n\n </div>\n\n </div>\n</div>\n';
4309
+ 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';
4247
4310
  class ActionBtn {
4248
4311
  constructor(conf) {
4249
4312
  __publicField(this, "conf");
@@ -4306,7 +4369,7 @@ class ActionBtn {
4306
4369
  this.setLoading(false);
4307
4370
  this.$el.innerText = this.getText();
4308
4371
  }
4309
- setLoading(value = true, loadingText) {
4372
+ setLoading(value, loadingText) {
4310
4373
  if (this.isLoading === value)
4311
4374
  return;
4312
4375
  this.isLoading = value;
@@ -4393,11 +4456,11 @@ class Comment extends Component {
4393
4456
  }
4394
4457
  render() {
4395
4458
  this.$el = createElement(CommentHTML);
4396
- this.$main = this.$el.querySelector(".atk-comment-main");
4459
+ this.$main = this.$el.querySelector(".atk-main");
4397
4460
  this.$header = this.$el.querySelector(".atk-header");
4398
4461
  this.$body = this.$el.querySelector(".atk-body");
4399
4462
  this.$content = this.$body.querySelector(".atk-content");
4400
- this.$actions = this.$el.querySelector(".atk-comment-actions");
4463
+ this.$actions = this.$el.querySelector(".atk-actions");
4401
4464
  this.$children = null;
4402
4465
  this.$el.setAttribute("data-comment-id", `${this.data.id}`);
4403
4466
  this.renderCheckUnread();
@@ -4540,7 +4603,7 @@ class Comment extends Component {
4540
4603
  }
4541
4604
  }
4542
4605
  if (this.data.is_allow_reply) {
4543
- const replyBtn = createElement(`<span data-atk-action="comment-reply">\u56DE\u590D</span>`);
4606
+ const replyBtn = createElement(`<span>\u56DE\u590D</span>`);
4544
4607
  this.$actions.append(replyBtn);
4545
4608
  replyBtn.addEventListener("click", (e) => {
4546
4609
  e.stopPropagation();
@@ -4612,6 +4675,7 @@ class Comment extends Component {
4612
4675
  this.children.push(childC);
4613
4676
  this.getChildrenEl().appendChild(childC.getEl());
4614
4677
  childC.playFadeInAnim();
4678
+ childC.checkHeightLimitArea("content");
4615
4679
  }
4616
4680
  getChildrenEl() {
4617
4681
  if (this.$children === null) {
@@ -4727,6 +4791,76 @@ class Comment extends Component {
4727
4791
  this.openURL = url;
4728
4792
  this.$el.classList.add("atk-openable");
4729
4793
  }
4794
+ checkHeightLimit() {
4795
+ this.checkHeightLimitArea("content");
4796
+ this.checkHeightLimitArea("children");
4797
+ }
4798
+ checkHeightLimitArea(area) {
4799
+ var _a, _b;
4800
+ const childrenMaxH = (_a = this.ctx.conf.heightLimit) == null ? void 0 : _a.children;
4801
+ const contentMaxH = (_b = this.ctx.conf.heightLimit) == null ? void 0 : _b.content;
4802
+ if (area === "children" && !childrenMaxH)
4803
+ return;
4804
+ if (area === "content" && !contentMaxH)
4805
+ return;
4806
+ let maxHeight;
4807
+ if (area === "children")
4808
+ maxHeight = childrenMaxH;
4809
+ if (area === "content")
4810
+ maxHeight = contentMaxH;
4811
+ const checkEl = ($el) => {
4812
+ if (!$el)
4813
+ return;
4814
+ if (getHeight($el) > maxHeight) {
4815
+ this.heightLimitAdd($el, maxHeight);
4816
+ }
4817
+ };
4818
+ if (area === "children") {
4819
+ checkEl(this.$children);
4820
+ } else if (area === "content") {
4821
+ checkEl(this.$content);
4822
+ checkEl(this.$replyTo);
4823
+ onImagesLoaded(this.$content, () => {
4824
+ checkEl(this.$content);
4825
+ });
4826
+ if (this.$replyTo) {
4827
+ onImagesLoaded(this.$replyTo, () => {
4828
+ checkEl(this.$replyTo);
4829
+ });
4830
+ }
4831
+ }
4832
+ }
4833
+ heightLimitRemove($el) {
4834
+ if (!$el)
4835
+ return;
4836
+ if (!$el.classList.contains("atk-height-limit"))
4837
+ return;
4838
+ $el.classList.remove("atk-height-limit");
4839
+ Array.from($el.children).forEach((e) => {
4840
+ if (e.classList.contains("atk-height-limit-btn"))
4841
+ e.remove();
4842
+ });
4843
+ $el.style.height = "";
4844
+ $el.style.overflow = "";
4845
+ }
4846
+ heightLimitAdd($el, maxHeight) {
4847
+ if (!$el)
4848
+ return;
4849
+ if ($el.classList.contains("atk-height-limit"))
4850
+ return;
4851
+ $el.classList.add("atk-height-limit");
4852
+ $el.style.height = `${maxHeight}px`;
4853
+ $el.style.overflow = "hidden";
4854
+ const $hideMoreOpenBtn = createElement(`<div class="atk-height-limit-btn">\u9605\u8BFB\u66F4\u591A</span>`);
4855
+ $hideMoreOpenBtn.onclick = (e) => {
4856
+ e.stopPropagation();
4857
+ this.heightLimitRemove($el);
4858
+ const children = this.getChildren();
4859
+ if (children.length === 1)
4860
+ children[0].heightLimitRemove(children[0].$content);
4861
+ };
4862
+ $el.append($hideMoreOpenBtn);
4863
+ }
4730
4864
  }
4731
4865
  var pagination = "";
4732
4866
  class Pagination {
@@ -4759,7 +4893,7 @@ class Pagination {
4759
4893
  this.checkDisabled();
4760
4894
  }
4761
4895
  get pageSize() {
4762
- return this.conf.pageSize || 15;
4896
+ return this.conf.pageSize;
4763
4897
  }
4764
4898
  get offset() {
4765
4899
  return this.pageSize * (this.page - 1);
@@ -4869,19 +5003,28 @@ class ReadMoreBtn {
4869
5003
  __publicField(this, "$el");
4870
5004
  __publicField(this, "$loading");
4871
5005
  __publicField(this, "$text");
5006
+ __publicField(this, "offset", 0);
5007
+ __publicField(this, "total", 0);
4872
5008
  this.conf = conf;
4873
5009
  this.$el = createElement(`<div class="atk-list-read-more" style="display: none;">
4874
5010
  <div class="atk-list-read-more-inner">
4875
5011
  <div class="atk-loading-icon" style="display: none;"></div>
4876
- <span class="atk-text">\u67E5\u770B\u66F4\u591A</span>
5012
+ <span class="atk-text">\u52A0\u8F7D\u66F4\u591A</span>
4877
5013
  </div>
4878
5014
  </div>`);
4879
5015
  this.$loading = this.$el.querySelector(".atk-loading-icon");
4880
5016
  this.$text = this.$el.querySelector(".atk-text");
4881
- this.$el.onclick = () => this.click();
5017
+ this.$el.onclick = () => {
5018
+ this.click();
5019
+ };
5020
+ }
5021
+ get hasMore() {
5022
+ return this.total > this.offset + this.conf.pageSize;
4882
5023
  }
4883
5024
  click() {
4884
- this.conf.onClick();
5025
+ if (this.hasMore)
5026
+ this.conf.onClick(this.offset + this.conf.pageSize);
5027
+ this.checkDisabled();
4885
5028
  }
4886
5029
  show() {
4887
5030
  this.$el.style.display = "";
@@ -4902,38 +5045,43 @@ class ReadMoreBtn {
4902
5045
  this.$el.classList.remove("atk-err");
4903
5046
  }, 2e3);
4904
5047
  }
5048
+ update(offset, total) {
5049
+ this.offset = offset;
5050
+ this.total = total;
5051
+ this.checkDisabled();
5052
+ }
5053
+ checkDisabled() {
5054
+ if (this.hasMore)
5055
+ this.show();
5056
+ else
5057
+ this.hide();
5058
+ }
4905
5059
  }
4906
5060
  class ListLite extends Component {
4907
- constructor(ctx, $parent) {
5061
+ constructor(ctx) {
4908
5062
  super(ctx);
4909
- __publicField(this, "$parent");
4910
5063
  __publicField(this, "$commentsWrap");
4911
5064
  __publicField(this, "comments", []);
4912
5065
  __publicField(this, "data");
4913
- __publicField(this, "pageSize", 15);
4914
- __publicField(this, "offset", 0);
4915
- __publicField(this, "type");
4916
- __publicField(this, "noCommentText");
4917
- __publicField(this, "renderComment");
4918
- __publicField(this, "paramsEditor");
4919
- __publicField(this, "onAfterLoad");
4920
5066
  __publicField(this, "isLoading", false);
4921
- __publicField(this, "isFirstLoad", true);
4922
- __publicField(this, "flatMode");
5067
+ __publicField(this, "noCommentText", "\u65E0\u5185\u5BB9");
5068
+ __publicField(this, "flatMode", false);
4923
5069
  __publicField(this, "pageMode", "pagination");
5070
+ __publicField(this, "pageSize", 20);
5071
+ __publicField(this, "scrollListenerAt");
5072
+ __publicField(this, "repositionAt");
4924
5073
  __publicField(this, "pagination");
4925
5074
  __publicField(this, "readMoreBtn");
4926
5075
  __publicField(this, "autoLoadScrollEvent");
4927
- __publicField(this, "autoLoadListenerAt");
5076
+ __publicField(this, "renderComment");
5077
+ __publicField(this, "paramsEditor");
5078
+ __publicField(this, "onAfterLoad");
4928
5079
  __publicField(this, "unread", []);
4929
- __publicField(this, "unreadHighlight", false);
4930
- this.$parent = $parent;
5080
+ __publicField(this, "unreadHighlight");
4931
5081
  this.$el = createElement(`<div class="atk-list-lite">
4932
5082
  <div class="atk-list-comments-wrap"></div>
4933
5083
  </div>`);
4934
5084
  this.$commentsWrap = this.$el.querySelector(".atk-list-comments-wrap");
4935
- this.pageSize = this.conf.pagination ? this.conf.pagination.pageSize || this.pageSize : this.pageSize;
4936
- this.noCommentText = this.conf.noComment || "\u65E0\u8BC4\u8BBA";
4937
5085
  window.setInterval(() => {
4938
5086
  this.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
4939
5087
  const date = el.getAttribute("data-atk-comment-date");
@@ -4942,11 +5090,10 @@ class ListLite extends Component {
4942
5090
  }, 30 * 1e3);
4943
5091
  this.ctx.on("unread-update", (data) => this.updateUnread(data.notifies));
4944
5092
  }
4945
- reqComments(offset = 0) {
5093
+ fetchComments(offset) {
4946
5094
  return __async(this, null, function* () {
4947
- if (offset === 0 && this.pageMode !== "pagination") {
4948
- this.clearAllComments();
4949
- }
5095
+ if (this.isLoading)
5096
+ return;
4950
5097
  const showLoading$1 = () => {
4951
5098
  this.isLoading = true;
4952
5099
  if (offset === 0)
@@ -4967,28 +5114,23 @@ class ListLite extends Component {
4967
5114
  };
4968
5115
  showLoading$1();
4969
5116
  this.ctx.trigger("comments-load");
5117
+ if (this.pageMode === "read-more" && offset === 0) {
5118
+ this.clearAllComments();
5119
+ }
4970
5120
  let listData;
4971
5121
  try {
4972
- listData = yield new Api(this.ctx).get(offset, this.type, this.flatMode, this.paramsEditor);
5122
+ listData = yield new Api(this.ctx).get(offset, this.pageSize, this.flatMode, this.paramsEditor);
4973
5123
  } catch (e) {
4974
- this.onError(e.msg || String(e));
5124
+ this.onError(e.msg || String(e), offset);
4975
5125
  throw e;
4976
5126
  } finally {
4977
5127
  hideLoading$1();
4978
5128
  }
4979
- if (this.ctx.conf.versionCheck) {
4980
- const needUpdate = this.apiVersionCheck(listData.api_version || {});
4981
- if (needUpdate)
4982
- return;
4983
- }
4984
- this.offset = offset;
5129
+ setError(this.$el, null);
4985
5130
  try {
4986
5131
  this.onLoad(listData, offset);
4987
- if (this.onAfterLoad) {
4988
- this.onAfterLoad(listData);
4989
- }
4990
5132
  } catch (e) {
4991
- this.onError(String(e));
5133
+ this.onError(String(e), offset);
4992
5134
  throw e;
4993
5135
  } finally {
4994
5136
  hideLoading$1();
@@ -4996,128 +5138,116 @@ class ListLite extends Component {
4996
5138
  });
4997
5139
  }
4998
5140
  onLoad(data, offset) {
4999
- var _a;
5000
- setError(this.$el, null);
5001
5141
  if (this.pageMode === "pagination") {
5002
5142
  this.clearAllComments();
5003
5143
  }
5004
5144
  this.data = data;
5145
+ if (this.ctx.conf.versionCheck && this.versionCheck(data.api_version))
5146
+ return;
5005
5147
  this.importComments(data.comments);
5006
- if (this.isFirstLoad) {
5007
- this.onLoadInit();
5008
- }
5009
- if (this.pageMode === "pagination") {
5010
- this.pagination.update(offset, ((_a = this.data) == null ? void 0 : _a.total_parents) || 0);
5011
- }
5012
- if (this.pageMode === "read-more") {
5013
- if (this.hasMoreComments)
5014
- this.readMoreBtn.show();
5015
- else
5016
- this.readMoreBtn.hide();
5017
- }
5148
+ this.refreshPagination(offset, this.flatMode ? data.total : data.total_roots);
5149
+ this.refreshUI();
5018
5150
  this.ctx.trigger("unread-update", { notifies: data.unread || [] });
5019
- this.isFirstLoad = false;
5020
- }
5021
- onLoadInit() {
5151
+ this.ctx.trigger("comments-loaded");
5152
+ if (this.onAfterLoad)
5153
+ this.onAfterLoad(data);
5154
+ }
5155
+ refreshPagination(offset, total) {
5156
+ const modePagination = this.pageMode === "pagination";
5157
+ const modeReadMoreBtn = this.pageMode === "read-more";
5158
+ const initialized = modePagination ? !!this.pagination : !!this.readMoreBtn;
5159
+ if (!initialized) {
5160
+ this.initPagination();
5161
+ }
5162
+ if (modePagination)
5163
+ this.pagination.update(offset, total);
5164
+ if (modeReadMoreBtn)
5165
+ this.readMoreBtn.update(offset, total);
5166
+ }
5167
+ initPagination() {
5022
5168
  var _a;
5023
- if (this.autoLoadScrollEvent) {
5024
- const at = this.autoLoadListenerAt || document;
5025
- at.removeEventListener("scroll", this.autoLoadScrollEvent);
5026
- }
5027
5169
  if (this.pageMode === "read-more") {
5028
- const readMoreBtn = new ReadMoreBtn({
5029
- onClick: () => __async(this, null, function* () {
5030
- const offset = this.offset + this.pageSize;
5031
- yield this.reqComments(offset);
5170
+ this.readMoreBtn = new ReadMoreBtn({
5171
+ pageSize: this.pageSize,
5172
+ onClick: (o) => __async(this, null, function* () {
5173
+ yield this.fetchComments(o);
5032
5174
  })
5033
5175
  });
5034
- if (this.readMoreBtn)
5035
- this.readMoreBtn.$el.replaceWith(readMoreBtn.$el);
5036
- else
5037
- this.$el.append(readMoreBtn.$el);
5038
- this.readMoreBtn = readMoreBtn;
5176
+ this.$el.append(this.readMoreBtn.$el);
5039
5177
  if ((_a = this.conf.pagination) == null ? void 0 : _a.autoLoad) {
5178
+ const at = this.scrollListenerAt || document;
5179
+ if (this.autoLoadScrollEvent)
5180
+ at.removeEventListener("scroll", this.autoLoadScrollEvent);
5040
5181
  this.autoLoadScrollEvent = () => {
5041
5182
  if (this.pageMode !== "read-more")
5042
5183
  return;
5043
- if (!this.hasMoreComments)
5184
+ if (!this.readMoreBtn)
5185
+ return;
5186
+ if (!this.readMoreBtn.hasMore)
5044
5187
  return;
5045
5188
  if (this.isLoading)
5046
5189
  return;
5047
5190
  const $target = this.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");
5048
5191
  if (!$target)
5049
5192
  return;
5050
- if (isVisible($target, this.autoLoadListenerAt)) {
5193
+ if (isVisible($target, this.scrollListenerAt)) {
5051
5194
  this.readMoreBtn.click();
5052
5195
  }
5053
5196
  };
5054
- const at = this.autoLoadListenerAt || document;
5055
5197
  at.addEventListener("scroll", this.autoLoadScrollEvent);
5056
5198
  }
5057
- } else if (this.pageMode === "pagination") {
5058
- const pagination2 = new Pagination(this.parentCommentsCount, {
5199
+ }
5200
+ if (this.pageMode === "pagination") {
5201
+ this.pagination = new Pagination(!this.flatMode ? this.data.total_roots : this.data.total, {
5059
5202
  pageSize: this.pageSize,
5060
- onChange: (offset) => __async(this, null, function* () {
5203
+ onChange: (o) => __async(this, null, function* () {
5061
5204
  if (this.ctx.conf.editorTravel === true) {
5062
5205
  this.ctx.trigger("editor-travel-back");
5063
5206
  }
5064
- yield this.reqComments(offset);
5065
- if (this.$parent) {
5066
- let topPos = 0;
5067
- if (!this.autoLoadListenerAt && this.$parent) {
5068
- topPos = getOffset(this.$parent).top;
5069
- }
5070
- const at = this.autoLoadListenerAt || window;
5207
+ yield this.fetchComments(o);
5208
+ if (this.repositionAt) {
5209
+ const at = this.scrollListenerAt || window;
5071
5210
  at.scroll({
5072
- top: topPos,
5211
+ top: this.repositionAt ? getOffset(this.repositionAt).top : 0,
5073
5212
  left: 0
5074
5213
  });
5075
5214
  }
5076
5215
  })
5077
5216
  });
5078
- if (this.pagination)
5079
- this.pagination.$el.replaceWith(pagination2.$el);
5080
- else
5081
- this.$el.append(pagination2.$el);
5082
- this.pagination = pagination2;
5217
+ this.$el.append(this.pagination.$el);
5083
5218
  }
5084
5219
  }
5085
- onError(msg) {
5220
+ onError(msg, offset) {
5086
5221
  var _a;
5087
5222
  msg = String(msg);
5088
5223
  console.error(msg);
5089
- if (this.isFirstLoad || this.pageMode === "pagination") {
5090
- const errEl = createElement(`<span>${msg}\uFF0C\u65E0\u6CD5\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u6570\u636E<br/></span>`);
5091
- const retryBtn = createElement('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');
5092
- retryBtn.onclick = () => {
5093
- this.reqComments(this.offset);
5094
- };
5095
- errEl.appendChild(retryBtn);
5096
- const adminBtn = createElement('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');
5097
- adminBtn.onclick = () => {
5098
- this.ctx.trigger("sidebar-show");
5099
- };
5100
- if (!this.ctx.user.data.isAdmin) {
5101
- adminBtn.classList.add("atk-hide");
5102
- }
5103
- errEl.appendChild(adminBtn);
5104
- setError(this.$el, errEl);
5105
- } else {
5224
+ if (offset !== 0 && this.pageMode === "read-more") {
5106
5225
  (_a = this.readMoreBtn) == null ? void 0 : _a.showErr(`\u83B7\u53D6\u5931\u8D25`);
5226
+ return;
5107
5227
  }
5228
+ const $err = createElement(`<span>${msg}\uFF0C\u65E0\u6CD5\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u6570\u636E<br/></span>`);
5229
+ const $retryBtn = createElement('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');
5230
+ $retryBtn.onclick = () => this.fetchComments(0);
5231
+ $err.appendChild($retryBtn);
5232
+ const adminBtn = createElement('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');
5233
+ adminBtn.onclick = () => this.ctx.trigger("sidebar-show");
5234
+ if (!this.ctx.user.data.isAdmin)
5235
+ adminBtn.classList.add("atk-hide");
5236
+ $err.appendChild(adminBtn);
5237
+ setError(this.$el, $err);
5108
5238
  }
5109
5239
  refreshUI() {
5110
- const noComment = this.comments.length <= 0;
5111
- let noCommentEl = this.$commentsWrap.querySelector(".atk-list-no-comment");
5112
- if (noComment) {
5113
- if (!noCommentEl) {
5114
- noCommentEl = createElement('<div class="atk-list-no-comment"></div>');
5115
- this.$commentsWrap.appendChild(noCommentEl);
5116
- noCommentEl.innerHTML = this.noCommentText;
5240
+ const isNoComment = this.comments.length <= 0;
5241
+ let $noComment = this.$commentsWrap.querySelector(".atk-list-no-comment");
5242
+ if (isNoComment) {
5243
+ if (!$noComment) {
5244
+ $noComment = createElement('<div class="atk-list-no-comment"></div>');
5245
+ $noComment.innerHTML = this.noCommentText;
5246
+ this.$commentsWrap.appendChild($noComment);
5117
5247
  }
5248
+ } else {
5249
+ $noComment == null ? void 0 : $noComment.remove();
5118
5250
  }
5119
- if (!noComment && noCommentEl)
5120
- noCommentEl.remove();
5121
5251
  this.ctx.trigger("check-admin-show-el");
5122
5252
  }
5123
5253
  createComment(data) {
@@ -5132,66 +5262,58 @@ class ListLite extends Component {
5132
5262
  };
5133
5263
  return comment2;
5134
5264
  }
5135
- importComments(rawData) {
5136
- const queryImportChildren = (parentC) => {
5137
- const children = rawData.filter((o) => o.rid === parentC.data.id);
5138
- if (children.length === 0)
5139
- return;
5140
- children.forEach((itemData) => {
5141
- itemData.is_allow_reply = parentC.data.is_allow_reply;
5142
- const childC = this.createComment(itemData);
5265
+ importComments(srcData) {
5266
+ if (this.flatMode) {
5267
+ srcData.forEach((commentData) => {
5268
+ this.putCommentFlatMode(commentData, srcData, "append");
5269
+ });
5270
+ } else {
5271
+ this.importCommentsNesting(srcData);
5272
+ }
5273
+ }
5274
+ importCommentsNesting(srcData) {
5275
+ const loadChildren = (parentC) => {
5276
+ const children = srcData.filter((o) => o.rid === parentC.data.id);
5277
+ children.forEach((childData) => {
5278
+ const childC = this.createComment(childData);
5143
5279
  childC.render();
5144
5280
  parentC.putChild(childC);
5145
- queryImportChildren(childC);
5281
+ loadChildren(childC);
5146
5282
  });
5147
5283
  };
5148
- if (!this.flatMode) {
5149
- rawData.filter((o) => o.rid === 0).forEach((rootCommentData) => {
5150
- if (rootCommentData.is_collapsed)
5151
- rootCommentData.is_allow_reply = false;
5152
- const rootComment = this.createComment(rootCommentData);
5153
- rootComment.render();
5154
- this.comments.push(rootComment);
5155
- this.$commentsWrap.appendChild(rootComment.getEl());
5156
- rootComment.playFadeInAnim();
5157
- queryImportChildren(rootComment);
5158
- });
5159
- } else {
5160
- rawData.forEach((commentData) => {
5161
- this.putCommentFlatMode(commentData, rawData, "append");
5162
- });
5163
- }
5164
- this.eachComment(this.comments, (c) => {
5165
- if (c.getIsRoot())
5166
- this.checkMoreHide(c);
5284
+ const rootComments = srcData.filter((o) => o.rid === 0);
5285
+ rootComments.forEach((rootData) => {
5286
+ const rootC = this.createComment(rootData);
5287
+ rootC.render();
5288
+ this.$commentsWrap.appendChild(rootC.getEl());
5289
+ rootC.playFadeInAnim();
5290
+ this.comments.push(rootC);
5291
+ loadChildren(rootC);
5292
+ rootC.checkHeightLimit();
5167
5293
  });
5168
- this.refreshUI();
5169
- this.ctx.trigger("comments-loaded");
5170
5294
  }
5171
- putCommentFlatMode(commentItem, comments, insertMode) {
5172
- if (commentItem.is_collapsed)
5173
- commentItem.is_allow_reply = false;
5174
- const comment2 = this.createComment(commentItem);
5175
- if (commentItem.rid !== 0) {
5176
- const rComment = comments.find((o) => o.id === commentItem.rid);
5295
+ putCommentFlatMode(cData, srcData, insertMode) {
5296
+ if (cData.is_collapsed)
5297
+ cData.is_allow_reply = false;
5298
+ const comment2 = this.createComment(cData);
5299
+ if (cData.rid !== 0) {
5300
+ const rComment = srcData.find((o) => o.id === cData.rid);
5177
5301
  if (rComment)
5178
5302
  comment2.replyTo = rComment;
5179
5303
  }
5180
5304
  comment2.render();
5181
- if (insertMode === "append") {
5305
+ if (insertMode === "append")
5182
5306
  this.comments.push(comment2);
5183
- } else {
5307
+ if (insertMode === "prepend")
5184
5308
  this.comments.unshift(comment2);
5185
- }
5186
- if (commentItem.visible) {
5187
- if (insertMode === "append") {
5188
- this.$commentsWrap.appendChild(comment2.getEl());
5189
- } else {
5309
+ if (cData.visible) {
5310
+ if (insertMode === "append")
5311
+ this.$commentsWrap.append(comment2.getEl());
5312
+ if (insertMode === "prepend")
5190
5313
  this.$commentsWrap.prepend(comment2.getEl());
5191
- }
5192
5314
  comment2.playFadeInAnim();
5193
5315
  }
5194
- this.checkMoreHide(comment2);
5316
+ comment2.checkHeightLimit();
5195
5317
  return comment2;
5196
5318
  }
5197
5319
  insertComment(commentData) {
@@ -5201,18 +5323,17 @@ class ListLite extends Component {
5201
5323
  if (commentData.rid === 0) {
5202
5324
  this.$commentsWrap.prepend(comment2.getEl());
5203
5325
  this.comments.unshift(comment2);
5204
- this.checkMoreHide(comment2);
5205
5326
  } else {
5206
5327
  const parent = this.findComment(commentData.rid);
5207
5328
  if (parent) {
5208
5329
  parent.putChild(comment2);
5209
- if (parent.$children)
5210
- this.removeHideMore(parent.$children);
5211
- this.eachComment(parent.children, (c) => {
5212
- this.checkMoreHide(c);
5330
+ comment2.getParents().forEach((p) => {
5331
+ if (p.$children)
5332
+ p.heightLimitRemove(p.$children);
5213
5333
  });
5214
5334
  }
5215
5335
  }
5336
+ comment2.checkHeightLimit();
5216
5337
  scrollIntoView(comment2.getEl());
5217
5338
  comment2.playFadeInAnim();
5218
5339
  } else {
@@ -5224,92 +5345,6 @@ class ListLite extends Component {
5224
5345
  this.refreshUI();
5225
5346
  this.ctx.trigger("comments-loaded");
5226
5347
  }
5227
- checkMoreHide(c) {
5228
- const check = () => {
5229
- this.checkMoreHideEl(c, "children");
5230
- this.checkMoreHideEl(c, "content");
5231
- if (c.$replyTo)
5232
- this.checkMoreHideEl(c, "replyTo");
5233
- };
5234
- check();
5235
- if (c.$content.querySelectorAll("img").length) {
5236
- onImagesLoaded(c.$content, () => {
5237
- check();
5238
- });
5239
- }
5240
- }
5241
- checkMoreHideEl(comment2, area, allowHeight = 300) {
5242
- var _a, _b;
5243
- const childrenH = (_a = this.ctx.conf.heightLimit) == null ? void 0 : _a.children;
5244
- const contentH = (_b = this.ctx.conf.heightLimit) == null ? void 0 : _b.content;
5245
- if (area === "children" && !childrenH)
5246
- return;
5247
- if ((area === "content" || area === "replyTo") && !contentH)
5248
- return;
5249
- if (area === "children")
5250
- allowHeight = childrenH || 300;
5251
- else
5252
- allowHeight = contentH || 200;
5253
- let $target;
5254
- if (area === "children")
5255
- $target = comment2.$children;
5256
- else if (area === "content")
5257
- $target = comment2.$content;
5258
- else if (area === "replyTo")
5259
- $target = comment2.$replyTo;
5260
- if (!$target)
5261
- return;
5262
- let $hideMoreOpenBtn = $target.querySelector(".atk-more-hide-open-btn");
5263
- const removeHideMore = () => {
5264
- $target.classList.remove("atk-comment-more-hide");
5265
- if ($hideMoreOpenBtn)
5266
- $hideMoreOpenBtn.remove();
5267
- $target.style.height = "";
5268
- $target.style.overflow = "";
5269
- };
5270
- if (getHeight($target) > allowHeight) {
5271
- $target.classList.add("atk-comment-more-hide");
5272
- $target.style.height = `${allowHeight}px`;
5273
- $target.style.overflow = "hidden";
5274
- if (!$hideMoreOpenBtn) {
5275
- $hideMoreOpenBtn = createElement(`<div class="atk-more-hide-open-btn">\u9605\u8BFB\u66F4\u591A</span>`);
5276
- $hideMoreOpenBtn.onclick = (e) => {
5277
- e.stopPropagation();
5278
- removeHideMore();
5279
- if (comment2.getIsRoot()) {
5280
- const children = comment2.getChildren();
5281
- if (children.length > 1) {
5282
- this.eachComment(children, (c) => {
5283
- this.checkMoreHideEl(c, "content", contentH || 200);
5284
- });
5285
- }
5286
- }
5287
- };
5288
- $target.append($hideMoreOpenBtn);
5289
- }
5290
- }
5291
- }
5292
- removeHideMore($target) {
5293
- const $hideMoreOpenBtn = $target.querySelector(".atk-more-hide-open-btn");
5294
- $target.classList.remove("atk-comment-more-hide");
5295
- if ($hideMoreOpenBtn)
5296
- $hideMoreOpenBtn.remove();
5297
- $target.style.height = "";
5298
- $target.style.overflow = "";
5299
- }
5300
- get commentsCount() {
5301
- var _a;
5302
- return Number((_a = this.data) == null ? void 0 : _a.total) || 0;
5303
- }
5304
- get parentCommentsCount() {
5305
- var _a;
5306
- return Number((_a = this.data) == null ? void 0 : _a.total_parents) || 0;
5307
- }
5308
- get hasMoreComments() {
5309
- if (!this.data)
5310
- return false;
5311
- return (!this.flatMode ? this.data.total_parents : this.data.total) > this.offset + this.pageSize;
5312
- }
5313
5348
  eachComment(commentList, action) {
5314
5349
  if (commentList.length === 0)
5315
5350
  return;
@@ -5333,13 +5368,6 @@ class ListLite extends Component {
5333
5368
  });
5334
5369
  return comment2;
5335
5370
  }
5336
- getCommentCount() {
5337
- let count = 0;
5338
- this.eachComment(this.comments, () => {
5339
- count++;
5340
- });
5341
- return count;
5342
- }
5343
5371
  deleteComment(comment2) {
5344
5372
  let findComment;
5345
5373
  if (typeof comment2 === "number") {
@@ -5367,7 +5395,7 @@ class ListLite extends Component {
5367
5395
  }
5368
5396
  updateUnread(notifies) {
5369
5397
  this.unread = notifies;
5370
- if (this.unreadHighlight) {
5398
+ if (this.unreadHighlight === true) {
5371
5399
  this.eachComment(this.comments, (comment2) => {
5372
5400
  const notify = this.unread.find((o) => o.comment_id === comment2.data.id);
5373
5401
  if (notify) {
@@ -5385,16 +5413,16 @@ class ListLite extends Component {
5385
5413
  });
5386
5414
  }
5387
5415
  }
5388
- apiVersionCheck(versionData) {
5416
+ versionCheck(versionData) {
5389
5417
  const needVersion = (versionData == null ? void 0 : versionData.fe_min_version) || "0.0.0";
5390
- const needUpdate = versionCompare(needVersion, "2.1.3") === 1;
5418
+ const needUpdate = versionCompare(needVersion, "2.1.6") === 1;
5391
5419
  if (needUpdate) {
5392
- const errEl = createElement(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C ${"2.1.3"}\uFF0C\u9700\u6C42\u7248\u672C >= ${needVersion}</span><br/><br/></div>`);
5420
+ const errEl = createElement(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C ${"2.1.6"}\uFF0C\u9700\u6C42\u7248\u672C >= ${needVersion}</span><br/><br/></div>`);
5393
5421
  const ignoreBtn = createElement('<span style="cursor:pointer;">\u5FFD\u7565</span>');
5394
5422
  ignoreBtn.onclick = () => {
5395
5423
  setError(this.ctx, null);
5396
5424
  this.ctx.conf.versionCheck = false;
5397
- this.reqComments(0);
5425
+ this.fetchComments(0);
5398
5426
  };
5399
5427
  errEl.append(ignoreBtn);
5400
5428
  setError(this.ctx, errEl, '<span class="atk-warn-title">Artalk Warn</span>');
@@ -5404,9 +5432,9 @@ class ListLite extends Component {
5404
5432
  }
5405
5433
  class List extends ListLite {
5406
5434
  constructor(ctx) {
5407
- var _a;
5435
+ var _a, _b;
5408
5436
  const el = createElement(ListHTML);
5409
- super(ctx, el);
5437
+ super(ctx);
5410
5438
  __publicField(this, "$closeCommentBtn");
5411
5439
  __publicField(this, "$openSidebarBtn");
5412
5440
  __publicField(this, "$unreadBadge");
@@ -5421,9 +5449,11 @@ class List extends ListLite {
5421
5449
  }
5422
5450
  this.flatMode = flatMode;
5423
5451
  this.pageMode = ((_a = this.conf.pagination) == null ? void 0 : _a.readMore) ? "read-more" : "pagination";
5452
+ this.pageSize = ((_b = this.conf.pagination) == null ? void 0 : _b.pageSize) || 20;
5453
+ this.repositionAt = this.$el;
5424
5454
  this.initListActionBtn();
5425
- this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.1.3"}">Artalk</a>`;
5426
- this.ctx.on("list-reload", () => this.reqComments(0));
5455
+ this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.1.6"}">Artalk</a>`;
5456
+ this.ctx.on("list-reload", () => this.fetchComments(0));
5427
5457
  this.ctx.on("list-refresh-ui", () => this.refreshUI());
5428
5458
  this.ctx.on("list-import", (data) => this.importComments(data));
5429
5459
  this.ctx.on("list-insert", (data) => this.insertComment(data));
@@ -5452,15 +5482,16 @@ class List extends ListLite {
5452
5482
  });
5453
5483
  }
5454
5484
  refreshUI() {
5485
+ var _a;
5455
5486
  super.refreshUI();
5456
- this.$el.querySelector(".atk-comment-count-num").innerText = String(this.commentsCount);
5487
+ this.$el.querySelector(".atk-comment-count-num").innerText = String(Number((_a = this.data) == null ? void 0 : _a.total) || 0);
5457
5488
  if (!!this.ctx.user.data.nick && !!this.ctx.user.data.email) {
5458
5489
  this.$openSidebarBtn.classList.remove("atk-hide");
5459
5490
  } else {
5460
5491
  this.$openSidebarBtn.classList.add("atk-hide");
5461
5492
  }
5462
5493
  this.ctx.trigger("check-admin-show-el");
5463
- this.$openSidebarBtn.innerText = !this.ctx.user.data.isAdmin ? "\u901A\u77E5\u4E2D\u5FC3" : "\u63A7\u5236\u4E2D\u5FC3";
5494
+ this.$openSidebarBtn.querySelector(".atk-text").innerText = !this.ctx.user.data.isAdmin ? "\u901A\u77E5\u4E2D\u5FC3" : "\u63A7\u5236\u4E2D\u5FC3";
5464
5495
  if (!!this.data && !!this.data.page && this.data.page.admin_only === true) {
5465
5496
  this.ctx.trigger("editor-close");
5466
5497
  this.$closeCommentBtn.innerHTML = "\u6253\u5F00\u8BC4\u8BBA";
@@ -5525,1036 +5556,22 @@ class List extends ListLite {
5525
5556
  }
5526
5557
  }
5527
5558
  }
5528
- var sidebar = "";
5529
- var MD5 = function(d) {
5530
- var r = M(V(Y(X(d), 8 * d.length)));
5531
- return r.toLowerCase();
5532
- };
5533
- function M(d) {
5534
- for (var _, m = "0123456789ABCDEF", f = "", r = 0; r < d.length; r++)
5535
- _ = d.charCodeAt(r), f += m.charAt(_ >>> 4 & 15) + m.charAt(15 & _);
5536
- return f;
5537
- }
5538
- function X(d) {
5539
- for (var _ = Array(d.length >> 2), m = 0; m < _.length; m++)
5540
- _[m] = 0;
5541
- for (m = 0; m < 8 * d.length; m += 8)
5542
- _[m >> 5] |= (255 & d.charCodeAt(m / 8)) << m % 32;
5543
- return _;
5544
- }
5545
- function V(d) {
5546
- for (var _ = "", m = 0; m < 32 * d.length; m += 8)
5547
- _ += String.fromCharCode(d[m >> 5] >>> m % 32 & 255);
5548
- return _;
5549
- }
5550
- function Y(d, _) {
5551
- d[_ >> 5] |= 128 << _ % 32, d[14 + (_ + 64 >>> 9 << 4)] = _;
5552
- for (var m = 1732584193, f = -271733879, r = -1732584194, i = 271733878, n = 0; n < d.length; n += 16) {
5553
- var h = m, t = f, g = r, e = i;
5554
- f = md5_ii(f = md5_ii(f = md5_ii(f = md5_ii(f = md5_hh(f = md5_hh(f = md5_hh(f = md5_hh(f = md5_gg(f = md5_gg(f = md5_gg(f = md5_gg(f = md5_ff(f = md5_ff(f = md5_ff(f = md5_ff(f, r = md5_ff(r, i = md5_ff(i, m = md5_ff(m, f, r, i, d[n + 0], 7, -680876936), f, r, d[n + 1], 12, -389564586), m, f, d[n + 2], 17, 606105819), i, m, d[n + 3], 22, -1044525330), r = md5_ff(r, i = md5_ff(i, m = md5_ff(m, f, r, i, d[n + 4], 7, -176418897), f, r, d[n + 5], 12, 1200080426), m, f, d[n + 6], 17, -1473231341), i, m, d[n + 7], 22, -45705983), r = md5_ff(r, i = md5_ff(i, m = md5_ff(m, f, r, i, d[n + 8], 7, 1770035416), f, r, d[n + 9], 12, -1958414417), m, f, d[n + 10], 17, -42063), i, m, d[n + 11], 22, -1990404162), r = md5_ff(r, i = md5_ff(i, m = md5_ff(m, f, r, i, d[n + 12], 7, 1804603682), f, r, d[n + 13], 12, -40341101), m, f, d[n + 14], 17, -1502002290), i, m, d[n + 15], 22, 1236535329), r = md5_gg(r, i = md5_gg(i, m = md5_gg(m, f, r, i, d[n + 1], 5, -165796510), f, r, d[n + 6], 9, -1069501632), m, f, d[n + 11], 14, 643717713), i, m, d[n + 0], 20, -373897302), r = md5_gg(r, i = md5_gg(i, m = md5_gg(m, f, r, i, d[n + 5], 5, -701558691), f, r, d[n + 10], 9, 38016083), m, f, d[n + 15], 14, -660478335), i, m, d[n + 4], 20, -405537848), r = md5_gg(r, i = md5_gg(i, m = md5_gg(m, f, r, i, d[n + 9], 5, 568446438), f, r, d[n + 14], 9, -1019803690), m, f, d[n + 3], 14, -187363961), i, m, d[n + 8], 20, 1163531501), r = md5_gg(r, i = md5_gg(i, m = md5_gg(m, f, r, i, d[n + 13], 5, -1444681467), f, r, d[n + 2], 9, -51403784), m, f, d[n + 7], 14, 1735328473), i, m, d[n + 12], 20, -1926607734), r = md5_hh(r, i = md5_hh(i, m = md5_hh(m, f, r, i, d[n + 5], 4, -378558), f, r, d[n + 8], 11, -2022574463), m, f, d[n + 11], 16, 1839030562), i, m, d[n + 14], 23, -35309556), r = md5_hh(r, i = md5_hh(i, m = md5_hh(m, f, r, i, d[n + 1], 4, -1530992060), f, r, d[n + 4], 11, 1272893353), m, f, d[n + 7], 16, -155497632), i, m, d[n + 10], 23, -1094730640), r = md5_hh(r, i = md5_hh(i, m = md5_hh(m, f, r, i, d[n + 13], 4, 681279174), f, r, d[n + 0], 11, -358537222), m, f, d[n + 3], 16, -722521979), i, m, d[n + 6], 23, 76029189), r = md5_hh(r, i = md5_hh(i, m = md5_hh(m, f, r, i, d[n + 9], 4, -640364487), f, r, d[n + 12], 11, -421815835), m, f, d[n + 15], 16, 530742520), i, m, d[n + 2], 23, -995338651), r = md5_ii(r, i = md5_ii(i, m = md5_ii(m, f, r, i, d[n + 0], 6, -198630844), f, r, d[n + 7], 10, 1126891415), m, f, d[n + 14], 15, -1416354905), i, m, d[n + 5], 21, -57434055), r = md5_ii(r, i = md5_ii(i, m = md5_ii(m, f, r, i, d[n + 12], 6, 1700485571), f, r, d[n + 3], 10, -1894986606), m, f, d[n + 10], 15, -1051523), i, m, d[n + 1], 21, -2054922799), r = md5_ii(r, i = md5_ii(i, m = md5_ii(m, f, r, i, d[n + 8], 6, 1873313359), f, r, d[n + 15], 10, -30611744), m, f, d[n + 6], 15, -1560198380), i, m, d[n + 13], 21, 1309151649), r = md5_ii(r, i = md5_ii(i, m = md5_ii(m, f, r, i, d[n + 4], 6, -145523070), f, r, d[n + 11], 10, -1120210379), m, f, d[n + 2], 15, 718787259), i, m, d[n + 9], 21, -343485551), m = safe_add(m, h), f = safe_add(f, t), r = safe_add(r, g), i = safe_add(i, e);
5555
- }
5556
- return Array(m, f, r, i);
5557
- }
5558
- function md5_cmn(d, _, m, f, r, i) {
5559
- return safe_add(bit_rol(safe_add(safe_add(_, d), safe_add(f, i)), r), m);
5560
- }
5561
- function md5_ff(d, _, m, f, r, i, n) {
5562
- return md5_cmn(_ & m | ~_ & f, d, _, r, i, n);
5563
- }
5564
- function md5_gg(d, _, m, f, r, i, n) {
5565
- return md5_cmn(_ & f | m & ~f, d, _, r, i, n);
5566
- }
5567
- function md5_hh(d, _, m, f, r, i, n) {
5568
- return md5_cmn(_ ^ m ^ f, d, _, r, i, n);
5569
- }
5570
- function md5_ii(d, _, m, f, r, i, n) {
5571
- return md5_cmn(m ^ (_ | ~f), d, _, r, i, n);
5572
- }
5573
- function safe_add(d, _) {
5574
- var m = (65535 & d) + (65535 & _);
5575
- return (d >> 16) + (_ >> 16) + (m >> 16) << 16 | 65535 & m;
5576
- }
5577
- function bit_rol(d, _) {
5578
- return d << _ | d >>> 32 - _;
5579
- }
5580
- var SidebarHTML = '<div class="atk-sidebar">\n <div class="atk-sidebar-inner">\n <div class="atk-sidebar-header">\n <span class="atk-avatar">\n <span class="atk-site-logo"></span>\n </span>\n <span class="atk-menu">\n <span class="atk-item atk-active atk-sidebar-title">\u63A7\u5236\u4E2D\u5FC3</span>\n </span>\n <div class="atk-sidebar-close"><i class="atk-icon atk-icon-close"></i></div>\n </div>\n <div class="atk-sidebar-nav">\n <div class="akt-curt-view-btn">\n <div class="atk-icon"><span></span><span></span><span></span></div>\n <div class="atk-text"></div>\n </div>\n <div class="atk-tabs"></div>\n <div class="atk-tabs atk-views" style="display: none;"></div>\n </div>\n <div class="atk-sidebar-view-wrap"></div>\n </div>\n</div>\n';
5581
- class SidebarView extends Component {
5582
- constructor(ctx, $parent) {
5583
- super(ctx);
5584
- __publicField(this, "viewTabs", {});
5585
- __publicField(this, "viewActiveTab", "");
5586
- __publicField(this, "$parent");
5587
- this.$parent = $parent;
5588
- this.$el = createElement(`<div class="atk-sidebar-view"></div>`);
5589
- }
5590
- mount(siteName) {
5591
- }
5592
- switchTab(tab, siteName) {
5593
- }
5594
- }
5595
- __publicField(SidebarView, "viewName", "");
5596
- __publicField(SidebarView, "viewTitle", "");
5597
- __publicField(SidebarView, "viewAdminOnly", false);
5598
- class MessageView extends SidebarView {
5599
- constructor() {
5600
- super(...arguments);
5601
- __publicField(this, "viewTabs", {});
5602
- __publicField(this, "viewActiveTab", "");
5603
- __publicField(this, "list");
5604
- }
5605
- mount(siteName) {
5606
- if (this.ctx.user.data.isAdmin) {
5607
- this.viewTabs = {
5608
- admin_all: "\u5168\u90E8",
5609
- admin_pending: "\u5F85\u5BA1",
5610
- all: "\u4E2A\u4EBA"
5611
- };
5612
- this.viewActiveTab = "admin_all";
5613
- } else {
5614
- this.viewTabs = {
5615
- mentions: "\u63D0\u53CA",
5616
- all: "\u5168\u90E8",
5617
- mine: "\u6211\u7684",
5618
- pending: "\u5F85\u5BA1"
5619
- };
5620
- this.viewActiveTab = "mentions";
5621
- }
5622
- this.list = new ListLite(this.ctx, this.$el);
5623
- this.list.flatMode = true;
5624
- this.list.unreadHighlight = true;
5625
- this.list.autoLoadListenerAt = this.$parent;
5626
- this.list.pageMode = "pagination";
5627
- this.list.noCommentText = '<div class="atk-sidebar-no-content">\u65E0\u5185\u5BB9</div>';
5628
- this.list.renderComment = (comment2) => {
5629
- comment2.setOpenURL(`${comment2.data.page_key}#atk-comment-${comment2.data.id}`);
5630
- comment2.onReplyBtnClick = () => {
5631
- if (this.ctx.conf.editorTravel === true) {
5632
- this.ctx.trigger("editor-reply", { data: comment2.data, $el: comment2.$el, scroll: false });
5633
- } else {
5634
- this.ctx.trigger("sidebar-hide");
5635
- this.ctx.trigger("editor-reply", { data: comment2.data, $el: comment2.$el, scroll: true });
5636
- }
5637
- };
5638
- };
5639
- this.list.paramsEditor = (params) => {
5640
- params.site_name = siteName;
5641
- };
5642
- this.$el.innerHTML = "";
5643
- this.$el.append(this.list.$el);
5644
- this.switchTab(this.viewActiveTab, siteName);
5645
- }
5646
- switchTab(tab, siteName) {
5647
- this.viewActiveTab = tab;
5648
- this.list.type = tab;
5649
- this.list.isFirstLoad = true;
5650
- this.list.paramsEditor = (params) => {
5651
- params.site_name = siteName;
5652
- };
5653
- this.list.reqComments();
5654
- return true;
5655
- }
5656
- }
5657
- __publicField(MessageView, "viewName", "comments");
5658
- __publicField(MessageView, "viewTitle", "\u8BC4\u8BBA");
5659
- var pageList = "";
5660
- var itemTextEditor = "";
5661
- class ItemTextEditor {
5662
- constructor(conf) {
5663
- __publicField(this, "conf");
5664
- __publicField(this, "$el");
5665
- __publicField(this, "$input");
5666
- __publicField(this, "$yesBtn");
5667
- __publicField(this, "$noBtn");
5668
- __publicField(this, "value", "");
5669
- __publicField(this, "allowSubmit", true);
5670
- this.conf = conf;
5671
- this.$el = createElement(`<div class="atk-item-text-editor-layer">
5672
- <div class="atk-edit-form">
5673
- <input class="atk-main-input" type="text" placeholder="\u8F93\u5165\u5185\u5BB9..." autocomplete="off" autofocus>
5674
- </div>
5675
- <div class="atk-actions">
5676
- <div class="atk-item atk-yes-btn">
5677
- <i class="atk-icon atk-icon-yes"></i>
5678
- </div>
5679
- <div class="atk-item atk-no-btn">
5680
- <i class="atk-icon atk-icon-no"></i>
5681
- </div>
5682
- </div>
5683
- </div>`);
5684
- this.$input = this.$el.querySelector(".atk-main-input");
5685
- this.$yesBtn = this.$el.querySelector(".atk-yes-btn");
5686
- this.$noBtn = this.$el.querySelector(".atk-no-btn");
5687
- this.$input.value = conf.initValue || "";
5688
- this.value = conf.initValue || "";
5689
- if (this.conf.placeholder)
5690
- this.$input.placeholder = this.conf.placeholder;
5691
- this.$input.oninput = () => this.onInput();
5692
- this.$input.onkeyup = (evt) => {
5693
- if (evt.key === "Enter" || evt.keyCode === 13) {
5694
- evt.preventDefault();
5695
- this.submit();
5696
- }
5697
- };
5698
- window.setTimeout(() => this.$input.focus(), 80);
5699
- this.$yesBtn.onclick = () => {
5700
- this.submit();
5701
- };
5702
- this.$noBtn.onclick = () => {
5703
- this.cancel();
5704
- };
5705
- }
5706
- appendTo(parentDOM) {
5707
- parentDOM.append(this.$el);
5708
- return this;
5709
- }
5710
- onInput() {
5711
- this.value = this.$input.value;
5712
- if (this.conf.validator) {
5713
- const ok = this.conf.validator(this.value);
5714
- this.setAllowSubmit(ok);
5715
- if (!ok) {
5716
- this.$input.classList.add("atk-invalid");
5717
- } else {
5718
- this.$input.classList.remove("atk-invalid");
5719
- }
5720
- }
5721
- }
5722
- setAllowSubmit(allow) {
5723
- if (this.allowSubmit === allow)
5724
- return;
5725
- this.allowSubmit = allow;
5726
- if (!allow) {
5727
- this.$yesBtn.classList.add(".atk-disabled");
5728
- } else {
5729
- this.$yesBtn.classList.remove(".atk-disabled");
5730
- }
5731
- }
5732
- submit() {
5733
- return __async(this, null, function* () {
5734
- if (!this.allowSubmit)
5735
- return;
5736
- if (this.conf.onYes) {
5737
- let isContinue;
5738
- if (this.conf.onYes instanceof (() => __async(this, null, function* () {
5739
- })).constructor) {
5740
- isContinue = yield this.conf.onYes(this.value);
5741
- } else {
5742
- isContinue = this.conf.onYes(this.value);
5743
- }
5744
- if (isContinue === void 0 || isContinue === true) {
5745
- this.closeEditor();
5746
- }
5747
- } else {
5748
- this.closeEditor();
5749
- }
5750
- });
5751
- }
5752
- cancel() {
5753
- return __async(this, null, function* () {
5754
- if (this.conf.onNo) {
5755
- let isContinue;
5756
- if (this.conf.onNo instanceof (() => __async(this, null, function* () {
5757
- })).constructor) {
5758
- isContinue = yield this.conf.onNo();
5759
- } else {
5760
- isContinue = this.conf.onNo();
5761
- }
5762
- if (isContinue === void 0 || isContinue === true) {
5763
- this.closeEditor();
5764
- }
5765
- } else {
5766
- this.closeEditor();
5767
- }
5768
- });
5769
- }
5770
- closeEditor() {
5771
- this.$el.remove();
5772
- }
5773
- }
5774
- class PageList extends Component {
5775
- constructor(ctx) {
5776
- super(ctx);
5777
- __publicField(this, "$editor");
5778
- __publicField(this, "$inputer");
5779
- __publicField(this, "pages", []);
5780
- this.$el = createElement(`<div class="atk-page-list"></div>`);
5781
- }
5782
- clearAll() {
5783
- this.pages = [];
5784
- this.$el.innerHTML = "";
5785
- }
5786
- importPages(pages) {
5787
- this.pages.push(...pages);
5788
- pages.forEach((page) => {
5789
- const $page = this.renderPage(page);
5790
- this.$el.append($page);
5791
- });
5792
- }
5793
- renderPage(page) {
5794
- const $page = createElement(`<div class="atk-page-item">
5795
- <div class="atk-page-main">
5796
- <div class="atk-title"></div>
5797
- <div class="atk-sub"></div>
5798
- </div>
5799
- <div class="atk-page-actions">
5800
- <div class="atk-item atk-edit-btn">
5801
- <i class="atk-icon atk-icon-edit"></i>
5802
- </div>
5803
- </div>
5804
- </div>`);
5805
- const $main = $page.querySelector(".atk-page-main");
5806
- const $title = $main.querySelector(".atk-title");
5807
- const $sub = $main.querySelector(".atk-sub");
5808
- const $editBtn = $page.querySelector(".atk-edit-btn");
5809
- $title.innerText = page.title;
5810
- $sub.innerText = page.url || page.key;
5811
- $editBtn.onclick = () => this.showEditor(page, $page);
5812
- return $page;
5813
- }
5814
- showEditor(page, $page) {
5815
- this.closeEditor();
5816
- this.$editor = createElement(`<div class="atk-page-edit-layer">
5817
- <div class="atk-page-main-actions">
5818
- <div class="atk-item atk-title-edit-btn">\u6807\u9898\u4FEE\u6539</div>
5819
- <div class="atk-item atk-key-edit-btn">KEY \u53D8\u66F4</div>
5820
- <div class="atk-item atk-admin-only-btn"></div>
5821
- </div>
5822
- <div class="atk-page-actions">
5823
- <div class="atk-item atk-sync-btn">
5824
- <i class="atk-icon atk-icon-sync"></i>
5825
- </div>
5826
- <div class="atk-item atk-del-btn">
5827
- <i class="atk-icon atk-icon-del"></i>
5828
- </div>
5829
- <div class="atk-item atk-close-btn">
5830
- <i class="atk-icon atk-icon-close"></i>
5831
- </div>
5832
- </div>
5833
- </div>`);
5834
- $page.prepend(this.$editor);
5835
- const $titleEditBtn = this.$editor.querySelector(".atk-title-edit-btn");
5836
- const $keyEditBtn = this.$editor.querySelector(".atk-key-edit-btn");
5837
- const $adminOnlyBtn = this.$editor.querySelector(".atk-admin-only-btn");
5838
- const $syncBtn = this.$editor.querySelector(".atk-sync-btn");
5839
- const $delBtn = this.$editor.querySelector(".atk-del-btn");
5840
- const $closeBtn = this.$editor.querySelector(".atk-close-btn");
5841
- const showLoading$1 = () => {
5842
- showLoading(this.$editor);
5843
- };
5844
- const hideLoading$1 = () => {
5845
- hideLoading(this.$editor);
5846
- };
5847
- const showError = (msg) => {
5848
- window.alert(msg);
5849
- };
5850
- $closeBtn.onclick = () => this.closeEditor();
5851
- const openTextEditor = (key) => {
5852
- const textEditor = new ItemTextEditor({
5853
- initValue: page[key] || "",
5854
- onYes: (val) => __async(this, null, function* () {
5855
- showLoading(textEditor.$el);
5856
- let p;
5857
- try {
5858
- p = yield new Api(this.ctx).pageEdit(__spreadProps(__spreadValues({}, page), { [key]: val }));
5859
- } catch (err) {
5860
- showError(`\u4FEE\u6539\u5931\u8D25\uFF1A${err.msg || "\u672A\u77E5\u9519\u8BEF"}`);
5861
- console.error(err);
5862
- return false;
5863
- } finally {
5864
- hideLoading(textEditor.$el);
5865
- }
5866
- $page.replaceWith(this.renderPage(p));
5867
- return true;
5868
- })
5869
- });
5870
- textEditor.appendTo(this.$editor);
5871
- };
5872
- $titleEditBtn.onclick = () => openTextEditor("title");
5873
- $keyEditBtn.onclick = () => openTextEditor("key");
5874
- const adminOnlyActionBtn = new ActionBtn({
5875
- text: () => {
5876
- $adminOnlyBtn.classList.remove("atk-green", "atk-yellow");
5877
- $adminOnlyBtn.classList.add(!page.admin_only ? "atk-green" : "atk-yellow");
5878
- return !page.admin_only ? "\u6240\u6709\u4EBA\u53EF\u8BC4" : "\u7BA1\u7406\u5458\u53EF\u8BC4";
5879
- }
5880
- }).appendTo($adminOnlyBtn);
5881
- $adminOnlyBtn.onclick = () => __async(this, null, function* () {
5882
- showLoading$1();
5883
- let p;
5884
- try {
5885
- p = yield new Api(this.ctx).pageEdit(__spreadProps(__spreadValues({}, page), { admin_only: !page.admin_only }));
5886
- } catch (err) {
5887
- showError(`\u4FEE\u6539\u5931\u8D25\uFF1A${err.msg || "\u672A\u77E5\u9519\u8BEF"}`);
5888
- console.log(err);
5889
- return;
5890
- } finally {
5891
- hideLoading$1();
5892
- }
5893
- page.admin_only = p.admin_only;
5894
- adminOnlyActionBtn.updateText();
5895
- });
5896
- $syncBtn.onclick = () => __async(this, null, function* () {
5897
- showLoading$1();
5898
- let p;
5899
- try {
5900
- p = yield new Api(this.ctx).pageFetch(page.id);
5901
- } catch (err) {
5902
- showError(`\u540C\u6B65\u5931\u8D25\uFF1A${err.msg || "\u672A\u77E5\u9519\u8BEF"}`);
5903
- console.log(err);
5904
- return;
5905
- } finally {
5906
- hideLoading$1();
5907
- }
5908
- $page.replaceWith(this.renderPage(p));
5909
- });
5910
- $delBtn.onclick = () => {
5911
- const del = () => __async(this, null, function* () {
5912
- showLoading$1();
5913
- try {
5914
- yield new Api(this.ctx).pageDel(page.key, page.site_name);
5915
- } catch (err) {
5916
- console.log(err);
5917
- showError(`\u5220\u9664\u5931\u8D25 ${String(err)}`);
5918
- return;
5919
- } finally {
5920
- hideLoading$1();
5921
- }
5922
- $page.remove();
5923
- });
5924
- if (window.confirm(`\u786E\u8BA4\u5220\u9664\u9875\u9762 "${page.title || page.key}"\uFF1F\u5C06\u4F1A\u5220\u9664\u6240\u6709\u76F8\u5173\u6570\u636E`))
5925
- del();
5926
- };
5927
- }
5928
- closeEditor() {
5929
- if (!this.$editor)
5930
- return;
5931
- this.$editor.remove();
5932
- }
5933
- }
5934
- const PAGE_SIZE = 20;
5935
- class PagesView extends SidebarView {
5936
- constructor() {
5937
- super(...arguments);
5938
- __publicField(this, "viewTabs", {});
5939
- __publicField(this, "viewActiveTab", "");
5940
- __publicField(this, "pageList");
5941
- __publicField(this, "pagination");
5942
- }
5943
- mount(siteName) {
5944
- if (!this.pageList) {
5945
- this.pageList = new PageList(this.ctx);
5946
- this.$el.append(this.pageList.$el);
5947
- }
5948
- this.switchTab(this.viewActiveTab, siteName);
5949
- }
5950
- switchTab(tab, siteName) {
5951
- this.reqPages(siteName, 0);
5952
- }
5953
- reqPages(siteName, offset) {
5954
- return __async(this, null, function* () {
5955
- var _a;
5956
- this.pageList.clearAll();
5957
- (_a = this.$el.parentNode) == null ? void 0 : _a.scrollTo(0, 0);
5958
- showLoading(this.$el);
5959
- const data = yield new Api(this.ctx).pageGet(siteName, offset, PAGE_SIZE);
5960
- this.pageList.importPages(data.pages || []);
5961
- hideLoading(this.$el);
5962
- if (!this.pagination) {
5963
- this.pagination = new Pagination(data.total, {
5964
- pageSize: PAGE_SIZE,
5965
- onChange: (o) => {
5966
- this.reqPages(siteName, o);
5967
- }
5968
- });
5969
- this.$el.append(this.pagination.$el);
5970
- }
5971
- if (this.pagination && offset === 0)
5972
- this.pagination.update(offset, data.total);
5973
- });
5974
- }
5975
- }
5976
- __publicField(PagesView, "viewName", "pages");
5977
- __publicField(PagesView, "viewTitle", "\u9875\u9762");
5978
- __publicField(PagesView, "viewAdminOnly", true);
5979
- var siteList = "";
5980
- class SiteList extends Component {
5981
- constructor(ctx) {
5982
- super(ctx);
5983
- __publicField(this, "sites", []);
5984
- __publicField(this, "$header");
5985
- __publicField(this, "$headerTitle");
5986
- __publicField(this, "$headerActions");
5987
- __publicField(this, "$rowsWrap");
5988
- __publicField(this, "$editor");
5989
- __publicField(this, "activeSite", "");
5990
- __publicField(this, "$add");
5991
- this.$el = createElement(`<div class="atk-site-list">
5992
- <div class="atk-header">
5993
- <div class="atk-title"></div>
5994
- <div class="atk-actions">
5995
- <div class="atk-item atk-site-add-btn"><i class="atk-icon atk-icon-plus"></i></div>
5996
- </div>
5997
- </div>
5998
- <div class="atk-site-rows-wrap"></div>
5999
- </div>`);
6000
- this.$header = this.$el.querySelector(".atk-header");
6001
- this.$headerTitle = this.$header.querySelector(".atk-title");
6002
- this.$headerActions = this.$header.querySelector(".atk-actions");
6003
- this.$rowsWrap = this.$el.querySelector(".atk-site-rows-wrap");
6004
- this.$headerTitle.innerText = `\u5171 0 \u4E2A\u7AD9\u70B9`;
6005
- const $addBtn = this.$headerActions.querySelector(".atk-site-add-btn");
6006
- $addBtn.onclick = () => {
6007
- this.closeEditor();
6008
- this.showAdd();
6009
- };
6010
- }
6011
- loadSites(sites) {
6012
- this.sites = sites;
6013
- this.activeSite = "";
6014
- this.$rowsWrap.innerHTML = "";
6015
- this.$headerTitle.innerText = `\u5171 0 \u4E2A\u7AD9\u70B9`;
6016
- let $row;
6017
- for (let i = 0; i < sites.length; i++) {
6018
- const site = sites[i];
6019
- if (i % 4 === 0) {
6020
- $row = createElement('<div class="atk-site-row">');
6021
- this.$rowsWrap.append($row);
6022
- }
6023
- const $site = this.renderSite(site, $row);
6024
- $row.append($site);
6025
- }
6026
- this.$headerTitle.innerText = `\u5171 ${sites.length} \u4E2A\u7AD9\u70B9`;
6027
- }
6028
- renderSite(site, $row) {
6029
- const $site = createElement(`<div class="atk-site-item">
6030
- <div class="atk-site-logo"></div>
6031
- <div class="atk-site-name"></div>
6032
- </div>`);
6033
- const $siteLogo = $site.querySelector(".atk-site-logo");
6034
- const $siteName = $site.querySelector(".atk-site-name");
6035
- const setActive = () => {
6036
- $site.classList.add("atk-active");
6037
- };
6038
- $siteLogo.innerText = site.name.substr(0, 1);
6039
- $siteName.innerText = site.name;
6040
- $site.onclick = () => {
6041
- this.closeEditor();
6042
- this.closeAdd();
6043
- setActive();
6044
- this.showEditor(site, $site, $row);
6045
- };
6046
- if (this.activeSite === site.name) {
6047
- setActive();
6048
- }
6049
- return $site;
6050
- }
6051
- showEditor(site, $site, $row) {
6052
- this.activeSite = site.name;
6053
- this.$editor = createElement(`
6054
- <div class="atk-site-edit">
6055
- <div class="atk-header">
6056
- <div class="atk-site-info">
6057
- <span class="atk-site-name"></span>
6058
- <span class="atk-site-urls"></span>
6059
- </div>
6060
- <div class="atk-close-btn">
6061
- <i class="atk-icon atk-icon-close"></i>
6062
- </div>
6063
- </div>
6064
- <div class="atk-main">
6065
- <div class="atk-site-text-actions">
6066
- <div class="atk-item atk-rename-btn">\u91CD\u547D\u540D</div>
6067
- <div class="atk-item atk-edit-url-btn">\u4FEE\u6539 URL</div>
6068
- <!--<div class="atk-item atk-export-btn">\u5BFC\u51FA</div>
6069
- <div class="atk-item atk-import-btn">\u5BFC\u5165</div>-->
6070
- </div>
6071
- <div class="atk-site-btn-actions">
6072
- <div class="atk-item atk-del-btn">
6073
- <i class="atk-icon atk-icon-del"></i>
6074
- </div>
6075
- </div>
6076
- </div>
6077
- </div>`);
6078
- $row.before(this.$editor);
6079
- const $siteName = this.$editor.querySelector(".atk-site-name");
6080
- const $siteUrls = this.$editor.querySelector(".atk-site-urls");
6081
- const $closeBtn = this.$editor.querySelector(".atk-close-btn");
6082
- $closeBtn.onclick = () => this.closeEditor();
6083
- const update = (s) => {
6084
- var _a;
6085
- site = s;
6086
- $siteName.innerText = site.name;
6087
- $siteName.onclick = () => {
6088
- if (site.first_url)
6089
- window.open(site.first_url);
6090
- };
6091
- $siteUrls.innerHTML = "";
6092
- (_a = site.urls) == null ? void 0 : _a.forEach((u) => {
6093
- const $item = createElement('<span class="atk-url-item"></span>');
6094
- $siteUrls.append($item);
6095
- $item.innerText = (u || "").replace(/\/$/, "");
6096
- $item.onclick = () => {
6097
- window.open(u);
6098
- };
6099
- });
6100
- };
6101
- update(site);
6102
- const $main = this.$editor.querySelector(".atk-main");
6103
- const $actions = this.$editor.querySelector(".atk-site-text-actions");
6104
- const $renameBtn = $actions.querySelector(".atk-rename-btn");
6105
- const $editUrlBtn = $actions.querySelector(".atk-edit-url-btn");
6106
- const $delBtn = this.$editor.querySelector(".atk-del-btn");
6107
- const showLoading$1 = () => {
6108
- showLoading(this.$editor);
6109
- };
6110
- const hideLoading$1 = () => {
6111
- hideLoading(this.$editor);
6112
- };
6113
- const showError = (msg) => {
6114
- window.alert(msg);
6115
- };
6116
- const openTextEditor = (key) => {
6117
- let initValue = site[key] || "";
6118
- if (key === "urls")
6119
- initValue = site.urls_raw || "";
6120
- const textEditor = new ItemTextEditor({
6121
- initValue,
6122
- onYes: (val) => __async(this, null, function* () {
6123
- showLoading(textEditor.$el);
6124
- let s;
6125
- try {
6126
- s = yield new Api(this.ctx).siteEdit(__spreadProps(__spreadValues({}, site), { [key]: val }));
6127
- } catch (err) {
6128
- showError(`\u4FEE\u6539\u5931\u8D25\uFF1A${err.msg || "\u672A\u77E5\u9519\u8BEF"}`);
6129
- console.error(err);
6130
- return false;
6131
- } finally {
6132
- hideLoading(textEditor.$el);
6133
- }
6134
- $site.replaceWith(this.renderSite(s, $row));
6135
- update(s);
6136
- return true;
6137
- })
6138
- });
6139
- textEditor.appendTo($main);
6140
- };
6141
- $renameBtn.onclick = () => openTextEditor("name");
6142
- $editUrlBtn.onclick = () => openTextEditor("urls");
6143
- $delBtn.onclick = () => {
6144
- const del = () => __async(this, null, function* () {
6145
- showLoading$1();
6146
- try {
6147
- yield new Api(this.ctx).siteDel(site.id, true);
6148
- } catch (err) {
6149
- console.log(err);
6150
- showError(`\u5220\u9664\u5931\u8D25 ${String(err)}`);
6151
- return;
6152
- } finally {
6153
- hideLoading$1();
6154
- }
6155
- this.closeEditor();
6156
- $site.remove();
6157
- this.sites = this.sites.filter((s) => s.name !== site.name);
6158
- });
6159
- if (window.confirm(`\u786E\u8BA4\u5220\u9664\u7AD9\u70B9 "${site.name}"\uFF1F\u5C06\u4F1A\u5220\u9664\u6240\u6709\u76F8\u5173\u6570\u636E`))
6160
- del();
6161
- };
6162
- }
6163
- closeEditor() {
6164
- if (!this.$editor)
6165
- return;
6166
- this.$editor.remove();
6167
- this.$rowsWrap.querySelectorAll(".atk-site-item").forEach((e) => e.classList.remove("atk-active"));
6168
- this.activeSite = "";
6169
- }
6170
- showAdd() {
6171
- this.closeAdd();
6172
- this.$add = createElement(`
6173
- <div class="atk-site-add">
6174
- <div class="atk-header">
6175
- <div class="atk-title">\u65B0\u589E\u7AD9\u70B9</div>
6176
- <div class="atk-close-btn">
6177
- <i class="atk-icon atk-icon-close"></i>
6178
- </div>
6179
- </div>
6180
- <div class="atk-form">
6181
- <input type="text" name="AtkSiteName" placeholder="\u7AD9\u70B9\u540D\u79F0" autocomplete="off">
6182
- <input type="text" name="AtkSiteUrls" placeholder="\u7AD9\u70B9 URL\uFF08\u591A\u4E2A\u7528\u9017\u53F7\u9694\u5F00\uFF09" autocomplete="off">
6183
- <button class="atk-btn" name="AtkSubmit">\u521B\u5EFA</button>
6184
- </div>
6185
- </div>`);
6186
- this.$header.after(this.$add);
6187
- const $closeBtn = this.$add.querySelector(".atk-close-btn");
6188
- $closeBtn.onclick = () => this.closeAdd();
6189
- const $siteName = this.$add.querySelector('[name="AtkSiteName"]');
6190
- const $siteUrls = this.$add.querySelector('[name="AtkSiteUrls"]');
6191
- const $submitBtn = this.$add.querySelector('[name="AtkSubmit"]');
6192
- $submitBtn.onclick = () => __async(this, null, function* () {
6193
- const siteName = $siteName.value.trim();
6194
- const siteUrls = $siteUrls.value.trim();
6195
- if (siteName === "") {
6196
- $siteName.focus();
6197
- return;
6198
- }
6199
- showLoading(this.$add);
6200
- let s;
6201
- try {
6202
- s = yield new Api(this.ctx).siteAdd(siteName, siteUrls);
6203
- } catch (err) {
6204
- window.alert(`\u521B\u5EFA\u5931\u8D25\uFF1A${err.msg || ""}`);
6205
- console.error(err);
6206
- return;
6207
- } finally {
6208
- hideLoading(this.$add);
6209
- }
6210
- this.sites.push(s);
6211
- this.loadSites(this.sites);
6212
- this.closeAdd();
6213
- });
6214
- const keyDown = (evt) => {
6215
- if (evt.key === "Enter") {
6216
- $submitBtn.click();
6217
- }
6218
- };
6219
- $siteName.onkeyup = (evt) => keyDown(evt);
6220
- $siteUrls.onkeyup = (evt) => keyDown(evt);
6221
- }
6222
- closeAdd() {
6223
- var _a;
6224
- (_a = this.$add) == null ? void 0 : _a.remove();
6225
- }
6226
- }
6227
- class SitesView extends SidebarView {
6228
- constructor() {
6229
- super(...arguments);
6230
- __publicField(this, "viewTabs", {});
6231
- __publicField(this, "viewActiveTab", "");
6232
- __publicField(this, "siteList");
6233
- }
6234
- mount(siteName) {
6235
- if (!this.siteList) {
6236
- this.siteList = new SiteList(this.ctx);
6237
- this.$el.append(this.siteList.$el);
6238
- }
6239
- this.reqSites();
6240
- }
6241
- switchTab(tab, siteName) {
6242
- this.reqSites();
6243
- }
6244
- reqSites() {
6245
- return __async(this, null, function* () {
6246
- const sites = yield new Api(this.ctx).siteGet();
6247
- this.siteList.loadSites(sites);
6248
- });
6249
- }
6250
- }
6251
- __publicField(SitesView, "viewName", "sites");
6252
- __publicField(SitesView, "viewTitle", "\u7AD9\u70B9");
6253
- __publicField(SitesView, "viewAdminOnly", true);
6254
- class TransferView extends SidebarView {
6255
- constructor() {
6256
- super(...arguments);
6257
- __publicField(this, "\xDF");
6258
- __publicField(this, "viewTabs", {
6259
- "import": "\u5BFC\u5165",
6260
- "export": "\u5BFC\u51FA"
6261
- });
6262
- __publicField(this, "viewActiveTab", "import");
6263
- }
6264
- mount(siteName) {
6265
- this.switchTab("import", siteName);
6266
- }
6267
- switchTab(tab, siteName) {
6268
- if (tab === "import") {
6269
- this.initImport();
6270
- } else if (tab === "export") {
6271
- this.initExport();
6272
- return false;
6273
- }
6274
- return true;
6275
- }
6276
- initImport() {
6277
- this.$el.innerHTML = `<div class="atk-log-wrap" style="display: none;">
6278
- <div class="atk-log-back-btn">\u8FD4\u56DE</div>
6279
- <div class="atk-log"></div>
6280
- </div>
6281
- <div class="atk-form">
6282
- <div class="atk-label">\u6570\u636E\u7C7B\u578B</div>
6283
- <select name="AtkDataType">
6284
- <option value="artrans">Artrans (\u6570\u636E\u884C\u56CA)</option>
6285
- <option value="artalk_v1">Artalk v1 (PHP \u65E7\u7248)</option>
6286
- <option value="typecho">Typecho</option>
6287
- <option value="wordpress">WordPress</option>
6288
- <option value="disqus">Disqus</option>
6289
- <option value="commento">Commento</option>
6290
- <option value="valine">Valine</option>
6291
- <option value="twikoo">Twikoo</option>
6292
- </select>
6293
- <div class="atk-label atk-data-file-label">\u6570\u636E\u6587\u4EF6</div>
6294
- <input type="file" name="AtkDataFile" accept="text/plain,.json">
6295
- <div class="atk-label">\u76EE\u6807\u7AD9\u70B9\u540D</div>
6296
- <input type="text" name="AtkSiteName" placeholder="\u8F93\u5165\u5185\u5BB9..." autocomplete="off">
6297
- <div class="atk-label">\u76EE\u6807\u7AD9\u70B9 URL</div>
6298
- <input type="text" name="AtkSiteURL" placeholder="\u8F93\u5165\u5185\u5BB9..." autocomplete="off">
6299
- <div class="atk-label">\u542F\u52A8\u53C2\u6570\uFF08\u53EF\u9009\uFF09</div>
6300
- <textarea name="AtkPayload"></textarea>
6301
- <span class="atk-desc">\u542F\u52A8\u53C2\u6570\u67E5\u9605\uFF1A\u201C<a href="https://artalk.js.org/guide/transfer.html" target="_blank">\u6587\u6863 \xB7 \u6570\u636E\u642C\u5BB6</a>\u201D</span>
6302
- <button class="atk-btn" name="AtkSubmit">\u5BFC\u5165</button>
6303
- </div>`;
6304
- const $form = this.$el.querySelector(".atk-form");
6305
- const $dataType = $form.querySelector('[name="AtkDataType"]');
6306
- const $dataFile = $form.querySelector('[name="AtkDataFile"]');
6307
- const $dataFileLabel = $form.querySelector(".atk-data-file-label");
6308
- const $siteName = $form.querySelector('[name="AtkSiteName"]');
6309
- const $siteURL = $form.querySelector('[name="AtkSiteURL"]');
6310
- const $payload = $form.querySelector('[name="AtkPayload"]');
6311
- const $submitBtn = $form.querySelector('[name="AtkSubmit"]');
6312
- const setError2 = (msg) => window.alert(msg);
6313
- $dataType.onchange = () => {
6314
- if (["typecho"].includes($dataType.value)) {
6315
- $dataFile.style.display = "none";
6316
- $dataFileLabel.style.display = "none";
6317
- } else {
6318
- $dataFile.style.display = "";
6319
- $dataFileLabel.style.display = "";
6320
- }
6321
- };
6322
- $submitBtn.onclick = () => {
6323
- var _a;
6324
- const dataType = $dataType.value.trim();
6325
- const siteName = $siteName.value.trim();
6326
- const siteURL = $siteURL.value.trim();
6327
- const payload = $payload.value.trim();
6328
- if (dataType === "") {
6329
- setError2("\u8BF7\u9009\u62E9\u6570\u636E\u7C7B\u578B");
6330
- return;
6331
- }
6332
- let rData = {};
6333
- if (payload) {
6334
- try {
6335
- rData = JSON.parse(payload);
6336
- } catch (err) {
6337
- setError2(`Payload JSON \u683C\u5F0F\u6709\u8BEF\uFF1A${String(err)}`);
6338
- return;
6339
- }
6340
- if (rData instanceof Object) {
6341
- setError2(`Payload \u9700\u4E3A JSON \u5BF9\u8C61`);
6342
- return;
6343
- }
6344
- }
6345
- if (siteName)
6346
- rData.t_name = siteName;
6347
- if (siteURL)
6348
- rData.t_url = siteURL;
6349
- const createSession = (dataStr) => {
6350
- const $logWrap = this.$el.querySelector(".atk-log-wrap");
6351
- const $log = $logWrap.querySelector(".atk-log");
6352
- const $backBtn = this.$el.querySelector(".atk-log-back-btn");
6353
- $logWrap.style.display = "";
6354
- $form.style.display = "none";
6355
- $backBtn.onclick = () => {
6356
- $logWrap.style.display = "none";
6357
- $form.style.display = "";
6358
- };
6359
- if (dataStr)
6360
- rData.json_data = dataStr;
6361
- const frameName = `f_${+new Date()}`;
6362
- const $frame = document.createElement("iframe");
6363
- $frame.className = "atk-iframe";
6364
- $frame.name = frameName;
6365
- $log.innerHTML = "";
6366
- $log.append($frame);
6367
- const formParams = {
6368
- type: dataType,
6369
- payload: JSON.stringify(rData),
6370
- token: this.ctx.user.data.token || ""
6371
- };
6372
- const $formTmp = document.createElement("form");
6373
- $formTmp.style.display = "none";
6374
- $formTmp.setAttribute("method", "post");
6375
- $formTmp.setAttribute("action", `${this.ctx.conf.server}/admin/import`);
6376
- $formTmp.setAttribute("target", frameName);
6377
- Object.entries(formParams).forEach(([key, val]) => {
6378
- const $inputTmp = document.createElement("input");
6379
- $inputTmp.setAttribute("type", "hidden");
6380
- $inputTmp.setAttribute("name", key);
6381
- $inputTmp.value = val;
6382
- $formTmp.appendChild($inputTmp);
6383
- });
6384
- $logWrap.append($formTmp);
6385
- $formTmp.submit();
6386
- $formTmp.remove();
6387
- };
6388
- const reader = new FileReader();
6389
- reader.onload = () => {
6390
- const data = String(reader.result);
6391
- createSession(data);
6392
- };
6393
- if ((_a = $dataFile.files) == null ? void 0 : _a.length) {
6394
- reader.readAsText($dataFile.files[0]);
6395
- } else {
6396
- createSession();
6397
- }
6398
- };
6399
- }
6400
- initExport() {
6401
- return __async(this, null, function* () {
6402
- showLoading(this.$el);
6403
- try {
6404
- const d = yield new Api(this.ctx).export();
6405
- this.download(`artrans-${this.getYmdHisFilename()}.json`, d);
6406
- } catch (err) {
6407
- console.log(err);
6408
- window.alert(`${String(err)}`);
6409
- return;
6410
- } finally {
6411
- hideLoading(this.$el);
6412
- }
6413
- });
6414
- }
6415
- download(filename, text) {
6416
- const el = document.createElement("a");
6417
- el.setAttribute("href", `data:text/json;charset=utf-8,${encodeURIComponent(text)}`);
6418
- el.setAttribute("download", filename);
6419
- el.style.display = "none";
6420
- document.body.appendChild(el);
6421
- el.click();
6422
- document.body.removeChild(el);
6423
- }
6424
- getYmdHisFilename() {
6425
- const date = new Date();
6426
- const year = date.getFullYear();
6427
- const month = date.getMonth() + 1;
6428
- const day = date.getDate();
6429
- const hours = date.getHours();
6430
- const minutes = date.getMinutes();
6431
- const seconds = date.getSeconds();
6432
- return `${year}${month}${day}-${hours}${padWithZeros(minutes, 2)}${padWithZeros(seconds, 2)}`;
6433
- }
6434
- }
6435
- __publicField(TransferView, "viewName", "transfer");
6436
- __publicField(TransferView, "viewTitle", "\u8FC1\u79FB");
6437
- __publicField(TransferView, "viewAdminOnly", true);
6438
- class SiteListFloater {
6439
- constructor(ctx, conf) {
6440
- __publicField(this, "ctx");
6441
- __publicField(this, "conf");
6442
- __publicField(this, "$el");
6443
- __publicField(this, "sites", []);
6444
- __publicField(this, "$sites");
6445
- __publicField(this, "outsideChecker");
6446
- this.ctx = ctx;
6447
- this.conf = conf;
6448
- this.$el = createElement(`<div class="atk-site-list-floater" style="display: none;">
6449
- <div class="atk-sites"></div>
6450
- </div>`);
6451
- this.$sites = this.$el.querySelector(".atk-sites");
6452
- }
6453
- load(selectedSite) {
6454
- return __async(this, null, function* () {
6455
- this.$sites.innerHTML = "";
6456
- const renderSiteItem = (siteName, siteLogo, siteTarget, onclick) => {
6457
- const $site = createElement(`<div class="atk-site-item">
6458
- <div class="atk-site-logo"></div>
6459
- <div class="atk-site-name"></div>
6460
- </div>`);
6461
- $site.onclick = !onclick ? () => this.switch(siteTarget || siteName) : () => onclick();
6462
- $site.setAttribute("data-name", siteTarget || siteName);
6463
- const $siteLogo = $site.querySelector(".atk-site-logo");
6464
- const $siteName = $site.querySelector(".atk-site-name");
6465
- $siteLogo.innerText = siteLogo;
6466
- $siteName.innerText = siteName;
6467
- if (selectedSite === (siteTarget || siteName))
6468
- $site.classList.add("atk-active");
6469
- this.$sites.append($site);
6470
- };
6471
- renderSiteItem("\u6240\u6709\u7AD9\u70B9", "_", "__ATK_SITE_ALL");
6472
- const sites = yield new Api(this.ctx).siteGet();
6473
- sites.forEach((site) => {
6474
- renderSiteItem(site.name, site.name.substr(0, 1));
6475
- });
6476
- renderSiteItem("\u7AD9\u70B9\u7BA1\u7406", "+", "", () => {
6477
- this.conf.onClickSitesViewBtn();
6478
- this.hide();
6479
- });
6480
- });
6481
- }
6482
- switch(siteName) {
6483
- if (this.conf.onSwitchSite(siteName) === false) {
6484
- return;
6485
- }
6486
- this.$sites.querySelectorAll(".atk-site-item").forEach((e) => {
6487
- if (e.getAttribute("data-name") !== siteName) {
6488
- e.classList.remove("atk-active");
6489
- } else {
6490
- e.classList.add("atk-active");
6491
- }
6492
- });
6493
- this.hide();
6494
- }
6495
- show($trigger) {
6496
- this.$el.style.display = "";
6497
- if ($trigger) {
6498
- this.outsideChecker = (evt) => {
6499
- const isClickInside = $trigger.contains(evt.target) || this.$el.contains(evt.target);
6500
- if (!isClickInside) {
6501
- this.hide();
6502
- }
6503
- };
6504
- document.addEventListener("click", this.outsideChecker);
6505
- }
6506
- }
6507
- hide() {
6508
- this.$el.style.display = "none";
6509
- if (this.outsideChecker)
6510
- document.removeEventListener("click", this.outsideChecker);
6511
- }
6512
- }
6513
- const DEFAULT_VIEW = "comments";
6514
- const REGISTER_VIEWS = [
6515
- MessageView,
6516
- PagesView,
6517
- SitesView,
6518
- TransferView
6519
- ];
6520
- class Sidebar extends Component {
5559
+ var sidebarLayer = "";
5560
+ var SidebarHTML = '<div class="atk-sidebar-layer">\n <div class="atk-sidebar-inner">\n <div class="atk-sidebar-header">\n <div class="atk-sidebar-close"><i class="atk-icon atk-icon-close"></i></div>\n </div>\n <div class="atk-sidebar-iframe-wrap"></div>\n </div>\n</div>\n';
5561
+ class SidebarLayer extends Component {
6521
5562
  constructor(ctx) {
6522
5563
  super(ctx);
6523
5564
  __publicField(this, "layer");
6524
5565
  __publicField(this, "$header");
6525
- __publicField(this, "$headerMenu");
6526
- __publicField(this, "$title");
6527
- __publicField(this, "$avatar");
6528
- __publicField(this, "$siteLogo");
6529
5566
  __publicField(this, "$closeBtn");
6530
- __publicField(this, "$nav");
6531
- __publicField(this, "$curtViewBtn");
6532
- __publicField(this, "$curtViewBtnIcon");
6533
- __publicField(this, "$curtViewBtnText");
6534
- __publicField(this, "$navTabs");
6535
- __publicField(this, "$navViews");
6536
- __publicField(this, "$viewWrap");
6537
- __publicField(this, "siteSwitcher");
6538
- __publicField(this, "curtSite");
6539
- __publicField(this, "curtView", DEFAULT_VIEW);
6540
- __publicField(this, "curtTab");
6541
- __publicField(this, "viewInstances", {});
6542
- __publicField(this, "viewSwitcherShow", false);
5567
+ __publicField(this, "$iframeWrap");
5568
+ __publicField(this, "$iframe");
6543
5569
  __publicField(this, "firstShow", true);
5570
+ __publicField(this, "loadingTimer", null);
6544
5571
  this.$el = createElement(SidebarHTML);
6545
5572
  this.$header = this.$el.querySelector(".atk-sidebar-header");
6546
- this.$headerMenu = this.$header.querySelector(".atk-menu");
6547
- this.$title = this.$header.querySelector(".atk-sidebar-title");
6548
- this.$avatar = this.$header.querySelector(".atk-avatar");
6549
5573
  this.$closeBtn = this.$header.querySelector(".atk-sidebar-close");
6550
- this.$nav = this.$el.querySelector(".atk-sidebar-nav");
6551
- this.$curtViewBtn = this.$nav.querySelector(".akt-curt-view-btn");
6552
- this.$curtViewBtnIcon = this.$curtViewBtn.querySelector(".atk-icon");
6553
- this.$curtViewBtnText = this.$curtViewBtn.querySelector(".atk-text");
6554
- this.$navTabs = this.$nav.querySelector(".atk-tabs");
6555
- this.$navViews = this.$nav.querySelector(".atk-views");
6556
- this.$viewWrap = this.$el.querySelector(".atk-sidebar-view-wrap");
6557
- this.initViewSwitcher();
5574
+ this.$iframeWrap = this.$el.querySelector(".atk-sidebar-iframe-wrap");
6558
5575
  this.$closeBtn.onclick = () => {
6559
5576
  this.hide();
6560
5577
  };
@@ -6564,111 +5581,36 @@ class Sidebar extends Component {
6564
5581
  this.firstShow = true;
6565
5582
  });
6566
5583
  }
6567
- get isAdmin() {
6568
- return this.ctx.user.data.isAdmin;
6569
- }
6570
- get curtViewInstance() {
6571
- return this.curtView ? this.viewInstances[this.curtView] : void 0;
6572
- }
6573
- initViewSwitcher() {
6574
- this.$curtViewBtn.onclick = () => {
6575
- this.toggleViewSwitcher();
6576
- };
6577
- this.$navViews.innerHTML = "";
6578
- REGISTER_VIEWS.forEach((view) => {
6579
- const $item = createElement(`<div class="atk-tab-item"></div>`);
6580
- this.$navViews.append($item);
6581
- $item.setAttribute("data-name", view.viewName);
6582
- $item.innerText = view.viewTitle;
6583
- if (view.viewName === this.curtView) {
6584
- $item.classList.add("atk-active");
6585
- this.$curtViewBtnText.innerText = view.viewTitle;
6586
- }
6587
- $item.onclick = () => {
6588
- this.switchView(view.viewName);
6589
- this.toggleViewSwitcher();
6590
- };
6591
- });
6592
- }
6593
- toggleViewSwitcher() {
6594
- if (!this.viewSwitcherShow) {
6595
- this.$navViews.style.display = "";
6596
- this.$navTabs.style.display = "none";
6597
- this.$curtViewBtnIcon.classList.add("atk-arrow");
6598
- } else {
6599
- this.$navViews.style.display = "none";
6600
- this.$navTabs.style.display = "";
6601
- this.$curtViewBtnIcon.classList.remove("atk-arrow");
6602
- }
6603
- this.viewSwitcherShow = !this.viewSwitcherShow;
6604
- }
6605
5584
  show() {
6606
5585
  return __async(this, null, function* () {
6607
5586
  this.$el.style.transform = "";
6608
- this.layer = new Layer(this.ctx, "sidebar", this.$el);
6609
- this.layer.afterHide = () => {
6610
- if (this.ctx.conf.editorTravel === true) {
6611
- this.ctx.trigger("editor-travel-back");
6612
- }
6613
- };
5587
+ if (this.layer == null) {
5588
+ this.layer = new Layer(this.ctx, "sidebar", this.$el);
5589
+ this.layer.afterHide = () => {
5590
+ if (this.ctx.conf.editorTravel === true) {
5591
+ this.ctx.trigger("editor-travel-back");
5592
+ }
5593
+ };
5594
+ }
6614
5595
  this.layer.show();
6615
- this.$viewWrap.scrollTo(0, 0);
6616
5596
  setTimeout(() => {
6617
5597
  this.$el.style.transform = "translate(0, 0)";
6618
5598
  }, 20);
6619
5599
  if (this.firstShow) {
6620
- if (this.isAdmin) {
6621
- this.$title.innerText = "\u63A7\u5236\u4E2D\u5FC3";
6622
- this.$curtViewBtn.style.display = "";
6623
- if (!this.siteSwitcher) {
6624
- this.siteSwitcher = new SiteListFloater(this.ctx, {
6625
- onSwitchSite: (siteName) => {
6626
- this.switchSite(siteName);
6627
- },
6628
- onClickSitesViewBtn: () => {
6629
- this.switchView("sites");
6630
- }
6631
- });
6632
- this.$viewWrap.before(this.siteSwitcher.$el);
6633
- this.$avatar.onclick = (evt) => {
6634
- var _a;
6635
- if (!this.isAdmin)
6636
- return;
6637
- (_a = this.siteSwitcher) == null ? void 0 : _a.show(evt.target);
6638
- };
6639
- }
6640
- this.curtSite = this.conf.site;
6641
- showLoading(this.$el);
6642
- try {
6643
- yield this.siteSwitcher.load(this.curtSite);
6644
- } catch (err) {
6645
- const $err = createElement(`<span>\u52A0\u8F7D\u5931\u8D25\uFF1A${err.msg || "\u7F51\u7EDC\u9519\u8BEF"}<br/></span>`);
6646
- const $retryBtn = createElement('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');
6647
- $err.appendChild($retryBtn);
6648
- $retryBtn.onclick = () => {
6649
- setError(this.$el, null);
6650
- this.show();
6651
- };
6652
- setError(this.$el, $err);
6653
- return;
6654
- } finally {
6655
- hideLoading(this.$el);
6656
- }
6657
- this.$avatar.innerHTML = "";
6658
- this.$siteLogo = createElement('<div class="atk-site-logo"></div>');
6659
- this.$siteLogo.innerText = (this.curtSite || "").substr(0, 1);
6660
- this.$avatar.append(this.$siteLogo);
6661
- } else {
6662
- this.$title.innerText = "\u901A\u77E5\u4E2D\u5FC3";
6663
- this.$curtViewBtn.style.display = "none";
6664
- this.curtSite = this.conf.site;
6665
- const $avatarImg = document.createElement("img");
6666
- $avatarImg.src = getGravatarURL(this.ctx, MD5(this.ctx.user.data.email.toLowerCase()));
6667
- this.$avatar.innerHTML = "";
6668
- this.$avatar.append($avatarImg);
6669
- }
6670
- this.switchView(DEFAULT_VIEW);
5600
+ this.$iframeWrap.innerHTML = "";
5601
+ this.$iframe = createElement("<iframe></iframe>");
5602
+ const baseURL = `${this.conf.server.replace(/\/$/, "")}/../sidebar/`;
5603
+ const userData = encodeURIComponent(JSON.stringify(this.ctx.user.data));
5604
+ this.iframeLoad(`${baseURL}?pageKey=${encodeURIComponent(this.conf.pageKey)}&site=${encodeURIComponent(this.conf.site || "")}&user=${userData}${this.conf.darkMode ? `&darkMode=1` : ``}`);
5605
+ this.$iframeWrap.append(this.$iframe);
6671
5606
  this.firstShow = false;
5607
+ } else {
5608
+ if (this.conf.darkMode && !this.$iframe.src.match(/darkMode=1$/)) {
5609
+ this.iframeLoad(`${this.$iframe.src}&darkMode=1`);
5610
+ }
5611
+ if (!this.conf.darkMode && this.$iframe.src.match(/darkMode=1$/)) {
5612
+ this.iframeLoad(this.$iframe.src.replace(/&darkMode=1$/, ""));
5613
+ }
6672
5614
  }
6673
5615
  });
6674
5616
  }
@@ -6677,58 +5619,39 @@ class Sidebar extends Component {
6677
5619
  this.$el.style.transform = "";
6678
5620
  (_a = this.layer) == null ? void 0 : _a.hide();
6679
5621
  }
6680
- switchView(viewName) {
6681
- let view = this.viewInstances[viewName];
6682
- if (!view) {
6683
- const View = REGISTER_VIEWS.find((o) => o.viewName === viewName);
6684
- view = new View(this.ctx, this.$viewWrap);
6685
- this.viewInstances[viewName] = view;
6686
- }
6687
- view.mount(this.curtSite);
6688
- this.curtView = viewName;
6689
- this.curtTab = view.viewActiveTab;
6690
- this.$curtViewBtnText.innerText = view.constructor.viewTitle;
6691
- this.$navViews.querySelectorAll(".atk-tab-item").forEach((e) => {
6692
- if (e.getAttribute("data-name") === viewName) {
6693
- e.classList.add("atk-active");
6694
- } else {
6695
- e.classList.remove("atk-active");
6696
- }
6697
- });
6698
- this.loadViewTabs(view);
6699
- this.$viewWrap.innerHTML = "";
6700
- this.$viewWrap.append(view.$el);
6701
- this.$viewWrap.classList.forEach((c) => {
6702
- if (c.startsWith("atk-view-name-"))
6703
- this.$viewWrap.classList.remove(c);
6704
- });
6705
- this.$viewWrap.classList.add(`atk-view-name-${view.constructor.viewName}`);
6706
- }
6707
- loadViewTabs(view) {
6708
- this.$navTabs.innerHTML = "";
6709
- Object.entries(view.viewTabs).forEach(([tabName, label]) => {
6710
- const $tab = createElement(`<div class="atk-tab-item"></div>`);
6711
- this.$navTabs.append($tab);
6712
- $tab.innerText = label;
6713
- if (view.viewActiveTab === tabName)
6714
- $tab.classList.add("atk-active");
6715
- $tab.onclick = () => {
6716
- if (view.switchTab(tabName, this.curtSite) === false) {
6717
- return;
5622
+ iframeLoad(src) {
5623
+ if (!this.$iframe)
5624
+ return;
5625
+ this.$iframe.src = src;
5626
+ showLoading(this.$iframeWrap);
5627
+ this.$iframe.onload = () => {
5628
+ hideLoading(this.$iframeWrap);
5629
+ };
5630
+ }
5631
+ checkReqStatus(url) {
5632
+ return __async(this, null, function* () {
5633
+ if (this.loadingTimer !== null)
5634
+ window.clearTimeout(this.loadingTimer);
5635
+ this.loadingTimer = window.setTimeout(() => __async(this, null, function* () {
5636
+ try {
5637
+ yield fetch(url);
5638
+ } catch (err) {
5639
+ console.log(err);
5640
+ const $errAlert = createElement(`<div class="atk-err-alert"> <div class="atk-title">\u4FA7\u8FB9\u680F\u4F3C\u4E4E\u6253\u5F00\u5931\u8D25</div> <div class="atk-text"><span id="AtkReload">\u91CD\u65B0\u52A0\u8F7D</span> / <span id="AtkCancel">\u53D6\u6D88</span></div></div>`);
5641
+ const $reloadBtn = $errAlert.querySelector("#AtkReload");
5642
+ const $cancelBtn = $errAlert.querySelector("#AtkCancel");
5643
+ $reloadBtn.onclick = () => {
5644
+ this.iframeLoad(url);
5645
+ $errAlert.remove();
5646
+ };
5647
+ $cancelBtn.onclick = () => {
5648
+ $errAlert.remove();
5649
+ };
5650
+ this.$iframeWrap.append($errAlert);
6718
5651
  }
6719
- this.$navTabs.querySelectorAll(".atk-active").forEach((e) => e.classList.remove("atk-active"));
6720
- $tab.classList.add("atk-active");
6721
- this.curtTab = tabName;
6722
- };
5652
+ }), 2e3);
6723
5653
  });
6724
5654
  }
6725
- switchSite(siteName) {
6726
- this.curtSite = siteName;
6727
- const curtView = this.curtViewInstance;
6728
- curtView == null ? void 0 : curtView.switchTab(this.curtTab, siteName);
6729
- if (this.$siteLogo)
6730
- this.$siteLogo.innerText = this.curtSite.substr(0, 1);
6731
- }
6732
5655
  }
6733
5656
  const _Artalk = class {
6734
5657
  constructor(customConf) {
@@ -6738,7 +5661,7 @@ const _Artalk = class {
6738
5661
  __publicField(this, "checkerLauncher");
6739
5662
  __publicField(this, "editor");
6740
5663
  __publicField(this, "list");
6741
- __publicField(this, "sidebar");
5664
+ __publicField(this, "sidebarLayer");
6742
5665
  this.conf = __spreadValues(__spreadValues({}, _Artalk.defaults), customConf);
6743
5666
  this.conf.server = this.conf.server.replace(/\/$/, "");
6744
5667
  if (!this.conf.pageKey) {
@@ -6762,10 +5685,11 @@ const _Artalk = class {
6762
5685
  this.$root.appendChild(this.editor.$el);
6763
5686
  this.list = new List(this.ctx);
6764
5687
  this.$root.appendChild(this.list.$el);
6765
- this.sidebar = new Sidebar(this.ctx);
6766
- this.$root.appendChild(this.sidebar.$el);
6767
- this.list.reqComments();
5688
+ this.sidebarLayer = new SidebarLayer(this.ctx);
5689
+ this.$root.appendChild(this.sidebarLayer.$el);
5690
+ this.list.fetchComments(0);
6768
5691
  this.initEventBind();
5692
+ this.initPV();
6769
5693
  }
6770
5694
  initEventBind() {
6771
5695
  window.addEventListener("hashchange", () => {
@@ -6777,6 +5701,9 @@ const _Artalk = class {
6777
5701
  const { $wrap: $layerWrap } = GetLayerWrap(this.ctx);
6778
5702
  if ($layerWrap)
6779
5703
  $layerWrap.querySelectorAll(`[atk-only-admin-show]`).forEach((item) => items.push(item));
5704
+ const $sidebarEl = document.querySelector(".atk-sidebar");
5705
+ if ($sidebarEl)
5706
+ $sidebarEl.querySelectorAll(`[atk-only-admin-show]`).forEach((item) => items.push(item));
6780
5707
  items.forEach(($item) => {
6781
5708
  if (this.ctx.user.data.isAdmin)
6782
5709
  $item.classList.remove("atk-hide");
@@ -6790,7 +5717,7 @@ const _Artalk = class {
6790
5717
  });
6791
5718
  }
6792
5719
  reload() {
6793
- this.list.reqComments();
5720
+ this.list.fetchComments(0);
6794
5721
  }
6795
5722
  initDarkMode() {
6796
5723
  const darkModeClassName = "atk-dark-mode";
@@ -6812,6 +5739,17 @@ const _Artalk = class {
6812
5739
  this.ctx.conf.darkMode = darkMode;
6813
5740
  this.initDarkMode();
6814
5741
  }
5742
+ initPV() {
5743
+ return __async(this, null, function* () {
5744
+ if (!this.conf.pvEl || !document.querySelector(this.conf.pvEl))
5745
+ return;
5746
+ const $pv = document.querySelector(this.conf.pvEl);
5747
+ const pvNum = yield new Api(this.ctx).pv();
5748
+ if (Number.isNaN(Number(pvNum)))
5749
+ return;
5750
+ $pv.innerText = String(pvNum);
5751
+ });
5752
+ }
6815
5753
  on(name, handler) {
6816
5754
  this.ctx.on(name, handler, "external");
6817
5755
  }