添加文章分享到QQ,分享到微信朋友圈
This commit is contained in:
parent
e86beeb99a
commit
77d1b82feb
|
@ -1393,24 +1393,24 @@ spec:
|
|||
value: true
|
||||
- label: 禁用
|
||||
value: false
|
||||
# - $formkit: radio
|
||||
# name: qq_edit
|
||||
# help: 启用分享到QQ
|
||||
# value: true
|
||||
# options:
|
||||
# - label: 启用
|
||||
# value: true
|
||||
# - label: 禁用
|
||||
# value: false
|
||||
# - $formkit: radio
|
||||
# name: wechat_edit
|
||||
# help: 启用分享到微信朋友圈
|
||||
# value: true
|
||||
# options:
|
||||
# - label: 启用
|
||||
# value: true
|
||||
# - label: 禁用
|
||||
# value: false
|
||||
- $formkit: radio
|
||||
name: qq_edit
|
||||
help: 启用分享到QQ
|
||||
value: true
|
||||
options:
|
||||
- label: 启用
|
||||
value: true
|
||||
- label: 禁用
|
||||
value: false
|
||||
- $formkit: radio
|
||||
name: wechat_edit
|
||||
help: 启用分享到微信朋友圈
|
||||
value: true
|
||||
options:
|
||||
- label: 启用
|
||||
value: true
|
||||
- label: 禁用
|
||||
value: false
|
||||
- $formkit: group
|
||||
name: copyrights
|
||||
label: 版权声明
|
||||
|
|
|
@ -262,6 +262,54 @@ rm.sharePage = function () {
|
|||
rm.hideRightMenu();
|
||||
}
|
||||
|
||||
function isMobileDevice() {
|
||||
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
rm.shareToQQ = function () {
|
||||
var url = /*[[${post.status.permalink}]]*/ window.location.href;
|
||||
var title = $('#post-info .post-title')[0].innerText;
|
||||
if (isMobileDevice()) {
|
||||
// 使用手机分享方式
|
||||
window.location.href = "mqqapi://share/to_fri?src_type=web&version=1&file_type=news&url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title) + "&callback_type=scheme&generalpastboard=1";
|
||||
} else {
|
||||
// 使用Web分享方式
|
||||
window.open("https://connect.qq.com/widget/shareqq/index.html?url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title));
|
||||
}
|
||||
btf.snackbarShow('分享链接地址成功', false, 2000);
|
||||
rm.hideRightMenu();
|
||||
}
|
||||
|
||||
rm.shareToWechat = function () {
|
||||
|
||||
// 手机分享逻辑
|
||||
if (isMobileDevice) {
|
||||
|
||||
wx.config({
|
||||
// 配置微信的appID、timestamp、nonceStr、signature等参数
|
||||
// ...
|
||||
debug: false,
|
||||
jsApiList: ['onMenuShareTimeline'] // 需要使用的微信接口
|
||||
});
|
||||
|
||||
wx.ready(function () {
|
||||
wx.onMenuShareTimeline({
|
||||
title: $('#post-info .post-title')[0].innerText,
|
||||
link: window.location.href,
|
||||
imgUrl: $('#coverdiv img')[0].src,
|
||||
success: function () {
|
||||
btf.snackbarShow('分享链接地址成功', false, 2000);
|
||||
rm.hideRightMenu();
|
||||
},
|
||||
cancel: function () {
|
||||
btf.snackbarShow('分享链接地址失败', false, 2000);
|
||||
rm.hideRightMenu();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 复制当前选中文本
|
||||
var selectTextNow = '';
|
||||
document.onmouseup = document.ondbclick = selceText;
|
||||
|
|
|
@ -163,6 +163,8 @@
|
|||
<!-- 复制 https://githubfast.com/zenorocha/clipboard.js -->
|
||||
<script th:src="${assets_link + '/libs/clipboard/clipboard.min.js'}"></script>
|
||||
|
||||
<script th:if="${theme.config.post.share_right.wechat_edit}" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
||||
|
||||
<!-- 关于统计-->
|
||||
<script th:if="${#strings.contains(theme.config.about.widgetList,'statistics-map')}" th:src="${assets_link + '/libs/countup/countup.js'}"></script>
|
||||
|
||||
|
|
|
@ -61,6 +61,16 @@
|
|||
<div class="share-button" id="post-share-url" onclick="rm.copyPageUrl()" title="复制链接"><i
|
||||
class="haofont hao-icon-link"></i></div>
|
||||
</div>
|
||||
<div class="share-link weibo" th:if="${theme.config.post.share_right.qq_edit}">
|
||||
<div class="share-button" id="post-share-url-qq" onclick="rm.shareToQQ()" title="分享到QQ">
|
||||
<i class="haofont hao-icon-qq" style="font-size:19px"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="share-link weibo" th:if="${theme.config.post.share_right.wechat_edit}">
|
||||
<div class="share-button" id="post-share-url-wechat" onclick="rm.shareToWechat()" title="分享到微信朋友圈">
|
||||
<i class="haofont hao-icon-weixin" style="font-size:22px"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-tools-right">
|
||||
<div class="tag_share">
|
||||
|
|
|
@ -67,6 +67,16 @@
|
|||
<div class="share-button" id="post-share-url" onclick="rm.copyPageUrl()" title="复制链接"><i
|
||||
class="haofont hao-icon-link"></i></div>
|
||||
</div>
|
||||
<div class="share-link weibo" th:if="${theme.config.post.share_right.qq_edit}">
|
||||
<div class="share-button" id="post-share-url-qq" onclick="rm.shareToQQ()" title="分享到QQ">
|
||||
<i class="haofont hao-icon-qq" style="font-size:19px"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="share-link weibo" th:if="${theme.config.post.share_right.wechat_edit}">
|
||||
<div class="share-button" id="post-share-url-wechat" onclick="rm.shareToWechat()" title="分享到微信朋友圈">
|
||||
<i class="haofont hao-icon-weixin" style="font-size:22px"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue