vuepress-plugin-twikoo 1.0.13 → 1.0.14
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/Comment.vue +9 -5
- package/package.json +2 -3
package/Comment.vue
CHANGED
|
@@ -37,7 +37,8 @@ export default {
|
|
|
37
37
|
...this.$frontmatter
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const targetContainer = document.querySelector(TWIKOO_CONTAINER);
|
|
40
|
+
const targetContainer = this.moveContainerWithRetry(() => document.querySelector(TWIKOO_CONTAINER));
|
|
41
|
+
|
|
41
42
|
if (!this.needComment(frontmatter) || !targetContainer) {
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
@@ -51,7 +52,7 @@ export default {
|
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
// 尝试移动评论容器(带重试机制)
|
|
54
|
-
this.moveContainerWithRetry();
|
|
55
|
+
this.moveContainerWithRetry(() => this.moveContainer());
|
|
55
56
|
|
|
56
57
|
},
|
|
57
58
|
|
|
@@ -71,16 +72,19 @@ export default {
|
|
|
71
72
|
},
|
|
72
73
|
|
|
73
74
|
// 带重试机制的移动逻辑(解决异步 DOM 生成问题)
|
|
74
|
-
moveContainerWithRetry(maxRetries = 5, interval = 100) {
|
|
75
|
+
moveContainerWithRetry(maxRetries = 5, interval = 100, func) {
|
|
75
76
|
let retries = 0;
|
|
76
77
|
|
|
77
78
|
const retry = () => {
|
|
78
|
-
const success =
|
|
79
|
+
const success = func();
|
|
79
80
|
retries++;
|
|
80
81
|
|
|
82
|
+
if (!success) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
// 移动成功 或 达到最大重试次数,终止重试
|
|
82
87
|
if (success || retries >= maxRetries) {
|
|
83
|
-
if(!success) console.error('Twikoo 评论容器移动失败,最大重试次数已达');
|
|
84
88
|
return;
|
|
85
89
|
}
|
|
86
90
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuepress-plugin-twikoo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Twikoo comment plugin for vuepress 1.x",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
"publish": "npm publish"
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
8
|
|
|
10
9
|
},
|
|
11
10
|
"repository": {
|