mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 17:50:54 +08:00
update
This commit is contained in:
@@ -8,19 +8,15 @@ script.
|
||||
const keyArray = Array.from(eleGroup).map(i => i.getAttribute('data-page-key'))
|
||||
|
||||
const headerList = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': window.location.origin
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
'site_name': '!{site}',
|
||||
'type':'page_comment',
|
||||
'page_keys': keyArray
|
||||
})
|
||||
method: 'GET',
|
||||
}
|
||||
|
||||
const res = await fetch('!{server}/api/stat', headerList)
|
||||
const searchParams = new URLSearchParams({
|
||||
'site_name': '!{site}',
|
||||
'page_keys': keyArray
|
||||
})
|
||||
|
||||
const res = await fetch(`!{server}/api/v2/stats/page_comment?${searchParams}`, headerList)
|
||||
const result = await res.json()
|
||||
|
||||
keyArray.forEach((key, index) => {
|
||||
|
||||
@@ -11,7 +11,6 @@ script.
|
||||
site: '!{site}',
|
||||
pageKey: location.pathname,
|
||||
darkMode: document.documentElement.getAttribute('data-theme') === 'dark',
|
||||
countEl: '.artalk-count'
|
||||
},!{JSON.stringify(option)}))
|
||||
|
||||
if (GLOBAL_CONFIG.lightbox === 'null') return
|
||||
|
||||
39
layout/includes/third-party/comments/twikoo.pug
vendored
39
layout/includes/third-party/comments/twikoo.pug
vendored
@@ -3,22 +3,6 @@
|
||||
|
||||
script.
|
||||
(() => {
|
||||
const init = () => {
|
||||
twikoo.init(Object.assign({
|
||||
el: '#twikoo-wrap',
|
||||
envId: '!{envId}',
|
||||
region: '!{region}',
|
||||
onCommentLoaded: () => {
|
||||
btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
|
||||
}
|
||||
}, !{JSON.stringify(option)}))
|
||||
}
|
||||
|
||||
const loadTwikoo = () => {
|
||||
if (typeof twikoo === 'object') setTimeout(init,0)
|
||||
else getScript('!{url_for(theme.asset.twikoo)}').then(init)
|
||||
}
|
||||
|
||||
const getCount = () => {
|
||||
const countELement = document.getElementById('twikoo-count')
|
||||
if(!countELement) return
|
||||
@@ -34,12 +18,27 @@ script.
|
||||
})
|
||||
}
|
||||
|
||||
const init = () => {
|
||||
twikoo.init(Object.assign({
|
||||
el: '#twikoo-wrap',
|
||||
envId: '!{envId}',
|
||||
region: '!{region}',
|
||||
onCommentLoaded: () => {
|
||||
btf.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
|
||||
}
|
||||
}, !{JSON.stringify(option)}))
|
||||
|
||||
!{count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : ''}
|
||||
}
|
||||
|
||||
const loadTwikoo = () => {
|
||||
if (typeof twikoo === 'object') setTimeout(init,0)
|
||||
else getScript('!{url_for(theme.asset.twikoo)}').then(init)
|
||||
}
|
||||
|
||||
if ('!{use[0]}' === 'Twikoo' || !!{lazyload}) {
|
||||
if (!{lazyload}) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
|
||||
else {
|
||||
loadTwikoo()
|
||||
!{count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : ''}
|
||||
}
|
||||
else loadTwikoo()
|
||||
} else {
|
||||
window.loadOtherComment = loadTwikoo
|
||||
}
|
||||
|
||||
15
layout/includes/third-party/comments/waline.pug
vendored
15
layout/includes/third-party/comments/waline.pug
vendored
@@ -3,8 +3,10 @@
|
||||
|
||||
script.
|
||||
(() => {
|
||||
const initWaline = () => {
|
||||
const waline = Waline.init(Object.assign({
|
||||
let initFn = window.walineFn || null
|
||||
|
||||
const initWaline = (Fn) => {
|
||||
const waline = Fn(Object.assign({
|
||||
el: '#waline-wrap',
|
||||
serverURL: '!{serverURL}',
|
||||
pageview: !{lazyload ? false : pageview},
|
||||
@@ -18,15 +20,16 @@ script.
|
||||
}
|
||||
|
||||
btf.addGlobalFn('pjax', destroyWaline, 'destroyWaline')
|
||||
|
||||
}
|
||||
|
||||
const loadWaline = async () => {
|
||||
if (typeof Waline === 'object') initWaline()
|
||||
if (initFn) initWaline(initFn)
|
||||
else {
|
||||
await getCSS('!{url_for(theme.asset.waline_css)}')
|
||||
await getScript('!{url_for(theme.asset.waline_js)}')
|
||||
initWaline()
|
||||
const { init } = await import('!{url_for(theme.asset.waline_js)}')
|
||||
initFn = init || Waline.init
|
||||
initWaline(initFn)
|
||||
window.walineFn = initFn
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ script.
|
||||
|
||||
const getSetting = async () => {
|
||||
try {
|
||||
const res = await fetch('!{server}/api/conf', { method: 'GET' })
|
||||
const res = await fetch('!{server}/api/v2/conf', { method: 'GET' })
|
||||
return await res.json()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -55,24 +55,20 @@ script.
|
||||
}
|
||||
|
||||
const headerList = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': window.location.origin
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
'site_name': '!{site}',
|
||||
'limit': '!{theme.newest_comments.limit}',
|
||||
'type':'latest_comments'
|
||||
})
|
||||
method: 'GET',
|
||||
}
|
||||
|
||||
const searchParams = new URLSearchParams({
|
||||
'site_name': '!{site}',
|
||||
'limit': '!{theme.newest_comments.limit}',
|
||||
})
|
||||
|
||||
const getComment = async () => {
|
||||
try {
|
||||
const res = await fetch('!{server}/api/stat', headerList)
|
||||
const res = await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`, headerList)
|
||||
const result = await res.json()
|
||||
const avatarStr = await getSetting()
|
||||
const { mirror, params, default:defaults } = avatarStr.data.frontend_conf.gravatar
|
||||
const { mirror, params, default:defaults } = avatarStr.frontend_conf.gravatar
|
||||
const avatarCdn = !{avatarCdn} || mirror
|
||||
let avatarDefault = !{avatarDefault} || params || defaults
|
||||
avatarDefault = avatarDefault.startsWith('d=') ? avatarDefault : `d=${avatarDefault}`
|
||||
|
||||
Reference in New Issue
Block a user