hexo-theme-volantis 4.3.1 → 5.0.0-alpha.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/README.md +6 -4
  2. package/_config.yml +599 -246
  3. package/languages/en.yml +7 -0
  4. package/languages/zh-CN.yml +13 -2
  5. package/languages/zh-TW.yml +7 -0
  6. package/layout/404.ejs +1 -1
  7. package/layout/_meta/author.ejs +4 -4
  8. package/layout/_meta/category.ejs +11 -8
  9. package/layout/_meta/counter.ejs +29 -7
  10. package/layout/_meta/date.ejs +1 -1
  11. package/layout/_meta/music.ejs +1 -1
  12. package/layout/_meta/share.ejs +1 -1
  13. package/layout/_meta/tags.ejs +3 -0
  14. package/layout/_meta/thumbnail.ejs +3 -1
  15. package/layout/_meta/updated.ejs +1 -1
  16. package/layout/_meta/walinecount.ejs +2 -1
  17. package/layout/{_cover → _partial/_cover}/blank.ejs +0 -0
  18. package/layout/{_cover → _partial/_cover}/dock.ejs +1 -1
  19. package/layout/{_cover → _partial/_cover}/featured.ejs +1 -1
  20. package/layout/{_cover → _partial/_cover}/focus.ejs +1 -1
  21. package/layout/_partial/_cover/layout.ejs +8 -0
  22. package/layout/{_cover → _partial/_cover}/search.ejs +2 -2
  23. package/layout/_partial/archive.ejs +2 -2
  24. package/layout/_partial/article.ejs +21 -16
  25. package/layout/_partial/categories.ejs +1 -1
  26. package/layout/_partial/cover.ejs +8 -28
  27. package/layout/_partial/footer.ejs +19 -11
  28. package/layout/_partial/head.ejs +70 -116
  29. package/layout/_partial/header.ejs +17 -11
  30. package/layout/_partial/meta.ejs +18 -4
  31. package/layout/_partial/post.ejs +35 -9
  32. package/layout/_partial/scripts/_ctrl/cdnCtrl.ejs +126 -0
  33. package/layout/_partial/scripts/{coverCtrl.ejs → _ctrl/coverCtrl.ejs} +17 -25
  34. package/layout/_partial/scripts/_ctrl.ejs +2 -0
  35. package/layout/_partial/scripts/content-visibility-scroll-fix.ejs +88 -0
  36. package/layout/_partial/scripts/global.ejs +422 -109
  37. package/layout/_partial/scripts/index.ejs +91 -46
  38. package/layout/_partial/scripts/toc.ejs +98 -68
  39. package/layout/_partial/side.ejs +4 -1
  40. package/layout/_plugins/_page_plugins/artitalk/index.ejs +15 -0
  41. package/layout/_plugins/_page_plugins/bbtalk/index.ejs +10 -0
  42. package/layout/_plugins/_page_plugins/fcircle/index.ejs +12 -0
  43. package/layout/_plugins/_page_plugins/gitter/index.ejs +14 -0
  44. package/layout/_plugins/_page_plugins/indent/index.ejs +16 -0
  45. package/layout/_plugins/_page_plugins/index.ejs +27 -0
  46. package/layout/_plugins/_page_plugins/katex/index.ejs +13 -0
  47. package/layout/{_third-party/math/mathjax/script.ejs → _plugins/_page_plugins/mathjax/index.ejs} +2 -2
  48. package/layout/_plugins/_page_plugins/snackbar/index.ejs +55 -0
  49. package/layout/{_partial/scripts/counter.ejs → _plugins/analytics/LCCounter.ejs} +0 -0
  50. package/layout/{_third-party → _plugins}/analytics/script.ejs +43 -5
  51. package/layout/{_third-party → _plugins}/aplayer/layout.ejs +0 -0
  52. package/layout/_plugins/aplayer/script.ejs +74 -0
  53. package/layout/_plugins/chat/gitter/script.ejs +17 -0
  54. package/layout/_plugins/chat/index.ejs +1 -0
  55. package/layout/_plugins/chat/tidio/script.ejs +1 -0
  56. package/layout/_plugins/comments/artalk/script.ejs +59 -0
  57. package/layout/_plugins/comments/beaudar/script.ejs +61 -0
  58. package/layout/_plugins/comments/discuss/script.ejs +30 -0
  59. package/layout/_plugins/comments/disqus/script.ejs +98 -0
  60. package/layout/_plugins/comments/disqusjs/script.ejs +35 -0
  61. package/layout/_plugins/comments/giscus/script.ejs +47 -0
  62. package/layout/_plugins/comments/gitalk/script.ejs +24 -0
  63. package/layout/_plugins/comments/hashover/script.ejs +5 -0
  64. package/layout/{_third-party → _plugins}/comments/index.ejs +10 -3
  65. package/layout/_plugins/comments/isso/script.ejs +27 -0
  66. package/layout/_plugins/comments/livere/script.ejs +15 -0
  67. package/layout/_plugins/comments/twikoo/script.ejs +40 -0
  68. package/layout/_plugins/comments/utterances/script.ejs +43 -0
  69. package/layout/_plugins/comments/vssue/script.ejs +37 -0
  70. package/layout/_plugins/comments/waline/script.ejs +62 -0
  71. package/layout/_plugins/comments/z-custom/script.ejs +1 -0
  72. package/layout/_plugins/darkmode/script.ejs +114 -0
  73. package/layout/{_third-party → _plugins}/end-of-support/script.ejs +25 -8
  74. package/layout/_plugins/github-api/script.ejs +27 -0
  75. package/layout/_plugins/highlight/highlightjs/script.ejs +26 -0
  76. package/layout/_plugins/highlight/prismjs/script.ejs +25 -0
  77. package/layout/_plugins/highlight/script.ejs +1 -0
  78. package/layout/{_third-party → _plugins}/lazyload/script.ejs +1 -1
  79. package/layout/{_third-party → _plugins}/nodewaves/script.ejs +1 -1
  80. package/layout/_plugins/parallax/script.ejs +74 -0
  81. package/layout/{_third-party → _plugins}/pjax/animate.ejs +31 -31
  82. package/layout/_plugins/pjax/index.ejs +73 -0
  83. package/layout/_plugins/pjax/pdata.ejs +56 -0
  84. package/layout/{_third-party → _plugins}/preload/script.ejs +3 -3
  85. package/layout/_plugins/rightmenu/layout.ejs +119 -0
  86. package/layout/_plugins/rightmenus/layout.ejs +137 -0
  87. package/layout/_plugins/scrollreveal/script.ejs +25 -0
  88. package/layout/_plugins/search/script.ejs +50 -0
  89. package/layout/{_third-party → _plugins}/share/layout.ejs +0 -0
  90. package/layout/_plugins/swiper/script.ejs +37 -0
  91. package/layout/_pre.ejs +2 -2
  92. package/layout/_widget/_pre.ejs +5 -0
  93. package/layout/_widget/blogger.ejs +1 -1
  94. package/layout/_widget/category.ejs +2 -2
  95. package/layout/_widget/copyright.ejs +1 -1
  96. package/layout/_widget/grid.ejs +3 -3
  97. package/layout/_widget/lastupdate.ejs +27 -0
  98. package/layout/_widget/list.ejs +2 -2
  99. package/layout/_widget/load.ejs +18 -0
  100. package/layout/_widget/music.ejs +3 -2
  101. package/layout/_widget/page.ejs +1 -1
  102. package/layout/_widget/qrcode.ejs +1 -1
  103. package/layout/_widget/related_posts.ejs +1 -1
  104. package/layout/_widget/tagcloud.ejs +1 -1
  105. package/layout/_widget/text.ejs +1 -1
  106. package/layout/_widget/toc.ejs +6 -2
  107. package/layout/_widget/webinfo.ejs +13 -76
  108. package/layout/archive.ejs +4 -4
  109. package/layout/category.ejs +9 -4
  110. package/layout/docs.ejs +1 -1
  111. package/layout/friends.ejs +6 -25
  112. package/layout/index.ejs +1 -1
  113. package/layout/layout.ejs +30 -12
  114. package/layout/list.ejs +1 -1
  115. package/layout/page.ejs +1 -1
  116. package/layout/post.ejs +1 -1
  117. package/layout/tag.ejs +8 -3
  118. package/package.json +5 -3
  119. package/scripts/events/index.js +13 -0
  120. package/scripts/events/lib/check-configuration.js +43 -0
  121. package/scripts/events/lib/check-environment.js +74 -0
  122. package/scripts/events/lib/config.js +34 -9
  123. package/scripts/events/lib/render-stylus.js +78 -0
  124. package/scripts/events/lib/stellar-tag-utils.js +76 -0
  125. package/scripts/filters/content-visibility.js +25 -0
  126. package/scripts/{render → filters}/img.js +0 -0
  127. package/scripts/filters/replace.js +15 -0
  128. package/scripts/{z-lazyload/lib/process.js → filters/z-lazyload.js} +6 -3
  129. package/scripts/helpers/custom-files.js +165 -0
  130. package/scripts/helpers/first-style.js +19 -0
  131. package/scripts/helpers/head/autoCanonical.js +15 -0
  132. package/scripts/helpers/head/generate_preload_fontfamily.js +22 -0
  133. package/scripts/helpers/head/generate_seo.js +24 -0
  134. package/scripts/helpers/head/generate_title__keywords__description.js +101 -0
  135. package/scripts/{related_posts/index.js → helpers/related-posts.js} +1 -1
  136. package/scripts/helpers/revisioned.js +158 -0
  137. package/scripts/helpers/structured-data/index.js +2 -0
  138. package/scripts/helpers/structured-data/lib/blogposting.js +77 -0
  139. package/scripts/helpers/structured-data/lib/breadcrumblist.js +152 -0
  140. package/scripts/helpers/structured-data/lib/config.js +31 -0
  141. package/scripts/helpers/structured-data/lib/index.js +30 -0
  142. package/scripts/helpers/structured-data/lib/organization.js +15 -0
  143. package/scripts/helpers/structured-data/lib/person.js +16 -0
  144. package/scripts/helpers/structured-data/lib/website.js +42 -0
  145. package/scripts/tags/btn.js +6 -1
  146. package/scripts/tags/btns.js +7 -2
  147. package/scripts/tags/checkbox.js +12 -2
  148. package/scripts/tags/contributors.js +100 -0
  149. package/scripts/tags/dropmenu.js +18 -3
  150. package/scripts/tags/fancybox.js +44 -10
  151. package/scripts/tags/folding.js +6 -1
  152. package/scripts/tags/frame.js +6 -1
  153. package/scripts/tags/friends.js +99 -0
  154. package/scripts/tags/ghcard.js +6 -1
  155. package/scripts/tags/image.js +14 -2
  156. package/scripts/tags/link.js +6 -1
  157. package/scripts/tags/md.js +59 -0
  158. package/scripts/tags/media.js +25 -1
  159. package/scripts/tags/note.js +36 -3
  160. package/scripts/tags/site.js +87 -51
  161. package/scripts/tags/span.js +12 -2
  162. package/scripts/tags/swiper.js +38 -0
  163. package/scripts/tags/tabs.js +33 -3
  164. package/scripts/tags/timeline.js +6 -1
  165. package/source/css/Readme.md +28 -0
  166. package/source/css/_defines/AutoPrefixCSS.styl +347 -0
  167. package/source/css/_defines/Readme.md +3 -0
  168. package/source/css/_defines/color.styl +41 -1
  169. package/source/css/_defines/effect.styl +0 -13
  170. package/source/css/_defines/fonts.styl +17 -18
  171. package/source/css/_defines/func.styl +12 -30
  172. package/source/css/_first/base_first.styl +118 -0
  173. package/source/css/_first/{cover.styl → cover_first.styl} +113 -87
  174. package/source/css/_first/dark_first.styl +76 -0
  175. package/source/css/_first/fontfamily_first.styl +17 -0
  176. package/source/css/_first/{navbar.styl → navbar_first.styl} +4 -10
  177. package/source/css/_first/search_first.styl +12 -0
  178. package/source/css/{_base/index.styl → _style/_base/base.styl} +9 -93
  179. package/source/css/_style/_base/fontfamily_async.styl +8 -0
  180. package/source/css/{_layout → _style/_layout}/archive.styl +0 -0
  181. package/source/css/{_layout → _style/_layout}/article.styl +3 -30
  182. package/source/css/{_layout → _style/_layout}/footer.styl +0 -0
  183. package/source/css/_style/_layout/friends-simpleuser.styl +23 -0
  184. package/source/css/_style/_layout/friends-traditional.styl +81 -0
  185. package/source/css/{_layout → _style/_layout}/img.styl +0 -0
  186. package/source/css/_style/_layout/loading.styl +14 -0
  187. package/source/css/{_layout → _style/_layout}/main.styl +19 -7
  188. package/source/css/{_layout → _style/_layout}/md.styl +0 -0
  189. package/source/css/{_layout → _style/_layout}/pagination.styl +1 -1
  190. package/source/css/{_layout → _style/_layout}/posts.styl +2 -0
  191. package/source/css/{_first → _style/_layout}/search.styl +0 -103
  192. package/source/css/{_layout → _style/_layout}/sidebar.styl +23 -3
  193. package/source/css/{_layout → _style/_layout}/snackbar.styl +0 -0
  194. package/source/css/{_layout → _style/_layout}/toc.styl +3 -3
  195. package/source/css/{_layout → _style/_layout}/video.styl +0 -0
  196. package/source/css/_style/_plugins/_dark/dark_async.styl +41 -0
  197. package/source/css/_style/_plugins/_dark/dark_plugins.styl +136 -0
  198. package/source/css/_style/_plugins/_highlight/highlightjs/clipboard.styl +36 -0
  199. package/source/css/_style/_plugins/_highlight/highlightjs/color.styl +96 -0
  200. package/source/css/_style/_plugins/_highlight/highlightjs/index.styl +102 -0
  201. package/source/css/_style/_plugins/_highlight/highlightjs/language.styl +63 -0
  202. package/source/css/_style/_plugins/_highlight/index.styl +1 -0
  203. package/source/css/_style/_plugins/_highlight/prismjs/clipboard.styl +33 -0
  204. package/source/css/_style/_plugins/_highlight/prismjs/index.styl +8 -0
  205. package/source/css/_style/_plugins/_highlight/prismjs/language.styl +63 -0
  206. package/source/css/_style/_plugins/_rightmenu/reading.styl +56 -0
  207. package/source/css/{_plugins → _style/_plugins/_rightmenu}/rightmenu.styl +22 -2
  208. package/source/css/{_plugins → _style/_plugins}/aplayer.styl +8 -1
  209. package/source/css/{_plugins → _style/_plugins}/cursor.styl +49 -19
  210. package/source/css/_style/_plugins/fontcolor.styl +84 -0
  211. package/source/css/{_plugins → _style/_plugins}/gitalk.styl +0 -0
  212. package/source/css/_style/_plugins/index.styl +24 -0
  213. package/source/css/{_plugins → _style/_plugins}/mathjax.styl +0 -0
  214. package/source/css/_style/_plugins/message.styl +14 -0
  215. package/source/css/{_plugins → _style/_plugins}/pjaxanimate.styl +0 -0
  216. package/source/css/_style/_tag-plugins/Readme.md +6 -0
  217. package/source/css/{_tag-plugins → _style/_tag-plugins}/btns.styl +0 -0
  218. package/source/css/{_tag-plugins → _style/_tag-plugins}/checkbox.styl +0 -0
  219. package/source/css/{_tag-plugins → _style/_tag-plugins}/dropmenu.styl +0 -0
  220. package/source/css/{_plugins → _style/_tag-plugins}/fancybox.styl +8 -9
  221. package/source/css/{_tag-plugins → _style/_tag-plugins}/folding.styl +0 -0
  222. package/source/css/{_tag-plugins → _style/_tag-plugins}/frame.styl +0 -0
  223. package/source/css/_style/_tag-plugins/friends.styl +72 -0
  224. package/source/css/{_tag-plugins → _style/_tag-plugins}/ghcard.styl +0 -0
  225. package/source/css/{_tag-plugins → _style/_tag-plugins}/image.styl +0 -0
  226. package/source/css/{_tag-plugins → _style/_tag-plugins}/link.styl +0 -0
  227. package/source/css/{_tag-plugins → _style/_tag-plugins}/media.styl +0 -0
  228. package/source/css/{_tag-plugins → _style/_tag-plugins}/note.styl +0 -0
  229. package/source/css/_style/_tag-plugins/sites.styl +87 -0
  230. package/source/css/{_tag-plugins → _style/_tag-plugins}/span.styl +0 -0
  231. package/source/css/_style/_tag-plugins/swiper.styl +44 -0
  232. package/source/css/{_tag-plugins → _style/_tag-plugins}/table.styl +0 -0
  233. package/source/css/{_tag-plugins → _style/_tag-plugins}/tabs.styl +0 -0
  234. package/source/css/_style/_tag-plugins/tag.json +35 -0
  235. package/source/css/_style/_tag-plugins/text.styl +31 -0
  236. package/source/css/{_tag-plugins → _style/_tag-plugins}/timeline.styl +0 -0
  237. package/source/css/_style/index.styl +8 -0
  238. package/source/css/first.styl +17 -6
  239. package/source/css/style.styl +9 -7
  240. package/source/js/app.js +1051 -278
  241. package/source/js/plugins/aplayer.js +186 -0
  242. package/source/js/plugins/parallax.js +191 -0
  243. package/source/js/plugins/rightMenu.js +577 -0
  244. package/source/js/plugins/rightMenus.js +616 -0
  245. package/source/js/plugins/tags/contributors.js +92 -0
  246. package/source/js/plugins/tags/friends.js +93 -0
  247. package/source/js/plugins/tags/sites.js +96 -0
  248. package/source/js/search/hexo.js +180 -373
  249. package/.eslintrc.json +0 -111
  250. package/layout/_meta/valinecount.ejs +0 -15
  251. package/layout/_partial/rightmenu.ejs +0 -199
  252. package/layout/_partial/scripts/cover.ejs +0 -45
  253. package/layout/_partial/scripts/darkmode.ejs +0 -85
  254. package/layout/_partial/scripts/import.ejs +0 -3
  255. package/layout/_partial/scripts/issues.ejs +0 -18
  256. package/layout/_partial/scripts/search.ejs +0 -62
  257. package/layout/_partial/snackbar.ejs +0 -22
  258. package/layout/_third-party/aplayer/script.ejs +0 -26
  259. package/layout/_third-party/clipboard/script.ejs +0 -54
  260. package/layout/_third-party/comments/disqus/layout.ejs +0 -5
  261. package/layout/_third-party/comments/disqus/script.ejs +0 -90
  262. package/layout/_third-party/comments/disqusjs/layout.ejs +0 -1
  263. package/layout/_third-party/comments/disqusjs/script.ejs +0 -34
  264. package/layout/_third-party/comments/gitalk/layout.ejs +0 -1
  265. package/layout/_third-party/comments/gitalk/script.ejs +0 -22
  266. package/layout/_third-party/comments/hashover/layout.ejs +0 -2
  267. package/layout/_third-party/comments/hashover/script.ejs +0 -1
  268. package/layout/_third-party/comments/isso/layout.ejs +0 -1
  269. package/layout/_third-party/comments/isso/script.ejs +0 -1
  270. package/layout/_third-party/comments/livere/layout.ejs +0 -3
  271. package/layout/_third-party/comments/livere/script.ejs +0 -10
  272. package/layout/_third-party/comments/minivaline/layout.ejs +0 -3
  273. package/layout/_third-party/comments/minivaline/script.ejs +0 -34
  274. package/layout/_third-party/comments/twikoo/layout.ejs +0 -3
  275. package/layout/_third-party/comments/twikoo/script.ejs +0 -32
  276. package/layout/_third-party/comments/valine/layout.ejs +0 -3
  277. package/layout/_third-party/comments/valine/script.ejs +0 -49
  278. package/layout/_third-party/comments/vssue/layout.ejs +0 -1
  279. package/layout/_third-party/comments/vssue/script.ejs +0 -21
  280. package/layout/_third-party/comments/waline/layout.ejs +0 -3
  281. package/layout/_third-party/comments/waline/script.ejs +0 -33
  282. package/layout/_third-party/fancybox/script.ejs +0 -61
  283. package/layout/_third-party/highlightjs/script.ejs +0 -11
  284. package/layout/_third-party/pjax/index.ejs +0 -78
  285. package/layout/_third-party/pjax/pdata.ejs +0 -53
  286. package/layout/_third-party/scrollreveal/script.ejs +0 -21
  287. package/layout/_third-party/tidio/script.ejs +0 -3
  288. package/layout/artitalk.ejs +0 -13
  289. package/layout/bb.ejs +0 -10
  290. package/package-lock.json +0 -916
  291. package/scripts/tags/issues.js +0 -41
  292. package/scripts/z-lazyload/index.js +0 -4
  293. package/source/css/_highlight/index.styl +0 -316
  294. package/source/css/_layout/friends.styl +0 -79
  295. package/source/css/_plugins/clipboard.styl +0 -37
  296. package/source/css/_plugins/dark.styl +0 -149
  297. package/source/css/_plugins/darkmode.styl +0 -9
  298. package/source/css/_plugins/index.styl +0 -18
  299. package/source/css/_plugins/twikoo.styl +0 -21
  300. package/source/css/_plugins/valine.styl +0 -183
  301. package/source/css/_tag-plugins/simpleuser.styl +0 -21
  302. package/source/css/_tag-plugins/site-card.styl +0 -70
  303. package/source/js/aplayer.js +0 -167
  304. package/source/js/issues.js +0 -186
  305. package/source/js/search/algolia.js +0 -344
  306. package/source/js/search/azure.js +0 -355
  307. package/source/js/search/baidu.js +0 -340
  308. package/source/js/search/google.js +0 -339
  309. package/source/js/valine.js +0 -5137
