init...
This commit is contained in:
50
themes/anzhiyu/hexo-theme-anzhiyu-main/layout/includes/third-party/chat/chatra.pug
vendored
Normal file
50
themes/anzhiyu/hexo-theme-anzhiyu-main/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/hexo-theme-anzhiyu-main/layout/includes/third-party/chat/crisp.pug
vendored
Normal file
45
themes/anzhiyu/hexo-theme-anzhiyu-main/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/hexo-theme-anzhiyu-main/layout/includes/third-party/chat/daovoice.pug
vendored
Normal file
40
themes/anzhiyu/hexo-theme-anzhiyu-main/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/hexo-theme-anzhiyu-main/layout/includes/third-party/chat/index.pug
vendored
Normal file
8
themes/anzhiyu/hexo-theme-anzhiyu-main/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/hexo-theme-anzhiyu-main/layout/includes/third-party/chat/tidio.pug
vendored
Normal file
47
themes/anzhiyu/hexo-theme-anzhiyu-main/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()
|
||||
}
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user