hexo-theme-solitude 1.7.3 → 1.7.5

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 CHANGED
@@ -164,6 +164,7 @@ aside:
164
164
  page:
165
165
  noSticky: "about"
166
166
  Sticky: "newestPost,allInfo"
167
+ position: 0 # left(0): 左侧 / right(1): 右侧
167
168
  # 侧边栏个人信息卡片
168
169
  # Sidebar personal information
169
170
  card:
@@ -708,6 +709,7 @@ comment:
708
709
  commentBarrage: false # 热评开关 / Hot comment switch
709
710
  lazyload: true # 懒加载
710
711
  count: true # 评论数展示
712
+ avatar: https://cravatar.cn # Gravatar link
711
713
  newest_comment:
712
714
  enable: false
713
715
  storage: 421000 # 缓存时间
package/languages/en.yml CHANGED
@@ -16,15 +16,12 @@ copy_copyright:
16
16
  source: Source
17
17
  info: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
18
18
 
19
- lately:
20
- second: ' second'
21
- minute: ' minute'
22
- hour: ' hour'
23
- day: ' day'
24
- month: ' month'
25
- year: ' year'
26
- ago: ' ago'
27
- error: ' NaN'
19
+ time:
20
+ day: " days ago"
21
+ hour: " hours ago"
22
+ just: "just"
23
+ min: " minutes ago"
24
+ month: " months ago"
28
25
 
29
26
  page:
30
27
  tag: Tags
@@ -17,15 +17,12 @@ copy_copyright:
17
17
  source: 来源
18
18
  info: 著作权归作者所有。 商业转载请联系作者获得授权,非商业转载请注明出处。
19
19
 
20
- lately:
21
- second:
22
- minute: 分钟
23
- hour: 小时
24
- day:
25
- month: 个月
26
- year: 年
27
- ago: 前
28
- error: NaN
20
+ time:
21
+ day: "天前"
22
+ hour: "小时前"
23
+ just: "刚刚"
24
+ min: "分钟前"
25
+ month: "个月前"
29
26
 
30
27
  page:
31
28
  tag: 标签
@@ -17,15 +17,12 @@ copy_copyright:
17
17
  source: 來源
18
18
  info: 著作權歸作者所有。 商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。
19
19
 
20
- lately:
21
- second:
22
- minute: 分鐘
23
- hour: 小時
24
- day:
25
- month: 个月
26
- year: 年
27
- ago: 前
28
- error: NaN
20
+ time:
21
+ day: "天前"
22
+ hour: "小時前"
23
+ just: "剛剛"
24
+ min: "分鐘前"
25
+ month: "個月前"
29
26
 
30
27
  page:
31
28
  tag: 標籤
@@ -97,15 +97,12 @@
97
97
  error: _p('copy.error'),
98
98
  },
99
99
  backtop: _p('nav.backtop'),
100
- lately: {
101
- second: _p('lately.second'),
102
- minute: _p('lately.minute'),
103
- hour: _p('lately.hour'),
104
- day: _p('lately.day'),
105
- month: _p('lately.month'),
106
- year: _p('lately.year'),
107
- ago: _p('lately.ago'),
108
- error: _p('lately.error'),
100
+ time: {
101
+ day: _p('time.day'),
102
+ hour: _p('time.hour'),
103
+ just: _p('time.just'),
104
+ min: _p('time.min'),
105
+ month: _p('time.month')
109
106
  },
110
107
  f12: _p('f12'),
111
108
  }
@@ -18,9 +18,6 @@ div
18
18
  // md5
19
19
  script(src=url_for(theme.cdn.blueimp_md5))
20
20
 
21
- // lately
22
- script(src=url_for(theme.cdn.lately_js))
23
-
24
21
  if theme.mermaid
25
22
  script(src=url_for(theme.cdn.mermaid_js))
26
23
 
@@ -106,10 +103,6 @@ div
106
103
  != item
107
104
 
108
105
  div#js-pjax
109
- case config.lang
110
- when 'en'
111
- script.
112
- utils.changeTimeFormat()
113
106
  if theme.mermaid
