hexo-theme-stellar 1.8.0 → 1.10.0
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/_config.yml +85 -22
- package/languages/en.yml +0 -5
- package/languages/zh-CN.yml +0 -5
- package/languages/zh-TW.yml +0 -5
- package/layout/404.ejs +1 -1
- package/layout/_partial/cover/post_cover.ejs +25 -3
- package/layout/_partial/head.ejs +11 -0
- package/layout/_partial/main/footer.ejs +6 -17
- package/layout/_partial/main/header/index.ejs +1 -1
- package/layout/_partial/plugins/comments/giscus/layout.ejs +39 -0
- package/layout/_partial/plugins/comments/giscus/script.ejs +26 -0
- package/layout/_partial/plugins/comments/layout.ejs +1 -1
- package/layout/_partial/plugins/comments/valine/script.ejs +1 -1
- package/layout/_partial/scripts/index.ejs +5 -3
- package/layout/_partial/sidebar/index.ejs +3 -1
- package/layout/_partial/sidebar/widgets/ghuser.ejs +59 -0
- package/layout/_partial/sidebar/widgets/repo_info.ejs +28 -9
- package/layout/mathjax.ejs +29 -0
- package/layout/page.ejs +1 -1
- package/layout/post.ejs +4 -1
- package/layout/wiki.ejs +1 -1
- package/package.json +1 -1
- package/scripts/tags/about.js +12 -13
- package/scripts/tags/friends.js +2 -3
- package/scripts/tags/ghcard.js +2 -2
- package/scripts/tags/index.js +3 -0
- package/scripts/tags/lib/users.js +22 -0
- package/scripts/tags/sites.js +2 -3
- package/scripts/tags/timeline.js +30 -25
- package/source/css/_common/base.styl +2 -0
- package/source/css/_common/button.styl +1 -1
- package/source/css/_common/cap.styl +1 -0
- package/source/css/_common/device.styl +2 -2
- package/source/css/_common/highlight.styl +18 -6
- package/source/css/_common/html.styl +2 -0
- package/source/css/_common/loading.styl +5 -0
- package/source/css/_common/pre.styl +6 -0
- package/source/css/_custom.styl +17 -1
- package/source/css/_defines/const.styl +1 -0
- package/source/css/_defines/theme.styl +1 -1
- package/source/css/_layout/layout.styl +2 -2
- package/source/css/_layout/main.styl +3 -3
- package/source/css/_layout/md.styl +39 -13
- package/source/css/_layout/partial/article-footer.styl +0 -2
- package/source/css/_layout/partial/footer.styl +4 -2
- package/source/css/_layout/partial/navbar.styl +1 -1
- package/source/css/_layout/partial/paginator.styl +4 -0
- package/source/css/_layout/partial/related.styl +3 -0
- package/source/css/_layout/sidebar/ghuser.styl +80 -0
- package/source/css/_layout/sidebar/repo_info.styl +4 -1
- package/source/css/_layout/sidebar/sidebar.styl +3 -4
- package/source/css/_layout/tag-plugins/about.styl +13 -16
- package/source/css/_layout/tag-plugins/common.styl +1 -1
- package/source/css/_layout/tag-plugins/folding.styl +2 -0
- package/source/css/_layout/tag-plugins/friends.styl +3 -6
- package/source/css/_layout/tag-plugins/inline-labels.styl +1 -0
- package/source/css/_layout/tag-plugins/link.styl +2 -1
- package/source/css/_layout/tag-plugins/note.styl +8 -0
- package/source/css/_layout/tag-plugins/sites.styl +2 -6
- package/source/css/_layout/tag-plugins/tabs.styl +5 -0
- package/source/css/_layout/tag-plugins/timeline.styl +85 -2
- package/source/css/_layout/tag-plugins/toc.styl +1 -1
- package/source/css/_plugins/comments/utterances.styl +3 -0
- package/source/css/_plugins/comments/waline.styl +61 -0
- package/source/css/_plugins/index.styl +2 -0
- package/source/js/main.js +13 -15
- package/source/js/plugins/friends.js +5 -5
- package/source/js/plugins/ghinfo.js +73 -0
- package/source/js/plugins/sites.js +1 -1
- package/source/js/plugins/timeline.js +122 -0
|
@@ -20,9 +20,12 @@
|
|
|
20
20
|
padding: 0.5rem .5rem
|
|
21
21
|
font-size: $fs-13
|
|
22
22
|
justify-content: space-between
|
|
23
|
-
flex-direction: row-reverse
|
|
24
23
|
svg
|
|
25
24
|
width: 1em
|
|
26
25
|
height: 1em
|
|
26
|
+
margin-left: 4px
|
|
27
|
+
div
|
|
28
|
+
display: flex
|
|
29
|
+
align-items: center
|
|
27
30
|
a:hover
|
|
28
31
|
background: var(--block-hover)
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
padding: var(--gap-l)
|
|
7
7
|
padding-top: "calc(2 * %s)" % var(--gap-l)
|
|
8
8
|
height: "calc(100vh - 3 * %s)" % var(--gap-l)
|
|
9
|
-
@media screen and (max-width: $device-
|
|
9
|
+
@media screen and (max-width: $device-mobile-max)
|
|
10
10
|
padding-top: "calc(1 * %s)" % var(--gap-l)
|
|
11
11
|
height: "calc(100% - 2 * %s)" % var(--gap-l)
|
|
12
12
|
|
|
13
13
|
.l_left[layout=wiki]
|
|
14
14
|
padding-bottom: 0
|
|
15
15
|
height: "calc(100vh - 2 * %s)" % var(--gap-l)
|
|
16
|
-
@media screen and (max-width: $device-
|
|
16
|
+
@media screen and (max-width: $device-mobile-max)
|
|
17
17
|
height: "calc(100% - 1 * %s)" % var(--gap-l)
|
|
18
18
|
.widgets >:last-child
|
|
19
19
|
margin-bottom: 6rem
|
|
@@ -149,6 +149,7 @@ nav.menu
|
|
|
149
149
|
.l_left .widgets
|
|
150
150
|
overflow: scroll
|
|
151
151
|
flex-grow: 1
|
|
152
|
+
scrollbar-width: none
|
|
152
153
|
scrollbar(0, 0)
|
|
153
154
|
z-index: 1
|
|
154
155
|
.widget-wrap
|
|
@@ -188,8 +189,6 @@ nav.menu
|
|
|
188
189
|
margin-top: .5em
|
|
189
190
|
margin-bottom: .5em
|
|
190
191
|
line-height: 1.5
|
|
191
|
-
>a:hover
|
|
192
|
-
text-decoration: underline
|
|
193
192
|
.widget-header+.widget-body
|
|
194
193
|
margin-top: 0
|
|
195
194
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
.tag-plugin.about
|
|
2
2
|
background: var(--block)
|
|
3
|
-
border-radius: $border-
|
|
3
|
+
border-radius: $border-card
|
|
4
4
|
padding: 2rem
|
|
5
5
|
.about-header
|
|
6
6
|
display flex
|
|
7
|
-
|
|
8
|
-
justify-content: space-between
|
|
7
|
+
justify-content: center
|
|
9
8
|
flex-wrap: wrap
|
|
9
|
+
margin: 1.5rem 0 3rem
|
|
10
10
|
img
|
|
11
11
|
object-fit: contain
|
|
12
12
|
>img
|
|
@@ -28,28 +28,25 @@
|
|
|
28
28
|
>p
|
|
29
29
|
line-height: 1.5
|
|
30
30
|
.tag-plugin.navbar:last-child
|
|
31
|
+
text-align: center
|
|
31
32
|
nav.cap
|
|
32
33
|
margin-top: 1rem
|
|
34
|
+
background: var(--card)
|
|
35
|
+
box-shadow: $boxshadow-button
|
|
33
36
|
a
|
|
34
|
-
|
|
35
|
-
color: $color-link
|
|
36
|
-
background: var(--block-hover)
|
|
37
|
-
&.active
|
|
38
|
-
background: none
|
|
37
|
+
color: var(--text-p2)
|
|
39
38
|
&:hover
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
background: var(--block)
|
|
40
|
+
&.active
|
|
41
|
+
background: var(--block)
|
|
42
|
+
box-shadow: none
|
|
44
43
|
.about-header+.about-body
|
|
45
44
|
margin-top: 1.5rem
|
|
46
45
|
|
|
47
46
|
@media screen and (max-width: $device-mobile)
|
|
48
47
|
.tag-plugin.about
|
|
49
|
-
padding: 1rem
|
|
48
|
+
padding: 1.5rem 1rem
|
|
50
49
|
.about-header
|
|
51
|
-
|
|
52
|
-
.avatar
|
|
53
|
-
margin: 1rem auto
|
|
50
|
+
margin: 2.5rem 0 3rem
|
|
54
51
|
p
|
|
55
52
|
width 100%
|
|
@@ -15,12 +15,9 @@
|
|
|
15
15
|
align-items: stretch
|
|
16
16
|
&+.group-header
|
|
17
17
|
margin-top: 2rem
|
|
18
|
-
.
|
|
18
|
+
.stellar-friends-api
|
|
19
19
|
display: block
|
|
20
|
-
|
|
21
|
-
min-height: 50px
|
|
22
|
-
margin: 2rem 0
|
|
23
|
-
text-align: center
|
|
20
|
+
|
|
24
21
|
|
|
25
22
|
.users-wrap .user-card
|
|
26
23
|
flex-shrink: 1
|
|
@@ -33,7 +30,7 @@
|
|
|
33
30
|
width: 16.66%
|
|
34
31
|
@media screen and (max-width: 820px)
|
|
35
32
|
width: 20%
|
|
36
|
-
@media screen and (max-width: $device-
|
|
33
|
+
@media screen and (max-width: $device-mobile-max)
|
|
37
34
|
width: 16.66%
|
|
38
35
|
@media screen and (max-width: $device-mobile)
|
|
39
36
|
width: 25%
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
margin: 1em auto
|
|
4
4
|
display: flex
|
|
5
5
|
justify-content: center
|
|
6
|
-
@media screen and (max-width: $device-mobile-
|
|
6
|
+
@media screen and (max-width: $device-mobile-425)
|
|
7
7
|
width: 100%
|
|
8
8
|
|
|
9
9
|
.md .link-card
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
flex-direction: column
|
|
33
33
|
align-items: stretch
|
|
34
34
|
width: 400px
|
|
35
|
+
text-align: justify
|
|
35
36
|
|
|
36
37
|
.md .link-card
|
|
37
38
|
line-height: 1.2
|
|
@@ -11,12 +11,8 @@
|
|
|
11
11
|
width: 100%
|
|
12
12
|
&+.group-header
|
|
13
13
|
margin-top: 2rem
|
|
14
|
-
.
|
|
14
|
+
.stellar-sites-api
|
|
15
15
|
display: block
|
|
16
|
-
.loading-wrap
|
|
17
|
-
min-height: 50px
|
|
18
|
-
margin: 2rem 0
|
|
19
|
-
text-align: center
|
|
20
16
|
|
|
21
17
|
.sites-wrap .group-body
|
|
22
18
|
display: grid
|
|
@@ -26,7 +22,7 @@
|
|
|
26
22
|
grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 1rem)
|
|
27
23
|
@media screen and (max-width: 900px)
|
|
28
24
|
grid-template-columns: repeat(auto-fill, "calc((100% - 1 * %s) / 2)" % 1rem)
|
|
29
|
-
@media screen and (max-width: $device-
|
|
25
|
+
@media screen and (max-width: $device-mobile-max)
|
|
30
26
|
grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 1rem)
|
|
31
27
|
@media screen and (max-width: $device-mobile)
|
|
32
28
|
grid-template-columns: repeat(auto-fill, "calc((100% - 1 * %s) / 2)" % 1rem)
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
.tag-plugin.timeline
|
|
1
|
+
.md .tag-plugin.folding .body:has(.timeline)
|
|
2
|
+
background: var(--site-bg)
|
|
3
|
+
|
|
4
|
+
.md .tag-plugin.timeline
|
|
2
5
|
position: relative
|
|
3
|
-
margin:
|
|
6
|
+
margin-top: 0
|
|
4
7
|
padding-left: 16px
|
|
5
8
|
&:before
|
|
6
9
|
content: ''
|
|
@@ -12,6 +15,10 @@
|
|
|
12
15
|
border-radius: 8px
|
|
13
16
|
top: .5rem
|
|
14
17
|
bottom: 0
|
|
18
|
+
&:has(.loading-wrap)
|
|
19
|
+
padding-left: 0
|
|
20
|
+
&:before
|
|
21
|
+
display: none
|
|
15
22
|
|
|
16
23
|
.tag-plugin.timeline .timenode
|
|
17
24
|
position: relative
|
|
@@ -45,6 +52,7 @@
|
|
|
45
52
|
color: var(--text-p3)
|
|
46
53
|
font-family: $ff-code
|
|
47
54
|
trans1 color
|
|
55
|
+
opacity: 0.75
|
|
48
56
|
a
|
|
49
57
|
color: inherit
|
|
50
58
|
font-weight: inherit
|
|
@@ -74,3 +82,78 @@
|
|
|
74
82
|
margin: .5rem 0
|
|
75
83
|
.tag-plugin.copy
|
|
76
84
|
width: 240px
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
.tag-plugin.timeline.stellar-timeline-api .body
|
|
88
|
+
max-height: convert(hexo-config('tag_plugins.timeline.max-height'))
|
|
89
|
+
overflow: scroll
|
|
90
|
+
p
|
|
91
|
+
font-size: $fs-14
|
|
92
|
+
p.title
|
|
93
|
+
font-size: 1rem
|
|
94
|
+
font-weight: 500
|
|
95
|
+
margin: 0
|
|
96
|
+
padding: 0.5rem 0 0.75rem
|
|
97
|
+
line-height: 1.25
|
|
98
|
+
border-bottom: 1px dashed var(--block-border)
|
|
99
|
+
pre code
|
|
100
|
+
font-size: $fs-12
|
|
101
|
+
|
|
102
|
+
.tag-plugin.timeline.stellar-timeline-api .body .footer
|
|
103
|
+
padding: 0.5rem 0 1rem
|
|
104
|
+
margin-bottom: -0.5rem
|
|
105
|
+
user-select: none
|
|
106
|
+
font-weight: 500
|
|
107
|
+
display: flex
|
|
108
|
+
flex-wrap: wrap
|
|
109
|
+
justify-content: space-between
|
|
110
|
+
align-items: stretch
|
|
111
|
+
position: sticky
|
|
112
|
+
position: -webkit-sticky
|
|
113
|
+
bottom: -0.5rem
|
|
114
|
+
background: var(--card)
|
|
115
|
+
span
|
|
116
|
+
line-height: 1.8
|
|
117
|
+
&:empty
|
|
118
|
+
display: none
|
|
119
|
+
a.comments
|
|
120
|
+
margin-right: 0
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
.tag-plugin.timeline.stellar-timeline-api .body .footer .flex
|
|
124
|
+
display: flex
|
|
125
|
+
flex-wrap: wrap
|
|
126
|
+
font-size: $fs-12
|
|
127
|
+
align-items: stretch
|
|
128
|
+
.reaction
|
|
129
|
+
border-color: var(--block)
|
|
130
|
+
border-style: dashed
|
|
131
|
+
.item
|
|
132
|
+
border-width: 1px
|
|
133
|
+
border-style: solid
|
|
134
|
+
margin: 2px
|
|
135
|
+
border-radius: 4px
|
|
136
|
+
padding: 0 0.5rem
|
|
137
|
+
display: flex
|
|
138
|
+
align-items: center
|
|
139
|
+
&.comments
|
|
140
|
+
border-width: 0
|
|
141
|
+
&:first-child
|
|
142
|
+
margin-left: 0
|
|
143
|
+
&:last-child
|
|
144
|
+
margin-right: 0
|
|
145
|
+
.key
|
|
146
|
+
margin-right: 4px
|
|
147
|
+
|
|
148
|
+
.tag-plugin.timeline.stellar-timeline-api .body .footer a.comments
|
|
149
|
+
border-radius: 4px
|
|
150
|
+
padding: 0 0.5rem
|
|
151
|
+
color: white
|
|
152
|
+
trans1: all
|
|
153
|
+
margin-left: 2px
|
|
154
|
+
background: $color-theme
|
|
155
|
+
.key
|
|
156
|
+
margin-right: 4px
|
|
157
|
+
&:hover
|
|
158
|
+
background: $color-hover
|
|
159
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.cmt-body.waline
|
|
2
|
+
--waline-font-size: 0.9375rem;
|
|
3
|
+
/* 常规颜色 */
|
|
4
|
+
--waline-white: #fff;
|
|
5
|
+
--waline-light-grey: #999;
|
|
6
|
+
--waline-dark-grey: #666;
|
|
7
|
+
/* 主题色 */
|
|
8
|
+
--waline-theme-color: #3498db;
|
|
9
|
+
--waline-active-color: #2ecc71;
|
|
10
|
+
/* 布局颜色 */
|
|
11
|
+
--waline-color: #444;
|
|
12
|
+
--waline-bgcolor: #fff;
|
|
13
|
+
--waline-bgcolor-light: #f8f8f8;
|
|
14
|
+
--waline-bgcolor-hover: #f0f0f0;
|
|
15
|
+
--waline-border-color: #ddd;
|
|
16
|
+
--waline-disable-bgcolor: #f8f8f8;
|
|
17
|
+
--waline-disable-color: #bbb;
|
|
18
|
+
--waline-code-bgcolor: #282c34;
|
|
19
|
+
/* 特殊颜色 */
|
|
20
|
+
--waline-bq-color: #f0f0f0;
|
|
21
|
+
/* 头像 */
|
|
22
|
+
--waline-avatar-size: 3.25rem;
|
|
23
|
+
--waline-m-avatar-size: calc(var(--waline-avatar-size) * 9 / 13);
|
|
24
|
+
/* 徽章 */
|
|
25
|
+
--waline-badge-color: #3498db;
|
|
26
|
+
--waline-badge-font-size: 0.725em;
|
|
27
|
+
/* 信息 */
|
|
28
|
+
--waline-info-bgcolor: #f8f8f8;
|
|
29
|
+
--waline-info-color: #999;
|
|
30
|
+
--waline-info-font-size: 0.725em;
|
|
31
|
+
/* 渲染选择 */
|
|
32
|
+
--waline-border: 1px solid var(--waline-border-color);
|
|
33
|
+
--waline-avatar-radius: 50%;
|
|
34
|
+
--waline-box-shadow: none;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@media (prefers-color-scheme: dark)
|
|
38
|
+
--waline-white: #000;
|
|
39
|
+
--waline-light-grey: #666;
|
|
40
|
+
--waline-dark-grey: #999;
|
|
41
|
+
/* 布局颜色 */
|
|
42
|
+
|
|
43
|
+
--waline-color: #fff;
|
|
44
|
+
--waline-bgcolor: var(--block);
|
|
45
|
+
--waline-bgcolor-light: #272727;
|
|
46
|
+
--waline-border-color: #333;
|
|
47
|
+
--waline-disable-bgcolor: #444;
|
|
48
|
+
--waline-disable-color: #272727;
|
|
49
|
+
/* 特殊颜色 */
|
|
50
|
+
--waline-bq-color: #272727;
|
|
51
|
+
/* 其他颜色 */
|
|
52
|
+
--waline-info-bgcolor: #272727;
|
|
53
|
+
--waline-info-color: #666;
|
|
54
|
+
|
|
55
|
+
.wl-count
|
|
56
|
+
@media (prefers-color-scheme: dark)
|
|
57
|
+
padding: .375em;
|
|
58
|
+
font-weight: bold;
|
|
59
|
+
font-size: 1.25em;
|
|
60
|
+
color: #fff;
|
|
61
|
+
|
package/source/js/main.js
CHANGED
|
@@ -213,21 +213,19 @@ if (stellar.plugins.lazyload) {
|
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
//
|
|
217
|
-
if (stellar.plugins.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
stellar.loadScript(stellar.plugins.friendsjs, { defer: true })
|
|
230
|
-
})
|
|
216
|
+
// stellar js
|
|
217
|
+
if (stellar.plugins.stellar) {
|
|
218
|
+
for (let key of Object.keys(stellar.plugins.stellar)) {
|
|
219
|
+
let js = stellar.plugins.stellar[key];
|
|
220
|
+
const els = document.getElementsByClassName('stellar-' + key + '-api');
|
|
221
|
+
if (els != undefined && els.length > 0) {
|
|
222
|
+
stellar.jQuery(() => {
|
|
223
|
+
stellar.loadScript(js, { defer: true });
|
|
224
|
+
if (key == 'timeline') {
|
|
225
|
+
stellar.loadScript(stellar.plugins.marked);
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
}
|
|
231
229
|
}
|
|
232
230
|
}
|
|
233
231
|
|
|
@@ -47,13 +47,13 @@ const friendsjs = {
|
|
|
47
47
|
$(el).append('<div class="loading-wrap"><svg class="loading" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2709"><path d="M832 512c0-176-144-320-320-320V128c211.2 0 384 172.8 384 384h-64zM192 512c0 176 144 320 320 320v64C300.8 896 128 723.2 128 512h64z" p-id="2710"></path></svg><p></p></div>');
|
|
48
48
|
friendsjs.requestAPI(cfg.api, function(data) {
|
|
49
49
|
$(el).find('.loading-wrap').remove();
|
|
50
|
-
const arr = data.content;
|
|
50
|
+
const arr = data.content || data;
|
|
51
51
|
arr.forEach((item, i) => {
|
|
52
52
|
var user = '<div class="user-card">';
|
|
53
53
|
user += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer"';
|
|
54
|
-
user += ' href="' + item.url + '">';
|
|
55
|
-
user += '<img src="' + (item.avatar || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';">';
|
|
56
|
-
user += '<div class="name"><span>' + item.title + '</span></div>';
|
|
54
|
+
user += ' href="' + (item.html_url || item.url) + '">';
|
|
55
|
+
user += '<img src="' + (item.avatar_url || item.avatar || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';">';
|
|
56
|
+
user += '<div class="name"><span>' + (item.title || item.login) + '</span></div>';
|
|
57
57
|
user += '</a>';
|
|
58
58
|
user += '</div>';
|
|
59
59
|
$(el).find('.group-body').append(user);
|
|
@@ -66,7 +66,7 @@ const friendsjs = {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
$(function () {
|
|
69
|
-
const els = document.getElementsByClassName('
|
|
69
|
+
const els = document.getElementsByClassName('stellar-friends-api');
|
|
70
70
|
for (var i = 0; i < els.length; i++) {
|
|
71
71
|
const el = els[i];
|
|
72
72
|
const api = el.getAttribute('api');
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const GitHubInfo = {
|
|
2
|
+
requestAPI: (url, callback, timeout) => {
|
|
3
|
+
let retryTimes = 5;
|
|
4
|
+
function request() {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
let status = 0; // 0 等待 1 完成 2 超时
|
|
7
|
+
let timer = setTimeout(() => {
|
|
8
|
+
if (status === 0) {
|
|
9
|
+
status = 2;
|
|
10
|
+
timer = null;
|
|
11
|
+
reject('请求超时');
|
|
12
|
+
if (retryTimes == 0) {
|
|
13
|
+
timeout();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}, 5000);
|
|
17
|
+
fetch(url).then(function(response) {
|
|
18
|
+
if (status !== 2) {
|
|
19
|
+
clearTimeout(timer);
|
|
20
|
+
resolve(response);
|
|
21
|
+
timer = null;
|
|
22
|
+
status = 1;
|
|
23
|
+
}
|
|
24
|
+
if (response.ok) {
|
|
25
|
+
return response.json();
|
|
26
|
+
}
|
|
27
|
+
throw new Error('Network response was not ok.');
|
|
28
|
+
}).then(function(data) {
|
|
29
|
+
retryTimes = 0;
|
|
30
|
+
callback(data);
|
|
31
|
+
}).catch(function(error) {
|
|
32
|
+
if (retryTimes > 0) {
|
|
33
|
+
retryTimes -= 1;
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
request();
|
|
36
|
+
}, 5000);
|
|
37
|
+
} else {
|
|
38
|
+
timeout();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
request();
|
|
44
|
+
},
|
|
45
|
+
layout: (cfg) => {
|
|
46
|
+
const el = $(cfg.el)[0];
|
|
47
|
+
GitHubInfo.requestAPI(cfg.api, function(data) {
|
|
48
|
+
const arr = data.content || data;
|
|
49
|
+
for (let key of Object.keys(data)) {
|
|
50
|
+
$(el).find("[type=text]#" + key).text(data[key]);
|
|
51
|
+
$(el).find("[type=link]#" + key).attr("href", data[key]);
|
|
52
|
+
$(el).find("[type=img]#" + key).attr("src", data[key]);
|
|
53
|
+
}
|
|
54
|
+
}, function() {
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
$(function () {
|
|
60
|
+
const els = document.getElementsByClassName('stellar-ghinfo-api');
|
|
61
|
+
for (var i = 0; i < els.length; i++) {
|
|
62
|
+
const el = els[i];
|
|
63
|
+
const api = el.getAttribute('api');
|
|
64
|
+
if (api == null) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
var cfg = new Object();
|
|
68
|
+
cfg.el = el;
|
|
69
|
+
cfg.api = api;
|
|
70
|
+
cfg.class = el.getAttribute('class');
|
|
71
|
+
GitHubInfo.layout(cfg);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
@@ -69,7 +69,7 @@ const sitesjs = {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
$(function () {
|
|
72
|
-
const els = document.getElementsByClassName('
|
|
72
|
+
const els = document.getElementsByClassName('stellar-sites-api');
|
|
73
73
|
for (var i = 0; i < els.length; i++) {
|
|
74
74
|
const el = els[i];
|
|
75
75
|
const api = el.getAttribute('api');
|