artalk 2.1.4 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CNAME +1 -0
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.es.js +303 -1248
- package/dist/Artalk.iife.js +1 -1
- package/dist/Artalk.js +1 -1
- package/index.html +143 -0
- package/package.json +8 -29
- package/postcss.config.js +5 -0
- package/src/api/index.ts +14 -0
- package/src/api/request.ts +4 -2
- package/src/artalk.ts +28 -6
- package/src/components/comment.ts +20 -3
- package/src/components/html/list.html +4 -2
- package/src/components/html/sidebar-layer.html +8 -0
- package/src/components/list.ts +60 -0
- package/src/components/sidebar-layer.ts +143 -0
- package/src/defaults.ts +1 -0
- package/src/lib/detect.js +3 -1
- package/src/lib/utils.ts +25 -0
- package/src/style/_extend.less +0 -80
- package/src/style/comment.less +6 -0
- package/src/style/list.less +66 -0
- package/src/style/main.less +1 -1
- package/src/style/sidebar-layer.less +92 -0
- package/types/artalk-config.d.ts +4 -1
- package/types/artalk-data.d.ts +3 -0
- package/vite-common.config.ts +15 -0
- package/vite-demo.config.ts +14 -0
- package/vite.config.ts +36 -0
- package/LICENSE +0 -674
- package/README.md +0 -84
- package/src/components/admin/page-list.ts +0 -194
- package/src/components/admin/site-list-floater.ts +0 -98
- package/src/components/admin/site-list.ts +0 -289
- package/src/components/html/sidebar.html +0 -22
- package/src/components/item-text-editor.ts +0 -136
- package/src/components/sidebar-view.ts +0 -26
- package/src/components/sidebar-views/comments-view.ts +0 -73
- package/src/components/sidebar-views/pages-view.ts +0 -61
- package/src/components/sidebar-views/setting-view.ts +0 -21
- package/src/components/sidebar-views/sites-view.ts +0 -36
- package/src/components/sidebar-views/transfer-view.ts +0 -218
- package/src/components/sidebar.ts +0 -293
- package/src/lib/md5.js +0 -6
- package/src/style/item-text-editor.less +0 -35
- package/src/style/page-list.less +0 -50
- package/src/style/sidebar.less +0 -420
- 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: {
|
|
@@ -194,7 +195,7 @@ function unescape(html) {
|
|
|
194
195
|
}
|
|
195
196
|
const caret = /(^|[^\[])\^/g;
|
|
196
197
|
function edit(regex, opt) {
|
|
197
|
-
regex = 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.
|
|
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
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
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,
|
|
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})((?:
|
|
509
|
+
const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
|
|
512
510
|
while (src) {
|
|
513
|
-
|
|
511
|
+
endEarly = false;
|
|
512
|
+
if (!(cap = itemRegex.exec(src))) {
|
|
514
513
|
break;
|
|
515
514
|
}
|
|
516
|
-
if (
|
|
515
|
+
if (this.rules.block.hr.test(src)) {
|
|
517
516
|
break;
|
|
518
517
|
}
|
|
519
|
-
|
|
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 =
|
|
524
|
+
itemContents = line.trimLeft();
|
|
523
525
|
} else {
|
|
524
526
|
indent = cap[2].search(/[^ ]/);
|
|
525
|
-
indent =
|
|
526
|
-
itemContents =
|
|
527
|
+
indent = indent > 4 ? 1 : indent;
|
|
528
|
+
itemContents = line.slice(indent);
|
|
529
|
+
indent += cap[1].length;
|
|
527
530
|
}
|
|
528
531
|
blankLine = false;
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
lines = [];
|
|
532
|
+
if (!line && /^ *$/.test(nextLine)) {
|
|
533
|
+
raw += nextLine + "\n";
|
|
534
|
+
src = src.substring(nextLine.length + 1);
|
|
535
|
+
endEarly = true;
|
|
534
536
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
line =
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
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
|
-
|
|
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
|
|
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)\]:
|
|
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)\]\[(
|
|
1031
|
-
nolink: /^!?\[(
|
|
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")
|
|
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.
|
|
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
|
|
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
|
-
|
|
1501
|
+
const id = this.options.headerPrefix + slugger.slug(raw);
|
|
1502
|
+
return `<h${level} id="${id}">${text}</h${level}>
|
|
1503
|
+
`;
|
|
1481
1504
|
}
|
|
1482
|
-
return
|
|
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
|
|
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
|
|
1523
|
+
return `<p>${text}</p>
|
|
1524
|
+
`;
|
|
1499
1525
|
}
|
|
1500
1526
|
table(header, body) {
|
|
1501
1527
|
if (body)
|
|
1502
|
-
body =
|
|
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
|
|
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 ?
|
|
1511
|
-
return tag + content +
|
|
1538
|
+
const tag = flags.align ? `<${type} align="${flags.align}">` : `<${type}>`;
|
|
1539
|
+
return tag + content + `</${type}>
|
|
1540
|
+
`;
|
|
1512
1541
|
}
|
|
1513
1542
|
strong(text) {
|
|
1514
|
-
return
|
|
1543
|
+
return `<strong>${text}</strong>`;
|
|
1515
1544
|
}
|
|
1516
1545
|
em(text) {
|
|
1517
|
-
return
|
|
1546
|
+
return `<em>${text}</em>`;
|
|
1518
1547
|
}
|
|
1519
1548
|
codespan(text) {
|
|
1520
|
-
return
|
|
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
|
|
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 =
|
|
1574
|
+
let out = `<img src="${href}" alt="${text}"`;
|
|
1546
1575
|
if (title) {
|
|
1547
|
-
out +=
|
|
1576
|
+
out += ` title="${title}"`;
|
|
1548
1577
|
}
|
|
1549
1578
|
out += this.options.xhtml ? "/>" : ">";
|
|
1550
1579
|
return out;
|
|
@@ -2657,6 +2686,30 @@ function marked(ctx, src) {
|
|
|
2657
2686
|
}
|
|
2658
2687
|
return markedInstance.parse(src);
|
|
2659
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
|
+
}
|
|
2660
2713
|
function showLoading(parentElem) {
|
|
2661
2714
|
if (parentElem instanceof Context)
|
|
2662
2715
|
parentElem = parentElem.$root;
|
|
@@ -2950,7 +3003,8 @@ function Fetch(ctx, input, init, timeout) {
|
|
|
2950
3003
|
} else {
|
|
2951
3004
|
resp = yield timeoutPromise(timeout || ctx.conf.reqTimeout || 15e3, fetch(input, init));
|
|
2952
3005
|
}
|
|
2953
|
-
|
|
3006
|
+
const noAccessCodes = [401, 400];
|
|
3007
|
+
if (!resp.ok && !noAccessCodes.includes(resp.status))
|
|
2954
3008
|
throw new Error(`\u8BF7\u6C42\u54CD\u5E94 ${resp.status}`);
|
|
2955
3009
|
let json = yield resp.json();
|
|
2956
3010
|
const recall = (resolve, reject) => {
|
|
@@ -2972,7 +3026,7 @@ function Fetch(ctx, input, init, timeout) {
|
|
|
2972
3026
|
}
|
|
2973
3027
|
});
|
|
2974
3028
|
});
|
|
2975
|
-
} else if (json.data && json.data.need_login || resp.status
|
|
3029
|
+
} else if (json.data && json.data.need_login || noAccessCodes.includes(resp.status)) {
|
|
2976
3030
|
json = yield new Promise((resolve, reject) => {
|
|
2977
3031
|
ctx.trigger("checker-admin", {
|
|
2978
3032
|
onSuccess: () => {
|
|
@@ -3065,7 +3119,8 @@ class Api {
|
|
|
3065
3119
|
link: comment2.link,
|
|
3066
3120
|
content: comment2.content,
|
|
3067
3121
|
rid: comment2.rid,
|
|
3068
|
-
page_key: comment2.page_key
|
|
3122
|
+
page_key: comment2.page_key,
|
|
3123
|
+
ua: yield getCorrectUserAgent()
|
|
3069
3124
|
};
|
|
3070
3125
|
if (comment2.page_title)
|
|
3071
3126
|
params.page_title = comment2.page_title;
|
|
@@ -3234,6 +3289,17 @@ class Api {
|
|
|
3234
3289
|
}
|
|
3235
3290
|
return POST(this.ctx, `${this.baseURL}/mark-read`, params);
|
|
3236
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
|
+
}
|
|
3237
3303
|
captchaGet() {
|
|
3238
3304
|
return __async(this, null, function* () {
|
|
3239
3305
|
const data = yield GET(this.ctx, `${this.baseURL}/captcha/refresh`);
|
|
@@ -3995,7 +4061,7 @@ class Editor extends Component {
|
|
|
3995
4061
|
}
|
|
3996
4062
|
}
|
|
3997
4063
|
var list = "";
|
|
3998
|
-
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
|
|
4064
|
+
var ListHTML = '<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <div class="atk-text">\n <span class="atk-comment-count-num">0</span>\n \u6761\u8BC4\u8BBA\n </div>\n </div>\n <div class="atk-right-action">\n <span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show>\u5173\u95ED\u8BC4\u8BBA</span>\n <span data-action="open-sidebar" class="atk-hide atk-on">\n <span class="atk-unread-badge" style="display: none;"></span>\n <div class="atk-text">\u901A\u77E5\u4E2D\u5FC3</div>\n </span>\n </div>\n </div>\n <div class="atk-list-body"></div>\n <div class="atk-list-footer">\n <div class="atk-copyright"></div>\n </div>\n</div>\n';
|
|
3999
4065
|
var comment = "";
|
|
4000
4066
|
var win = window || {};
|
|
4001
4067
|
var nav = navigator || {};
|
|
@@ -4094,7 +4160,9 @@ function Detect(userAgent) {
|
|
|
4094
4160
|
"6.0": "Vista",
|
|
4095
4161
|
5.2: "XP",
|
|
4096
4162
|
5.1: "XP",
|
|
4097
|
-
"5.0": "2000"
|
|
4163
|
+
"5.0": "2000",
|
|
4164
|
+
"10.0": "10",
|
|
4165
|
+
"11.0": "11"
|
|
4098
4166
|
};
|
|
4099
4167
|
return hash2[v] || v;
|
|
4100
4168
|
},
|
|
@@ -4459,6 +4527,10 @@ class Comment extends Component {
|
|
|
4459
4527
|
} else {
|
|
4460
4528
|
$badge.remove();
|
|
4461
4529
|
}
|
|
4530
|
+
if (this.data.is_pinned) {
|
|
4531
|
+
const $pinnedBadge = createElement(`<span class="atk-item atk-pinned-badge">\u7F6E\u9876</span>`);
|
|
4532
|
+
$nick.insertAdjacentElement("afterend", $pinnedBadge);
|
|
4533
|
+
}
|
|
4462
4534
|
const $date = this.$el.querySelector(".atk-date");
|
|
4463
4535
|
$date.innerText = this.getDateFormatted();
|
|
4464
4536
|
$date.setAttribute("data-atk-comment-date", String(+new Date(this.data.date)));
|
|
@@ -4572,6 +4644,14 @@ class Comment extends Component {
|
|
|
4572
4644
|
delBtn.setClick(() => {
|
|
4573
4645
|
this.adminDelete(delBtn);
|
|
4574
4646
|
});
|
|
4647
|
+
const pinnedBtn = new ActionBtn({
|
|
4648
|
+
text: () => this.data.is_pinned ? "\u53D6\u6D88\u7F6E\u9876" : "\u7F6E\u9876",
|
|
4649
|
+
adminOnly: true
|
|
4650
|
+
});
|
|
4651
|
+
pinnedBtn.appendTo(this.$actions);
|
|
4652
|
+
pinnedBtn.setClick(() => {
|
|
4653
|
+
this.adminEdit("pinned", pendingBtn);
|
|
4654
|
+
});
|
|
4575
4655
|
}
|
|
4576
4656
|
refreshUI() {
|
|
4577
4657
|
const originalEl = this.$el;
|
|
@@ -4682,6 +4762,8 @@ class Comment extends Component {
|
|
|
4682
4762
|
modify.is_collapsed = !modify.is_collapsed;
|
|
4683
4763
|
} else if (type === "pending") {
|
|
4684
4764
|
modify.is_pending = !modify.is_pending;
|
|
4765
|
+
} else if (type === "pinned") {
|
|
4766
|
+
modify.is_pinned = !modify.is_pinned;
|
|
4685
4767
|
}
|
|
4686
4768
|
new Api(this.ctx).commentEdit(modify).then((comment2) => {
|
|
4687
4769
|
btnElem.setLoading(false);
|
|
@@ -5347,9 +5429,9 @@ class ListLite extends Component {
|
|
|
5347
5429
|
}
|
|
5348
5430
|
versionCheck(versionData) {
|
|
5349
5431
|
const needVersion = (versionData == null ? void 0 : versionData.fe_min_version) || "0.0.0";
|
|
5350
|
-
const needUpdate = versionCompare(needVersion, "2.1.
|
|
5432
|
+
const needUpdate = versionCompare(needVersion, "2.1.7") === 1;
|
|
5351
5433
|
if (needUpdate) {
|
|
5352
|
-
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.
|
|
5434
|
+
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.7"}\uFF0C\u9700\u6C42\u7248\u672C >= ${needVersion}</span><br/><br/></div>`);
|
|
5353
5435
|
const ignoreBtn = createElement('<span style="cursor:pointer;">\u5FFD\u7565</span>');
|
|
5354
5436
|
ignoreBtn.onclick = () => {
|
|
5355
5437
|
setError(this.ctx, null);
|
|
@@ -5370,6 +5452,8 @@ class List extends ListLite {
|
|
|
5370
5452
|
__publicField(this, "$closeCommentBtn");
|
|
5371
5453
|
__publicField(this, "$openSidebarBtn");
|
|
5372
5454
|
__publicField(this, "$unreadBadge");
|
|
5455
|
+
__publicField(this, "$commentCount");
|
|
5456
|
+
__publicField(this, "$dropdownWrap");
|
|
5373
5457
|
el.querySelector(".atk-list-body").append(this.$el);
|
|
5374
5458
|
this.$el = el;
|
|
5375
5459
|
let flatMode = false;
|
|
@@ -5384,7 +5468,9 @@ class List extends ListLite {
|
|
|
5384
5468
|
this.pageSize = ((_b = this.conf.pagination) == null ? void 0 : _b.pageSize) || 20;
|
|
5385
5469
|
this.repositionAt = this.$el;
|
|
5386
5470
|
this.initListActionBtn();
|
|
5387
|
-
this.$el.querySelector(".atk-
|
|
5471
|
+
this.$commentCount = this.$el.querySelector(".atk-comment-count");
|
|
5472
|
+
this.initDropdown();
|
|
5473
|
+
this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.1.7"}">Artalk</a>`;
|
|
5388
5474
|
this.ctx.on("list-reload", () => this.fetchComments(0));
|
|
5389
5475
|
this.ctx.on("list-refresh-ui", () => this.refreshUI());
|
|
5390
5476
|
this.ctx.on("list-import", (data) => this.importComments(data));
|
|
@@ -5487,1036 +5573,84 @@ class List extends ListLite {
|
|
|
5487
5573
|
this.$unreadBadge.style.display = "none";
|
|
5488
5574
|
}
|
|
5489
5575
|
}
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
for (var _, m = "0123456789ABCDEF", f = "", r = 0; r < d.length; r++)
|
|
5498
|
-
_ = d.charCodeAt(r), f += m.charAt(_ >>> 4 & 15) + m.charAt(15 & _);
|
|
5499
|
-
return f;
|
|
5500
|
-
}
|
|
5501
|
-
function X(d) {
|
|
5502
|
-
for (var _ = Array(d.length >> 2), m = 0; m < _.length; m++)
|
|
5503
|
-
_[m] = 0;
|
|
5504
|
-
for (m = 0; m < 8 * d.length; m += 8)
|
|
5505
|
-
_[m >> 5] |= (255 & d.charCodeAt(m / 8)) << m % 32;
|
|
5506
|
-
return _;
|
|
5507
|
-
}
|
|
5508
|
-
function V(d) {
|
|
5509
|
-
for (var _ = "", m = 0; m < 32 * d.length; m += 8)
|
|
5510
|
-
_ += String.fromCharCode(d[m >> 5] >>> m % 32 & 255);
|
|
5511
|
-
return _;
|
|
5512
|
-
}
|
|
5513
|
-
function Y(d, _) {
|
|
5514
|
-
d[_ >> 5] |= 128 << _ % 32, d[14 + (_ + 64 >>> 9 << 4)] = _;
|
|
5515
|
-
for (var m = 1732584193, f = -271733879, r = -1732584194, i = 271733878, n = 0; n < d.length; n += 16) {
|
|
5516
|
-
var h = m, t = f, g = r, e = i;
|
|
5517
|
-
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);
|
|
5518
|
-
}
|
|
5519
|
-
return Array(m, f, r, i);
|
|
5520
|
-
}
|
|
5521
|
-
function md5_cmn(d, _, m, f, r, i) {
|
|
5522
|
-
return safe_add(bit_rol(safe_add(safe_add(_, d), safe_add(f, i)), r), m);
|
|
5523
|
-
}
|
|
5524
|
-
function md5_ff(d, _, m, f, r, i, n) {
|
|
5525
|
-
return md5_cmn(_ & m | ~_ & f, d, _, r, i, n);
|
|
5526
|
-
}
|
|
5527
|
-
function md5_gg(d, _, m, f, r, i, n) {
|
|
5528
|
-
return md5_cmn(_ & f | m & ~f, d, _, r, i, n);
|
|
5529
|
-
}
|
|
5530
|
-
function md5_hh(d, _, m, f, r, i, n) {
|
|
5531
|
-
return md5_cmn(_ ^ m ^ f, d, _, r, i, n);
|
|
5532
|
-
}
|
|
5533
|
-
function md5_ii(d, _, m, f, r, i, n) {
|
|
5534
|
-
return md5_cmn(m ^ (_ | ~f), d, _, r, i, n);
|
|
5535
|
-
}
|
|
5536
|
-
function safe_add(d, _) {
|
|
5537
|
-
var m = (65535 & d) + (65535 & _);
|
|
5538
|
-
return (d >> 16) + (_ >> 16) + (m >> 16) << 16 | 65535 & m;
|
|
5539
|
-
}
|
|
5540
|
-
function bit_rol(d, _) {
|
|
5541
|
-
return d << _ | d >>> 32 - _;
|
|
5542
|
-
}
|
|
5543
|
-
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';
|
|
5544
|
-
class SidebarView extends Component {
|
|
5545
|
-
constructor(ctx, $parent) {
|
|
5546
|
-
super(ctx);
|
|
5547
|
-
__publicField(this, "viewTabs", {});
|
|
5548
|
-
__publicField(this, "viewActiveTab", "");
|
|
5549
|
-
__publicField(this, "$parent");
|
|
5550
|
-
this.$parent = $parent;
|
|
5551
|
-
this.$el = createElement(`<div class="atk-sidebar-view"></div>`);
|
|
5552
|
-
}
|
|
5553
|
-
mount(siteName) {
|
|
5554
|
-
}
|
|
5555
|
-
switchTab(tab, siteName) {
|
|
5556
|
-
}
|
|
5557
|
-
}
|
|
5558
|
-
__publicField(SidebarView, "viewName", "");
|
|
5559
|
-
__publicField(SidebarView, "viewTitle", "");
|
|
5560
|
-
__publicField(SidebarView, "viewAdminOnly", false);
|
|
5561
|
-
class MessageView extends SidebarView {
|
|
5562
|
-
constructor() {
|
|
5563
|
-
super(...arguments);
|
|
5564
|
-
__publicField(this, "viewTabs", {});
|
|
5565
|
-
__publicField(this, "viewActiveTab", "");
|
|
5566
|
-
__publicField(this, "list");
|
|
5567
|
-
}
|
|
5568
|
-
mount(siteName) {
|
|
5569
|
-
if (this.ctx.user.data.isAdmin) {
|
|
5570
|
-
this.viewTabs = {
|
|
5571
|
-
admin_all: "\u5168\u90E8",
|
|
5572
|
-
admin_pending: "\u5F85\u5BA1",
|
|
5573
|
-
all: "\u4E2A\u4EBA"
|
|
5574
|
-
};
|
|
5575
|
-
this.viewActiveTab = "admin_all";
|
|
5576
|
-
} else {
|
|
5577
|
-
this.viewTabs = {
|
|
5578
|
-
mentions: "\u63D0\u53CA",
|
|
5579
|
-
all: "\u5168\u90E8",
|
|
5580
|
-
mine: "\u6211\u7684",
|
|
5581
|
-
pending: "\u5F85\u5BA1"
|
|
5582
|
-
};
|
|
5583
|
-
this.viewActiveTab = "mentions";
|
|
5584
|
-
}
|
|
5585
|
-
this.list = new ListLite(this.ctx);
|
|
5586
|
-
this.list.flatMode = true;
|
|
5587
|
-
this.list.unreadHighlight = true;
|
|
5588
|
-
this.list.scrollListenerAt = this.$parent;
|
|
5589
|
-
this.list.pageMode = "pagination";
|
|
5590
|
-
this.list.noCommentText = '<div class="atk-sidebar-no-content">\u65E0\u5185\u5BB9</div>';
|
|
5591
|
-
this.list.renderComment = (comment2) => {
|
|
5592
|
-
comment2.setOpenURL(`${comment2.data.page_key}#atk-comment-${comment2.data.id}`);
|
|
5593
|
-
comment2.onReplyBtnClick = () => {
|
|
5594
|
-
if (this.ctx.conf.editorTravel === true) {
|
|
5595
|
-
this.ctx.trigger("editor-reply", { data: comment2.data, $el: comment2.$el, scroll: false });
|
|
5596
|
-
} else {
|
|
5597
|
-
this.ctx.trigger("sidebar-hide");
|
|
5598
|
-
this.ctx.trigger("editor-reply", { data: comment2.data, $el: comment2.$el, scroll: true });
|
|
5599
|
-
}
|
|
5576
|
+
initDropdown() {
|
|
5577
|
+
this.$dropdownWrap = this.$commentCount;
|
|
5578
|
+
this.$commentCount.classList.add("atk-dropdown-wrap");
|
|
5579
|
+
this.$commentsWrap.append(createElement(`<span class="atk-arrow-down-icon"></span>`));
|
|
5580
|
+
const reloadUseParamsEditor = (func) => {
|
|
5581
|
+
this.paramsEditor = (p) => {
|
|
5582
|
+
func(p);
|
|
5600
5583
|
};
|
|
5584
|
+
this.fetchComments(0);
|
|
5601
5585
|
};
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
this.$el.append(this.list.$el);
|
|
5607
|
-
this.switchTab(this.viewActiveTab, siteName);
|
|
5608
|
-
}
|
|
5609
|
-
switchTab(tab, siteName) {
|
|
5610
|
-
this.viewActiveTab = tab;
|
|
5611
|
-
this.list.paramsEditor = (params) => {
|
|
5612
|
-
params.type = tab;
|
|
5613
|
-
params.site_name = siteName;
|
|
5614
|
-
};
|
|
5615
|
-
this.list.fetchComments(0);
|
|
5616
|
-
return true;
|
|
5617
|
-
}
|
|
5618
|
-
}
|
|
5619
|
-
__publicField(MessageView, "viewName", "comments");
|
|
5620
|
-
__publicField(MessageView, "viewTitle", "\u8BC4\u8BBA");
|
|
5621
|
-
var pageList = "";
|
|
5622
|
-
var itemTextEditor = "";
|
|
5623
|
-
class ItemTextEditor {
|
|
5624
|
-
constructor(conf) {
|
|
5625
|
-
__publicField(this, "conf");
|
|
5626
|
-
__publicField(this, "$el");
|
|
5627
|
-
__publicField(this, "$input");
|
|
5628
|
-
__publicField(this, "$yesBtn");
|
|
5629
|
-
__publicField(this, "$noBtn");
|
|
5630
|
-
__publicField(this, "value", "");
|
|
5631
|
-
__publicField(this, "allowSubmit", true);
|
|
5632
|
-
this.conf = conf;
|
|
5633
|
-
this.$el = createElement(`<div class="atk-item-text-editor-layer">
|
|
5634
|
-
<div class="atk-edit-form">
|
|
5635
|
-
<input class="atk-main-input" type="text" placeholder="\u8F93\u5165\u5185\u5BB9..." autocomplete="off" autofocus>
|
|
5636
|
-
</div>
|
|
5637
|
-
<div class="atk-actions">
|
|
5638
|
-
<div class="atk-item atk-yes-btn">
|
|
5639
|
-
<i class="atk-icon atk-icon-yes"></i>
|
|
5640
|
-
</div>
|
|
5641
|
-
<div class="atk-item atk-no-btn">
|
|
5642
|
-
<i class="atk-icon atk-icon-no"></i>
|
|
5643
|
-
</div>
|
|
5644
|
-
</div>
|
|
5645
|
-
</div>`);
|
|
5646
|
-
this.$input = this.$el.querySelector(".atk-main-input");
|
|
5647
|
-
this.$yesBtn = this.$el.querySelector(".atk-yes-btn");
|
|
5648
|
-
this.$noBtn = this.$el.querySelector(".atk-no-btn");
|
|
5649
|
-
this.$input.value = conf.initValue || "";
|
|
5650
|
-
this.value = conf.initValue || "";
|
|
5651
|
-
if (this.conf.placeholder)
|
|
5652
|
-
this.$input.placeholder = this.conf.placeholder;
|
|
5653
|
-
this.$input.oninput = () => this.onInput();
|
|
5654
|
-
this.$input.onkeyup = (evt) => {
|
|
5655
|
-
if (evt.key === "Enter" || evt.keyCode === 13) {
|
|
5656
|
-
evt.preventDefault();
|
|
5657
|
-
this.submit();
|
|
5658
|
-
}
|
|
5659
|
-
};
|
|
5660
|
-
window.setTimeout(() => this.$input.focus(), 80);
|
|
5661
|
-
this.$yesBtn.onclick = () => {
|
|
5662
|
-
this.submit();
|
|
5663
|
-
};
|
|
5664
|
-
this.$noBtn.onclick = () => {
|
|
5665
|
-
this.cancel();
|
|
5666
|
-
};
|
|
5667
|
-
}
|
|
5668
|
-
appendTo(parentDOM) {
|
|
5669
|
-
parentDOM.append(this.$el);
|
|
5670
|
-
return this;
|
|
5671
|
-
}
|
|
5672
|
-
onInput() {
|
|
5673
|
-
this.value = this.$input.value;
|
|
5674
|
-
if (this.conf.validator) {
|
|
5675
|
-
const ok = this.conf.validator(this.value);
|
|
5676
|
-
this.setAllowSubmit(ok);
|
|
5677
|
-
if (!ok) {
|
|
5678
|
-
this.$input.classList.add("atk-invalid");
|
|
5679
|
-
} else {
|
|
5680
|
-
this.$input.classList.remove("atk-invalid");
|
|
5681
|
-
}
|
|
5682
|
-
}
|
|
5683
|
-
}
|
|
5684
|
-
setAllowSubmit(allow) {
|
|
5685
|
-
if (this.allowSubmit === allow)
|
|
5686
|
-
return;
|
|
5687
|
-
this.allowSubmit = allow;
|
|
5688
|
-
if (!allow) {
|
|
5689
|
-
this.$yesBtn.classList.add(".atk-disabled");
|
|
5690
|
-
} else {
|
|
5691
|
-
this.$yesBtn.classList.remove(".atk-disabled");
|
|
5692
|
-
}
|
|
5693
|
-
}
|
|
5694
|
-
submit() {
|
|
5695
|
-
return __async(this, null, function* () {
|
|
5696
|
-
if (!this.allowSubmit)
|
|
5697
|
-
return;
|
|
5698
|
-
if (this.conf.onYes) {
|
|
5699
|
-
let isContinue;
|
|
5700
|
-
if (this.conf.onYes instanceof (() => __async(this, null, function* () {
|
|
5701
|
-
})).constructor) {
|
|
5702
|
-
isContinue = yield this.conf.onYes(this.value);
|
|
5703
|
-
} else {
|
|
5704
|
-
isContinue = this.conf.onYes(this.value);
|
|
5705
|
-
}
|
|
5706
|
-
if (isContinue === void 0 || isContinue === true) {
|
|
5707
|
-
this.closeEditor();
|
|
5708
|
-
}
|
|
5709
|
-
} else {
|
|
5710
|
-
this.closeEditor();
|
|
5711
|
-
}
|
|
5712
|
-
});
|
|
5713
|
-
}
|
|
5714
|
-
cancel() {
|
|
5715
|
-
return __async(this, null, function* () {
|
|
5716
|
-
if (this.conf.onNo) {
|
|
5717
|
-
let isContinue;
|
|
5718
|
-
if (this.conf.onNo instanceof (() => __async(this, null, function* () {
|
|
5719
|
-
})).constructor) {
|
|
5720
|
-
isContinue = yield this.conf.onNo();
|
|
5721
|
-
} else {
|
|
5722
|
-
isContinue = this.conf.onNo();
|
|
5723
|
-
}
|
|
5724
|
-
if (isContinue === void 0 || isContinue === true) {
|
|
5725
|
-
this.closeEditor();
|
|
5726
|
-
}
|
|
5727
|
-
} else {
|
|
5728
|
-
this.closeEditor();
|
|
5729
|
-
}
|
|
5730
|
-
});
|
|
5731
|
-
}
|
|
5732
|
-
closeEditor() {
|
|
5733
|
-
this.$el.remove();
|
|
5734
|
-
}
|
|
5735
|
-
}
|
|
5736
|
-
class PageList extends Component {
|
|
5737
|
-
constructor(ctx) {
|
|
5738
|
-
super(ctx);
|
|
5739
|
-
__publicField(this, "$editor");
|
|
5740
|
-
__publicField(this, "$inputer");
|
|
5741
|
-
__publicField(this, "pages", []);
|
|
5742
|
-
this.$el = createElement(`<div class="atk-page-list"></div>`);
|
|
5743
|
-
}
|
|
5744
|
-
clearAll() {
|
|
5745
|
-
this.pages = [];
|
|
5746
|
-
this.$el.innerHTML = "";
|
|
5747
|
-
}
|
|
5748
|
-
importPages(pages) {
|
|
5749
|
-
this.pages.push(...pages);
|
|
5750
|
-
pages.forEach((page) => {
|
|
5751
|
-
const $page = this.renderPage(page);
|
|
5752
|
-
this.$el.append($page);
|
|
5753
|
-
});
|
|
5754
|
-
}
|
|
5755
|
-
renderPage(page) {
|
|
5756
|
-
const $page = createElement(`<div class="atk-page-item">
|
|
5757
|
-
<div class="atk-page-main">
|
|
5758
|
-
<div class="atk-title"></div>
|
|
5759
|
-
<div class="atk-sub"></div>
|
|
5760
|
-
</div>
|
|
5761
|
-
<div class="atk-page-actions">
|
|
5762
|
-
<div class="atk-item atk-edit-btn">
|
|
5763
|
-
<i class="atk-icon atk-icon-edit"></i>
|
|
5764
|
-
</div>
|
|
5765
|
-
</div>
|
|
5766
|
-
</div>`);
|
|
5767
|
-
const $main = $page.querySelector(".atk-page-main");
|
|
5768
|
-
const $title = $main.querySelector(".atk-title");
|
|
5769
|
-
const $sub = $main.querySelector(".atk-sub");
|
|
5770
|
-
const $editBtn = $page.querySelector(".atk-edit-btn");
|
|
5771
|
-
$title.innerText = page.title;
|
|
5772
|
-
$sub.innerText = page.url || page.key;
|
|
5773
|
-
$editBtn.onclick = () => this.showEditor(page, $page);
|
|
5774
|
-
return $page;
|
|
5775
|
-
}
|
|
5776
|
-
showEditor(page, $page) {
|
|
5777
|
-
this.closeEditor();
|
|
5778
|
-
this.$editor = createElement(`<div class="atk-page-edit-layer">
|
|
5779
|
-
<div class="atk-page-main-actions">
|
|
5780
|
-
<div class="atk-item atk-title-edit-btn">\u6807\u9898\u4FEE\u6539</div>
|
|
5781
|
-
<div class="atk-item atk-key-edit-btn">KEY \u53D8\u66F4</div>
|
|
5782
|
-
<div class="atk-item atk-admin-only-btn"></div>
|
|
5783
|
-
</div>
|
|
5784
|
-
<div class="atk-page-actions">
|
|
5785
|
-
<div class="atk-item atk-sync-btn">
|
|
5786
|
-
<i class="atk-icon atk-icon-sync"></i>
|
|
5787
|
-
</div>
|
|
5788
|
-
<div class="atk-item atk-del-btn">
|
|
5789
|
-
<i class="atk-icon atk-icon-del"></i>
|
|
5790
|
-
</div>
|
|
5791
|
-
<div class="atk-item atk-close-btn">
|
|
5792
|
-
<i class="atk-icon atk-icon-close"></i>
|
|
5793
|
-
</div>
|
|
5794
|
-
</div>
|
|
5795
|
-
</div>`);
|
|
5796
|
-
$page.prepend(this.$editor);
|
|
5797
|
-
const $titleEditBtn = this.$editor.querySelector(".atk-title-edit-btn");
|
|
5798
|
-
const $keyEditBtn = this.$editor.querySelector(".atk-key-edit-btn");
|
|
5799
|
-
const $adminOnlyBtn = this.$editor.querySelector(".atk-admin-only-btn");
|
|
5800
|
-
const $syncBtn = this.$editor.querySelector(".atk-sync-btn");
|
|
5801
|
-
const $delBtn = this.$editor.querySelector(".atk-del-btn");
|
|
5802
|
-
const $closeBtn = this.$editor.querySelector(".atk-close-btn");
|
|
5803
|
-
const showLoading$1 = () => {
|
|
5804
|
-
showLoading(this.$editor);
|
|
5805
|
-
};
|
|
5806
|
-
const hideLoading$1 = () => {
|
|
5807
|
-
hideLoading(this.$editor);
|
|
5808
|
-
};
|
|
5809
|
-
const showError = (msg) => {
|
|
5810
|
-
window.alert(msg);
|
|
5811
|
-
};
|
|
5812
|
-
$closeBtn.onclick = () => this.closeEditor();
|
|
5813
|
-
const openTextEditor = (key) => {
|
|
5814
|
-
const textEditor = new ItemTextEditor({
|
|
5815
|
-
initValue: page[key] || "",
|
|
5816
|
-
onYes: (val) => __async(this, null, function* () {
|
|
5817
|
-
showLoading(textEditor.$el);
|
|
5818
|
-
let p;
|
|
5819
|
-
try {
|
|
5820
|
-
p = yield new Api(this.ctx).pageEdit(__spreadProps(__spreadValues({}, page), { [key]: val }));
|
|
5821
|
-
} catch (err) {
|
|
5822
|
-
showError(`\u4FEE\u6539\u5931\u8D25\uFF1A${err.msg || "\u672A\u77E5\u9519\u8BEF"}`);
|
|
5823
|
-
console.error(err);
|
|
5824
|
-
return false;
|
|
5825
|
-
} finally {
|
|
5826
|
-
hideLoading(textEditor.$el);
|
|
5827
|
-
}
|
|
5828
|
-
$page.replaceWith(this.renderPage(p));
|
|
5829
|
-
return true;
|
|
5830
|
-
})
|
|
5831
|
-
});
|
|
5832
|
-
textEditor.appendTo(this.$editor);
|
|
5833
|
-
};
|
|
5834
|
-
$titleEditBtn.onclick = () => openTextEditor("title");
|
|
5835
|
-
$keyEditBtn.onclick = () => openTextEditor("key");
|
|
5836
|
-
const adminOnlyActionBtn = new ActionBtn({
|
|
5837
|
-
text: () => {
|
|
5838
|
-
$adminOnlyBtn.classList.remove("atk-green", "atk-yellow");
|
|
5839
|
-
$adminOnlyBtn.classList.add(!page.admin_only ? "atk-green" : "atk-yellow");
|
|
5840
|
-
return !page.admin_only ? "\u6240\u6709\u4EBA\u53EF\u8BC4" : "\u7BA1\u7406\u5458\u53EF\u8BC4";
|
|
5841
|
-
}
|
|
5842
|
-
}).appendTo($adminOnlyBtn);
|
|
5843
|
-
$adminOnlyBtn.onclick = () => __async(this, null, function* () {
|
|
5844
|
-
showLoading$1();
|
|
5845
|
-
let p;
|
|
5846
|
-
try {
|
|
5847
|
-
p = yield new Api(this.ctx).pageEdit(__spreadProps(__spreadValues({}, page), { admin_only: !page.admin_only }));
|
|
5848
|
-
} catch (err) {
|
|
5849
|
-
showError(`\u4FEE\u6539\u5931\u8D25\uFF1A${err.msg || "\u672A\u77E5\u9519\u8BEF"}`);
|
|
5850
|
-
console.log(err);
|
|
5851
|
-
return;
|
|
5852
|
-
} finally {
|
|
5853
|
-
hideLoading$1();
|
|
5854
|
-
}
|
|
5855
|
-
page.admin_only = p.admin_only;
|
|
5856
|
-
adminOnlyActionBtn.updateText();
|
|
5857
|
-
});
|
|
5858
|
-
$syncBtn.onclick = () => __async(this, null, function* () {
|
|
5859
|
-
showLoading$1();
|
|
5860
|
-
let p;
|
|
5861
|
-
try {
|
|
5862
|
-
p = yield new Api(this.ctx).pageFetch(page.id);
|
|
5863
|
-
} catch (err) {
|
|
5864
|
-
showError(`\u540C\u6B65\u5931\u8D25\uFF1A${err.msg || "\u672A\u77E5\u9519\u8BEF"}`);
|
|
5865
|
-
console.log(err);
|
|
5866
|
-
return;
|
|
5867
|
-
} finally {
|
|
5868
|
-
hideLoading$1();
|
|
5869
|
-
}
|
|
5870
|
-
$page.replaceWith(this.renderPage(p));
|
|
5871
|
-
});
|
|
5872
|
-
$delBtn.onclick = () => {
|
|
5873
|
-
const del = () => __async(this, null, function* () {
|
|
5874
|
-
showLoading$1();
|
|
5875
|
-
try {
|
|
5876
|
-
yield new Api(this.ctx).pageDel(page.key, page.site_name);
|
|
5877
|
-
} catch (err) {
|
|
5878
|
-
console.log(err);
|
|
5879
|
-
showError(`\u5220\u9664\u5931\u8D25 ${String(err)}`);
|
|
5880
|
-
return;
|
|
5881
|
-
} finally {
|
|
5882
|
-
hideLoading$1();
|
|
5883
|
-
}
|
|
5884
|
-
$page.remove();
|
|
5885
|
-
});
|
|
5886
|
-
if (window.confirm(`\u786E\u8BA4\u5220\u9664\u9875\u9762 "${page.title || page.key}"\uFF1F\u5C06\u4F1A\u5220\u9664\u6240\u6709\u76F8\u5173\u6570\u636E`))
|
|
5887
|
-
del();
|
|
5888
|
-
};
|
|
5889
|
-
}
|
|
5890
|
-
closeEditor() {
|
|
5891
|
-
if (!this.$editor)
|
|
5892
|
-
return;
|
|
5893
|
-
this.$editor.remove();
|
|
5894
|
-
}
|
|
5895
|
-
}
|
|
5896
|
-
const PAGE_SIZE = 20;
|
|
5897
|
-
class PagesView extends SidebarView {
|
|
5898
|
-
constructor() {
|
|
5899
|
-
super(...arguments);
|
|
5900
|
-
__publicField(this, "viewTabs", {});
|
|
5901
|
-
__publicField(this, "viewActiveTab", "");
|
|
5902
|
-
__publicField(this, "pageList");
|
|
5903
|
-
__publicField(this, "pagination");
|
|
5904
|
-
}
|
|
5905
|
-
mount(siteName) {
|
|
5906
|
-
if (!this.pageList) {
|
|
5907
|
-
this.pageList = new PageList(this.ctx);
|
|
5908
|
-
this.$el.append(this.pageList.$el);
|
|
5909
|
-
}
|
|
5910
|
-
this.switchTab(this.viewActiveTab, siteName);
|
|
5911
|
-
}
|
|
5912
|
-
switchTab(tab, siteName) {
|
|
5913
|
-
this.reqPages(siteName, 0);
|
|
5914
|
-
}
|
|
5915
|
-
reqPages(siteName, offset) {
|
|
5916
|
-
return __async(this, null, function* () {
|
|
5917
|
-
var _a;
|
|
5918
|
-
this.pageList.clearAll();
|
|
5919
|
-
(_a = this.$el.parentNode) == null ? void 0 : _a.scrollTo(0, 0);
|
|
5920
|
-
showLoading(this.$el);
|
|
5921
|
-
const data = yield new Api(this.ctx).pageGet(siteName, offset, PAGE_SIZE);
|
|
5922
|
-
this.pageList.importPages(data.pages || []);
|
|
5923
|
-
hideLoading(this.$el);
|
|
5924
|
-
if (!this.pagination) {
|
|
5925
|
-
this.pagination = new Pagination(data.total, {
|
|
5926
|
-
pageSize: PAGE_SIZE,
|
|
5927
|
-
onChange: (o) => {
|
|
5928
|
-
this.reqPages(siteName, o);
|
|
5929
|
-
}
|
|
5586
|
+
const dropdownList = [
|
|
5587
|
+
["\u6700\u65B0", () => {
|
|
5588
|
+
reloadUseParamsEditor((p) => {
|
|
5589
|
+
p.sort_by = "date_desc";
|
|
5930
5590
|
});
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
});
|
|
5936
|
-
}
|
|
5937
|
-
}
|
|
5938
|
-
__publicField(PagesView, "viewName", "pages");
|
|
5939
|
-
__publicField(PagesView, "viewTitle", "\u9875\u9762");
|
|
5940
|
-
__publicField(PagesView, "viewAdminOnly", true);
|
|
5941
|
-
var siteList = "";
|
|
5942
|
-
class SiteList extends Component {
|
|
5943
|
-
constructor(ctx) {
|
|
5944
|
-
super(ctx);
|
|
5945
|
-
__publicField(this, "sites", []);
|
|
5946
|
-
__publicField(this, "$header");
|
|
5947
|
-
__publicField(this, "$headerTitle");
|
|
5948
|
-
__publicField(this, "$headerActions");
|
|
5949
|
-
__publicField(this, "$rowsWrap");
|
|
5950
|
-
__publicField(this, "$editor");
|
|
5951
|
-
__publicField(this, "activeSite", "");
|
|
5952
|
-
__publicField(this, "$add");
|
|
5953
|
-
this.$el = createElement(`<div class="atk-site-list">
|
|
5954
|
-
<div class="atk-header">
|
|
5955
|
-
<div class="atk-title"></div>
|
|
5956
|
-
<div class="atk-actions">
|
|
5957
|
-
<div class="atk-item atk-site-add-btn"><i class="atk-icon atk-icon-plus"></i></div>
|
|
5958
|
-
</div>
|
|
5959
|
-
</div>
|
|
5960
|
-
<div class="atk-site-rows-wrap"></div>
|
|
5961
|
-
</div>`);
|
|
5962
|
-
this.$header = this.$el.querySelector(".atk-header");
|
|
5963
|
-
this.$headerTitle = this.$header.querySelector(".atk-title");
|
|
5964
|
-
this.$headerActions = this.$header.querySelector(".atk-actions");
|
|
5965
|
-
this.$rowsWrap = this.$el.querySelector(".atk-site-rows-wrap");
|
|
5966
|
-
this.$headerTitle.innerText = `\u5171 0 \u4E2A\u7AD9\u70B9`;
|
|
5967
|
-
const $addBtn = this.$headerActions.querySelector(".atk-site-add-btn");
|
|
5968
|
-
$addBtn.onclick = () => {
|
|
5969
|
-
this.closeEditor();
|
|
5970
|
-
this.showAdd();
|
|
5971
|
-
};
|
|
5972
|
-
}
|
|
5973
|
-
loadSites(sites) {
|
|
5974
|
-
this.sites = sites;
|
|
5975
|
-
this.activeSite = "";
|
|
5976
|
-
this.$rowsWrap.innerHTML = "";
|
|
5977
|
-
this.$headerTitle.innerText = `\u5171 0 \u4E2A\u7AD9\u70B9`;
|
|
5978
|
-
let $row;
|
|
5979
|
-
for (let i = 0; i < sites.length; i++) {
|
|
5980
|
-
const site = sites[i];
|
|
5981
|
-
if (i % 4 === 0) {
|
|
5982
|
-
$row = createElement('<div class="atk-site-row">');
|
|
5983
|
-
this.$rowsWrap.append($row);
|
|
5984
|
-
}
|
|
5985
|
-
const $site = this.renderSite(site, $row);
|
|
5986
|
-
$row.append($site);
|
|
5987
|
-
}
|
|
5988
|
-
this.$headerTitle.innerText = `\u5171 ${sites.length} \u4E2A\u7AD9\u70B9`;
|
|
5989
|
-
}
|
|
5990
|
-
renderSite(site, $row) {
|
|
5991
|
-
const $site = createElement(`<div class="atk-site-item">
|
|
5992
|
-
<div class="atk-site-logo"></div>
|
|
5993
|
-
<div class="atk-site-name"></div>
|
|
5994
|
-
</div>`);
|
|
5995
|
-
const $siteLogo = $site.querySelector(".atk-site-logo");
|
|
5996
|
-
const $siteName = $site.querySelector(".atk-site-name");
|
|
5997
|
-
const setActive = () => {
|
|
5998
|
-
$site.classList.add("atk-active");
|
|
5999
|
-
};
|
|
6000
|
-
$siteLogo.innerText = site.name.substr(0, 1);
|
|
6001
|
-
$siteName.innerText = site.name;
|
|
6002
|
-
$site.onclick = () => {
|
|
6003
|
-
this.closeEditor();
|
|
6004
|
-
this.closeAdd();
|
|
6005
|
-
setActive();
|
|
6006
|
-
this.showEditor(site, $site, $row);
|
|
6007
|
-
};
|
|
6008
|
-
if (this.activeSite === site.name) {
|
|
6009
|
-
setActive();
|
|
6010
|
-
}
|
|
6011
|
-
return $site;
|
|
6012
|
-
}
|
|
6013
|
-
showEditor(site, $site, $row) {
|
|
6014
|
-
this.activeSite = site.name;
|
|
6015
|
-
this.$editor = createElement(`
|
|
6016
|
-
<div class="atk-site-edit">
|
|
6017
|
-
<div class="atk-header">
|
|
6018
|
-
<div class="atk-site-info">
|
|
6019
|
-
<span class="atk-site-name"></span>
|
|
6020
|
-
<span class="atk-site-urls"></span>
|
|
6021
|
-
</div>
|
|
6022
|
-
<div class="atk-close-btn">
|
|
6023
|
-
<i class="atk-icon atk-icon-close"></i>
|
|
6024
|
-
</div>
|
|
6025
|
-
</div>
|
|
6026
|
-
<div class="atk-main">
|
|
6027
|
-
<div class="atk-site-text-actions">
|
|
6028
|
-
<div class="atk-item atk-rename-btn">\u91CD\u547D\u540D</div>
|
|
6029
|
-
<div class="atk-item atk-edit-url-btn">\u4FEE\u6539 URL</div>
|
|
6030
|
-
<!--<div class="atk-item atk-export-btn">\u5BFC\u51FA</div>
|
|
6031
|
-
<div class="atk-item atk-import-btn">\u5BFC\u5165</div>-->
|
|
6032
|
-
</div>
|
|
6033
|
-
<div class="atk-site-btn-actions">
|
|
6034
|
-
<div class="atk-item atk-del-btn">
|
|
6035
|
-
<i class="atk-icon atk-icon-del"></i>
|
|
6036
|
-
</div>
|
|
6037
|
-
</div>
|
|
6038
|
-
</div>
|
|
6039
|
-
</div>`);
|
|
6040
|
-
$row.before(this.$editor);
|
|
6041
|
-
const $siteName = this.$editor.querySelector(".atk-site-name");
|
|
6042
|
-
const $siteUrls = this.$editor.querySelector(".atk-site-urls");
|
|
6043
|
-
const $closeBtn = this.$editor.querySelector(".atk-close-btn");
|
|
6044
|
-
$closeBtn.onclick = () => this.closeEditor();
|
|
6045
|
-
const update = (s) => {
|
|
6046
|
-
var _a;
|
|
6047
|
-
site = s;
|
|
6048
|
-
$siteName.innerText = site.name;
|
|
6049
|
-
$siteName.onclick = () => {
|
|
6050
|
-
if (site.first_url)
|
|
6051
|
-
window.open(site.first_url);
|
|
6052
|
-
};
|
|
6053
|
-
$siteUrls.innerHTML = "";
|
|
6054
|
-
(_a = site.urls) == null ? void 0 : _a.forEach((u) => {
|
|
6055
|
-
const $item = createElement('<span class="atk-url-item"></span>');
|
|
6056
|
-
$siteUrls.append($item);
|
|
6057
|
-
$item.innerText = (u || "").replace(/\/$/, "");
|
|
6058
|
-
$item.onclick = () => {
|
|
6059
|
-
window.open(u);
|
|
6060
|
-
};
|
|
6061
|
-
});
|
|
6062
|
-
};
|
|
6063
|
-
update(site);
|
|
6064
|
-
const $main = this.$editor.querySelector(".atk-main");
|
|
6065
|
-
const $actions = this.$editor.querySelector(".atk-site-text-actions");
|
|
6066
|
-
const $renameBtn = $actions.querySelector(".atk-rename-btn");
|
|
6067
|
-
const $editUrlBtn = $actions.querySelector(".atk-edit-url-btn");
|
|
6068
|
-
const $delBtn = this.$editor.querySelector(".atk-del-btn");
|
|
6069
|
-
const showLoading$1 = () => {
|
|
6070
|
-
showLoading(this.$editor);
|
|
6071
|
-
};
|
|
6072
|
-
const hideLoading$1 = () => {
|
|
6073
|
-
hideLoading(this.$editor);
|
|
6074
|
-
};
|
|
6075
|
-
const showError = (msg) => {
|
|
6076
|
-
window.alert(msg);
|
|
6077
|
-
};
|
|
6078
|
-
const openTextEditor = (key) => {
|
|
6079
|
-
let initValue = site[key] || "";
|
|
6080
|
-
if (key === "urls")
|
|
6081
|
-
initValue = site.urls_raw || "";
|
|
6082
|
-
const textEditor = new ItemTextEditor({
|
|
6083
|
-
initValue,
|
|
6084
|
-
onYes: (val) => __async(this, null, function* () {
|
|
6085
|
-
showLoading(textEditor.$el);
|
|
6086
|
-
let s;
|
|
6087
|
-
try {
|
|
6088
|
-
s = yield new Api(this.ctx).siteEdit(__spreadProps(__spreadValues({}, site), { [key]: val }));
|
|
6089
|
-
} catch (err) {
|
|
6090
|
-
showError(`\u4FEE\u6539\u5931\u8D25\uFF1A${err.msg || "\u672A\u77E5\u9519\u8BEF"}`);
|
|
6091
|
-
console.error(err);
|
|
6092
|
-
return false;
|
|
6093
|
-
} finally {
|
|
6094
|
-
hideLoading(textEditor.$el);
|
|
6095
|
-
}
|
|
6096
|
-
$site.replaceWith(this.renderSite(s, $row));
|
|
6097
|
-
update(s);
|
|
6098
|
-
return true;
|
|
6099
|
-
})
|
|
6100
|
-
});
|
|
6101
|
-
textEditor.appendTo($main);
|
|
6102
|
-
};
|
|
6103
|
-
$renameBtn.onclick = () => openTextEditor("name");
|
|
6104
|
-
$editUrlBtn.onclick = () => openTextEditor("urls");
|
|
6105
|
-
$delBtn.onclick = () => {
|
|
6106
|
-
const del = () => __async(this, null, function* () {
|
|
6107
|
-
showLoading$1();
|
|
6108
|
-
try {
|
|
6109
|
-
yield new Api(this.ctx).siteDel(site.id, true);
|
|
6110
|
-
} catch (err) {
|
|
6111
|
-
console.log(err);
|
|
6112
|
-
showError(`\u5220\u9664\u5931\u8D25 ${String(err)}`);
|
|
6113
|
-
return;
|
|
6114
|
-
} finally {
|
|
6115
|
-
hideLoading$1();
|
|
6116
|
-
}
|
|
6117
|
-
this.closeEditor();
|
|
6118
|
-
$site.remove();
|
|
6119
|
-
this.sites = this.sites.filter((s) => s.name !== site.name);
|
|
6120
|
-
});
|
|
6121
|
-
if (window.confirm(`\u786E\u8BA4\u5220\u9664\u7AD9\u70B9 "${site.name}"\uFF1F\u5C06\u4F1A\u5220\u9664\u6240\u6709\u76F8\u5173\u6570\u636E`))
|
|
6122
|
-
del();
|
|
6123
|
-
};
|
|
6124
|
-
}
|
|
6125
|
-
closeEditor() {
|
|
6126
|
-
if (!this.$editor)
|
|
6127
|
-
return;
|
|
6128
|
-
this.$editor.remove();
|
|
6129
|
-
this.$rowsWrap.querySelectorAll(".atk-site-item").forEach((e) => e.classList.remove("atk-active"));
|
|
6130
|
-
this.activeSite = "";
|
|
6131
|
-
}
|
|
6132
|
-
showAdd() {
|
|
6133
|
-
this.closeAdd();
|
|
6134
|
-
this.$add = createElement(`
|
|
6135
|
-
<div class="atk-site-add">
|
|
6136
|
-
<div class="atk-header">
|
|
6137
|
-
<div class="atk-title">\u65B0\u589E\u7AD9\u70B9</div>
|
|
6138
|
-
<div class="atk-close-btn">
|
|
6139
|
-
<i class="atk-icon atk-icon-close"></i>
|
|
6140
|
-
</div>
|
|
6141
|
-
</div>
|
|
6142
|
-
<div class="atk-form">
|
|
6143
|
-
<input type="text" name="AtkSiteName" placeholder="\u7AD9\u70B9\u540D\u79F0" autocomplete="off">
|
|
6144
|
-
<input type="text" name="AtkSiteUrls" placeholder="\u7AD9\u70B9 URL\uFF08\u591A\u4E2A\u7528\u9017\u53F7\u9694\u5F00\uFF09" autocomplete="off">
|
|
6145
|
-
<button class="atk-btn" name="AtkSubmit">\u521B\u5EFA</button>
|
|
6146
|
-
</div>
|
|
6147
|
-
</div>`);
|
|
6148
|
-
this.$header.after(this.$add);
|
|
6149
|
-
const $closeBtn = this.$add.querySelector(".atk-close-btn");
|
|
6150
|
-
$closeBtn.onclick = () => this.closeAdd();
|
|
6151
|
-
const $siteName = this.$add.querySelector('[name="AtkSiteName"]');
|
|
6152
|
-
const $siteUrls = this.$add.querySelector('[name="AtkSiteUrls"]');
|
|
6153
|
-
const $submitBtn = this.$add.querySelector('[name="AtkSubmit"]');
|
|
6154
|
-
$submitBtn.onclick = () => __async(this, null, function* () {
|
|
6155
|
-
const siteName = $siteName.value.trim();
|
|
6156
|
-
const siteUrls = $siteUrls.value.trim();
|
|
6157
|
-
if (siteName === "") {
|
|
6158
|
-
$siteName.focus();
|
|
6159
|
-
return;
|
|
6160
|
-
}
|
|
6161
|
-
showLoading(this.$add);
|
|
6162
|
-
let s;
|
|
6163
|
-
try {
|
|
6164
|
-
s = yield new Api(this.ctx).siteAdd(siteName, siteUrls);
|
|
6165
|
-
} catch (err) {
|
|
6166
|
-
window.alert(`\u521B\u5EFA\u5931\u8D25\uFF1A${err.msg || ""}`);
|
|
6167
|
-
console.error(err);
|
|
6168
|
-
return;
|
|
6169
|
-
} finally {
|
|
6170
|
-
hideLoading(this.$add);
|
|
6171
|
-
}
|
|
6172
|
-
this.sites.push(s);
|
|
6173
|
-
this.loadSites(this.sites);
|
|
6174
|
-
this.closeAdd();
|
|
6175
|
-
});
|
|
6176
|
-
const keyDown = (evt) => {
|
|
6177
|
-
if (evt.key === "Enter") {
|
|
6178
|
-
$submitBtn.click();
|
|
6179
|
-
}
|
|
6180
|
-
};
|
|
6181
|
-
$siteName.onkeyup = (evt) => keyDown(evt);
|
|
6182
|
-
$siteUrls.onkeyup = (evt) => keyDown(evt);
|
|
6183
|
-
}
|
|
6184
|
-
closeAdd() {
|
|
6185
|
-
var _a;
|
|
6186
|
-
(_a = this.$add) == null ? void 0 : _a.remove();
|
|
6187
|
-
}
|
|
6188
|
-
}
|
|
6189
|
-
class SitesView extends SidebarView {
|
|
6190
|
-
constructor() {
|
|
6191
|
-
super(...arguments);
|
|
6192
|
-
__publicField(this, "viewTabs", {});
|
|
6193
|
-
__publicField(this, "viewActiveTab", "");
|
|
6194
|
-
__publicField(this, "siteList");
|
|
6195
|
-
}
|
|
6196
|
-
mount(siteName) {
|
|
6197
|
-
if (!this.siteList) {
|
|
6198
|
-
this.siteList = new SiteList(this.ctx);
|
|
6199
|
-
this.$el.append(this.siteList.$el);
|
|
6200
|
-
}
|
|
6201
|
-
this.reqSites();
|
|
6202
|
-
}
|
|
6203
|
-
switchTab(tab, siteName) {
|
|
6204
|
-
this.reqSites();
|
|
6205
|
-
}
|
|
6206
|
-
reqSites() {
|
|
6207
|
-
return __async(this, null, function* () {
|
|
6208
|
-
const sites = yield new Api(this.ctx).siteGet();
|
|
6209
|
-
this.siteList.loadSites(sites);
|
|
6210
|
-
});
|
|
6211
|
-
}
|
|
6212
|
-
}
|
|
6213
|
-
__publicField(SitesView, "viewName", "sites");
|
|
6214
|
-
__publicField(SitesView, "viewTitle", "\u7AD9\u70B9");
|
|
6215
|
-
__publicField(SitesView, "viewAdminOnly", true);
|
|
6216
|
-
class TransferView extends SidebarView {
|
|
6217
|
-
constructor() {
|
|
6218
|
-
super(...arguments);
|
|
6219
|
-
__publicField(this, "\xDF");
|
|
6220
|
-
__publicField(this, "viewTabs", {
|
|
6221
|
-
"import": "\u5BFC\u5165",
|
|
6222
|
-
"export": "\u5BFC\u51FA"
|
|
6223
|
-
});
|
|
6224
|
-
__publicField(this, "viewActiveTab", "import");
|
|
6225
|
-
}
|
|
6226
|
-
mount(siteName) {
|
|
6227
|
-
this.switchTab("import", siteName);
|
|
6228
|
-
}
|
|
6229
|
-
switchTab(tab, siteName) {
|
|
6230
|
-
if (tab === "import") {
|
|
6231
|
-
this.initImport();
|
|
6232
|
-
} else if (tab === "export") {
|
|
6233
|
-
this.initExport();
|
|
6234
|
-
return false;
|
|
6235
|
-
}
|
|
6236
|
-
return true;
|
|
6237
|
-
}
|
|
6238
|
-
initImport() {
|
|
6239
|
-
this.$el.innerHTML = `<div class="atk-log-wrap" style="display: none;">
|
|
6240
|
-
<div class="atk-log-back-btn">\u8FD4\u56DE</div>
|
|
6241
|
-
<div class="atk-log"></div>
|
|
6242
|
-
</div>
|
|
6243
|
-
<div class="atk-form">
|
|
6244
|
-
<div class="atk-label">\u6570\u636E\u7C7B\u578B</div>
|
|
6245
|
-
<select name="AtkDataType">
|
|
6246
|
-
<option value="artrans">Artrans (\u6570\u636E\u884C\u56CA)</option>
|
|
6247
|
-
<option value="artalk_v1">Artalk v1 (PHP \u65E7\u7248)</option>
|
|
6248
|
-
<option value="typecho">Typecho</option>
|
|
6249
|
-
<option value="wordpress">WordPress</option>
|
|
6250
|
-
<option value="disqus">Disqus</option>
|
|
6251
|
-
<option value="commento">Commento</option>
|
|
6252
|
-
<option value="valine">Valine</option>
|
|
6253
|
-
<option value="twikoo">Twikoo</option>
|
|
6254
|
-
</select>
|
|
6255
|
-
<div class="atk-label atk-data-file-label">\u6570\u636E\u6587\u4EF6</div>
|
|
6256
|
-
<input type="file" name="AtkDataFile" accept="text/plain,.json">
|
|
6257
|
-
<div class="atk-label">\u76EE\u6807\u7AD9\u70B9\u540D</div>
|
|
6258
|
-
<input type="text" name="AtkSiteName" placeholder="\u8F93\u5165\u5185\u5BB9..." autocomplete="off">
|
|
6259
|
-
<div class="atk-label">\u76EE\u6807\u7AD9\u70B9 URL</div>
|
|
6260
|
-
<input type="text" name="AtkSiteURL" placeholder="\u8F93\u5165\u5185\u5BB9..." autocomplete="off">
|
|
6261
|
-
<div class="atk-label">\u542F\u52A8\u53C2\u6570\uFF08\u53EF\u9009\uFF09</div>
|
|
6262
|
-
<textarea name="AtkPayload"></textarea>
|
|
6263
|
-
<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>
|
|
6264
|
-
<button class="atk-btn" name="AtkSubmit">\u5BFC\u5165</button>
|
|
6265
|
-
</div>`;
|
|
6266
|
-
const $form = this.$el.querySelector(".atk-form");
|
|
6267
|
-
const $dataType = $form.querySelector('[name="AtkDataType"]');
|
|
6268
|
-
const $dataFile = $form.querySelector('[name="AtkDataFile"]');
|
|
6269
|
-
const $dataFileLabel = $form.querySelector(".atk-data-file-label");
|
|
6270
|
-
const $siteName = $form.querySelector('[name="AtkSiteName"]');
|
|
6271
|
-
const $siteURL = $form.querySelector('[name="AtkSiteURL"]');
|
|
6272
|
-
const $payload = $form.querySelector('[name="AtkPayload"]');
|
|
6273
|
-
const $submitBtn = $form.querySelector('[name="AtkSubmit"]');
|
|
6274
|
-
const setError2 = (msg) => window.alert(msg);
|
|
6275
|
-
$dataType.onchange = () => {
|
|
6276
|
-
if (["typecho"].includes($dataType.value)) {
|
|
6277
|
-
$dataFile.style.display = "none";
|
|
6278
|
-
$dataFileLabel.style.display = "none";
|
|
6279
|
-
} else {
|
|
6280
|
-
$dataFile.style.display = "";
|
|
6281
|
-
$dataFileLabel.style.display = "";
|
|
6282
|
-
}
|
|
6283
|
-
};
|
|
6284
|
-
$submitBtn.onclick = () => {
|
|
6285
|
-
var _a;
|
|
6286
|
-
const dataType = $dataType.value.trim();
|
|
6287
|
-
const siteName = $siteName.value.trim();
|
|
6288
|
-
const siteURL = $siteURL.value.trim();
|
|
6289
|
-
const payload = $payload.value.trim();
|
|
6290
|
-
if (dataType === "") {
|
|
6291
|
-
setError2("\u8BF7\u9009\u62E9\u6570\u636E\u7C7B\u578B");
|
|
6292
|
-
return;
|
|
6293
|
-
}
|
|
6294
|
-
let rData = {};
|
|
6295
|
-
if (payload) {
|
|
6296
|
-
try {
|
|
6297
|
-
rData = JSON.parse(payload);
|
|
6298
|
-
} catch (err) {
|
|
6299
|
-
setError2(`Payload JSON \u683C\u5F0F\u6709\u8BEF\uFF1A${String(err)}`);
|
|
6300
|
-
return;
|
|
6301
|
-
}
|
|
6302
|
-
if (rData instanceof Object) {
|
|
6303
|
-
setError2(`Payload \u9700\u4E3A JSON \u5BF9\u8C61`);
|
|
6304
|
-
return;
|
|
6305
|
-
}
|
|
6306
|
-
}
|
|
6307
|
-
if (siteName)
|
|
6308
|
-
rData.t_name = siteName;
|
|
6309
|
-
if (siteURL)
|
|
6310
|
-
rData.t_url = siteURL;
|
|
6311
|
-
const createSession = (dataStr) => {
|
|
6312
|
-
const $logWrap = this.$el.querySelector(".atk-log-wrap");
|
|
6313
|
-
const $log = $logWrap.querySelector(".atk-log");
|
|
6314
|
-
const $backBtn = this.$el.querySelector(".atk-log-back-btn");
|
|
6315
|
-
$logWrap.style.display = "";
|
|
6316
|
-
$form.style.display = "none";
|
|
6317
|
-
$backBtn.onclick = () => {
|
|
6318
|
-
$logWrap.style.display = "none";
|
|
6319
|
-
$form.style.display = "";
|
|
6320
|
-
};
|
|
6321
|
-
if (dataStr)
|
|
6322
|
-
rData.json_data = dataStr;
|
|
6323
|
-
const frameName = `f_${+new Date()}`;
|
|
6324
|
-
const $frame = document.createElement("iframe");
|
|
6325
|
-
$frame.className = "atk-iframe";
|
|
6326
|
-
$frame.name = frameName;
|
|
6327
|
-
$log.innerHTML = "";
|
|
6328
|
-
$log.append($frame);
|
|
6329
|
-
const formParams = {
|
|
6330
|
-
type: dataType,
|
|
6331
|
-
payload: JSON.stringify(rData),
|
|
6332
|
-
token: this.ctx.user.data.token || ""
|
|
6333
|
-
};
|
|
6334
|
-
const $formTmp = document.createElement("form");
|
|
6335
|
-
$formTmp.style.display = "none";
|
|
6336
|
-
$formTmp.setAttribute("method", "post");
|
|
6337
|
-
$formTmp.setAttribute("action", `${this.ctx.conf.server}/admin/import`);
|
|
6338
|
-
$formTmp.setAttribute("target", frameName);
|
|
6339
|
-
Object.entries(formParams).forEach(([key, val]) => {
|
|
6340
|
-
const $inputTmp = document.createElement("input");
|
|
6341
|
-
$inputTmp.setAttribute("type", "hidden");
|
|
6342
|
-
$inputTmp.setAttribute("name", key);
|
|
6343
|
-
$inputTmp.value = val;
|
|
6344
|
-
$formTmp.appendChild($inputTmp);
|
|
5591
|
+
}],
|
|
5592
|
+
["\u6700\u70ED", () => {
|
|
5593
|
+
reloadUseParamsEditor((p) => {
|
|
5594
|
+
p.sort_by = "vote";
|
|
6345
5595
|
});
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
5596
|
+
}],
|
|
5597
|
+
["\u6700\u65E9", () => {
|
|
5598
|
+
reloadUseParamsEditor((p) => {
|
|
5599
|
+
p.sort_by = "date_asc";
|
|
5600
|
+
});
|
|
5601
|
+
}],
|
|
5602
|
+
["\u4F5C\u8005", () => {
|
|
5603
|
+
reloadUseParamsEditor((p) => {
|
|
5604
|
+
p.view_only_admin = true;
|
|
5605
|
+
});
|
|
5606
|
+
}]
|
|
5607
|
+
];
|
|
5608
|
+
let curtActive = 0;
|
|
5609
|
+
const onItemClick = (i, $item, name, action) => {
|
|
5610
|
+
action();
|
|
5611
|
+
curtActive = i;
|
|
5612
|
+
$dropdown.querySelectorAll(".active").forEach((e) => {
|
|
5613
|
+
e.classList.remove("active");
|
|
5614
|
+
});
|
|
5615
|
+
$item.classList.add("active");
|
|
5616
|
+
$dropdown.style.display = "none";
|
|
5617
|
+
setTimeout(() => {
|
|
5618
|
+
$dropdown.style.display = "";
|
|
5619
|
+
}, 80);
|
|
6360
5620
|
};
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
window.alert(`${String(err)}`);
|
|
6371
|
-
return;
|
|
6372
|
-
} finally {
|
|
6373
|
-
hideLoading(this.$el);
|
|
6374
|
-
}
|
|
6375
|
-
});
|
|
6376
|
-
}
|
|
6377
|
-
download(filename, text) {
|
|
6378
|
-
const el = document.createElement("a");
|
|
6379
|
-
el.setAttribute("href", `data:text/json;charset=utf-8,${encodeURIComponent(text)}`);
|
|
6380
|
-
el.setAttribute("download", filename);
|
|
6381
|
-
el.style.display = "none";
|
|
6382
|
-
document.body.appendChild(el);
|
|
6383
|
-
el.click();
|
|
6384
|
-
document.body.removeChild(el);
|
|
6385
|
-
}
|
|
6386
|
-
getYmdHisFilename() {
|
|
6387
|
-
const date = new Date();
|
|
6388
|
-
const year = date.getFullYear();
|
|
6389
|
-
const month = date.getMonth() + 1;
|
|
6390
|
-
const day = date.getDate();
|
|
6391
|
-
const hours = date.getHours();
|
|
6392
|
-
const minutes = date.getMinutes();
|
|
6393
|
-
const seconds = date.getSeconds();
|
|
6394
|
-
return `${year}${month}${day}-${hours}${padWithZeros(minutes, 2)}${padWithZeros(seconds, 2)}`;
|
|
6395
|
-
}
|
|
6396
|
-
}
|
|
6397
|
-
__publicField(TransferView, "viewName", "transfer");
|
|
6398
|
-
__publicField(TransferView, "viewTitle", "\u8FC1\u79FB");
|
|
6399
|
-
__publicField(TransferView, "viewAdminOnly", true);
|
|
6400
|
-
class SiteListFloater {
|
|
6401
|
-
constructor(ctx, conf) {
|
|
6402
|
-
__publicField(this, "ctx");
|
|
6403
|
-
__publicField(this, "conf");
|
|
6404
|
-
__publicField(this, "$el");
|
|
6405
|
-
__publicField(this, "sites", []);
|
|
6406
|
-
__publicField(this, "$sites");
|
|
6407
|
-
__publicField(this, "outsideChecker");
|
|
6408
|
-
this.ctx = ctx;
|
|
6409
|
-
this.conf = conf;
|
|
6410
|
-
this.$el = createElement(`<div class="atk-site-list-floater" style="display: none;">
|
|
6411
|
-
<div class="atk-sites"></div>
|
|
6412
|
-
</div>`);
|
|
6413
|
-
this.$sites = this.$el.querySelector(".atk-sites");
|
|
6414
|
-
}
|
|
6415
|
-
load(selectedSite) {
|
|
6416
|
-
return __async(this, null, function* () {
|
|
6417
|
-
this.$sites.innerHTML = "";
|
|
6418
|
-
const renderSiteItem = (siteName, siteLogo, siteTarget, onclick) => {
|
|
6419
|
-
const $site = createElement(`<div class="atk-site-item">
|
|
6420
|
-
<div class="atk-site-logo"></div>
|
|
6421
|
-
<div class="atk-site-name"></div>
|
|
6422
|
-
</div>`);
|
|
6423
|
-
$site.onclick = !onclick ? () => this.switch(siteTarget || siteName) : () => onclick();
|
|
6424
|
-
$site.setAttribute("data-name", siteTarget || siteName);
|
|
6425
|
-
const $siteLogo = $site.querySelector(".atk-site-logo");
|
|
6426
|
-
const $siteName = $site.querySelector(".atk-site-name");
|
|
6427
|
-
$siteLogo.innerText = siteLogo;
|
|
6428
|
-
$siteName.innerText = siteName;
|
|
6429
|
-
if (selectedSite === (siteTarget || siteName))
|
|
6430
|
-
$site.classList.add("atk-active");
|
|
6431
|
-
this.$sites.append($site);
|
|
5621
|
+
const $dropdown = createElement(`<ul class="atk-dropdown atk-fade-in"></ul>`);
|
|
5622
|
+
dropdownList.forEach((item, i) => {
|
|
5623
|
+
const name = item[0];
|
|
5624
|
+
const action = item[1];
|
|
5625
|
+
const $item = createElement(`<li class="atk-dropdown-item"><span></span></li>`);
|
|
5626
|
+
const $link = $item.querySelector("span");
|
|
5627
|
+
$link.innerText = name;
|
|
5628
|
+
$link.onclick = () => {
|
|
5629
|
+
onItemClick(i, $item, name, action);
|
|
6432
5630
|
};
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
renderSiteItem(site.name, site.name.substr(0, 1));
|
|
6437
|
-
});
|
|
6438
|
-
renderSiteItem("\u7AD9\u70B9\u7BA1\u7406", "+", "", () => {
|
|
6439
|
-
this.conf.onClickSitesViewBtn();
|
|
6440
|
-
this.hide();
|
|
6441
|
-
});
|
|
6442
|
-
});
|
|
6443
|
-
}
|
|
6444
|
-
switch(siteName) {
|
|
6445
|
-
if (this.conf.onSwitchSite(siteName) === false) {
|
|
6446
|
-
return;
|
|
6447
|
-
}
|
|
6448
|
-
this.$sites.querySelectorAll(".atk-site-item").forEach((e) => {
|
|
6449
|
-
if (e.getAttribute("data-name") !== siteName) {
|
|
6450
|
-
e.classList.remove("atk-active");
|
|
6451
|
-
} else {
|
|
6452
|
-
e.classList.add("atk-active");
|
|
6453
|
-
}
|
|
5631
|
+
$dropdown.append($item);
|
|
5632
|
+
if (i === curtActive)
|
|
5633
|
+
$item.classList.add("active");
|
|
6454
5634
|
});
|
|
6455
|
-
this.
|
|
6456
|
-
}
|
|
6457
|
-
show($trigger) {
|
|
6458
|
-
this.$el.style.display = "";
|
|
6459
|
-
if ($trigger) {
|
|
6460
|
-
this.outsideChecker = (evt) => {
|
|
6461
|
-
const isClickInside = $trigger.contains(evt.target) || this.$el.contains(evt.target);
|
|
6462
|
-
if (!isClickInside) {
|
|
6463
|
-
this.hide();
|
|
6464
|
-
}
|
|
6465
|
-
};
|
|
6466
|
-
document.addEventListener("click", this.outsideChecker);
|
|
6467
|
-
}
|
|
6468
|
-
}
|
|
6469
|
-
hide() {
|
|
6470
|
-
this.$el.style.display = "none";
|
|
6471
|
-
if (this.outsideChecker)
|
|
6472
|
-
document.removeEventListener("click", this.outsideChecker);
|
|
5635
|
+
this.$dropdownWrap.append($dropdown);
|
|
6473
5636
|
}
|
|
6474
5637
|
}
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
PagesView,
|
|
6479
|
-
SitesView,
|
|
6480
|
-
TransferView
|
|
6481
|
-
];
|
|
6482
|
-
class Sidebar extends Component {
|
|
5638
|
+
var sidebarLayer = "";
|
|
5639
|
+
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';
|
|
5640
|
+
class SidebarLayer extends Component {
|
|
6483
5641
|
constructor(ctx) {
|
|
6484
5642
|
super(ctx);
|
|
6485
5643
|
__publicField(this, "layer");
|
|
6486
5644
|
__publicField(this, "$header");
|
|
6487
|
-
__publicField(this, "$headerMenu");
|
|
6488
|
-
__publicField(this, "$title");
|
|
6489
|
-
__publicField(this, "$avatar");
|
|
6490
|
-
__publicField(this, "$siteLogo");
|
|
6491
5645
|
__publicField(this, "$closeBtn");
|
|
6492
|
-
__publicField(this, "$
|
|
6493
|
-
__publicField(this, "$
|
|
6494
|
-
__publicField(this, "$curtViewBtnIcon");
|
|
6495
|
-
__publicField(this, "$curtViewBtnText");
|
|
6496
|
-
__publicField(this, "$navTabs");
|
|
6497
|
-
__publicField(this, "$navViews");
|
|
6498
|
-
__publicField(this, "$viewWrap");
|
|
6499
|
-
__publicField(this, "siteSwitcher");
|
|
6500
|
-
__publicField(this, "curtSite");
|
|
6501
|
-
__publicField(this, "curtView", DEFAULT_VIEW);
|
|
6502
|
-
__publicField(this, "curtTab");
|
|
6503
|
-
__publicField(this, "viewInstances", {});
|
|
6504
|
-
__publicField(this, "viewSwitcherShow", false);
|
|
5646
|
+
__publicField(this, "$iframeWrap");
|
|
5647
|
+
__publicField(this, "$iframe");
|
|
6505
5648
|
__publicField(this, "firstShow", true);
|
|
5649
|
+
__publicField(this, "loadingTimer", null);
|
|
6506
5650
|
this.$el = createElement(SidebarHTML);
|
|
6507
5651
|
this.$header = this.$el.querySelector(".atk-sidebar-header");
|
|
6508
|
-
this.$headerMenu = this.$header.querySelector(".atk-menu");
|
|
6509
|
-
this.$title = this.$header.querySelector(".atk-sidebar-title");
|
|
6510
|
-
this.$avatar = this.$header.querySelector(".atk-avatar");
|
|
6511
5652
|
this.$closeBtn = this.$header.querySelector(".atk-sidebar-close");
|
|
6512
|
-
this.$
|
|
6513
|
-
this.$curtViewBtn = this.$nav.querySelector(".akt-curt-view-btn");
|
|
6514
|
-
this.$curtViewBtnIcon = this.$curtViewBtn.querySelector(".atk-icon");
|
|
6515
|
-
this.$curtViewBtnText = this.$curtViewBtn.querySelector(".atk-text");
|
|
6516
|
-
this.$navTabs = this.$nav.querySelector(".atk-tabs");
|
|
6517
|
-
this.$navViews = this.$nav.querySelector(".atk-views");
|
|
6518
|
-
this.$viewWrap = this.$el.querySelector(".atk-sidebar-view-wrap");
|
|
6519
|
-
this.initViewSwitcher();
|
|
5653
|
+
this.$iframeWrap = this.$el.querySelector(".atk-sidebar-iframe-wrap");
|
|
6520
5654
|
this.$closeBtn.onclick = () => {
|
|
6521
5655
|
this.hide();
|
|
6522
5656
|
};
|
|
@@ -6526,111 +5660,36 @@ class Sidebar extends Component {
|
|
|
6526
5660
|
this.firstShow = true;
|
|
6527
5661
|
});
|
|
6528
5662
|
}
|
|
6529
|
-
get isAdmin() {
|
|
6530
|
-
return this.ctx.user.data.isAdmin;
|
|
6531
|
-
}
|
|
6532
|
-
get curtViewInstance() {
|
|
6533
|
-
return this.curtView ? this.viewInstances[this.curtView] : void 0;
|
|
6534
|
-
}
|
|
6535
|
-
initViewSwitcher() {
|
|
6536
|
-
this.$curtViewBtn.onclick = () => {
|
|
6537
|
-
this.toggleViewSwitcher();
|
|
6538
|
-
};
|
|
6539
|
-
this.$navViews.innerHTML = "";
|
|
6540
|
-
REGISTER_VIEWS.forEach((view) => {
|
|
6541
|
-
const $item = createElement(`<div class="atk-tab-item"></div>`);
|
|
6542
|
-
this.$navViews.append($item);
|
|
6543
|
-
$item.setAttribute("data-name", view.viewName);
|
|
6544
|
-
$item.innerText = view.viewTitle;
|
|
6545
|
-
if (view.viewName === this.curtView) {
|
|
6546
|
-
$item.classList.add("atk-active");
|
|
6547
|
-
this.$curtViewBtnText.innerText = view.viewTitle;
|
|
6548
|
-
}
|
|
6549
|
-
$item.onclick = () => {
|
|
6550
|
-
this.switchView(view.viewName);
|
|
6551
|
-
this.toggleViewSwitcher();
|
|
6552
|
-
};
|
|
6553
|
-
});
|
|
6554
|
-
}
|
|
6555
|
-
toggleViewSwitcher() {
|
|
6556
|
-
if (!this.viewSwitcherShow) {
|
|
6557
|
-
this.$navViews.style.display = "";
|
|
6558
|
-
this.$navTabs.style.display = "none";
|
|
6559
|
-
this.$curtViewBtnIcon.classList.add("atk-arrow");
|
|
6560
|
-
} else {
|
|
6561
|
-
this.$navViews.style.display = "none";
|
|
6562
|
-
this.$navTabs.style.display = "";
|
|
6563
|
-
this.$curtViewBtnIcon.classList.remove("atk-arrow");
|
|
6564
|
-
}
|
|
6565
|
-
this.viewSwitcherShow = !this.viewSwitcherShow;
|
|
6566
|
-
}
|
|
6567
5663
|
show() {
|
|
6568
5664
|
return __async(this, null, function* () {
|
|
6569
5665
|
this.$el.style.transform = "";
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
this.ctx.
|
|
6574
|
-
|
|
6575
|
-
|
|
5666
|
+
if (this.layer == null) {
|
|
5667
|
+
this.layer = new Layer(this.ctx, "sidebar", this.$el);
|
|
5668
|
+
this.layer.afterHide = () => {
|
|
5669
|
+
if (this.ctx.conf.editorTravel === true) {
|
|
5670
|
+
this.ctx.trigger("editor-travel-back");
|
|
5671
|
+
}
|
|
5672
|
+
};
|
|
5673
|
+
}
|
|
6576
5674
|
this.layer.show();
|
|
6577
|
-
this.$viewWrap.scrollTo(0, 0);
|
|
6578
5675
|
setTimeout(() => {
|
|
6579
5676
|
this.$el.style.transform = "translate(0, 0)";
|
|
6580
5677
|
}, 20);
|
|
6581
5678
|
if (this.firstShow) {
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
this.switchSite(siteName);
|
|
6589
|
-
},
|
|
6590
|
-
onClickSitesViewBtn: () => {
|
|
6591
|
-
this.switchView("sites");
|
|
6592
|
-
}
|
|
6593
|
-
});
|
|
6594
|
-
this.$viewWrap.before(this.siteSwitcher.$el);
|
|
6595
|
-
this.$avatar.onclick = (evt) => {
|
|
6596
|
-
var _a;
|
|
6597
|
-
if (!this.isAdmin)
|
|
6598
|
-
return;
|
|
6599
|
-
(_a = this.siteSwitcher) == null ? void 0 : _a.show(evt.target);
|
|
6600
|
-
};
|
|
6601
|
-
}
|
|
6602
|
-
this.curtSite = this.conf.site;
|
|
6603
|
-
showLoading(this.$el);
|
|
6604
|
-
try {
|
|
6605
|
-
yield this.siteSwitcher.load(this.curtSite);
|
|
6606
|
-
} catch (err) {
|
|
6607
|
-
const $err = createElement(`<span>\u52A0\u8F7D\u5931\u8D25\uFF1A${err.msg || "\u7F51\u7EDC\u9519\u8BEF"}<br/></span>`);
|
|
6608
|
-
const $retryBtn = createElement('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');
|
|
6609
|
-
$err.appendChild($retryBtn);
|
|
6610
|
-
$retryBtn.onclick = () => {
|
|
6611
|
-
setError(this.$el, null);
|
|
6612
|
-
this.show();
|
|
6613
|
-
};
|
|
6614
|
-
setError(this.$el, $err);
|
|
6615
|
-
return;
|
|
6616
|
-
} finally {
|
|
6617
|
-
hideLoading(this.$el);
|
|
6618
|
-
}
|
|
6619
|
-
this.$avatar.innerHTML = "";
|
|
6620
|
-
this.$siteLogo = createElement('<div class="atk-site-logo"></div>');
|
|
6621
|
-
this.$siteLogo.innerText = (this.curtSite || "").substr(0, 1);
|
|
6622
|
-
this.$avatar.append(this.$siteLogo);
|
|
6623
|
-
} else {
|
|
6624
|
-
this.$title.innerText = "\u901A\u77E5\u4E2D\u5FC3";
|
|
6625
|
-
this.$curtViewBtn.style.display = "none";
|
|
6626
|
-
this.curtSite = this.conf.site;
|
|
6627
|
-
const $avatarImg = document.createElement("img");
|
|
6628
|
-
$avatarImg.src = getGravatarURL(this.ctx, MD5(this.ctx.user.data.email.toLowerCase()));
|
|
6629
|
-
this.$avatar.innerHTML = "";
|
|
6630
|
-
this.$avatar.append($avatarImg);
|
|
6631
|
-
}
|
|
6632
|
-
this.switchView(DEFAULT_VIEW);
|
|
5679
|
+
this.$iframeWrap.innerHTML = "";
|
|
5680
|
+
this.$iframe = createElement("<iframe></iframe>");
|
|
5681
|
+
const baseURL = `${this.conf.server.replace(/\/$/, "")}/../sidebar/`;
|
|
5682
|
+
const userData = encodeURIComponent(JSON.stringify(this.ctx.user.data));
|
|
5683
|
+
this.iframeLoad(`${baseURL}?pageKey=${encodeURIComponent(this.conf.pageKey)}&site=${encodeURIComponent(this.conf.site || "")}&user=${userData}${this.conf.darkMode ? `&darkMode=1` : ``}`);
|
|
5684
|
+
this.$iframeWrap.append(this.$iframe);
|
|
6633
5685
|
this.firstShow = false;
|
|
5686
|
+
} else {
|
|
5687
|
+
if (this.conf.darkMode && !this.$iframe.src.match(/darkMode=1$/)) {
|
|
5688
|
+
this.iframeLoad(`${this.$iframe.src}&darkMode=1`);
|
|
5689
|
+
}
|
|
5690
|
+
if (!this.conf.darkMode && this.$iframe.src.match(/darkMode=1$/)) {
|
|
5691
|
+
this.iframeLoad(this.$iframe.src.replace(/&darkMode=1$/, ""));
|
|
5692
|
+
}
|
|
6634
5693
|
}
|
|
6635
5694
|
});
|
|
6636
5695
|
}
|
|
@@ -6639,58 +5698,39 @@ class Sidebar extends Component {
|
|
|
6639
5698
|
this.$el.style.transform = "";
|
|
6640
5699
|
(_a = this.layer) == null ? void 0 : _a.hide();
|
|
6641
5700
|
}
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
this
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
Object.entries(view.viewTabs).forEach(([tabName, label]) => {
|
|
6672
|
-
const $tab = createElement(`<div class="atk-tab-item"></div>`);
|
|
6673
|
-
this.$navTabs.append($tab);
|
|
6674
|
-
$tab.innerText = label;
|
|
6675
|
-
if (view.viewActiveTab === tabName)
|
|
6676
|
-
$tab.classList.add("atk-active");
|
|
6677
|
-
$tab.onclick = () => {
|
|
6678
|
-
if (view.switchTab(tabName, this.curtSite) === false) {
|
|
6679
|
-
return;
|
|
5701
|
+
iframeLoad(src) {
|
|
5702
|
+
if (!this.$iframe)
|
|
5703
|
+
return;
|
|
5704
|
+
this.$iframe.src = src;
|
|
5705
|
+
showLoading(this.$iframeWrap);
|
|
5706
|
+
this.$iframe.onload = () => {
|
|
5707
|
+
hideLoading(this.$iframeWrap);
|
|
5708
|
+
};
|
|
5709
|
+
}
|
|
5710
|
+
checkReqStatus(url) {
|
|
5711
|
+
return __async(this, null, function* () {
|
|
5712
|
+
if (this.loadingTimer !== null)
|
|
5713
|
+
window.clearTimeout(this.loadingTimer);
|
|
5714
|
+
this.loadingTimer = window.setTimeout(() => __async(this, null, function* () {
|
|
5715
|
+
try {
|
|
5716
|
+
yield fetch(url);
|
|
5717
|
+
} catch (err) {
|
|
5718
|
+
console.log(err);
|
|
5719
|
+
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>`);
|
|
5720
|
+
const $reloadBtn = $errAlert.querySelector("#AtkReload");
|
|
5721
|
+
const $cancelBtn = $errAlert.querySelector("#AtkCancel");
|
|
5722
|
+
$reloadBtn.onclick = () => {
|
|
5723
|
+
this.iframeLoad(url);
|
|
5724
|
+
$errAlert.remove();
|
|
5725
|
+
};
|
|
5726
|
+
$cancelBtn.onclick = () => {
|
|
5727
|
+
$errAlert.remove();
|
|
5728
|
+
};
|
|
5729
|
+
this.$iframeWrap.append($errAlert);
|
|
6680
5730
|
}
|
|
6681
|
-
|
|
6682
|
-
$tab.classList.add("atk-active");
|
|
6683
|
-
this.curtTab = tabName;
|
|
6684
|
-
};
|
|
5731
|
+
}), 2e3);
|
|
6685
5732
|
});
|
|
6686
5733
|
}
|
|
6687
|
-
switchSite(siteName) {
|
|
6688
|
-
this.curtSite = siteName;
|
|
6689
|
-
const curtView = this.curtViewInstance;
|
|
6690
|
-
curtView == null ? void 0 : curtView.switchTab(this.curtTab, siteName);
|
|
6691
|
-
if (this.$siteLogo)
|
|
6692
|
-
this.$siteLogo.innerText = this.curtSite.substr(0, 1);
|
|
6693
|
-
}
|
|
6694
5734
|
}
|
|
6695
5735
|
const _Artalk = class {
|
|
6696
5736
|
constructor(customConf) {
|
|
@@ -6700,7 +5740,7 @@ const _Artalk = class {
|
|
|
6700
5740
|
__publicField(this, "checkerLauncher");
|
|
6701
5741
|
__publicField(this, "editor");
|
|
6702
5742
|
__publicField(this, "list");
|
|
6703
|
-
__publicField(this, "
|
|
5743
|
+
__publicField(this, "sidebarLayer");
|
|
6704
5744
|
this.conf = __spreadValues(__spreadValues({}, _Artalk.defaults), customConf);
|
|
6705
5745
|
this.conf.server = this.conf.server.replace(/\/$/, "");
|
|
6706
5746
|
if (!this.conf.pageKey) {
|
|
@@ -6724,10 +5764,11 @@ const _Artalk = class {
|
|
|
6724
5764
|
this.$root.appendChild(this.editor.$el);
|
|
6725
5765
|
this.list = new List(this.ctx);
|
|
6726
5766
|
this.$root.appendChild(this.list.$el);
|
|
6727
|
-
this.
|
|
6728
|
-
this.$root.appendChild(this.
|
|
5767
|
+
this.sidebarLayer = new SidebarLayer(this.ctx);
|
|
5768
|
+
this.$root.appendChild(this.sidebarLayer.$el);
|
|
6729
5769
|
this.list.fetchComments(0);
|
|
6730
5770
|
this.initEventBind();
|
|
5771
|
+
this.initPV();
|
|
6731
5772
|
}
|
|
6732
5773
|
initEventBind() {
|
|
6733
5774
|
window.addEventListener("hashchange", () => {
|
|
@@ -6739,6 +5780,9 @@ const _Artalk = class {
|
|
|
6739
5780
|
const { $wrap: $layerWrap } = GetLayerWrap(this.ctx);
|
|
6740
5781
|
if ($layerWrap)
|
|
6741
5782
|
$layerWrap.querySelectorAll(`[atk-only-admin-show]`).forEach((item) => items.push(item));
|
|
5783
|
+
const $sidebarEl = document.querySelector(".atk-sidebar");
|
|
5784
|
+
if ($sidebarEl)
|
|
5785
|
+
$sidebarEl.querySelectorAll(`[atk-only-admin-show]`).forEach((item) => items.push(item));
|
|
6742
5786
|
items.forEach(($item) => {
|
|
6743
5787
|
if (this.ctx.user.data.isAdmin)
|
|
6744
5788
|
$item.classList.remove("atk-hide");
|
|
@@ -6774,6 +5818,17 @@ const _Artalk = class {
|
|
|
6774
5818
|
this.ctx.conf.darkMode = darkMode;
|
|
6775
5819
|
this.initDarkMode();
|
|
6776
5820
|
}
|
|
5821
|
+
initPV() {
|
|
5822
|
+
return __async(this, null, function* () {
|
|
5823
|
+
if (!this.conf.pvEl || !document.querySelector(this.conf.pvEl))
|
|
5824
|
+
return;
|
|
5825
|
+
const $pv = document.querySelector(this.conf.pvEl);
|
|
5826
|
+
const pvNum = yield new Api(this.ctx).pv();
|
|
5827
|
+
if (Number.isNaN(Number(pvNum)))
|
|
5828
|
+
return;
|
|
5829
|
+
$pv.innerText = String(pvNum);
|
|
5830
|
+
});
|
|
5831
|
+
}
|
|
6777
5832
|
on(name, handler) {
|
|
6778
5833
|
this.ctx.on(name, handler, "external");
|
|
6779
5834
|
}
|