114
107
  script.
115
108
  mermaid.run();
@@ -111,7 +111,7 @@ script.
111
111
  )(window)
112
112
 
113
113
  console.log(
114
- "%c Program: Hexo %c Theme: Solitude %c Version: v1.7.3",
114
+ "%c Program: Hexo %c Theme: Solitude %c Version: v1.7.5",
115
115
  "border-radius:5px 0 0 5px;padding: 5px 10px;color:white;background:#ff3842;",
116
116
  "padding: 5px 10px;color:white;background:#3e9f50;",
117
117
  "border-radius:0 5px 5px 0;padding: 5px 10px;background:#0084ff;color:white;"
@@ -57,7 +57,7 @@ script.
57
57
  `).join('') : "!{_p('newest_comment.zero')}"
58
58
  window.lazyLoadInstance && window.lazyLoadInstance.update()
59
59
  window.pjax && window.pjax.refresh()
60
- utils && utils.changeTimeFormat()
60
+ sco && sco.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
61
61
  }
62
62
 
63
63
  const newestCommentInit = () => {
@@ -72,7 +72,7 @@ script.
72
72
  `).join('') : "!{_p('newest_comment.zero')}"
73
73
  window.lazyLoadInstance && window.lazyLoadInstance.update()
74
74
  window.pjax && window.pjax.refresh()
75
- utils && utils.changeTimeFormat()
75
+ sco && sco.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
76
76
  }
77
77
 
78
78
  newestCommentInit()
