update theme
This commit is contained in:
1 parent
522a86b511
commit
4fff64f05f
6 files changed
+106
-39
No files matched your search
@@ -622,7 +622,7 @@ search:
|
|||||||
share:
|
share:
|
||||||
# Choose: sharejs / addtoany
|
# Choose: sharejs / addtoany
|
||||||
# Leave it empty if you don't need share
|
# Leave it empty if you don't need share
|
||||||
use: sharejs
|
use: web_share
|
||||||
|
|
||||||
# Share.js
|
# Share.js
|
||||||
# https://github.com/overtrue/share.js
|
# https://github.com/overtrue/share.js
|
||||||
@@ -1185,7 +1185,7 @@ inject:
|
|||||||
- <script src="https://cdn.jsdmirror.com/npm/aplayer/dist/APlayer.min.js"></script>
|
- <script src="https://cdn.jsdmirror.com/npm/aplayer/dist/APlayer.min.js"></script>
|
||||||
- <script src="https://cdn.jsdmirror.com/npm/meting/dist/Meting.min.js"></script>
|
- <script src="https://cdn.jsdmirror.com/npm/meting/dist/Meting.min.js"></script>
|
||||||
- <script src="https://cdn.jsdmirror.com/gh/bishshi/welcomemessage/txmap.js"></script>
|
- <script src="https://cdn.jsdmirror.com/gh/bishshi/welcomemessage/txmap.js"></script>
|
||||||
- <script src="https://cdn.jsdmirror.com/gh/bishshi/rightmenu/rightmenu.js"></script>
|
- <script src="https://cdn.jsdmirror.com/gh/bishshi/rightmenu@1.2/rightmenu.js"></script>
|
||||||
- <script src="https://cdn.jsdmirror.com/gh/bishshi/sidecalendar/calendar.js"></script>
|
- <script src="https://cdn.jsdmirror.com/gh/bishshi/sidecalendar/calendar.js"></script>
|
||||||
- <script src="https://cdn.jsdmirror.com/npm/chinese-lunar@0.1.4/lib/chinese-lunar.js"></script>
|
- <script src="https://cdn.jsdmirror.com/npm/chinese-lunar@0.1.4/lib/chinese-lunar.js"></script>
|
||||||
- <script src="https://cdn.jsdmirror.com/npm/instantsearch.js@4.56.0"></script>
|
- <script src="https://cdn.jsdmirror.com/npm/instantsearch.js@4.56.0"></script>
|
||||||
|
|||||||
@@ -6,4 +6,6 @@ if use
|
|||||||
when 'addtoany'
|
when 'addtoany'
|
||||||
!=partial('includes/third-party/share/addtoany', {}, {cache: true})
|
!=partial('includes/third-party/share/addtoany', {}, {cache: true})
|
||||||
when 'sharejs'
|
when 'sharejs'
|
||||||
include ./share-js.pug
|
include ./share-js.pug
|
||||||
|
when 'web_share'
|
||||||
|
include ./web_share.pug
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
//- web_share.pug
|
||||||
|
|
||||||
|
style.
|
||||||
|
#web-share-btn {
|
||||||
|
background: var(--btn-bg);
|
||||||
|
color: var(--btn-color);
|
||||||
|
border: none;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
#web-share-btn:hover {
|
||||||
|
background: var(--btn-hover-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
#web-share-component
|
||||||
|
button#web-share-btn(title='分享本文')
|
||||||
|
i.fas.fa-share-alt
|
||||||
|
span= ' ' + _p('分享')
|
||||||
|
|
||||||
|
script.
|
||||||
|
(() => {
|
||||||
|
const setupWebShare = () => {
|
||||||
|
const btn = document.getElementById('web-share-btn')
|
||||||
|
if (!btn) return
|
||||||
|
|
||||||
|
// 点击事件处理
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (navigator.share) {
|
||||||
|
try {
|
||||||
|
await navigator.share({
|
||||||
|
title: '!{page.title || config.title}',
|
||||||
|
text: '!{truncate(strip_html(page.content), {length: 100})}',
|
||||||
|
url: window.location.href
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.log('分享取消或失败', err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 降级处理:比如弹出提示或复制链接
|
||||||
|
const shareData = window.location.href
|
||||||
|
navigator.clipboard.writeText(shareData).then(() => {
|
||||||
|
btf.snackbarShow('系统不支持分享,已将链接复制到剪贴板')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 考虑到 Butterfly 的 Pjax 跳转,需要重新绑定
|
||||||
|
setupWebShare()
|
||||||
|
document.addEventListener('pjax:complete', setupWebShare)
|
||||||
|
})()
|
||||||
Loaded 3 of 6 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user