增加打赏

This commit is contained in:
浪子 2024-05-18 19:38:20 +08:00
parent ed9ca82119
commit f23e6fad65
4 changed files with 116 additions and 6 deletions

66
dist/css/donate.css vendored Normal file
View File

@ -0,0 +1,66 @@
.donate-panel{
text-align: center;
position: relative;
}
#donate-btn{
width: 50px;
height: 50px;
/* #background: #e26d6d;*/
color: #fff;
font-size: 20px;
font-weight: 600;
border-radius: 50%;
text-align: center;
line-height: 50px;
cursor: pointer;
display: inline-block;
position: relative;
/* box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)*/
}
#donate-btn:hover{
/* #background: #bd4b4b;*/
}
#qrcode-panel{
position: absolute;
width: 300px;
height: 320px;
background:#fff;
top: 0;
left: 0;
border-radius: 5px;
/* padding: 5px; */
box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
}
.qrcode-body{
width: 100%;
height: 100%;
background:#fff;
position: relative;
border-radius: 5px;
}
.donate-memo{
padding: 10px;
font-size: 14px;
color: #999;
text-align: center;
}
#donate-close{
float: right;
padding: 0 5px;
font-size: 12px;
cursor: pointer;
}
#donate-close:hover{
color: #bd4b4b;
}
.donate-qrpay{
}
.donate-qrpay img{
width: 280px;
height: 280px;
}
input[name='pay']{
cursor: pointer;
}

30
dist/js/donate.js vendored Normal file
View File

@ -0,0 +1,30 @@
setTimeout(function(){
initDonate()
}, 1000);
function initDonate(){
var donateBtn = document.getElementById('donate-btn');
var donatePopup = document.getElementById('qrcode-panel');
if(!donateBtn && !donatePopup){
return
}
var l = donateBtn.offsetLeft-125;
var t = donateBtn.offsetTop-330;
donatePopup.style.left=l+'px'
donatePopup.style.top=t+'px'
donateBtn.addEventListener('click',function(){
donatePopup.style.display='';
event.stopPropagation()
})
document.getElementById('donate-close').addEventListener('click',function(){
donatePopup.style.display='none';
event.stopPropagation()
})
document.querySelector('body').addEventListener('click',function() {
donatePopup.style.display='none';
event.stopPropagation()
});
donatePopup.addEventListener('click',function() {
event.stopPropagation()
});
}

View File

@ -5,7 +5,7 @@ function themeConfig($form) {
$form->addInput($logoUrl);
$icoUrl = new Typecho_Widget_Helper_Form_Element_Text('icoUrl', NULL, NULL, _t('站点 Favicon 地址'));
$form->addInput($icoUrl);
$jzyear = new Typecho_Widget_Helper_Form_Element_Text('jzyear', NULL, NULL, _t('建站年份'));
$jzyear = new Typecho_Widget_Helper_Form_Element_Text('jzyear', NULL, NULL, _t('建站年份 eg. 2006'));
$form->addInput($jzyear);
$instagramurl = new Typecho_Widget_Helper_Form_Element_Text('instagramurl', NULL, NULL, _t('ins'));
$form->addInput($instagramurl);
@ -21,6 +21,10 @@ function themeConfig($form) {
$form->addInput($sitemapurl);
$cnavatar = new Typecho_Widget_Helper_Form_Element_Text('cnavatar', NULL, 'https://cravatar.cn/avatar/', _t('自定义Gravatar镜像服务器,默认https://cravatar.cn/avatar/'));
$form->addInput($cnavatar);
$donate = new Typecho_Widget_Helper_Form_Element_Text('donate', NULL, 'https://blogcdn.loliko.cn/donate/wx.png', _t('赞赏二维码'));
$form->addInput($donate);
$twikoo = new Typecho_Widget_Helper_Form_Element_Textarea('twikoo', NULL, NULL, _t('引用第三方评论'));
$form->addInput($twikoo);

View File

@ -31,23 +31,33 @@
<h2 class="post--single__title"><?php $this->title() ?></h2>
<div class="post--single__content graph" ><?php $this->content(); ?></div>
<div class="post--single__action">
<div class="post--single">
<?php if($this->options->donate): ?>
<!--打赏 -->
<script type="text/javascript" src="https://blogcdn.loliko.cn/donate/index_wx.js?121"></script>
<link rel="stylesheet" type="text/css" href="https://blogcdn.loliko.cn/donate/style_wx.css?121" />
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/donate.css'); ?>">
<script type="text/javascript" src="<?php $this->options->themeUrl('/dist/js/donate.js'); ?>"></script>
<div class="donate-panel">
<div id="donate-btn"></div>
<div id="donate-btn">
<button class="button--like">
<svg class="icon--default" viewBox="0 0 1024 1024" width="32" height="32">
<path
d="M332.8 249.6c38.4 0 83.2 19.2 108.8 44.8L467.2 320 512 364.8 556.8 320l25.6-25.6c32-32 70.4-44.8 108.8-44.8 19.2 0 38.4 6.4 57.6 12.8 44.8 25.6 70.4 57.6 76.8 108.8 6.4 44.8-6.4 89.6-38.4 121.6L512 774.4 236.8 492.8C204.8 460.8 185.6 416 192 371.2c6.4-44.8 38.4-83.2 76.8-108.8C288 256 313.6 249.6 332.8 249.6L332.8 249.6M332.8 185.6C300.8 185.6 268.8 192 243.2 204.8 108.8 275.2 89.6 441.6 185.6 537.6l281.6 281.6C480 832 499.2 838.4 512 838.4s32-6.4 38.4-19.2l281.6-281.6c96-96 76.8-262.4-57.6-332.8-25.6-12.8-57.6-19.2-89.6-19.2-57.6 0-115.2 25.6-153.6 64L512 275.2 486.4 249.6C448 211.2 390.4 185.6 332.8 185.6L332.8 185.6z">
</path>
</svg>
</button>
</div>
<div id="qrcode-panel" style="display: none;">
<div class="qrcode-body">
<div class="donate-memo">
<span id="donate-close">关闭</span>
</div>
<div class="donate-qrpay">
<img id="wxqr" src="https://blogcdn.loliko.cn/donate/wx.png" />
<img id="wxqr" src="<?php $this->options->donate() ?>" />
</div>
</div>
</div>
</div>
<?php endif; ?>
<!--打赏结束 -->
</div>
<!-- TAG -->