@@ -62,7 +62,7 @@ script.
62
62
  `).join('') : "!{_p('newest_comment.zero')}"
63
63
  window.lazyLoadInstance && window.lazyLoadInstance.update()
64
64
  window.pjax && window.pjax.refresh()
65
- utils && utils.changeTimeFormat()
65
+ sco && sco.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
66
66
  }
67
67
 
68
68
  newestCommentInit()
package/layout/index.pug CHANGED
@@ -1,11 +1,12 @@
1
1
  extends includes/layout
2
2
 
3
3
  block content
4
- #home_top
5
- if theme.says.home_mini
6
- include ./includes/widgets/home/bbTimeList
7
- if theme.hometop.enable && is_home_first_page()
8
- include ./includes/widgets/home/hometop
4
+ if theme.hometop.enable || theme.says.home_mini
5
+ #home_top
6
+ if theme.says.home_mini
7
+ include ./includes/widgets/home/bbTimeList
8
+ if theme.hometop.enable && is_home_first_page()
9
+ include ./includes/widgets/home/hometop
9
10
  main.layout#content-inner
10
11
  .recent-posts#recent-posts
11
12
  #category-bar
@@ -15,6 +16,5 @@ block content
15
16
 
16
17
  // pageination
17
18
  include ./includes/mixins/pagination
18
-
19
19
  // aside
20
20
  include ./includes/widgets/aside/aside
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-solitude",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
4
4
  "description": "A beautiful, powerful, and efficient Hexo theme developed by the efu.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -83,12 +83,7 @@ hexo.extend.filter.register('before_generate', () => {
83
83
  name: 'hexo-theme-solitude',
84
84
  file: 'js/third_party/universe.min.js',
85
85
  version
86
- },
87
- lately_js: {
88
- name: 'hexo-theme-solitude',
89
- file: 'js/third_party/lately.min.js',
90
- version
91
- },
86
+ }
92
87
  }
93
88
 
94
89
  const minFile = file => {
@@ -82,9 +82,10 @@ hexo.extend.filter.register('before_generate', () => {
82
82
  comment: false,
83
83
  }, award: {
84
84
  enable: false,
85
- wechat: 'https://7.isyangs.cn/34/65f2e5814db1a-34.png',
86
- alipay: 'https://7.isyangs.cn/34/65f2e5a6d2ef5-34.png',
87
- url: '/about/',
85
+ appreciators: '/',
86
+ title: '感谢您的赞赏。',
87
+ desc: '因为有你们的支持,我才体会到写文章的价值。',
88
+ list: [],
88
89
  }, rss: null, covercolor: {
89
90
  enable: false, mode: 'local', api: 'https://api.qjqq.cn/api/Imgcolor?img=', time: 43200000,
90
91
  }
@@ -10,7 +10,7 @@ hexo.extend.filter.register('after_post_render', function (data) {
10
10
  data.cc = data.cc || copyright
11
11
  data.cover = data.cover || cover[getRandomInt(0, cover?.length)]
12
12
  data.excerpt = data.description || data.excerpt
13
- data.toc = !!(config.aside.toc.post && data.toc !== false);
13
+ data.toc = !!(config.aside.toc.post && data.toc !== false)
14
14
  }
15
15
  if (data.layout === 'page') {
16
16
  let {cover} = hexo.theme.config.page.default
@@ -389,7 +389,7 @@ i.solitude
389
389
  +maxWidth1200()
390
390
  width 100%
391
391
 
392
- > div:first-child:not(.recent-posts)
392
+ > div:first-child:not(.recent-posts,.aside-content)
393
393
  box-shadow var(--efu-shadow-border)
394
394
  padding 1rem 2rem
395
395
  border-radius 12px
@@ -398,6 +398,8 @@ i.solitude
398
398
  align-self flex-start
399
399
  animation slide-in .6s .1s backwards
400
400
  position relative
401
+ if hexo-config('aside.position') == 0
402
+ order 2
401
403
 
402
404
  +maxWidth768()
403
405
  box-shadow none
@@ -194,4 +194,11 @@
194
194
 
195
195
  h4
196
196
  font-size 1.1rem
197
- line-height 1.3
197
+ line-height 1.3
198
+
199
+ if hexo-config('mediumZoom')
200
+ .medium-zoom--opened .medium-zoom-overlay
201
+ z-index 10
202
+
203
+ .medium-zoom-image--opened
204
+ z-index 11
@@ -15,8 +15,11 @@
15
15
  display none
16
16
 
17
17
  +minWidth1300()
18
- padding-left 1rem
19
18
  animation slide-in .6s .3s backwards
19
+ if hexo-config('aside.position') == 0
20
+ padding-right 1rem
21
+ else
22
+ padding-left 1rem
20
23
 
21
24
  .item-headline
22
25
  padding-bottom 0
@@ -1,11 +1,12 @@
1
- #home_top
2
- max-width 1400px
3
- margin .5rem auto auto
4
- padding 0 1.5rem
1
+ if hexo-config('hometop.enable') || hexo-config('says.enable')
2
+ #home_top
3
+ max-width 1400px
4
+ margin .5rem auto auto
5
+ padding 0 1.5rem
5
6
 
6
- +maxWidth768()
7
- padding 0
8
- margin-top 0
7
+ +maxWidth768()
8
+ padding 0
9
+ margin-top 0
9
10
 
10
11
  if hexo-config('hometop.enable')
11
12
  @import "home-top.styl"
@@ -1,3 +1,7 @@
1
+ #recent-posts
2
+ if hexo-config('aside.position') == 0
3
+ order 2
4
+
1
5
  if hexo-config('index_post_list.direction') == "column"
2
6
  #recent-posts
3
7
  position relative
package/source/js/main.js CHANGED
@@ -332,14 +332,17 @@ let sco = {
332
332
  },
333
333
  addRuntime: function () {
334
334
  let el = document.getElementById('runtimeshow')
335
- el && GLOBAL_CONFIG.runtime && (el.innerText = utils.timeDiff(new Date(GLOBAL_CONFIG.runtime), new Date()) + GLOBAL_CONFIG.lang.lately.day)
335
+ el && GLOBAL_CONFIG.runtime && (el.innerText = utils.timeDiff(new Date(GLOBAL_CONFIG.runtime), new Date()) + GLOBAL_CONFIG.lang.time.day)
336
336
  },
337
337
  toTalk: function (txt) {
338
338
  const inputs = ["#wl-edit", ".el-textarea__inner"]
339
339
  for (let i = 0; i < inputs.length; i++) {
340
340
  let el = document.querySelector(inputs[i])
341
341
  if (el != null) {
342
- el.dispatchEvent(new Event('input', {bubble: true, cancelable: true}))
342
+ el.dispatchEvent(new Event('input', {
343
+ bubble: true,
344
+ cancelable: true
345
+ }))
343
346
  el.value = '> ' + txt.replace(/\n/g, '\n> ') + '\n\n'
344
347
  utils.scrollToDest(utils.getEleTop(document.getElementById('post-comment')), 300)
345
348
  el.focus()
@@ -383,12 +386,31 @@ let sco = {
383
386
  const timeNow = new Date();
384
387
  const hours = timeNow.getHours();
385
388
  const lang = GLOBAL_CONFIG.aside.sayhello;
386
- const greetings = [
387
- {start: 0, end: 5, text: lang.goodnight},
388
- {start: 6, end: 10, text: lang.morning},
389
- {start: 11, end: 14, text: lang.noon},
390
- {start: 15, end: 18, text: lang.afternoon},
391
- {start: 19, end: 24, text: lang.night},
389
+ const greetings = [{
390
+ start: 0,
391
+ end: 5,
392
+ text: lang.goodnight
393
+ },
394
+ {
395
+ start: 6,
396
+ end: 10,
397
+ text: lang.morning
398
+ },
399
+ {
400
+ start: 11,
401
+ end: 14,
402
+ text: lang.noon
403
+ },
404
+ {
405
+ start: 15,
406
+ end: 18,
407
+ text: lang.afternoon
408
+ },
409
+ {
410
+ start: 19,
411
+ end: 24,
412
+ text: lang.night
413
+ },
392
414
  ];
393
415
  for (let greeting of greetings) {
394
416
  if (hours >= greeting.start && hours <= greeting.end) {
@@ -631,6 +653,13 @@ let sco = {
631
653
 
632
654
  document.addEventListener('mouseover', debounce(showOwoBig, 100));
633
655
  document.addEventListener('mouseout', hideOwoBig);
656
+ },
657
+ changeTimeFormat(selector) {
658
+ selector.forEach(item => {
659
+ const timeVal = item.getAttribute('datetime')
660
+ item.textContent = utils.diffDate(timeVal, true)
661
+ item.style.display = 'inline'
662
+ })
634
663
  }
635
664
  }
636
665
 
@@ -638,7 +667,12 @@ const addHighlight = () => {
638
667
  const highlight = GLOBAL_CONFIG.highlight;
639
668
  if (!highlight) return;
640
669
 
641
- const {copy, expand, limit, syntax} = highlight;
670
+ const {
671
+ copy,
672
+ expand,
673
+ limit,
674
+ syntax
675
+ } = highlight;
642
676
  const $isPrismjs = syntax === 'prismjs';
643
677
  const $isShowTool = highlight.enable || copy || expand || limit;
644
678
  const expandClass = !expand === true ? 'closed' : ''
@@ -722,7 +756,9 @@ const addHighlight = () => {
722
756
  $syntaxHighlight.forEach(item => {
723
757
  const langName = item.getAttribute('data-language') || 'Code'
724
758
  const highlightLangEle = `<div class="code-lang">${langName}</div>`
725
- utils.wrap(item, 'figure', {class: 'highlight'})
759
+ utils.wrap(item, 'figure', {
760
+ class: 'highlight'
761
+ })
726
762
  createEle(highlightLangEle, item)
727
763
  })
728
764
  } else {
@@ -737,7 +773,13 @@ const addHighlight = () => {
737
773
 
738
774
  const addCopyright = () => {
739
775
  if (!GLOBAL_CONFIG.copyright) return
740
- const {limit, author, link, source, info} = GLOBAL_CONFIG.copyright
776
+ const {
777
+ limit,
778
+ author,
779
+ link,
780
+ source,
781
+ info
782
+ } = GLOBAL_CONFIG.copyright
741
783
  const handleCopy = (e) => {
742
784
  e.preventDefault()
743
785
  const copyText = window.getSelection(0).toString()
@@ -792,11 +834,17 @@ class tabs {
792
834
  }
793
835
 
794
836
  window.refreshFn = () => {
837
+ if (PAGE_CONFIG.is_home) {
838
+ sco.changeTimeFormat(document.querySelectorAll('#recent-posts time'))
839
+ GLOBAL_CONFIG.runtime && sco.addRuntime()
840
+ } else {
841
+ sco.changeTimeFormat(document.querySelectorAll('#post-meta time'))
842
+ }
843
+
795
844
  sco.initAdjust()
796
845
  scrollFn()
797
846
  sidebarFn()
798
847
  initObserver()
799
- sco.addRuntime()
800
848
  sco.hideCookie()
801
849
  sco.addPhotoFigcaption()
802
850
  sco.setTimeState()
@@ -804,7 +852,6 @@ window.refreshFn = () => {
804
852
  sco.categoriesBarActive()
805
853
  sco.listenToPageInputPress()
806
854
  sco.addNavBackgroundInit()
807
- utils.changeTimeFormat()
808
855
  GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg()
809
856
  GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll("#article-container img:not(.flink-avatar)"))
810
857
  GLOBAL_CONFIG.randomlink && randomLinksList()
@@ -830,4 +877,4 @@ window.onkeydown = function (e) {
830
877
  (27 === e.keyCode) && sco.hideConsole();
831
878
  }
832
879
 
833
- document.addEventListener('copy', () => utils.snackbarShow(GLOBAL_CONFIG.lang.copy.success,false,3e3))
880
+ document.addEventListener('copy', () => utils.snackbarShow(GLOBAL_CONFIG.lang.copy.success, false, 3e3))
@@ -3,4 +3,4 @@
3
3
  * email: o@efu.me
4
4
  * website: https://efu.me
5
5
  */
6
- class efuAI{constructor(){this.root="https://summary.tianli0.top",this.aiTalkMode=!1,this.aiPostExplanation="",this.config=GLOBAL_CONFIG.post_ai,this.scoGPTIsRunning=!1}init(){this.generate(),this.AIEngine()}getTitleAndContent(){const e=document.getElementById("article-container"),t=document.title,n=e.getElementsByTagName("p"),i=e.querySelectorAll("h1, h2, h3, h4, h5");return(t+" "+Array.from(i).concat(Array.from(n)).map((e=>e.innerText.replace(/https?:\/\/[^\s]+/g,""))).join(" ")).slice(0,1e3)}async generate(){this.aiShowAnimation(this.fetch(document.title,this.getTitleAndContent(),this.config.key))}async fetch(e,t,n){const i=`${this.root}/?content=${encodeURIComponent(t)}&title=${e}&key=${encodeURIComponent(n)}&url=${encodeURIComponent(window.location.href)}`,s=await fetch(i),o=await s.json();return s.ok?(this.aiPostExplanation=o.summary,o.summary):(console.error("Request failed:",o.err_msg),o.err_msg)}aiShowAnimation(e,t=!1){const n=document.querySelector(".ai-explanation"),i=document.querySelector(".ai-tag");if(!n||this.scoGPTIsRunning)return;this.scoGPTIsRunning=!0,this.cleanSuggestions(),i.classList.add("loadingAI"),n.style.display="block",n.innerHTML='生成中...<span class="blinking-cursor"></span>';let s,o,a=!0,c=0,r=!0;const l=new IntersectionObserver((e=>{a=e[0].isIntersecting,a&&requestAnimationFrame(o)}),{threshold:0});e.then((e=>{s=performance.now(),o=()=>{if(c<e.length&&a){const r=performance.now(),g=r-s,h=e.slice(c,c+1),u=/[,。!、?,.!?]/.test(h),m=/[a-zA-Z0-9]/.test(h);g>=(u?100*Math.random()+100:m?10:25)&&(n.innerText=e.slice(0,c+1),s=r,c++,c<e.length?n.innerHTML=e.slice(0,c)+'<span class="blinking-cursor"></span>':(n.innerHTML=e,n.style.display="block",this.scoGPTIsRunning=!1,i.classList.remove("loadingAI"),l.disconnect(),t&&this.createSuggestions())),a&&requestAnimationFrame(o)}},a&&r&&setTimeout((()=>{requestAnimationFrame(o),r=!1}),3e3),l.observe(n)})).catch((e=>{console.error("检索信息失败:",e),n.innerHTML="检索信息失败",n.style.display="block",this.scoGPTIsRunning=!1,i.classList.remove("loadingAI"),l.disconnect()}))}AIEngine(){const e=document.querySelector(".ai-tag");e&&e.addEventListener("click",(()=>{this.scoGPTIsRunning||(this.aiTalkMode=!0,this.aiShowAnimation(Promise.resolve(this.config.talk),!0))}))}cleanSuggestions(){const e=document.querySelector(".ai-suggestions");e?e.innerHTML="":console.error("没有这个元素:'ai-suggestions'")}createSuggestions(){this.aiTalkMode&&(this.cleanSuggestions(),this.createSuggestionItemWithAction("这篇文章讲了什么?",(()=>{""===this.aiPostExplanation?this.generate():this.aiShowAnimation(Promise.resolve(this.aiPostExplanation),!0)})),this.config.randomPost&&this.createSuggestionItemWithAction("带我去看看其他文章",(()=>toRandomPost())),this.aiTalkMode=!0)}createSuggestionItemWithAction(e,t){const n=document.querySelector(".ai-suggestions");if(!n)return void console.error("无法找到具有class为ai-suggestions的元素");const i=document.createElement("div");i.classList.add("ai-suggestions-item"),i.textContent=e,i.addEventListener("click",t),n.appendChild(i)}}const efu_ai=new efuAI;
6
+ class efuAI{constructor(){this.root="https://summary.tianli0.top",this.aiTalkMode=!1,this.aiPostExplanation="",this.config=GLOBAL_CONFIG.post_ai,this.scoGPTIsRunning=!1}init(){this.scoGPTIsRunning=!1,this.generate(),this.AIEngine()}getTitleAndContent(){const e=document.getElementById("article-container"),t=document.title,n=e.getElementsByTagName("p"),i=e.querySelectorAll("h1, h2, h3, h4, h5");return(t+" "+Array.from(i).concat(Array.from(n)).map((e=>e.innerText.replace(/https?:\/\/[^\s]+/g,""))).join(" ")).slice(0,1e3)}async generate(){this.aiShowAnimation(this.fetch(document.title,this.getTitleAndContent(),this.config.key))}async fetch(e,t,n){const i=`${this.root}/?content=${encodeURIComponent(t)}&title=${e}&key=${encodeURIComponent(n)}&url=${encodeURIComponent(window.location.href)}`,s=await fetch(i),o=await s.json();return s.ok?(this.aiPostExplanation=o.summary,o.summary):(console.error("Request failed:",o.err_msg),o.err_msg)}aiShowAnimation(e,t=!1){const n=document.querySelector(".ai-explanation"),i=document.querySelector(".ai-tag");if(!n||this.scoGPTIsRunning)return;this.scoGPTIsRunning=!0,this.cleanSuggestions(),i.classList.add("loadingAI"),n.style.display="block",n.innerHTML='生成中...<span class="blinking-cursor"></span>';let s,o,a=!0,c=0,r=!0;const l=new IntersectionObserver((e=>{a=e[0].isIntersecting,a&&requestAnimationFrame(o)}),{threshold:0});e.then((e=>{s=performance.now(),o=()=>{if(c<e.length&&a){const r=performance.now(),g=r-s,h=e.slice(c,c+1),u=/[,。!、?,.!?]/.test(h),m=/[a-zA-Z0-9]/.test(h);g>=(u?100*Math.random()+100:m?10:25)&&(n.innerText=e.slice(0,c+1),s=r,c++,c<e.length?n.innerHTML=e.slice(0,c)+'<span class="blinking-cursor"></span>':(n.innerHTML=e,n.style.display="block",this.scoGPTIsRunning=!1,i.classList.remove("loadingAI"),l.disconnect(),t&&this.createSuggestions())),a&&requestAnimationFrame(o)}},a&&r&&setTimeout((()=>{requestAnimationFrame(o),r=!1}),3e3),l.observe(n)})).catch((e=>{console.error("检索信息失败:",e),n.innerHTML="检索信息失败",n.style.display="block",this.scoGPTIsRunning=!1,i.classList.remove("loadingAI"),l.disconnect()}))}AIEngine(){const e=document.querySelector(".ai-tag");e&&e.addEventListener("click",(()=>{this.scoGPTIsRunning||(this.aiTalkMode=!0,this.aiShowAnimation(Promise.resolve(this.config.talk),!0))}))}cleanSuggestions(){const e=document.querySelector(".ai-suggestions");e?e.innerHTML="":console.error("没有这个元素:'ai-suggestions'")}createSuggestions(){this.aiTalkMode&&(this.cleanSuggestions(),this.createSuggestionItemWithAction("这篇文章讲了什么?",(()=>{""===this.aiPostExplanation?this.generate():this.aiShowAnimation(Promise.resolve(this.aiPostExplanation),!0)})),this.config.randomPost&&this.createSuggestionItemWithAction("带我去看看其他文章",(()=>toRandomPost())),this.aiTalkMode=!0)}createSuggestionItemWithAction(e,t){const n=document.querySelector(".ai-suggestions");if(!n)return void console.error("无法找到具有class为ai-suggestions的元素");const i=document.createElement("div");i.classList.add("ai-suggestions-item"),i.textContent=e,i.addEventListener("click",t),n.appendChild(i)}}const efu_ai=new efuAI;
@@ -72,7 +72,10 @@ const utils = {
72
72
  const dur = (typeof duration !== 'undefined') ? duration : 5000
73
73
  document.styleSheets[0].addRule(':root', '--efu-snackbar-time:' + dur + 'ms!important')
74
74
  Snackbar.show({
75
- text: text, showAction: sa, duration: dur, pos: 'top-center'
75
+ text: text,
76
+ showAction: sa,
77
+ duration: dur,
78
+ pos: 'top-center'
76
79
  })
77
80
  },
78
81
 
@@ -109,7 +112,8 @@ const utils = {
109
112
  if (currentPos > pos || isNavFixed) pos = pos - 70
110
113
  if ('scrollBehavior' in document.documentElement.style) {
111
114
  window.scrollTo({
112
- top: pos, behavior: 'smooth'
115
+ top: pos,
116
+ behavior: 'smooth'
113
117
  })
114
118
  return
115
119
  }
@@ -175,7 +179,10 @@ const utils = {
175
179
  },
176
180
  lazyloadImg: function () {
177
181
  window.lazyLoadInstance = new LazyLoad({
178
- elements_selector: 'img', threshold: 0, data_src: 'lazy-src', callback_error: (img) => {
182
+ elements_selector: 'img',
183
+ threshold: 0,
184
+ data_src: 'lazy-src',
185
+ callback_error: (img) => {
179
186
  img.setAttribute("src", GLOBAL_CONFIG.lazyload.error);
180
187
  }
181
188
  })
@@ -184,7 +191,9 @@ const utils = {
184
191
  const lightbox = GLOBAL_CONFIG.lightbox
185
192
 
186
193
  if (lightbox === 'mediumZoom' && mediumZoom) {
187
- mediumZoom(selector, {background: "var(--efu-card-bg)"});
194
+ mediumZoom(selector, {
195
+ background: "var(--efu-card-bg)"
196
+ });
188
197
  }
189
198
 
190
199
  if (lightbox === 'fancybox') {
@@ -204,15 +213,19 @@ const utils = {
204
213
 
205
214
  if (!window.fancyboxRun) {
206
215
  Fancybox.bind('[data-fancybox]', {
207
- Hash: false, Thumbs: {
216
+ Hash: false,
217
+ Thumbs: {
208
218
  showOnStart: false
209
- }, Images: {
219
+ },
220
+ Images: {
210
221
  Panzoom: {
211
222
  maxScale: 4
212
223
  }
213
- }, Carousel: {
224
+ },
225
+ Carousel: {
214
226
  transition: 'slide'
215
- }, Toolbar: {
227
+ },
228
+ Toolbar: {
216
229
  display: {
217
230
  left: ['infobar'],
218
231
  middle: ['zoomIn', 'zoomOut', 'toggle1to1', 'rotateCCW', 'rotateCW', 'flipX', 'flipY'],
@@ -224,11 +237,31 @@ const utils = {
224
237
  }
225
238
  }
226
239
  },
227
- changeTimeFormat() {
228
- window.Lately && Lately.init({
229
- target: 'time',
230
- lang: GLOBAL_CONFIG.lang.lately,
231
- })
240
+ diffDate: (d, more = false) => {
241
+ const dateNow = new Date()
242
+ const datePost = new Date(d)
243
+ const dateDiff = dateNow.getTime() - datePost.getTime()
244
+ const minute = 1000 * 60
245
+ const hour = minute * 60
246
+ const day = hour * 24
247
+ const month = day * 30
248
+ const {
249
+ time
250
+ } = GLOBAL_CONFIG.lang
251
+
252
+ if (!more) return parseInt(dateDiff / day)
253
+
254
+ const monthCount = dateDiff / month
255
+ const dayCount = dateDiff / day
256
+ const hourCount = dateDiff / hour
257
+ const minuteCount = dateDiff / minute
258
+
259
+ if (monthCount > 12) return datePost.toISOString().slice(0, 10)
260
+ if (monthCount >= 1) return `${parseInt(monthCount)} ${time.month}`
261
+ if (dayCount >= 1) return `${parseInt(dayCount)} ${time.day}`
262
+ if (hourCount >= 1) return `${parseInt(hourCount)} ${time.hour}`
263
+ if (minuteCount >= 1) return `${parseInt(minuteCount)} ${time.min}`
264
+ return time.just
232
265
  },
233
266
  loadComment: (dom, callback) => {
234
267
  if ('IntersectionObserver' in window) {
@@ -237,7 +270,9 @@ const utils = {
237
270
  callback()
238
271
  observerItem.disconnect()
239
272
  }
240
- }, { threshold: [0] })
273
+ }, {
274
+ threshold: [0]
275
+ })
241
276
  observerItem.observe(dom)
242
277
  } else {
243
278
  callback()
@@ -1,6 +0,0 @@
1
- /**
2
- * Lately.min.js 2.5.2
3
- * MIT License - http://www.opensource.org/licenses/mit-license.php
4
- * https://tokinx.github.io/lately/
5
- */
6
- !function(){window.Lately=new function(){var t=this;this.lang={second:"秒",minute:"分钟",hour:"小时",day:"天",month:"个月",year:"年",ago:"前",error:"NaN"};var e=function(e){e=new Date(n(e));var r=new function(){this.second=(Date.now()-e.getTime())/1e3,this.minute=this.second/60,this.hour=this.minute/60,this.day=this.hour/24,this.month=this.day/30,this.year=this.month/12},i=Object.keys(r).reverse().find(function(t){return r[t]>=1});return(i?function(t,e){return Math.floor(t)+e}(r[i],t.lang[i]):t.lang.error)+t.lang.ago},n=function(t){return t=new Date(t&&("number"==typeof t?t:t.replace(/-/g,"/").replace("T"," "))),!isNaN(t.getTime())&&t.getTime()};return{init:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r.target,a=void 0===i?"time":i,o=r.lang;o&&(t.lang=o);var u=!0,h=!1,l=void 0;try{for(var s,c=document.querySelectorAll(a)[Symbol.iterator]();!(u=(s=c.next()).done);u=!0){var f=s.value,g=n(f.dateTime)||n(f.title)||n(f.innerHTML)||0;if(!g)return;f.title=new Date(g).toLocaleString(),f.innerHTML=e(g)}}catch(t){h=!0,l=t}finally{try{!u&&c.return&&c.return()}finally{if(h)throw l}}},format:e}}}();