Skip to content

Commit ee9e237

Browse files
committed
fix: gitalk cannot login; feat: manifest
1 parent f3be5c0 commit ee9e237

File tree

17 files changed

+237
-81
lines changed

17 files changed

+237
-81
lines changed

docs/.vuepress/components/MySWUpdatePopup.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default {
2121
@keyframes drop {
2222
0% {
2323
top: -20px;
24-
oapcity: 0;
24+
opacity: 0;
2525
}
2626
2727
100% {
@@ -52,8 +52,6 @@ export default {
5252
5353
.my-sw-update-popup button {
5454
background-color: #4db6ac;
55-
-moz-border-radius: 28px;
56-
-webkit-border-radius: 28px;
5755
border-radius: 28px;
5856
border: 1px solid #18ab29;
5957
display: inline-block;
@@ -62,7 +60,7 @@ export default {
6260
font-family: Arial;
6361
font-size: 16px;
6462
margin: 12px 50px;
65-
padding:13px 30px;
63+
padding: 13px 30px;
6664
text-decoration: none;
6765
text-shadow: 0px 1px 0px #2f6627;
6866
}

docs/.vuepress/enhanceApp.js

Lines changed: 16 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,24 @@
11
/*
22
* @Author: Rainy
33
* @Date: 2019-12-01 14:25:59
4-
* @LastEditors: Rainy
5-
* @LastEditTime: 2019-12-05 20:38:59
4+
* @LastEditors : Rainy
5+
* @LastEditTime : 2020-02-07 12:53:01
66
*/
77

8-
function tryRun (fn, times = 3) {
9-
let execCount = 1;
10-
fn(next);
11-
function next(delay) {
12-
if (execCount >= times) {
13-
return;
14-
}
15-
setTimeout(() => {
16-
execCount += 1
17-
fn(next)
18-
}, delay);
19-
}
20-
}
21-
22-
function integrateGitalk(router) {
23-
const linkGitalk = document.createElement('link');
24-
linkGitalk.href = 'https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css';
25-
linkGitalk.rel = 'stylesheet';
26-
document.body.appendChild(linkGitalk);
27-
const scriptGitalk = document.createElement('script');
28-
scriptGitalk.src = 'https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js';
29-
document.body.appendChild(scriptGitalk);
8+
// import copy from './utils/copy';
9+
import getGitalk from './utils/getGitalk';
3010

31-
router.afterEach((to, from) => {
32-
33-
if (scriptGitalk.onload) {
34-
loadGitalk(to);
35-
} else {
36-
scriptGitalk.onload = () => {
37-
loadGitalk(to);
38-
};
11+
export default ({ Vue, options, router, siteData }) => {
12+
setTimeout(() => {
13+
try {
14+
//对document的判断是防止编译的时候报错
15+
document &&
16+
(() => {
17+
getGitalk({ router });
18+
// copy();
19+
})();
20+
} catch (e) {
21+
console.error(e.message);
3922
}
40-
});
41-
42-
function loadGitalk(to) {
43-
let commentsContainer = document.getElementById('gitalk-container');
44-
if (!commentsContainer) {
45-
commentsContainer = document.createElement('div');
46-
commentsContainer.id = 'gitalk-container';
47-
commentsContainer.classList.add('content');
48-
}
49-
const $page = document.querySelector('.page');
50-
if ($page) {
51-
$page.appendChild(commentsContainer);
52-
if (typeof Gitalk !== 'undefined' && Gitalk instanceof Function) {
53-
renderGitalk(to.fullPath);
54-
}
55-
}
56-
}
57-
function renderGitalk(fullPath) {
58-
const gitalk = new Gitalk({
59-
clientID: '58efa883d352424befd3',
60-
clientSecret: 'faf0e2d7ff9355b3692d605d698f7abcbbd43388',
61-
repo: 'https://github.com/Rain120/awesome-javascript-code-implementation',
62-
owner: 'rain120',
63-
admin: ['rain120'],
64-
id: window.location.pathname || fullPath || 'comment',
65-
distractionFreeMode: false,
66-
language: 'zh-CN'
67-
});
68-
gitalk.render('gitalk-container');
69-
}
70-
}
71-
72-
export default ({ Vue, options, router }) => {
73-
try {
74-
document && integrateGitalk(router);
75-
} catch (e) {
76-
console.error(e.message);
77-
}
23+
}, 500);
7824
};
13.4 KB
Loading
15.9 KB
Loading
16.8 KB
Loading
22.9 KB
Loading
13.6 KB
Loading
13.6 KB
Loading
5.98 KB
Loading

0 commit comments

Comments
 (0)