mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
✨ 添加第三方chat服務 crisp
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
if theme.chat_btn
|
||||
script.
|
||||
((window.gitter = {}).chat = {}).options = {
|
||||
room: '#{theme.gitter.room}',
|
||||
activationElement: '#chat_btn'
|
||||
disableDefaultChat: true,
|
||||
};
|
||||
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
document.addEventListener('gitter-sidecar-ready', (e) => {
|
||||
const GitterChat = e.detail.Chat
|
||||
let chat
|
||||
|
||||
function initGitter () {
|
||||
chat = new GitterChat({
|
||||
room: '#{theme.gitter.room}',
|
||||
activationElement: '#chat_btn'
|
||||
});
|
||||
}
|
||||
|
||||
initGitter()
|
||||
|
||||
if (!{theme.pjax}) {
|
||||
document.addEventListener('pjax:complete', () => {
|
||||
chat.destroy()
|
||||
initGitter()
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
else
|
||||
script.
|
||||
((window.gitter = {}).chat = {}).options = {
|
||||
@@ -22,4 +39,5 @@ else
|
||||
document.getElementsByClassName('gitter-open-chat-button')[0].style.display= 'block'
|
||||
}
|
||||
}
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
|
||||
Reference in New Issue
Block a user