fix theme...
This commit is contained in:
3
themes/anzhiyu/layout/includes/third-party/aplayer.pug
vendored
Normal file
3
themes/anzhiyu/layout/includes/third-party/aplayer.pug
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
link(rel='stylesheet' href=url_for(theme.asset.aplayer_css) media="print" onload="this.media='all'")
|
||||
script(src=url_for(theme.asset.aplayer_js))
|
||||
script(src=url_for(theme.asset.meting_js))
|
||||
19
themes/anzhiyu/layout/includes/third-party/card-post-count/artalk.pug
vendored
Normal file
19
themes/anzhiyu/layout/includes/third-party/card-post-count/artalk.pug
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
- const { server, site } = theme.artalk
|
||||
|
||||
script.
|
||||
(() => {
|
||||
const getArtalkCount = () => {
|
||||
const runWidget = () => {
|
||||
Artalk.loadCountWidget({
|
||||
server: '!{server}',
|
||||
site: '!{site}',
|
||||
countEl: '.artalk-count'
|
||||
})
|
||||
}
|
||||
|
||||
if (typeof Artalk === 'function') runWidget()
|
||||
else getScript('!{theme.asset.artalk_js}').then(runWidget)
|
||||
}
|
||||
|
||||
window.pjax ? getArtalkCount() : window.addEventListener('load', getArtalkCount)
|
||||
})()
|
||||
9
themes/anzhiyu/layout/includes/third-party/card-post-count/index.pug
vendored
Normal file
9
themes/anzhiyu/layout/includes/third-party/card-post-count/index.pug
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
case theme.comments.use[0]
|
||||
when 'Twikoo'
|
||||
include ./twikoo.pug
|
||||
when 'Valine'
|
||||
include ./valine.pug
|
||||
when 'Waline'
|
||||
include ./waline.pug
|
||||
when 'Artalk'
|
||||
include ./artalk.pug
|
||||
37
themes/anzhiyu/layout/includes/third-party/card-post-count/twikoo.pug
vendored
Normal file
37
themes/anzhiyu/layout/includes/third-party/card-post-count/twikoo.pug
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
script.
|
||||
(() => {
|
||||
const getCommentUrl = () => {
|
||||
const eleGroup = document.querySelectorAll('#recent-posts .article-title')
|
||||
let urlArray = []
|
||||
eleGroup.forEach(i=>{
|
||||
urlArray.push(i.getAttribute('href'))
|
||||
})
|
||||
return urlArray
|
||||
}
|
||||
|
||||
const getCount = () => {
|
||||
const runTwikoo = () => {
|
||||
twikoo.getCommentsCount({
|
||||
envId: '!{theme.twikoo.envId}',
|
||||
region: '!{theme.twikoo.region}',
|
||||
urls: getCommentUrl(),
|
||||
includeReply: false
|
||||
}).then(function (res) {
|
||||
document.querySelectorAll('#recent-posts .twikoo-count').forEach((item,index) => {
|
||||
item.textContent = res[index].count
|
||||
})
|
||||
}).catch(function (err) {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
if (typeof twikoo === 'object') {
|
||||
runTwikoo()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.twikoo)}').then(runTwikoo)
|
||||
}
|
||||
}
|
||||
|
||||
window.pjax ? getCount() : window.addEventListener('load', getCount)
|
||||
|
||||
})()
|
||||
20
themes/anzhiyu/layout/includes/third-party/card-post-count/valine.pug
vendored
Normal file
20
themes/anzhiyu/layout/includes/third-party/card-post-count/valine.pug
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
script.
|
||||
(() => {
|
||||
function loadValine () {
|
||||
function initValine () {
|
||||
let initData = {
|
||||
el: '#vcomment',
|
||||
appId: '#{theme.valine.appId}',
|
||||
appKey: '#{theme.valine.appKey}',
|
||||
serverURLs: '#{theme.valine.serverURLs}'
|
||||
}
|
||||
|
||||
const valine = new Valine(initData)
|
||||
}
|
||||
|
||||
if (typeof Valine === 'function') initValine()
|
||||
else getScript('!{url_for(theme.asset.valine)}').then(initValine)
|
||||
}
|
||||
|
||||
window.pjax ? loadValine() : window.addEventListener('load', loadValine)
|
||||
})()
|
||||
21
themes/anzhiyu/layout/includes/third-party/card-post-count/waline.pug
vendored
Normal file
21
themes/anzhiyu/layout/includes/third-party/card-post-count/waline.pug
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
- const serverURL = theme.waline.serverURL.replace(/\/$/, '')
|
||||
script.
|
||||
(() => {
|
||||
async function loadWaline () {
|
||||
try {
|
||||
const eleGroup = document.querySelectorAll('#recent-posts .waline-comment-count')
|
||||
const keyArray = Array.from(eleGroup).map(i => i.getAttribute('data-path'))
|
||||
|
||||
const res = await fetch(`!{serverURL}/api/comment?type=count&url=${keyArray}`, { method: 'GET' })
|
||||
const result = await res.json()
|
||||
|
||||
result.data.forEach((count, index) => {
|
||||
eleGroup[index].textContent = count
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
window.pjax ? loadWaline() : window.addEventListener('load', loadWaline)
|
||||
})()
|
||||
50
themes/anzhiyu/layout/includes/third-party/chat/chatra.pug
vendored
Normal file
50
themes/anzhiyu/layout/includes/third-party/chat/chatra.pug
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
//- https://chatra.io/help/api/
|
||||
script.
|
||||
(() => {
|
||||
const isChatBtn = !{theme.chat_btn}
|
||||
const isChatHideShow = !{theme.chat_hide_show}
|
||||
|
||||
if (isChatBtn) {
|
||||
const close = () => {
|
||||
Chatra('minimizeWidget')
|
||||
Chatra('hide')
|
||||
}
|
||||
|
||||
const open = () => {
|
||||
Chatra('openChat', true)
|
||||
Chatra('show')
|
||||
}
|
||||
|
||||
window.ChatraSetup = {
|
||||
startHidden: true
|
||||
}
|
||||
|
||||
window.chatBtnFn = () => {
|
||||
const isShow = document.getElementById('chatra').classList.contains('chatra--expanded')
|
||||
isShow ? close() : open()
|
||||
}
|
||||
} else if (isChatHideShow) {
|
||||
window.chatBtn = {
|
||||
hide: () => {
|
||||
Chatra('hide')
|
||||
},
|
||||
show: () => {
|
||||
Chatra('show')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(function(d, w, c) {
|
||||
w.ChatraID = '#{theme.chatra.id}'
|
||||
var s = d.createElement('script')
|
||||
w[c] = w[c] || function() {
|
||||
(w[c].q = w[c].q || []).push(arguments)
|
||||
}
|
||||
s.async = true
|
||||
s.src = 'https://call.chatra.io/chatra.js'
|
||||
if (d.head) d.head.appendChild(s)
|
||||
})(document, window, 'Chatra')
|
||||
|
||||
})()
|
||||
|
||||
|
||||
45
themes/anzhiyu/layout/includes/third-party/chat/crisp.pug
vendored
Normal file
45
themes/anzhiyu/layout/includes/third-party/chat/crisp.pug
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
script.
|
||||
(() => {
|
||||
window.$crisp = [];
|
||||
window.CRISP_WEBSITE_ID = "!{theme.crisp.website_id}";
|
||||
(function () {
|
||||
d = document;
|
||||
s = d.createElement("script");
|
||||
s.src = "https://client.crisp.chat/l.js";
|
||||
s.async = 1;
|
||||
d.getElementsByTagName("head")[0].appendChild(s);
|
||||
})();
|
||||
$crisp.push(["safe", true])
|
||||
|
||||
const isChatBtn = !{theme.chat_btn}
|
||||
const isChatHideShow = !{theme.chat_hide_show}
|
||||
|
||||
if (isChatBtn) {
|
||||
const open = () => {
|
||||
$crisp.push(["do", "chat:show"])
|
||||
$crisp.push(["do", "chat:open"])
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
$crisp.push(["do", "chat:hide"])
|
||||
}
|
||||
|
||||
close()
|
||||
$crisp.push(["on", "chat:closed", function() {
|
||||
close()
|
||||
}])
|
||||
|
||||
window.chatBtnFn = () => {
|
||||
$crisp.is("chat:visible") ? close() : open()
|
||||
}
|
||||
} else if (isChatHideShow) {
|
||||
window.chatBtn = {
|
||||
hide: () => {
|
||||
$crisp.push(["do", "chat:hide"])
|
||||
},
|
||||
show: () => {
|
||||
$crisp.push(["do", "chat:show"])
|
||||
}
|
||||
}
|
||||
}
|
||||
})()
|
||||
40
themes/anzhiyu/layout/includes/third-party/chat/daovoice.pug
vendored
Normal file
40
themes/anzhiyu/layout/includes/third-party/chat/daovoice.pug
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
//- https://guide.daocloud.io/daovoice/javascript-api-5869833.html
|
||||
script.
|
||||
(() => {
|
||||
(function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/!{theme.daovoice.app_id}.js","daovoice")
|
||||
|
||||
const isChatBtn = !{theme.chat_btn}
|
||||
const isChatHideShow = !{theme.chat_hide_show}
|
||||
|
||||
daovoice('init', {
|
||||
app_id: '!{theme.daovoice.app_id}',},{
|
||||
launcher: {
|
||||
disableLauncherIcon: isChatBtn
|
||||
},
|
||||
});
|
||||
daovoice('update');
|
||||
|
||||
if (isChatBtn) {
|
||||
window.chatBtnFn = () => {
|
||||
const isShow = document.getElementById('daodream-messenger').classList.contains('daodream-messenger-active')
|
||||
isShow ? daovoice('hide') : daovoice('show')
|
||||
}
|
||||
} else if (isChatHideShow) {
|
||||
window.chatBtn = {
|
||||
hide: () => {
|
||||
daovoice('update', {},{
|
||||
launcher: {
|
||||
disableLauncherIcon: true
|
||||
}
|
||||
})
|
||||
},
|
||||
show: () => {
|
||||
daovoice('update', {}, {
|
||||
launcher: {
|
||||
disableLauncherIcon: false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})()
|
||||
8
themes/anzhiyu/layout/includes/third-party/chat/index.pug
vendored
Normal file
8
themes/anzhiyu/layout/includes/third-party/chat/index.pug
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
if theme.chatra && theme.chatra.enable
|
||||
include ./chatra.pug
|
||||
else if theme.tidio && theme.tidio.enable
|
||||
include ./tidio.pug
|
||||
else if theme.daovoice && theme.daovoice.enable
|
||||
include ./daovoice.pug
|
||||
else if theme.crisp && theme.crisp.enable
|
||||
include ./crisp.pug
|
||||
47
themes/anzhiyu/layout/includes/third-party/chat/tidio.pug
vendored
Normal file
47
themes/anzhiyu/layout/includes/third-party/chat/tidio.pug
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
script(src=`//code.tidio.co/${theme.tidio.public_key}.js` async)
|
||||
script.
|
||||
(() => {
|
||||
const isChatBtn = !{theme.chat_btn}
|
||||
const isChatHideShow = !{theme.chat_hide_show}
|
||||
|
||||
if (isChatBtn) {
|
||||
let isShow = false
|
||||
const close = () => {
|
||||
window.tidioChatApi.hide()
|
||||
isShow = false
|
||||
document.body.style.position = 'relative';
|
||||
document.documentElement.style.overflow = 'auto'
|
||||
}
|
||||
|
||||
const open = () => {
|
||||
window.tidioChatApi.open()
|
||||
window.tidioChatApi.show()
|
||||
isShow = true
|
||||
}
|
||||
|
||||
const onTidioChatApiReady = () => {
|
||||
window.tidioChatApi.hide()
|
||||
window.tidioChatApi.on("close", close)
|
||||
}
|
||||
if (window.tidioChatApi) {
|
||||
window.tidioChatApi.on("ready", onTidioChatApiReady)
|
||||
} else {
|
||||
document.addEventListener("tidioChat-ready", onTidioChatApiReady)
|
||||
}
|
||||
|
||||
window.chatBtnFn = () => {
|
||||
if (!window.tidioChatApi) return
|
||||
isShow ? close() : open()
|
||||
}
|
||||
} else if (isChatHideShow) {
|
||||
window.chatBtn = {
|
||||
hide: () => {
|
||||
window.tidioChatApi && window.tidioChatApi.hide()
|
||||
},
|
||||
show: () => {
|
||||
window.tidioChatApi && window.tidioChatApi.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
63
themes/anzhiyu/layout/includes/third-party/comments/artalk.pug
vendored
Normal file
63
themes/anzhiyu/layout/includes/third-party/comments/artalk.pug
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
- const { server, site, option } = theme.artalk
|
||||
- const { use, lazyload, count } = theme.comments
|
||||
|
||||
script.
|
||||
(() => {
|
||||
const initArtalk = () => {
|
||||
window.artalkItem = new Artalk(Object.assign({
|
||||
el: '#artalk-wrap',
|
||||
server: '!{server}',
|
||||
site: '!{site}',
|
||||
pageKey: location.pathname,
|
||||
darkMode: document.documentElement.getAttribute('data-theme') === 'dark',
|
||||
countEl: '.artalk-count'
|
||||
},!{JSON.stringify(option)}))
|
||||
|
||||
if (GLOBAL_CONFIG.lightbox === 'null') return
|
||||
window.artalkItem.use(ctx => {
|
||||
ctx.on('list-loaded', () => {
|
||||
ctx.getCommentList().forEach(comment => {
|
||||
const $content = comment.getRender().$content
|
||||
anzhiyu.loadLightbox($content.querySelectorAll('img:not([atk-emoticon])'))
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const loadArtalk = async () => {
|
||||
if (typeof window.artalkItem === 'object') {
|
||||
initArtalk()
|
||||
!{count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : ''}
|
||||
} else {
|
||||
await getCSS('!{theme.asset.artalk_css}')
|
||||
await getScript('!{theme.asset.artalk_js}')
|
||||
initArtalk()
|
||||
!{count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : ''}
|
||||
}
|
||||
}
|
||||
|
||||
const getCount = () => {
|
||||
Artalk.loadCountWidget({
|
||||
server: '!{server}',
|
||||
site: '!{site}',
|
||||
countEl: '.artalk-count'
|
||||
})
|
||||
}
|
||||
|
||||
const artalkChangeMode = theme => {
|
||||
const artalkWrap = document.getElementById('artalk-wrap')
|
||||
if (!(artalkWrap && artalkWrap.children.length)) return
|
||||
const isDark = theme === 'dark'
|
||||
window.artalkItem.setDarkMode(isDark)
|
||||
}
|
||||
|
||||
|
||||
anzhiyu.addGlobalFn('themeChange', artalkChangeMode, 'artalk')
|
||||
|
||||
if ('!{use[0]}' === 'Artalk' || !!{lazyload}) {
|
||||
if (!{lazyload}) anzhiyu.loadComment(document.getElementById('artalk-wrap'), loadArtalk)
|
||||
else loadArtalk()
|
||||
} else {
|
||||
window.loadOtherComment = loadArtalk
|
||||
}
|
||||
})()
|
||||
35
themes/anzhiyu/layout/includes/third-party/comments/index.pug
vendored
Normal file
35
themes/anzhiyu/layout/includes/third-party/comments/index.pug
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
- let defaultComment = theme.comments.use[0]
|
||||
hr
|
||||
#post-comment
|
||||
.comment-head
|
||||
.comment-headline
|
||||
i.anzhiyufont.anzhiyu-icon-comments
|
||||
span= ' ' + _p('comment')
|
||||
.comment-randomInfo
|
||||
a(onclick="anzhiyu.addRandomCommentInfo()" href="javascript:void(0)" style=theme.visitorMail.enable ? "" : "display: none") 匿名评论
|
||||
a(href=url_for('/privacy') style="margin-left: 4px") 隐私政策
|
||||
|
||||
if theme.comments.use.length > 1
|
||||
.comment-switch
|
||||
span.first-comment=defaultComment
|
||||
span#switch-btn
|
||||
span.second-comment=theme.comments.use[1]
|
||||
|
||||
if defaultComment == "Twikoo"
|
||||
.comment-tips#comment-tips
|
||||
span ✅ 你无需删除空行,直接评论以获取最佳展示效果
|
||||
|
||||
.comment-wrap
|
||||
each name in theme.comments.use
|
||||
div
|
||||
case name
|
||||
when 'Valine'
|
||||
#vcomment.vcomment
|
||||
when 'Twikoo'
|
||||
#twikoo-wrap
|
||||
when 'Waline'
|
||||
#waline-wrap
|
||||
when 'Artalk'
|
||||
#artalk-wrap
|
||||
|
||||
.comment-barrage
|
||||
10
themes/anzhiyu/layout/includes/third-party/comments/js.pug
vendored
Normal file
10
themes/anzhiyu/layout/includes/third-party/comments/js.pug
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
each name in theme.comments.use
|
||||
case name
|
||||
when 'Valine'
|
||||
!=partial('includes/third-party/comments/valine', {}, {cache: true})
|
||||
when 'Twikoo'
|
||||
!=partial('includes/third-party/comments/twikoo', {}, {cache: true})
|
||||
when 'Waline'
|
||||
!=partial('includes/third-party/comments/waline', {}, {cache: true})
|
||||
when 'Artalk'
|
||||
!=partial('includes/third-party/comments/artalk', {}, {cache: true})
|
||||
50
themes/anzhiyu/layout/includes/third-party/comments/twikoo.pug
vendored
Normal file
50
themes/anzhiyu/layout/includes/third-party/comments/twikoo.pug
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
- const { envId, region, option } = theme.twikoo
|
||||
- const { use, lazyload, count } = theme.comments
|
||||
|
||||
script.
|
||||
(() => {
|
||||
const init = () => {
|
||||
twikoo.init(Object.assign({
|
||||
el: '#twikoo-wrap',
|
||||
envId: '!{envId}',
|
||||
region: '!{region}',
|
||||
onCommentLoaded: () => {
|
||||
anzhiyu.loadLightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
|
||||
}
|
||||
}, !{JSON.stringify(option)}))
|
||||
}
|
||||
|
||||
const loadTwikoo = () => {
|
||||
if (typeof twikoo === 'object') setTimeout(runFn,0)
|
||||
else getScript('!{url_for(theme.asset.twikoo)}').then(runFn)
|
||||
}
|
||||
|
||||
const getCount = () => {
|
||||
const countELement = document.getElementById('twikoo-count')
|
||||
if(!countELement) return
|
||||
twikoo.getCommentsCount({
|
||||
envId: '!{envId}',
|
||||
region: '!{region}',
|
||||
urls: [window.location.pathname],
|
||||
includeReply: false
|
||||
}).then(res => {
|
||||
countELement.textContent = res[0].count
|
||||
}).catch(err => {
|
||||
console.error(err)
|
||||
})
|
||||
}
|
||||
|
||||
const runFn = () => {
|
||||
init();
|
||||
!{count ? 'GLOBAL_CONFIG_SITE.isPost && getCount()' : ''}
|
||||
}
|
||||
|
||||
if ('!{use[0]}' === 'Twikoo' || !!{lazyload}) {
|
||||
if (!{lazyload}) anzhiyu.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
|
||||
else {
|
||||
loadTwikoo()
|
||||
}
|
||||
} else {
|
||||
window.loadOtherComment = loadTwikoo
|
||||
}
|
||||
})()
|
||||
37
themes/anzhiyu/layout/includes/third-party/comments/valine.pug
vendored
Normal file
37
themes/anzhiyu/layout/includes/third-party/comments/valine.pug
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
- const { use, lazyload } = theme.comments
|
||||
- const { appId, appKey, avatar, serverURLs, visitor, option } = theme.valine
|
||||
|
||||
- let emojiMaps = '""'
|
||||
if site.data.valine
|
||||
- emojiMaps = JSON.stringify(site.data.valine)
|
||||
|
||||
script.
|
||||
(() => {
|
||||
const initValine = () => {
|
||||
const valine = new Valine(Object.assign({
|
||||
el: '#vcomment',
|
||||
appId: '#{appId}',
|
||||
appKey: '#{appKey}',
|
||||
avatar: '#{avatar}',
|
||||
serverURLs: '#{serverURLs}',
|
||||
emojiMaps: !{emojiMaps},
|
||||
path: window.location.pathname,
|
||||
visitor: #{visitor}
|
||||
}, !{JSON.stringify(option)}))
|
||||
}
|
||||
|
||||
const loadValine = async () => {
|
||||
if (typeof Valine === 'function') initValine()
|
||||
else {
|
||||
await getScript('!{url_for(theme.asset.valine)}')
|
||||
initValine()
|
||||
}
|
||||
}
|
||||
|
||||
if ('!{use[0]}' === 'Valine' || !!{lazyload}) {
|
||||
if (!{lazyload}) anzhiyu.loadComment(document.getElementById('vcomment'),loadValine)
|
||||
else setTimeout(loadValine, 0)
|
||||
} else {
|
||||
window.loadOtherComment = loadValine
|
||||
}
|
||||
})()
|
||||
32
themes/anzhiyu/layout/includes/third-party/comments/waline.pug
vendored
Normal file
32
themes/anzhiyu/layout/includes/third-party/comments/waline.pug
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
- const { serverURL, option, pageview } = theme.waline
|
||||
- const { lazyload, count, use } = theme.comments
|
||||
|
||||
script.
|
||||
(() => {
|
||||
const initWaline = () => {
|
||||
const waline = Waline.init(Object.assign({
|
||||
el: '#waline-wrap',
|
||||
serverURL: '!{serverURL}',
|
||||
pageview: !{lazyload ? false : pageview},
|
||||
dark: 'html[data-theme="dark"]',
|
||||
path: window.location.pathname,
|
||||
comment: !{lazyload ? false : count},
|
||||
}, !{JSON.stringify(option)}))
|
||||
}
|
||||
|
||||
const loadWaline = async () => {
|
||||
if (typeof Waline === 'object') initWaline()
|
||||
else {
|
||||
await getCSS('!{url_for(theme.asset.waline_css)}')
|
||||
await getScript('!{url_for(theme.asset.waline_js)}')
|
||||
initWaline()
|
||||
}
|
||||
}
|
||||
|
||||
if ('!{use[0]}' === 'Waline' || !!{lazyload}) {
|
||||
if (!{lazyload}) anzhiyu.loadComment(document.getElementById('waline-wrap'),loadWaline)
|
||||
else setTimeout(loadWaline, 0)
|
||||
} else {
|
||||
window.loadOtherComment = loadWaline
|
||||
}
|
||||
})()
|
||||
35
themes/anzhiyu/layout/includes/third-party/effect.pug
vendored
Normal file
35
themes/anzhiyu/layout/includes/third-party/effect.pug
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
if theme.fireworks && theme.fireworks.enable
|
||||
canvas.fireworks(mobile=`${theme.fireworks.mobile}`)
|
||||
script(src=url_for(theme.asset.fireworks))
|
||||
|
||||
if (theme.canvas_ribbon && theme.canvas_ribbon.enable)
|
||||
script(defer id="ribbon" src=url_for(theme.asset.canvas_ribbon) size=theme.canvas_ribbon.size
|
||||
alpha=theme.canvas_ribbon.alpha zIndex=theme.canvas_ribbon.zIndex mobile=`${theme.canvas_ribbon.mobile}` data-click=`${theme.canvas_ribbon.click_to_change}`)
|
||||
|
||||
if (theme.canvas_fluttering_ribbon && theme.canvas_fluttering_ribbon.enable)
|
||||
script(defer id="fluttering_ribbon" mobile=`${theme.canvas_fluttering_ribbon.mobile}` src=url_for(theme.asset.canvas_fluttering_ribbon))
|
||||
|
||||
if (theme.canvas_nest && theme.canvas_nest.enable)
|
||||
script#canvas_nest(defer color=theme.canvas_nest.color opacity=theme.canvas_nest.opacity zIndex=theme.canvas_nest.zIndex count=theme.canvas_nest.count mobile=`${theme.canvas_nest.mobile}` src=url_for(theme.asset.canvas_nest))
|
||||
|
||||
if theme.activate_power_mode.enable
|
||||
script(src=url_for(theme.asset.activate_power_mode))
|
||||
script.
|
||||
POWERMODE.colorful = !{theme.activate_power_mode.colorful};
|
||||
POWERMODE.shake = !{theme.activate_power_mode.shake};
|
||||
POWERMODE.mobile = !{theme.activate_power_mode.mobile};
|
||||
document.body.addEventListener('input', POWERMODE);
|
||||
|
||||
//- 鼠標特效
|
||||
if theme.click_heart && theme.click_heart.enable
|
||||
script#click-heart(src=url_for(theme.asset.click_heart) async mobile=`${theme.click_heart.mobile}`)
|
||||
|
||||
if theme.ClickShowText && theme.ClickShowText.enable
|
||||
script#click-show-text(
|
||||
src= url_for(theme.asset.ClickShowText)
|
||||
data-mobile= `${theme.ClickShowText.mobile}`
|
||||
data-text= theme.ClickShowText.text.join(",")
|
||||
data-fontsize= theme.ClickShowText.fontSize
|
||||
data-random= `${theme.ClickShowText.random}`
|
||||
async
|
||||
)
|
||||
128
themes/anzhiyu/layout/includes/third-party/footerBarSubtitle.pug
vendored
Normal file
128
themes/anzhiyu/layout/includes/third-party/footerBarSubtitle.pug
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
- const { effect,loop,source,sub,startDelay,typeSpeed,backSpeed } = theme.footer.footerBar.subTitle
|
||||
- let subContent = sub || new Array()
|
||||
|
||||
case source
|
||||
when 1
|
||||
script.
|
||||
function subtitleType () {
|
||||
fetch('https://v1.hitokoto.cn')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (!{effect}) {
|
||||
const from = '出自 ' + data.from
|
||||
const sub = !{JSON.stringify(subContent)}
|
||||
sub.unshift(data.hitokoto, from)
|
||||
window.typed = new Typed('#footer-type-tips', {
|
||||
strings: sub,
|
||||
startDelay: !{startDelay},
|
||||
typeSpeed: !{typeSpeed},
|
||||
loop: !{loop},
|
||||
backSpeed: !{backSpeed},
|
||||
})
|
||||
} else {
|
||||
document.getElementById('footer-type-tips').innerHTML = data.hitokoto
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (!{effect}) {
|
||||
if (typeof Typed === 'function') {
|
||||
subtitleType()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||
}
|
||||
} else {
|
||||
subtitleType()
|
||||
}
|
||||
|
||||
when 2
|
||||
script.
|
||||
function subtitleType () {
|
||||
getScript('https://yijuzhan.com/api/word.php?m=js').then(() => {
|
||||
const con = str[0]
|
||||
if (!{effect}) {
|
||||
const from = '出自 ' + str[1]
|
||||
const sub = !{JSON.stringify(subContent)}
|
||||
sub.unshift(con, from)
|
||||
window.typed = new Typed('#footer-type-tips', {
|
||||
strings: sub,
|
||||
startDelay: !{startDelay},
|
||||
typeSpeed: !{typeSpeed},
|
||||
loop: !{loop},
|
||||
backSpeed: !{backSpeed},
|
||||
})
|
||||
} else {
|
||||
document.getElementById('footer-type-tips').innerHTML = con
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (!{effect}) {
|
||||
if (typeof Typed === 'function') {
|
||||
subtitleType()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||
}
|
||||
} else {
|
||||
subtitleType()
|
||||
}
|
||||
|
||||
when 3
|
||||
script.
|
||||
function subtitleType () {
|
||||
getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js').then(() => {
|
||||
jinrishici.load(result =>{
|
||||
if (!{effect}) {
|
||||
const sub = !{JSON.stringify(subContent)}
|
||||
const content = result.data.content
|
||||
sub.unshift(content)
|
||||
window.typed = new Typed('#footer-type-tips', {
|
||||
strings: sub,
|
||||
startDelay: !{startDelay},
|
||||
typeSpeed: !{typeSpeed},
|
||||
loop: !{loop},
|
||||
backSpeed: !{backSpeed},
|
||||
})
|
||||
} else {
|
||||
document.getElementById('footer-type-tips').innerHTML = result.data.content
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (!{effect}) {
|
||||
if (typeof Typed === 'function') {
|
||||
subtitleType()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||
}
|
||||
} else {
|
||||
subtitleType()
|
||||
}
|
||||
|
||||
default
|
||||
- subContent = subContent.length ? subContent : new Array(config.subtitle)
|
||||
script.
|
||||
function subtitleType () {
|
||||
if (!{effect}) {
|
||||
window.typed = new Typed("#footer-type-tips", {
|
||||
strings: !{JSON.stringify(subContent)},
|
||||
startDelay: !{startDelay},
|
||||
typeSpeed: !{typeSpeed},
|
||||
loop: !{loop},
|
||||
backSpeed: !{backSpeed}
|
||||
})
|
||||
} else {
|
||||
document.getElementById("footer-type-tips").innerHTML = '!{subContent[0]}'
|
||||
}
|
||||
}
|
||||
|
||||
if (!{effect}) {
|
||||
if (typeof Typed === 'function') {
|
||||
subtitleType()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||
}
|
||||
} else {
|
||||
subtitleType()
|
||||
}
|
||||
18
themes/anzhiyu/layout/includes/third-party/math/index.pug
vendored
Normal file
18
themes/anzhiyu/layout/includes/third-party/math/index.pug
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
if theme.mathjax && theme.mathjax.enable
|
||||
if theme.mathjax.per_page
|
||||
if is_post() || is_page()
|
||||
include ./mathjax.pug
|
||||
else
|
||||
if page.mathjax
|
||||
include ./mathjax.pug
|
||||
|
||||
if theme.katex && theme.katex.enable
|
||||
if theme.katex.per_page
|
||||
if is_post() || is_page()
|
||||
include ./katex.pug
|
||||
else
|
||||
if page.katex
|
||||
include ./katex.pug
|
||||
|
||||
if theme.mermaid.enable
|
||||
include ./mermaid.pug
|
||||
9
themes/anzhiyu/layout/includes/third-party/math/katex.pug
vendored
Normal file
9
themes/anzhiyu/layout/includes/third-party/math/katex.pug
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
link(rel="stylesheet" type="text/css" href=url_for(theme.asset.katex))
|
||||
script(src=url_for(theme.asset.katex_copytex))
|
||||
script.
|
||||
(() => {
|
||||
document.querySelectorAll('#article-container span.katex-display').forEach(item => {
|
||||
anzhiyu.wrap(item, 'div', { class: 'katex-wrap'})
|
||||
})
|
||||
})()
|
||||
|
||||
38
themes/anzhiyu/layout/includes/third-party/math/mathjax.pug
vendored
Normal file
38
themes/anzhiyu/layout/includes/third-party/math/mathjax.pug
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
//- Mathjax 3
|
||||
script.
|
||||
if (!window.MathJax) {
|
||||
window.MathJax = {
|
||||
tex: {
|
||||
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
||||
tags: 'ams'
|
||||
},
|
||||
chtml: {
|
||||
scale: 1.1
|
||||
},
|
||||
options: {
|
||||
renderActions: {
|
||||
findScript: [10, doc => {
|
||||
for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
|
||||
const display = !!node.type.match(/; *mode=display/)
|
||||
const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
|
||||
const text = document.createTextNode('')
|
||||
node.parentNode.replaceChild(text, node)
|
||||
math.start = {node: text, delim: '', n: 0}
|
||||
math.end = {node: text, delim: '', n: 0}
|
||||
doc.math.push(math)
|
||||
}
|
||||
}, '']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const script = document.createElement('script')
|
||||
script.src = '!{url_for(theme.asset.mathjax)}'
|
||||
script.id = 'MathJax-script'
|
||||
script.async = true
|
||||
document.head.appendChild(script)
|
||||
} else {
|
||||
MathJax.startup.document.state(0)
|
||||
MathJax.texReset()
|
||||
MathJax.typesetPromise()
|
||||
}
|
||||
38
themes/anzhiyu/layout/includes/third-party/math/mermaid.pug
vendored
Normal file
38
themes/anzhiyu/layout/includes/third-party/math/mermaid.pug
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
script.
|
||||
(() => {
|
||||
const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap')
|
||||
if ($mermaid.length === 0) return
|
||||
const runMermaid = () => {
|
||||
window.loadMermaid = true
|
||||
const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '!{theme.mermaid.theme.dark}' : '!{theme.mermaid.theme.light}'
|
||||
|
||||
Array.from($mermaid).forEach((item, index) => {
|
||||
const mermaidSrc = item.firstElementChild
|
||||
const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
|
||||
const mermaidID = 'mermaid-' + index
|
||||
const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent
|
||||
|
||||
const renderFn = mermaid.render(mermaidID, mermaidDefinition)
|
||||
|
||||
const renderV10 = () => {
|
||||
renderFn.then(({svg}) => {
|
||||
mermaidSrc.insertAdjacentHTML('afterend', svg)
|
||||
})
|
||||
}
|
||||
|
||||
const renderV9 = svg => {
|
||||
mermaidSrc.insertAdjacentHTML('afterend', svg)
|
||||
}
|
||||
|
||||
typeof renderFn === 'string' ? renderV9(renderFn) : renderV10()
|
||||
})
|
||||
}
|
||||
|
||||
const loadMermaid = () => {
|
||||
window.loadMermaid ? runMermaid() : getScript('!{url_for(theme.asset.mermaid)}').then(runMermaid)
|
||||
}
|
||||
|
||||
anzhiyu.addGlobalFn('themeChange', runMermaid, 'mermaid')
|
||||
|
||||
window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
|
||||
})()
|
||||
110
themes/anzhiyu/layout/includes/third-party/newest-comments/artalk.pug
vendored
Normal file
110
themes/anzhiyu/layout/includes/third-party/newest-comments/artalk.pug
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
- const { server, site, option } = theme.artalk
|
||||
- const avatarCdn = option !== null && option.gravatar && option.gravatar.mirror
|
||||
- const avatarDefault = option !== null && option.gravatar && (option.gravatar.params || option.gravatar.default)
|
||||
|
||||
script.
|
||||
window.addEventListener('load', () => {
|
||||
const changeContent = (content) => {
|
||||
if (content === '') return content
|
||||
|
||||
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
|
||||
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
|
||||
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
|
||||
content = content.replace(/<[^>]+>/g,"") // remove html tag
|
||||
|
||||
if (content.length > 150) {
|
||||
content = content.substring(0,150) + '...'
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
const generateHtml = array => {
|
||||
let result = ''
|
||||
|
||||
if (array.length) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
result += '<div class=\'aside-list-item\'>'
|
||||
|
||||
if (!{theme.newest_comments.avatar}) {
|
||||
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
|
||||
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
||||
}
|
||||
|
||||
result += `<div class='content'>
|
||||
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
|
||||
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${anzhiyu.diffDate(array[i].date, true)}</time></div>
|
||||
</div></div>`
|
||||
}
|
||||
} else {
|
||||
result += '!{_p("aside.card_newest_comments.zero")}'
|
||||
}
|
||||
|
||||
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom && ($dom.innerHTML= result)
|
||||
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||
window.pjax && window.pjax.refresh($dom)
|
||||
}
|
||||
|
||||
const getSetting = async () => {
|
||||
try {
|
||||
const res = await fetch('!{server}/api/conf', { method: 'GET' })
|
||||
return await res.json()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
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'
|
||||
})
|
||||
}
|
||||
|
||||
const getComment = async () => {
|
||||
try {
|
||||
const res = await fetch('!{server}/api/stat', headerList)
|
||||
const result = await res.json()
|
||||
const avatarStr = await getSetting()
|
||||
const { mirror, params, default:defaults } = avatarStr.data.frontend_conf.gravatar
|
||||
const avatarCdn = !{avatarCdn} || mirror
|
||||
let avatarDefault = !{avatarDefault} || params || defaults
|
||||
avatarDefault = avatarDefault.startsWith('d=') ? avatarDefault : `d=${avatarDefault}`
|
||||
const artalk = result.data.map(function (e) {
|
||||
return {
|
||||
'avatar': `${avatarCdn}${e.email_encrypted}?${avatarDefault}`,
|
||||
'content': changeContent(e.content_marked),
|
||||
'nick': e.nick,
|
||||
'url': e.page_url,
|
||||
'date': e.date,
|
||||
}
|
||||
})
|
||||
saveToLocal.set('artalk-newest-comments', JSON.stringify(artalk), !{theme.newest_comments.storage}/(60*24))
|
||||
generateHtml(artalk)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom.innerHTML= "!{_p('aside.card_newest_comments.error')}"
|
||||
}
|
||||
}
|
||||
|
||||
const newestCommentInit = () => {
|
||||
if (document.querySelector('#card-newest-comments .aside-list')) {
|
||||
const data = saveToLocal.get('artalk-newest-comments')
|
||||
if (data) {
|
||||
generateHtml(JSON.parse(data))
|
||||
} else {
|
||||
getComment()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newestCommentInit()
|
||||
document.addEventListener('pjax:complete', newestCommentInit)
|
||||
})
|
||||
13
themes/anzhiyu/layout/includes/third-party/newest-comments/index.pug
vendored
Normal file
13
themes/anzhiyu/layout/includes/third-party/newest-comments/index.pug
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
- let { use } = theme.comments
|
||||
|
||||
if use
|
||||
- let forum,apiKey,userRepo
|
||||
case use[0]
|
||||
when 'Valine'
|
||||
include ./valine.pug
|
||||
when 'Waline'
|
||||
include ./waline.pug
|
||||
when 'Twikoo'
|
||||
include ./twikoo-comment.pug
|
||||
when 'Artalk'
|
||||
include ./artalk.pug
|
||||
90
themes/anzhiyu/layout/includes/third-party/newest-comments/twikoo-comment.pug
vendored
Normal file
90
themes/anzhiyu/layout/includes/third-party/newest-comments/twikoo-comment.pug
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
script.
|
||||
window.addEventListener('load', () => {
|
||||
const changeContent = (content) => {
|
||||
if (content === '') return content
|
||||
|
||||
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
|
||||
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
|
||||
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
|
||||
content = content.replace(/<[^>]+>/g,"") // remove html tag
|
||||
|
||||
if (content.length > 150) {
|
||||
content = content.substring(0,150) + '...'
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
const getComment = () => {
|
||||
const runTwikoo = () => {
|
||||
twikoo.getRecentComments({
|
||||
envId: '!{theme.twikoo.envId}',
|
||||
region: '!{theme.twikoo.region}',
|
||||
pageSize: !{theme.newest_comments.limit},
|
||||
includeReply: true
|
||||
}).then(function (res) {
|
||||
const twikooArray = res.map(e => {
|
||||
return {
|
||||
'content': changeContent(e.comment),
|
||||
'avatar': e.avatar,
|
||||
'nick': e.nick,
|
||||
'url': e.url + '#' + e.id,
|
||||
'date': new Date(e.created).toISOString()
|
||||
}
|
||||
})
|
||||
|
||||
saveToLocal.set('twikoo-newest-comments', JSON.stringify(twikooArray), !{theme.newest_comments.storage}/(60*24))
|
||||
generateHtml(twikooArray)
|
||||
}).catch(function (err) {
|
||||
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom.textContent= "!{_p('aside.card_newest_comments.error')}"
|
||||
})
|
||||
}
|
||||
|
||||
if (typeof twikoo === 'object') {
|
||||
runTwikoo()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.twikoo)}').then(runTwikoo)
|
||||
}
|
||||
}
|
||||
|
||||
const generateHtml = array => {
|
||||
let result = ''
|
||||
|
||||
if (array.length) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
result += '<div class=\'aside-list-item\'>'
|
||||
|
||||
if (!{theme.newest_comments.avatar}) {
|
||||
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
|
||||
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'><div class='name'><span>${array[i].nick} </span></div></a>`
|
||||
}
|
||||
|
||||
result += `<div class='content'>
|
||||
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
|
||||
<time datetime="${array[i].date}">${anzhiyu.diffDate(array[i].date, true)}</time></div>
|
||||
</div>`
|
||||
}
|
||||
} else {
|
||||
result += '!{_p("aside.card_newest_comments.zero")}'
|
||||
}
|
||||
|
||||
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom && ($dom.innerHTML= result)
|
||||
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||
window.pjax && window.pjax.refresh($dom)
|
||||
}
|
||||
|
||||
const newestCommentInit = () => {
|
||||
if (document.querySelector('#card-newest-comments .aside-list')) {
|
||||
const data = saveToLocal.get('twikoo-newest-comments')
|
||||
if (data) {
|
||||
generateHtml(JSON.parse(data))
|
||||
} else {
|
||||
getComment()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newestCommentInit()
|
||||
document.addEventListener('pjax:complete', newestCommentInit)
|
||||
})
|
||||
99
themes/anzhiyu/layout/includes/third-party/newest-comments/valine.pug
vendored
Normal file
99
themes/anzhiyu/layout/includes/third-party/newest-comments/valine.pug
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
- let default_avatar = theme.valine.avatar
|
||||
|
||||
script(src=url_for(theme.asset.blueimp_md5))
|
||||
script.
|
||||
window.addEventListener('load', () => {
|
||||
const changeContent = (content) => {
|
||||
if (content === '') return content
|
||||
|
||||
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
|
||||
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
|
||||
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
|
||||
content = content.replace(/<[^>]+>/g,"") // remove html tag
|
||||
|
||||
if (content.length > 150) {
|
||||
content = content.substring(0,150) + '...'
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
const getIcon = (icon, mail) => {
|
||||
if (icon) return icon
|
||||
let defaultIcon = '!{ default_avatar ? `?d=${default_avatar}` : ''}'
|
||||
let iconUrl = `https://gravatar.loli.net/avatar/${md5(mail.toLowerCase()) + defaultIcon}`
|
||||
return iconUrl
|
||||
}
|
||||
|
||||
const generateHtml = array => {
|
||||
let result = ''
|
||||
|
||||
if (array.length) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
result += '<div class=\'aside-list-item\'>'
|
||||
|
||||
if (!{theme.newest_comments.avatar}) {
|
||||
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
|
||||
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
||||
}
|
||||
|
||||
result += `<div class='content'>
|
||||
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
|
||||
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${anzhiyu.diffDate(array[i].date, true)}</time></div>
|
||||
</div></div>`
|
||||
}
|
||||
} else {
|
||||
result += '!{_p("aside.card_newest_comments.zero")}'
|
||||
}
|
||||
|
||||
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom && ($dom.innerHTML= result)
|
||||
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||
window.pjax && window.pjax.refresh($dom)
|
||||
}
|
||||
|
||||
const getComment = () => {
|
||||
const serverURL = '!{theme.valine.serverURLs || `https://${theme.valine.appId.substring(0,8)}.api.lncldglobal.com` }'
|
||||
|
||||
var settings = {
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"X-LC-Id": '!{theme.valine.appId}',
|
||||
"X-LC-Key": '!{theme.valine.appKey}',
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
}
|
||||
|
||||
fetch(`${serverURL}/1.1/classes/Comment?limit=!{theme.newest_comments.limit}&order=-createdAt`,settings)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const valineArray = data.results.map(function (e) {
|
||||
return {
|
||||
'avatar': getIcon(e.QQAvatar, e.mail),
|
||||
'content': changeContent(e.comment),
|
||||
'nick': e.nick,
|
||||
'url': e.url + '#' + e.objectId,
|
||||
'date': e.updatedAt,
|
||||
}
|
||||
})
|
||||
saveToLocal.set('valine-newest-comments', JSON.stringify(valineArray), !{theme.newest_comments.storage}/(60*24))
|
||||
generateHtml(valineArray)
|
||||
}).catch(e => {
|
||||
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom.textContent= "!{_p('aside.card_newest_comments.error')}"
|
||||
})
|
||||
}
|
||||
|
||||
const newestCommentInit = () => {
|
||||
if (document.querySelector('#card-newest-comments .aside-list')) {
|
||||
const data = saveToLocal.get('valine-newest-comments')
|
||||
if (data) {
|
||||
generateHtml(JSON.parse(data))
|
||||
} else {
|
||||
getComment()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newestCommentInit()
|
||||
document.addEventListener('pjax:complete', newestCommentInit)
|
||||
})
|
||||
81
themes/anzhiyu/layout/includes/third-party/newest-comments/waline.pug
vendored
Normal file
81
themes/anzhiyu/layout/includes/third-party/newest-comments/waline.pug
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
- const serverURL = theme.waline.serverURL.replace(/\/$/, '')
|
||||
|
||||
script.
|
||||
window.addEventListener('load', () => {
|
||||
const changeContent = content => {
|
||||
if (content === '') return content
|
||||
|
||||
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[!{_p("aside.card_newest_comments.image")}]') // replace image link
|
||||
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[!{_p("aside.card_newest_comments.link")}]') // replace url
|
||||
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[!{_p("aside.card_newest_comments.code")}]') // replace code
|
||||
content = content.replace(/<[^>]+>/g,"") // remove html tag
|
||||
|
||||
if (content.length > 150) {
|
||||
content = content.substring(0,150) + '...'
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
const generateHtml = array => {
|
||||
let result = ''
|
||||
|
||||
if (array.length) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
result += '<div class=\'aside-list-item\'>'
|
||||
|
||||
if (!{theme.newest_comments.avatar}) {
|
||||
const name = '!{theme.lazyload.enable ? "data-lazy-src" : "src"}'
|
||||
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'></a>`
|
||||
}
|
||||
|
||||
result += `<div class='content'>
|
||||
<a class='comment' href='${array[i].url}' title='${array[i].content}'>${array[i].content}</a>
|
||||
<div class='name'><span>${array[i].nick} / </span><time datetime="${array[i].date}">${anzhiyu.diffDate(array[i].date, true)}</time></div>
|
||||
</div></div>`
|
||||
}
|
||||
} else {
|
||||
result += '!{_p("aside.card_newest_comments.zero")}'
|
||||
}
|
||||
|
||||
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom && ($dom.innerHTML= result)
|
||||
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||
window.pjax && window.pjax.refresh($dom)
|
||||
}
|
||||
|
||||
const getComment = async () => {
|
||||
try {
|
||||
const res = await fetch('!{serverURL}/api/comment?type=recent&count=!{theme.newest_comments.limit}', { method: 'GET' })
|
||||
const result = await res.json()
|
||||
const walineArray = result.data.map(e => {
|
||||
return {
|
||||
'content': changeContent(e.comment),
|
||||
'avatar': e.avatar,
|
||||
'nick': e.nick,
|
||||
'url': e.url + '#' + e.objectId,
|
||||
'date': e.time || e.insertedAt
|
||||
}
|
||||
})
|
||||
saveToLocal.set('waline-newest-comments', JSON.stringify(walineArray), !{theme.newest_comments.storage}/(60*24))
|
||||
generateHtml(walineArray)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
const $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom.textContent= "!{_p('aside.card_newest_comments.error')}"
|
||||
}
|
||||
}
|
||||
|
||||
const newestCommentInit = () => {
|
||||
if (document.querySelector('#card-newest-comments .aside-list')) {
|
||||
const data = saveToLocal.get('waline-newest-comments')
|
||||
if (data) {
|
||||
generateHtml(JSON.parse(data))
|
||||
} else {
|
||||
getComment()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newestCommentInit()
|
||||
document.addEventListener('pjax:complete', newestCommentInit)
|
||||
})
|
||||
20
themes/anzhiyu/layout/includes/third-party/pangu.pug
vendored
Normal file
20
themes/anzhiyu/layout/includes/third-party/pangu.pug
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
script.
|
||||
function panguFn () {
|
||||
if (typeof pangu === 'object') pangu.autoSpacingPage()
|
||||
else {
|
||||
getScript('!{url_for(theme.asset.pangu)}')
|
||||
.then(() => {
|
||||
pangu.autoSpacingPage()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function panguInit () {
|
||||
if (!{theme.pangu.field === 'post'}){
|
||||
GLOBAL_CONFIG_SITE.isPost && panguFn()
|
||||
} else {
|
||||
panguFn()
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', panguInit)
|
||||
77
themes/anzhiyu/layout/includes/third-party/pjax.pug
vendored
Normal file
77
themes/anzhiyu/layout/includes/third-party/pjax.pug
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
- var pjaxExclude = 'a:not([target="_blank"])'
|
||||
if theme.pjax.exclude
|
||||
each val in theme.pjax.exclude
|
||||
- pjaxExclude = pjaxExclude + `:not([href="${val}"])`
|
||||
|
||||
- let pjaxSelectors = ['head > title','#config-diff', '#body-wrap','#rightside-config-hide','#rightside-config-show','.js-pjax']
|
||||
|
||||
- let choose = theme.comments.use
|
||||
if choose
|
||||
if theme.Open_Graph_meta && (choose.includes('Twikoo'))
|
||||
- pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]', 'meta[property="og:type"]', 'meta[property="og:site_name"]', 'meta[property="og:description"]')
|
||||
|
||||
script(src=url_for(theme.asset.pjax))
|
||||
script.
|
||||
let pjaxSelectors = !{JSON.stringify(pjaxSelectors)}
|
||||
var pjax = new Pjax({
|
||||
elements: '!{pjaxExclude}',
|
||||
selectors: pjaxSelectors,
|
||||
cacheBust: false,
|
||||
analytics: !{theme.google_analytics ? true : false},
|
||||
scrollRestoration: false
|
||||
})
|
||||
|
||||
document.addEventListener('pjax:send', function () {
|
||||
// removeEventListener scroll
|
||||
anzhiyu.removeGlobalFnEvent('pjax')
|
||||
anzhiyu.removeGlobalFnEvent('themeChange')
|
||||
|
||||
document.getElementById('rightside').classList.remove('rightside-show')
|
||||
|
||||
if (window.aplayers) {
|
||||
for (let i = 0; i < window.aplayers.length; i++) {
|
||||
if (!window.aplayers[i].options.fixed) {
|
||||
window.aplayers[i].destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typeof typed === 'object' && typed.destroy()
|
||||
|
||||
//reset readmode
|
||||
const $bodyClassList = document.body.classList
|
||||
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
|
||||
})
|
||||
|
||||
document.addEventListener('pjax:complete', function () {
|
||||
window.refreshFn()
|
||||
|
||||
document.querySelectorAll('script[data-pjax]').forEach(item => {
|
||||
const newScript = document.createElement('script')
|
||||
const content = item.text || item.textContent || item.innerHTML || ""
|
||||
Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
|
||||
newScript.appendChild(document.createTextNode(content))
|
||||
item.parentNode.replaceChild(newScript, item)
|
||||
})
|
||||
|
||||
GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()
|
||||
|
||||
typeof panguInit === 'function' && panguInit()
|
||||
|
||||
// google analytics
|
||||
typeof gtag === 'function' && gtag('config', '!{theme.google_analytics}', {'page_path': window.location.pathname});
|
||||
|
||||
// baidu analytics
|
||||
typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);
|
||||
|
||||
typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()
|
||||
|
||||
// prismjs
|
||||
typeof Prism === 'object' && Prism.highlightAll()
|
||||
})
|
||||
|
||||
document.addEventListener('pjax:error', e => {
|
||||
if (e.request.status === 404) {
|
||||
pjax.loadUrl('!{url_for("/404.html")}')
|
||||
}
|
||||
})
|
||||
5
themes/anzhiyu/layout/includes/third-party/prismjs.pug
vendored
Normal file
5
themes/anzhiyu/layout/includes/third-party/prismjs.pug
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
if config.prismjs && config.prismjs.enable && !config.prismjs.preprocess
|
||||
script(src=url_for(theme.asset.prismjs_js))
|
||||
script(src=url_for(theme.asset.prismjs_autoloader))
|
||||
if config.prismjs.line_number
|
||||
script(src=url_for(theme.asset.prismjs_lineNumber_js))
|
||||
66
themes/anzhiyu/layout/includes/third-party/runtime/runtime-js.pug
vendored
Normal file
66
themes/anzhiyu/layout/includes/third-party/runtime/runtime-js.pug
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
- let launch_time = theme.footer.runtime.launch_time
|
||||
- let offduty_img = theme.footer.runtime.offduty_img
|
||||
- let offduty_description = theme.footer.runtime.offduty_description
|
||||
script(async=true).
|
||||
(function () {
|
||||
var grt = new Date("#{launch_time}"); //设置网站上线时间
|
||||
var now = new Date();
|
||||
var dnum;
|
||||
var hnum;
|
||||
var mnum;
|
||||
var snum;
|
||||
var nowHour;
|
||||
|
||||
// 计算并更新天数、小时数、分钟数和秒数
|
||||
function updateTime() {
|
||||
now = new Date(); // 更新 now 的值
|
||||
nowHour = now.getHours(); // 更新 nowHour 的值
|
||||
var days = (now - grt) / 1000 / 60 / 60 / 24;
|
||||
dnum = Math.floor(days);
|
||||
var hours = (now - grt) / 1000 / 60 / 60 - 24 * dnum;
|
||||
hnum = Math.floor(hours);
|
||||
if (String(hnum).length == 1) {
|
||||
hnum = "0" + hnum;
|
||||
}
|
||||
var minutes = (now - grt) / 1000 / 60 - 24 * 60 * dnum - 60 * hnum;
|
||||
mnum = Math.floor(minutes);
|
||||
if (String(mnum).length == 1) {
|
||||
mnum = "0" + mnum;
|
||||
}
|
||||
var seconds = (now - grt) / 1000 - 24 * 60 * 60 * dnum - 60 * 60 * hnum - 60 * mnum;
|
||||
snum = Math.round(seconds);
|
||||
if (String(snum).length == 1) {
|
||||
snum = "0" + snum;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新网页中显示的网站运行时间
|
||||
function updateHtml() {
|
||||
const footer = document.getElementById("footer");
|
||||
if (!footer) return
|
||||
let currentTimeHtml = "";
|
||||
if (nowHour < 18 && nowHour >= 9) {
|
||||
// 如果是上班时间,默认就是"安知鱼-上班摸鱼中.svg"图片,不需要更改
|
||||
currentTimeHtml = `本站居然运行了 ${dnum} 天<span id='runtime'> ${hnum} 小时 ${mnum} 分 ${snum} 秒 </span><i class='anzhiyufont anzhiyu-icon-heartbeat' style='color:red'></i>`;
|
||||
} else {
|
||||
// 如果是下班时间,插入"安知鱼-下班啦.svg"图片
|
||||
let img = document.querySelector("#workboard .workSituationImg");
|
||||
if (img != null) {
|
||||
img.src = "#{offduty_img}";
|
||||
img.title = "#{offduty_description}";
|
||||
img.alt = "#{offduty_description}";
|
||||
}
|
||||
|
||||
currentTimeHtml = `本站居然运行了 ${dnum} 天<span id='runtime'> ${hnum} 小时 ${mnum} 分 ${snum} 秒 </span><i class='anzhiyufont anzhiyu-icon-heartbeat' style='color:red'></i>`;
|
||||
}
|
||||
|
||||
if (document.getElementById("runtimeTextTip")) {
|
||||
document.getElementById("runtimeTextTip").innerHTML = currentTimeHtml;
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
updateTime();
|
||||
updateHtml();
|
||||
}, 1000);
|
||||
})();
|
||||
21
themes/anzhiyu/layout/includes/third-party/search/algolia.pug
vendored
Normal file
21
themes/anzhiyu/layout/includes/third-party/search/algolia.pug
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#algolia-search
|
||||
.search-dialog
|
||||
nav.search-nav
|
||||
span.search-dialog-title= _p('search.title')
|
||||
button.search-close-button
|
||||
i.anzhiyufont.anzhiyu-icon-xmark
|
||||
|
||||
.search-wrap
|
||||
#algolia-search-input
|
||||
hr
|
||||
#algolia-search-results
|
||||
#algolia-hits
|
||||
if theme.algolia_search.enable && theme.algolia_search.tags
|
||||
each item, index in theme.algolia_search.tags
|
||||
a.tag-list(href=url_for("/tags/" + item), title=item)=item
|
||||
#algolia-pagination
|
||||
#algolia-info
|
||||
.algolia-stats
|
||||
.algolia-poweredBy
|
||||
|
||||
#search-mask
|
||||
26
themes/anzhiyu/layout/includes/third-party/search/docsearch.pug
vendored
Normal file
26
themes/anzhiyu/layout/includes/third-party/search/docsearch.pug
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
- const { appId, apiKey, indexName, option } = theme.docsearch
|
||||
|
||||
.docsearch-wrap
|
||||
#docsearch(style="display:none")
|
||||
link(rel="stylesheet" href=url_for(theme.asset.docsearch_css))
|
||||
script(src=url_for(theme.asset.docsearch_js))
|
||||
script.
|
||||
(() => {
|
||||
docsearch(Object.assign({
|
||||
appId: '!{appId}',
|
||||
apiKey: '!{apiKey}',
|
||||
indexName: '!{indexName}',
|
||||
container: '#docsearch',
|
||||
}, !{JSON.stringify(option)}))
|
||||
|
||||
const handleClick = () => {
|
||||
document.querySelector('.DocSearch-Button').click()
|
||||
}
|
||||
|
||||
const searchClickFn = () => {
|
||||
anzhiyu.addEventListenerPjax(document.querySelector('#search-button > .search'), 'click', handleClick)
|
||||
}
|
||||
|
||||
searchClickFn()
|
||||
window.addEventListener('pjax:complete', searchClickFn)
|
||||
})()
|
||||
6
themes/anzhiyu/layout/includes/third-party/search/index.pug
vendored
Normal file
6
themes/anzhiyu/layout/includes/third-party/search/index.pug
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
if theme.algolia_search.enable
|
||||
include ./algolia.pug
|
||||
else if theme.local_search.enable
|
||||
include ./local-search.pug
|
||||
else if theme.docsearch.enable
|
||||
include ./docsearch.pug
|
||||
20
themes/anzhiyu/layout/includes/third-party/search/local-search.pug
vendored
Normal file
20
themes/anzhiyu/layout/includes/third-party/search/local-search.pug
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
#local-search
|
||||
.search-dialog
|
||||
nav.search-nav
|
||||
span.search-dialog-title= _p('search.title')
|
||||
span#loading-status
|
||||
button.search-close-button
|
||||
i.anzhiyufont.anzhiyu-icon-xmark
|
||||
|
||||
#loading-database.is-center
|
||||
i.anzhiyufont.anzhiyu-icon-spinner.anzhiyu-pulse-icon
|
||||
span= ' ' + _p("search.load_data")
|
||||
|
||||
.search-wrap
|
||||
#local-search-input
|
||||
.local-search-box
|
||||
input(placeholder=_p("search.local_search.input_placeholder") type="text").local-search-box--input
|
||||
hr
|
||||
#local-search-results
|
||||
|
||||
#search-mask
|
||||
10
themes/anzhiyu/layout/includes/third-party/share/addtoany.pug
vendored
Normal file
10
themes/anzhiyu/layout/includes/third-party/share/addtoany.pug
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
.addtoany
|
||||
.a2a_kit.a2a_kit_size_32.a2a_default_style
|
||||
- let addtoanyItem = theme.addtoany.item.split(',')
|
||||
each name in addtoanyItem
|
||||
a(class="a2a_button_" + name)
|
||||
|
||||
a.a2a_dd(href="https://www.addtoany.com/share")
|
||||
script(async src='https://static.addtoany.com/menu/page.js')
|
||||
|
||||
|
||||
6
themes/anzhiyu/layout/includes/third-party/share/index.pug
vendored
Normal file
6
themes/anzhiyu/layout/includes/third-party/share/index.pug
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
if (theme.sharejs.enable || theme.addtoany.enable)
|
||||
.post_share
|
||||
if theme.sharejs.enable
|
||||
include ./share-js.pug
|
||||
else if theme.addtoany.enable
|
||||
!=partial('includes/third-party/share/addtoany', {}, {cache: true})
|
||||
3
themes/anzhiyu/layout/includes/third-party/share/share-js.pug
vendored
Normal file
3
themes/anzhiyu/layout/includes/third-party/share/share-js.pug
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.social-share(data-image=url_for(page.cover|| theme.avatar.img) data-sites= theme.sharejs.sites)
|
||||
link(rel='stylesheet' href=url_for(theme.asset.sharejs_css) media="print" onload="this.media='all'")
|
||||
script(src=url_for(theme.asset.sharejs) defer)
|
||||
128
themes/anzhiyu/layout/includes/third-party/subtitle.pug
vendored
Normal file
128
themes/anzhiyu/layout/includes/third-party/subtitle.pug
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
- const { effect,loop,source,sub,startDelay,typeSpeed,backSpeed } = theme.subtitle
|
||||
- let subContent = sub || new Array()
|
||||
|
||||
case source
|
||||
when 1
|
||||
script.
|
||||
function subtitleType () {
|
||||
fetch('https://v1.hitokoto.cn')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (!{effect}) {
|
||||
const from = '出自 ' + data.from
|
||||
const sub = !{JSON.stringify(subContent)}
|
||||
sub.unshift(data.hitokoto, from)
|
||||
window.typed = new Typed('#subtitle', {
|
||||
strings: sub,
|
||||
startDelay: !{startDelay},
|
||||
typeSpeed: !{typeSpeed},
|
||||
loop: !{loop},
|
||||
backSpeed: !{backSpeed},
|
||||
})
|
||||
} else {
|
||||
document.getElementById('subtitle').innerHTML = data.hitokoto
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (!{effect}) {
|
||||
if (typeof Typed === 'function') {
|
||||
subtitleType()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||
}
|
||||
} else {
|
||||
subtitleType()
|
||||
}
|
||||
|
||||
when 2
|
||||
script.
|
||||
function subtitleType () {
|
||||
getScript('https://yijuzhan.com/api/word.php?m=js').then(() => {
|
||||
const con = str[0]
|
||||
if (!{effect}) {
|
||||
const from = '出自 ' + str[1]
|
||||
const sub = !{JSON.stringify(subContent)}
|
||||
sub.unshift(con, from)
|
||||
window.typed = new Typed('#subtitle', {
|
||||
strings: sub,
|
||||
startDelay: !{startDelay},
|
||||
typeSpeed: !{typeSpeed},
|
||||
loop: !{loop},
|
||||
backSpeed: !{backSpeed},
|
||||
})
|
||||
} else {
|
||||
document.getElementById('subtitle').innerHTML = con
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (!{effect}) {
|
||||
if (typeof Typed === 'function') {
|
||||
subtitleType()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||
}
|
||||
} else {
|
||||
subtitleType()
|
||||
}
|
||||
|
||||
when 3
|
||||
script.
|
||||
function subtitleType () {
|
||||
getScript('https://sdk.jinrishici.com/v2/browser/jinrishici.js').then(() => {
|
||||
jinrishici.load(result =>{
|
||||
if (!{effect}) {
|
||||
const sub = !{JSON.stringify(subContent)}
|
||||
const content = result.data.content
|
||||
sub.unshift(content)
|
||||
window.typed = new Typed('#subtitle', {
|
||||
strings: sub,
|
||||
startDelay: !{startDelay},
|
||||
typeSpeed: !{typeSpeed},
|
||||
loop: !{loop},
|
||||
backSpeed: !{backSpeed},
|
||||
})
|
||||
} else {
|
||||
document.getElementById('subtitle').innerHTML = result.data.content
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (!{effect}) {
|
||||
if (typeof Typed === 'function') {
|
||||
subtitleType()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||
}
|
||||
} else {
|
||||
subtitleType()
|
||||
}
|
||||
|
||||
default
|
||||
- subContent = subContent.length ? subContent : new Array(config.subtitle)
|
||||
script.
|
||||
function subtitleType () {
|
||||
if (!{effect}) {
|
||||
window.typed = new Typed("#subtitle", {
|
||||
strings: !{JSON.stringify(subContent)},
|
||||
startDelay: !{startDelay},
|
||||
typeSpeed: !{typeSpeed},
|
||||
loop: !{loop},
|
||||
backSpeed: !{backSpeed}
|
||||
})
|
||||
} else {
|
||||
document.getElementById("subtitle").innerHTML = '!{subContent[0]}'
|
||||
}
|
||||
}
|
||||
|
||||
if (!{effect}) {
|
||||
if (typeof Typed === 'function') {
|
||||
subtitleType()
|
||||
} else {
|
||||
getScript('!{url_for(theme.asset.typed)}').then(subtitleType)
|
||||
}
|
||||
} else {
|
||||
subtitleType()
|
||||
}
|
||||
Reference in New Issue
Block a user