@@ -0,0 +1,616 @@
1
+
2
+ const RightMenus = {
3
+ defaultEvent: ['copyText', 'copyLink', 'copyPaste', 'copyAll', 'copyCut', 'copyImg', 'printMode', 'readMode'],
4
+ defaultGroup: ['navigation', 'inputBox', 'seletctText', 'elementCheck', 'elementImage', 'articlePage'],
5
+ messageRightMenu: volantis.GLOBAL_CONFIG.plugins.message.enable && volantis.GLOBAL_CONFIG.plugins.message.rightmenu.enable,
6
+ corsAnywhere: volantis.GLOBAL_CONFIG.plugins.rightmenus.options.corsAnywhere,
7
+ urlRegx: /^((https|http)?:\/\/)+[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
8
+ imgRegx: /\.(jpe?g|png|webp|svg|gif|jifi)(-|_|!|\?|\/)?.*$/,
9
+
10
+ /**
11
+ * 加载右键菜单
12
+ */
13
+ initialMenu: () => {
14
+ RightMenus.fun.init();
15
+ volantis.pjax.send(() => {
16
+ RightMenus.fun.hideMenu();
17
+ if (volantis.isReadModel) RightMenus.fun.readMode();
18
+ })
19
+ },
20
+
21
+ /**
22
+ * 读取剪切板
23
+ * @returns text
24
+ */
25
+ readClipboard: async () => {
26
+ let clipboardText;
27
+ const result = await navigator.permissions.query({ name: 'clipboard-read' });
28
+ switch (result.state) {
29
+ case 'granted':
30
+ case 'prompt':
31
+ clipboardText = await navigator.clipboard.readText()
32
+ break;
33
+ default:
34
+ window.clipboardRead = false;
35
+ break;
36
+ }
37
+ return clipboardText;
38
+ },
39
+
40
+ /**
41
+ * 写入文本到剪切板
42
+ * @param {String} text
43
+ */
44
+ writeClipText: text => {
45
+ return navigator.clipboard
46
+ .writeText(text)
47
+ .then(() => {
48
+ return Promise.resolve()
49
+ })
50
+ .catch(err => {
51
+ return Promise.reject(err)
52
+ })
53
+ },
54
+
55
+ /**
56
+ * 写入图片到剪切板
57
+ * @param {*} link
58
+ * @param {*} success
59
+ * @param {*} error
60
+ */
61
+ writeClipImg: async (link, success, error) => {
62
+ const image = new Image;
63
+ image.crossOrigin = "Anonymous";
64
+ image.addEventListener('load', () => {
65
+ let canvas = document.createElement("canvas");
66
+ let context = canvas.getContext("2d");
67
+ canvas.width = image.width;
68
+ canvas.height = image.height;
69
+ context.drawImage(image, 0, 0);
70
+ canvas.toBlob(blob => {
71
+ navigator.clipboard.write([
72
+ new ClipboardItem({ 'image/png': blob })
73
+ ]).then(e => {
74
+ success(e)
75
+ }).catch(e => {
76
+ error(e)
77
+ })
78
+ }, 'image/png')
79
+ }, false)
80
+ image.src = `${link}?(lll¬ω¬)`;
81
+ },
82
+
83
+ /**
84
+ * 粘贴文本到剪切板
85
+ * @param {*} elemt
86
+ * @param {*} value
87
+ */
88
+ insertAtCaret: (elemt, value) => {
89
+ const startPos = elemt.selectionStart,
90
+ endPos = elemt.selectionEnd;
91
+ if (document.selection) {
92
+ elemt.focus();
93
+ var sel = document.selection.createRange();
94
+ sel.text = value;
95
+ elemt.focus();
96
+ } else {
97
+ if (startPos || startPos == '0') {
98
+ var scrollTop = elemt.scrollTop;
99
+ elemt.value = elemt.value.substring(0, startPos) + value + elemt.value.substring(endPos, elemt.value.length);
100
+ elemt.focus();
101
+ elemt.selectionStart = startPos + value.length;
102
+ elemt.selectionEnd = startPos + value.length;
103
+ elemt.scrollTop = scrollTop;
104
+ } else {
105
+ elemt.value += value;
106
+ elemt.focus();
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ /**
113
+ * 事件处理区域
114
+ */
115
+ RightMenus.fun = (() => {
116
+ const rightMenuConfig = volantis.GLOBAL_CONFIG.plugins.rightmenus;
117
+
118
+ const
119
+ fn = {},
120
+ _rightMenuWrapper = document.getElementById('rightmenu-wrapper'),
121
+ _rightMenuContent = document.getElementById('rightmenu-content'),
122
+ _rightMenuList = document.querySelectorAll('#rightmenu-content li.menuLoad-Content'),
123
+ _rightMenuListWithHr = document.querySelectorAll('#rightmenu-content li, #rightmenu-content hr, #menuMusic'),
124
+ _readBkg = document.getElementById('read_bkg'),
125
+ _menuMusic = document.getElementById('menuMusic'),
126
+ _backward = document.querySelector('#menuMusic .backward'),
127
+ _toggle = document.querySelector('#menuMusic .toggle'),
128
+ _forward = document.querySelector('#menuMusic .forward');
129
+
130
+ // 公共数据
131
+ let globalData = {
132
+ mouseEvent: null,
133
+ isInputBox: false,
134
+ selectText: '',
135
+ inputValue: '',
136
+ isLink: false,
137
+ linkUrl: '',
138
+ isMediaLink: false,
139
+ mediaLinkUrl: '',
140
+ isImage: false,
141
+ isArticle: false,
142
+ pathName: '',
143
+ isReadClipboard: true,
144
+ isShowMusic: false,
145
+ statusCheck: false
146
+ }
147
+ const globalDataBackup = Object.assign({}, globalData);
148
+
149
+ /**
150
+ * 初始化监听事件处理
151
+ */
152
+ fn.initEvent = () => {
153
+ fn.elementAppend();
154
+ fn.contextmenu();
155
+ fn.menuEvent();
156
+ }
157
+
158
+ /**
159
+ * 预置元素设定
160
+ */
161
+ fn.elementAppend = () => {
162
+ // 阅读模式
163
+ if (_readBkg) _readBkg.parentNode.removeChild(_readBkg);
164
+ const readBkg = document.createElement("div");
165
+ readBkg.className = "common_read_bkg common_read_hide";
166
+ readBkg.id = "read_bkg";
167
+ window.document.body.appendChild(readBkg);
168
+ }
169
+
170
+ /**
171
+ * 右键菜单位置设定
172
+ * @param {*} event
173
+ */
174
+ fn.menuPosition = (event) => {
175
+ try {
176
+ let mouseClientX = event.clientX;
177
+ let mouseClientY = event.clientY;
178
+ let screenWidth = document.documentElement.clientWidth || document.body.clientWidth;
179
+ let screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
180
+
181
+ _rightMenuWrapper.style.display = 'block';
182
+ fn.menuControl(event);
183
+
184
+ let menuWidth = _rightMenuContent.offsetWidth;
185
+ let menuHeight = _rightMenuContent.offsetHeight;
186
+ let showLeft = mouseClientX + menuWidth > screenWidth ? mouseClientX - menuWidth + 10 : mouseClientX;
187
+ let showTop = mouseClientY + menuHeight > screenHeight ? mouseClientY - menuHeight + 10 : mouseClientY;
188
+ showTop = mouseClientY + menuHeight > screenHeight && showTop < menuHeight && mouseClientY < menuHeight ?
189
+ showTop + (screenHeight - menuHeight - showTop - 10) : showTop;
190
+ _rightMenuWrapper.style.left = `${showLeft}px`;
191
+ _rightMenuWrapper.style.top = `${showTop}px`;
192
+ if (volantis.GLOBAL_CONFIG.plugins.message.rightmenu.notice) fn.menuNotic();
193
+ } catch (error) {
194
+ if (volantis.GLOBAL_CONFIG.debug) console.error(error);
195
+ fn.hideMenu();
196
+ return true;
197
+ }
198
+ return false;
199
+ }
200
+
201
+ /**
202
+ * 菜单项控制
203
+ * @param {*} event
204
+ */
205
+ fn.menuControl = (event) => {
206
+ fn.globalDataSet(event);
207
+ if (!!_menuMusic) _menuMusic.style.display = globalData.isShowMusic ? 'block' : 'none';
208
+ _rightMenuList.forEach(item => {
209
+ item.style.display = 'none';
210
+ const nodeName = item.firstElementChild.nodeName;
211
+ const groupName = item.firstElementChild.getAttribute('data-group');
212
+ const itemEvent = item.firstElementChild.getAttribute('data-event');
213
+ if (globalData.statusCheck || globalData.isArticle) {
214
+ switch (groupName) {
215
+ case 'inputBox':
216
+ if (globalData.isInputBox) {
217
+ item.style.display = 'block';
218
+ if (itemEvent === 'copyCut' && !globalData.selectText) item.style.display = 'none';
219
+ if (itemEvent === 'copyAll' && !globalData.inputValue) item.style.display = 'none';
220
+ if (itemEvent === 'copyPaste' && !globalData.isReadClipboard) item.style.display = 'none';
221
+ }
222
+ break;
223
+ case 'seletctText':
224
+ if (!!globalData.selectText) item.style.display = 'block';
225
+ break;
226
+ case 'elementCheck':
227
+ if (globalData.isLink || globalData.isMediaLink) item.style.display = 'block';
228
+ break;
229
+ case 'elementImage':
230
+ if (globalData.isImage) item.style.display = 'block';
231
+ break;
232
+ case 'articlePage':
233
+ if (globalData.isArticle) item.style.display = 'block';
234
+ break;
235
+ default:
236
+ item.style.display = nodeName === 'A'
237
+ ? globalData.isArticle && !globalData.statusCheck && rightMenuConfig.options.articleShowLink
238
+ ? 'block'
239
+ : 'none'
240
+ : 'block';
241
+ break;
242
+ }
243
+ } else if (nodeName === 'A' || RightMenus.defaultGroup.every(item => { return groupName !== item })) {
244
+ item.style.display = 'block';
245
+ }
246
+ })
247
+
248
+ // 执行外部事件
249
+ volantis.mouseEvent = event;
250
+ volantis.rightmenu.method.handle.start()
251
+
252
+ // 过滤 HR 元素
253
+ let elementHrItem = { item: null, hide: true };
254
+ _rightMenuListWithHr.forEach((item) => {
255
+ if (item.nodeName === "HR") {
256
+ item.style.display = 'block';
257
+ if (!elementHrItem.item) {
258
+ elementHrItem.item = item;
259
+ return;
260
+ }
261
+ if (elementHrItem.hide || elementHrItem.item.nextElementSibling.nodeName === "hr") {
262
+ elementHrItem.item.style.display = 'none';
263
+ }
264
+ elementHrItem.item = item;
265
+ elementHrItem.hide = true;
266
+ } else {
267
+ if (item.style.display === 'block' && elementHrItem.hide) {
268
+ elementHrItem.hide = false;
269
+ }
270
+ }
271
+ })
272
+ if (!!elementHrItem.item && elementHrItem.hide) elementHrItem.item.style.display = 'none';
273
+ }
274
+
275
+ /**
276
+ * 元素状态判断/全局数据设置
277
+ * @param {*} event
278
+ */
279
+ fn.globalDataSet = (event) => {
280
+ globalData = Object.assign({}, globalDataBackup);
281
+ globalData.mouseEvent = event;
282
+ globalData.selectText = window.getSelection().toString();
283
+
284
+ // 判断是否为输入框
285
+ if (event.target.tagName.toLowerCase() === 'input' || event.target.tagName.toLowerCase() === 'textarea') {
286
+ globalData.isInputBox = true;
287
+ globalData.inputValue = event.target.value;
288
+ }
289
+
290
+ // 判断是否允许读取剪切板
291
+ if (globalData.isInputBox && window.clipboardRead === false) {
292
+ globalData.isReadClipboard = false;
293
+ }
294
+
295
+ // 判断是否包含链接
296
+ if (!!event.target.href && RightMenus.urlRegx.test(event.target.href)) {
297
+ globalData.isLink = true;
298
+ globalData.linkUrl = event.target.href;
299
+ }
300
+
301
+ // 判断是否包含媒体链接
302
+ if (!!event.target.currentSrc && RightMenus.urlRegx.test(event.target.currentSrc)) {
303
+ globalData.isMediaLink = true;
304
+ globalData.mediaLinkUrl = event.target.currentSrc;
305
+ }
306
+
307
+ // 判断是否为图片地址
308
+ if (globalData.isMediaLink && RightMenus.imgRegx.test(globalData.mediaLinkUrl)) {
309
+ globalData.isImage = true;
310
+ }
311
+
312
+ // 判断是否为文章页面
313
+ if (!!(document.querySelector('#post.article') || null)) {
314
+ globalData.isArticle = true;
315
+ globalData.pathName = window.location.pathname;
316
+ }
317
+
318
+ // 判断是否显示音乐控制器
319
+ if (volantis.GLOBAL_CONFIG.plugins.aplayer.enable
320
+ && typeof RightMenuAplayer !== 'undefined'
321
+ && RightMenuAplayer.APlayer.player !== undefined) {
322
+ if (rightMenuConfig.options.musicAlwaysShow
323
+ || RightMenuAplayer.APlayer.status === 'play'
324
+ || RightMenuAplayer.APlayer.status === 'undefined') {
325
+ globalData.isShowMusic = true;
326
+ }
327
+ }
328
+
329
+ // 设定校验状态
330
+ if (!!globalData.selectText || globalData.isInputBox || globalData.isLink || globalData.isMediaLink) {
331
+ globalData.statusCheck = true;
332
+ }
333
+ }
334
+
335
+ /**
336
+ * 全局右键监听函数
337
+ */
338
+ fn.contextmenu = () => {
339
+ window.document.oncontextmenu = (event) => {
340
+ if (event.ctrlKey || document.body.offsetWidth <= 500) {
341
+ fn.hideMenu();
342
+ return true;
343
+ }
344
+ return fn.menuPosition(event);
345
+ }
346
+
347
+ _rightMenuWrapper.oncontextmenu = (event) => {
348
+ event.stopPropagation();
349
+ event.preventDefault();
350
+ return false;
351
+ }
352
+
353
+ window.removeEventListener('blur', fn.hideMenu);
354
+ window.addEventListener('blur', fn.hideMenu);
355
+ document.body.removeEventListener('click', fn.hideMenu);
356
+ document.body.addEventListener('click', fn.hideMenu);
357
+ }
358
+
359
+ /**
360
+ * 菜单项事件处理函数
361
+ */
362
+ fn.menuEvent = () => {
363
+ _rightMenuList.forEach(item => {
364
+ let eventName = item.firstElementChild.getAttribute('data-event');
365
+ const id = item.firstElementChild.getAttribute('id');
366
+ const groupName = item.firstElementChild.getAttribute('data-group');
367
+ if (item.firstElementChild.nodeName === "A") return;
368
+ item.addEventListener('click', () => {
369
+ try {
370
+ if (RightMenus.defaultEvent.every(item => { return eventName !== item })) {
371
+ if (groupName === 'seletctText') {
372
+ RightMenusFunction[id](globalData.selectText)
373
+ } else if (groupName === 'elementCheck') {
374
+ RightMenusFunction[id](globalData.isLink ? globalData.linkUrl : globalData.mediaLinkUrl)
375
+ } else if (groupName === 'elementImage') {
376
+ RightMenusFunction[id](globalData.mediaLinkUrl)
377
+ } else {
378
+ RightMenusFunction[id]()
379
+ }
380
+ } else {
381
+ fn[eventName]()
382
+ }
383
+ } catch (error) {
384
+ if (volantis.GLOBAL_CONFIG.debug) {
385
+ console.error({
386
+ id: id,
387
+ error: error,
388
+ globalData: globalData,
389
+ groupName: groupName,
390
+ eventName: eventName
391
+ });
392
+ }
393
+ if (RightMenus.messageRightMenu) {
394
+ VolantisApp.message('错误提示', error, {
395
+ icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
396
+ time: '15000'
397
+ });
398
+ }
399
+ }
400
+ })
401
+ })
402
+
403
+ if (_forward && _toggle && _forward) {
404
+ _backward.onclick = (e) => {
405
+ e.preventDefault();
406
+ e.stopPropagation();
407
+ RightMenuAplayer.aplayerBackward();
408
+ }
409
+ _toggle.onclick = (e) => {
410
+ e.preventDefault();
411
+ e.stopPropagation();
412
+ RightMenuAplayer.aplayerToggle();
413
+ }
414
+ _forward.onclick = (e) => {
415
+ e.preventDefault();
416
+ e.stopPropagation();
417
+ RightMenuAplayer.aplayerForward();
418
+ }
419
+ }
420
+ }
421
+
422
+ /**
423
+ * 隐藏菜单显示
424
+ */
425
+ fn.hideMenu = () => {
426
+ _rightMenuWrapper.style.display = null;
427
+ _rightMenuWrapper.style.left = null;
428
+ _rightMenuWrapper.style.top = null;
429
+ }
430
+
431
+ /**
432
+ * 右键菜单覆盖提示
433
+ */
434
+ fn.menuNotic = () => {
435
+ const NoticeRightMenu = localStorage.getItem('NoticeRightMenu') === 'true';
436
+ if (RightMenus.messageRightMenu && !NoticeRightMenu)
437
+ VolantisApp.message('右键菜单', '唤醒原系统菜单请使用:<kbd>Ctrl</kbd> + <kbd>右键</kbd>', {
438
+ icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
439
+ displayMode: 1,
440
+ time: 9000
441
+ }, () => {
442
+ localStorage.setItem('NoticeRightMenu', 'true')
443
+ });
444
+ }
445
+
446
+ fn.copyText = () => {
447
+ VolantisApp.utilWriteClipText(globalData.selectText)
448
+ .then(() => {
449
+ if (RightMenus.messageRightMenu) {
450
+ VolantisApp.messageCopyright();
451
+ }
452
+ }).catch(e => {
453
+ if (RightMenus.messageRightMenu) {
454
+ VolantisApp.message('系统提示', e, {
455
+ icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
456
+ displayMode: 1,
457
+ time: 9000
458
+ });
459
+ }
460
+ })
461
+ }
462
+
463
+ fn.copyLink = () => {
464
+ VolantisApp.utilWriteClipText(globalData.linkUrl || globalData.mediaLinkUrl)
465
+ .then(() => {
466
+ if (RightMenus.messageRightMenu) {
467
+ VolantisApp.messageCopyright();
468
+ }
469
+ }).catch(e => {
470
+ if (RightMenus.messageRightMenu) {
471
+ VolantisApp.message('系统提示', e, {
472
+ icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
473
+ displayMode: 1,
474
+ time: 9000
475
+ });
476
+ }
477
+ })
478
+ }
479
+
480
+ fn.copyAll = () => {
481
+ globalData.mouseEvent.target.select();
482
+ }
483
+
484
+ fn.copyPaste = async () => {
485
+ const result = await RightMenus.readClipboard() || '';
486
+ if (RightMenus.messageRightMenu && window.clipboardRead === false) {
487
+ VolantisApp.message('系统提示', '未授予剪切板读取权限!');
488
+ } else if (RightMenus.messageRightMenu && result === '') {
489
+ VolantisApp.message('系统提示', '仅支持复制文本内容!');
490
+ } else {
491
+ RightMenus.insertAtCaret(globalData.mouseEvent.target, result);
492
+ }
493
+ }
494
+
495
+ fn.copyCut = () => {
496
+ const statrPos = globalData.mouseEvent.target.selectionStart;
497
+ const endPos = globalData.mouseEvent.target.selectionEnd;
498
+ const inputStr = globalData.inputValue;
499
+ fn.copyText(globalData.selectText);
500
+ globalData.mouseEvent.target.value = inputStr.substring(0, statrPos) + inputStr.substring(endPos, inputStr.length);
501
+ globalData.mouseEvent.target.selectionStart = statrPos;
502
+ globalData.mouseEvent.target.selectionEnd = statrPos;
503
+ globalData.mouseEvent.target.focus();
504
+ }
505
+
506
+ fn.copyImg = () => {
507
+ if (volantis.GLOBAL_CONFIG.plugins.message.rightmenu.notice) {
508
+ VolantisApp.message('系统提示', '复制中,请等待。', {
509
+ icon: rightMenuConfig.options.iconPrefix + ' fa-images'
510
+ })
511
+ }
512
+ RightMenus.writeClipImg(globalData.mediaLinkUrl, e => {
513
+ if (RightMenus.messageRightMenu) {
514
+ VolantisApp.hideMessage();
515
+ VolantisApp.message('系统提示', '图片复制成功!', {
516
+ icon: rightMenuConfig.options.iconPrefix + ' fa-images'
517
+ });
518
+ }
519
+ }, (e) => {
520
+ console.error(e);
521
+ if (RightMenus.messageRightMenu) {
522
+ VolantisApp.hideMessage();
523
+ VolantisApp.message('系统提示', '复制失败:' + e, {
524
+ icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
525
+ time: 9000
526
+ });
527
+ }
528
+ })
529
+ }
530
+
531
+ fn.printMode = () => {
532
+ if (window.location.pathname === globalData.pathName) {
533
+ if (RightMenus.messageRightMenu) {
534
+ const message = '是否打印当前页面?<br><em style="font-size: 80%">建议打印时勾选背景图形</em><br>'
535
+ VolantisApp.question('', message, { time: 9000 }, () => { fn.printHtml() })
536
+ } else {
537
+ fn.printHtml()
538
+ }
539
+ }
540
+ }
541
+
542
+ fn.printHtml = () => {
543
+ if (volantis.isReadModel) fn.readMode();
544
+ DOMController.setAttribute('details', 'open', 'true');
545
+ DOMController.removeList([
546
+ '.cus-article-bkg', '.iziToast-overlay', '.iziToast-wrapper', '.prev-next',
547
+ 'footer', '#l_header', '#l_cover', '#l_side', '#comments', '#s-top', '#BKG',
548
+ '#rightmenu-wrapper', '.nav-tabs', '.parallax-mirror', '.new-meta-item.share', 'div.footer'
549
+ ]);
550
+ DOMController.setStyleList([
551
+ ['body', 'backgroundColor', 'unset'], ['#l_main', 'width', '100%'], ['#post', 'boxShadow', 'none'],
552
+ ['#post', 'background', 'none'], ['#post', 'padding', '0'], ['h1', 'textAlign', 'center'],
553
+ ['h1', 'fontWeight', '600'], ['h1', 'fontSize', '2rem'], ['h1', 'marginBottom', '20px'],
554
+ ['.tab-pane', 'display', 'block'], ['.tab-content', 'borderTop', 'none'], ['.highlight>table pre', 'whiteSpace', 'pre-wrap'],
555
+ ['.highlight>table pre', 'wordBreak', 'break-all'], ['.fancybox img', 'height', 'auto'], ['.fancybox img', 'weight', 'auto']
556
+ ]);
557
+ setTimeout(() => {
558
+ window.print();
559
+ document.body.innerHTML = '';
560
+ window.location.reload();
561
+ }, 50);
562
+ }
563
+
564
+ fn.readMode = () => {
565
+ if (typeof ScrollReveal === 'function') ScrollReveal().clean('#comments');
566
+ DOMController.fadeToggleList([
567
+ document.querySelector('#l_header'), document.querySelector('footer'),
568
+ document.querySelector('#s-top'), document.querySelector('.article-meta#bottom'),
569
+ document.querySelector('.prev-next'), document.querySelector('#l_side'),
570
+ document.querySelector('#comments')
571
+ ]);
572
+ DOMController.toggleClassList([
573
+ [document.querySelector('#l_main'), 'common_read'], [document.querySelector('#l_main'), 'common_read_main'],
574
+ [document.querySelector('#l_body'), 'common_read'], [document.querySelector('#safearea'), 'common_read'],
575
+ [document.querySelector('#pjax-container'), 'common_read'], [document.querySelector('#read_bkg'), 'common_read_hide'],
576
+ [document.querySelector('h1'), 'common_read_h1'], [document.querySelector('#post'), 'post_read'],
577
+ [document.querySelector('#l_cover'), 'read_cover'], [document.querySelector('.widget.toc-wrapper'), 'post_read']
578
+ ]);
579
+ volantis.isReadModel = volantis.isReadModel === undefined ? true : !volantis.isReadModel;
580
+ if (volantis.isReadModel) {
581
+ if (RightMenus.messageRightMenu) VolantisApp.message('系统提示', '阅读模式已开启,您可以点击屏幕空白处退出。', {
582
+ backgroundColor: 'var(--color-read-post)',
583
+ icon: rightMenuConfig.options.iconPrefix + ' fa-book-reader',
584
+ displayMode: 1,
585
+ time: 5000
586
+ });
587
+ document.querySelector('#l_body').removeEventListener('click', fn.readMode);
588
+ document.querySelector('#l_body').addEventListener('click', (event) => {
589
+ if (DOMController.hasClass(event.target, 'common_read')) {
590
+ fn.readMode();
591
+ }
592
+ });
593
+ } else {
594
+ document.querySelector('#l_body').removeEventListener('click', fn.readMode);
595
+ document.querySelector('#post').removeEventListener('click', fn.readMode);
596
+ document.querySelector('.prev-next').style.display = 'flex'; // 单独修改
597
+ }
598
+ }
599
+
600
+ return {
601
+ init: fn.initEvent,
602
+ hideMenu: fn.hideMenu,
603
+ readMode: fn.readMode
604
+ }
605
+ })()
606
+
607
+ Object.freeze(RightMenus);
608
+ volantis.requestAnimationFrame(() => {
609
+ if (document.readyState !== 'loading') {
610
+ RightMenus.initialMenu();
611
+ } else {
612
+ document.addEventListener("DOMContentLoaded", function () {
613
+ RightMenus.initialMenu();
614
+ })
615
+ }
616
+ });
@@ -0,0 +1,92 @@
1
+ const ContributorsJS = {
2
+ requestAPI: (url, callback, timeout) => {
3
+ let retryTimes = 5;
4
+
5
+ function request() {
6
+ return new Promise((resolve, reject) => {
7
+ let status = 0; // 0 等待 1 完成 2 超时
8
+ let timer = setTimeout(() => {
9
+ if (status === 0) {
10
+ status = 2;
11
+ timer = null;
12
+ reject('请求超时');
13
+ if (retryTimes == 0) {
14
+ timeout();
15
+ }
16
+ }
17
+ }, 5000);
18
+ fetch(url).then(function (response) {
19
+ if (status !== 2) {
20
+ clearTimeout(timer);
21
+ resolve(response);
22
+ timer = null;
23
+ status = 1;
24
+ }
25
+ if (response.ok) {
26
+ return response.json();
27
+ }
28
+ throw new Error('Network response was not ok.');
29
+ }).then(function (data) {
30
+ retryTimes = 0;
31
+ callback(data);
32
+ }).catch(function (error) {
33
+ if (retryTimes > 0) {
34
+ retryTimes -= 1;
35
+ setTimeout(() => {
36
+ request();
37
+ }, 5000);
38
+ } else {
39
+ timeout();
40
+ }
41
+ });
42
+ });
43
+ }
44
+ request();
45
+ },
46
+ layout: (cfg) => {
47
+ const el = cfg.el;
48
+ ContributorsJS.requestAPI(cfg.api, function (data) {
49
+ el.querySelector('.loading-wrap').remove();
50
+ var cellALL = "";
51
+ (data || []).forEach((item, i) => {
52
+ var user = '<div class="user-card">';
53
+ user += '<a class="card-link" target="_blank" rel="external noopener noreferrer"';
54
+ user += ' href="' + item.html_url + '">';
55
+ user += '<img alt="' + item.login + '" src="' + (item.avatar_url || cfg.avatar) + '" onerror="errorImgAvatar(this)">';
56
+ user += '<div class="name"><span>' + item.login + '</span></div>';
57
+ user += '</a>';
58
+ user += '</div>';
59
+ cellALL += user;
60
+ });
61
+ el.querySelector('.group-body').innerHTML = cellALL;
62
+ }, function () {
63
+ try {
64
+ el.querySelector('.loading-wrap svg').remove();
65
+ el.querySelector('.loading-wrap p').innerText('加载失败,请稍后重试。');
66
+ } catch (e) { }
67
+ });
68
+ },
69
+ start: () => {
70
+ const els = document.getElementsByClassName('contributorsjs-wrap');
71
+ for (var i = 0; i < els.length; i++) {
72
+ const el = els[i];
73
+ const api = el.getAttribute('api');
74
+ if (api == null) {
75
+ continue;
76
+ }
77
+ var cfg = new Object();
78
+ cfg.el = el;
79
+ cfg.api = api;
80
+ cfg.class = el.getAttribute('class');
81
+ cfg.avatar = volantis.GLOBAL_CONFIG.default.avatar;
82
+ ContributorsJS.layout(cfg);
83
+ }
84
+ }
85
+ }
86
+
87
+
88
+
89
+ ContributorsJS.start();
90
+ document.addEventListener('pjax:complete', function () {
91
+ ContributorsJS.start();
92
+ });