Skip to content

Commit

Permalink
demo添加打赏二维码
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyuecn committed Dec 9, 2019
1 parent aa9d9f5 commit b182de2
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,6 @@ public void onPermissionRequest(PermissionRequest request) {
# :star:捐赠
如果这个库有帮助到您,请 Star 一下。

你也可以选择使用支付宝或微信给我捐赠
您也可以使用支付宝或微信打赏作者

![](https://gitee.com/xiangyuecn/Recorder/raw/master/assets/donate-alipay.png) ![](https://gitee.com/xiangyuecn/Recorder/raw/master/assets/donate-weixin.png)
2 changes: 1 addition & 1 deletion app-support-sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,6 @@ rec中的方法不一定都能使用,主要用来获取内部缓冲用的,
# :star:捐赠
如果这个库有帮助到您,请 Star 一下。

你也可以选择使用支付宝或微信给我捐赠
您也可以使用支付宝或微信打赏作者

![](https://gitee.com/xiangyuecn/Recorder/raw/master/assets/donate-alipay.png) ![](https://gitee.com/xiangyuecn/Recorder/raw/master/assets/donate-weixin.png)
10 changes: 10 additions & 0 deletions app-support-sample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -773,5 +773,15 @@ <h3>ConsoleX:</h3>
};
</script>

<!-- 加载打赏挂件 -->
<script DEF="/*=:=*/" src="../assets/zdemo.widget.donate.js"
DEF="/*<@ crossorigin='anonymous' src='https://xiangyuecn.github.io/Recorder/assets/zdemo.widget.donate.js' @>*/"></script>
<script>
DonateWidget({
log:function(msg){reclog(msg)}
,mobElem:$(".reclog").append('<div class="DonateView"></div>').find(".DonateView")[0]
});
</script>

</body>
</html>
2 changes: 1 addition & 1 deletion assets/demo-vue/dist/index.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions assets/demo-vue/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@
<div class="rootView"></div>
<script src="dist/index.js"></script>

<!-- 控制台组件 -->
<script src="https://cdn.bootcss.com/eruda/1.5.4/eruda.min.js"></script>
<script>eruda.init();</script>

<!-- 加载打赏挂件 -->
<script src="../zdemo.widget.donate.js"></script>
<script>
var donateView=document.createElement("div");
document.querySelector(".mainLog").appendChild(donateView);
DonateWidget({
log:function(msg){vue_main.reclog(msg)}
,mobElem:donateView
});
</script>
</body>
</html>
3 changes: 3 additions & 0 deletions assets/demo-vue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@ logMeta(`UA`,navigator.userAgent);
logMeta(`URL`,location.href.replace(/#.*/g,""));
mainRef.reclog("点击打开录音,然后再点击开始录音",2);


window.vue_root=root;
window.vue_main=mainRef;
console.log("Vue",Vue);
console.log("Recorder",Import_Recorder);
4 changes: 4 additions & 0 deletions assets/npm-home/hash-history.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[
{
"sha1": "5156b98907b5acfa01a47dff4859327b8dc6f25a",
"time": "2019-12-9 16:33:08"
},
{
"sha1": "b64b52e7109e4d8ad42dbcf9c2e988ff794806af",
"time": "2019-12-6 22:53:28"
Expand Down
167 changes: 167 additions & 0 deletions assets/zdemo.widget.donate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
//打赏挂件,创意来自:https://github.com/TangSY/echarts-map-demo
(function(){

var ImgAlipay="https://gitee.com/xiangyuecn/Recorder/raw/master/assets/donate-alipay.png";
var ImgWeixin="https://gitee.com/xiangyuecn/Recorder/raw/master/assets/donate-weixin.png";

var IsMobile=/mobile/i.test(navigator.userAgent);

var DonateWidget=function(set){
return new Fn(set);
};
var Fn=function(set){
this.set={
log:function(htmlMsg){}
,mobElem:null
};
for(var k in set){
this.set[k]=set[k];
};

var This=this;
DonateWidget.cur=This;

This.view();
document.body.addEventListener("click",function(e){
if(/button/i.test(e.target.tagName) || /btn/i.test(e.target.className)){
try{
This.dialog();
}catch(e){}
};
});
};
Fn.prototype=DonateWidget.prototype={
log:function(htmlMsg){
htmlMsg='[打赏挂件]'+htmlMsg;
console.log(htmlMsg.replace(/<[^<>]+?>/g,""));
this.set.log(htmlMsg);
}
,view:function(){
if(IsMobile){
if(this.set.mobElem){
this._render(false,false,this.set.mobElem);
};
}else{
var dis=localStorage["DonateWidget_SetDisable"];
if(dis && Date.now()-new Date(dis).getTime()<24*60*60*1000){
this.log('已禁用打赏挂件一天,可通过命令开启:DonateWidget.SetDisable(0) <a href="" onclick="DonateWidget.SetDisable(0);return false">exec</a>');
return;
};

this.dialog(0,"Float");
};
}
,dialog:function(showNow,_f){
if(!_f){
//点击了按钮后一天后再开启
var time=localStorage["DonateWidget_Close"];
if(!showNow && time && Date.now()-new Date(time).getTime()<24*60*60*1000){
return;
};
};

DonateWidget.cur.close(0,"Float",1);
DonateWidget.cur.close(0,"Box",1);

var zIndex=1;
var all=document.querySelectorAll("*");
for(var i=0;i<all.length;i++){
var v=+getComputedStyle(all[i]).zIndex||0;
if(v>zIndex){
zIndex=v+1;
};
};

var fixedElem=document.createElement("div");
fixedElem.innerHTML='\
<div class="DonateWidget_dialog'+(_f||"Box")+'" style="z-index:'+zIndex+';position: fixed;display:flex;align-items:center;justify-content:center;'+(_f?'top:20%;right:5px':'left:0;top:0;width:100%;height:100%;background:rgba(0,0,0,0.3)')+'">\
<div onclick="DonateWidget.cur.close(1,\''+(_f||"Box")+'\')" style="position: absolute;font-size:32px;cursor: pointer;top: 0;right:8px;color:#fff;">×</div>\
<div class="DonateWidget_dialogRender"></div>\
</div>';
document.body.appendChild(fixedElem);

this._render(!_f,!!_f,fixedElem.querySelector(".DonateWidget_dialogRender"));
}
,_render:function(isDialog,isFloat,elem){
var title="赏包辣条?";
var time=new Date("2020/01/25").getTime();//大年初一
var td=Math.ceil((time-Date.now())/24/60/60/1000);
if(td>0){
title="剩余"+td+"天就过年了,给大伙拜个早年吧~ 赏包辣条?";
}else if(td>-30){
tiltle="春节快乐,给大伙拜年啦~ 赏个红包?";
};

var min=IsMobile?true:isDialog?false:true;
elem.innerHTML='\
<div style="border-radius:12px;background:linear-gradient(160deg, rgba(0,179,255,'+(isFloat?".7":"1")+') 20%, rgba(177,0,255,'+(isFloat?".7":"1")+') 80%);max-width:'+(min?300:520)+'px;padding:'+(min?20:30)+'px;text-align: center;">\
<div style="font-size:18px;color:#fff;">'+title+'</div>\
<div style="padding-top:14px">\
<img src="'+ImgAlipay+'" style="width:'+(min?145:220)+'px">\
<img src="'+ImgWeixin+'" style="width:'+(min?145:220)+'px">\
</div>\
<div style="padding-top:10px">\
<button onclick="DonateWidget.cur.click(0,'+(isDialog?1:0)+','+(isFloat?1:0)+')" class="DonateWidget_Btn" style="margin-right:'+(min?10:40)+'px">算了吧'+unescape("%uD83D%uDE36")+'</button>\
<button onclick="DonateWidget.cur.click(1,'+(isDialog?1:0)+','+(isFloat?1:0)+')" class="DonateWidget_Btn">已打赏~ 壕气'+unescape("%uD83D%uDE18")+'</button>\
</div>\
<style>\
.DonateWidget_Btn{\
display: inline-block;\
cursor: pointer;\
border: none;\
border-radius: 3px;\
background: #f60;\
color:#fff;\
padding: 0 15px;\
line-height: 36px;\
height: 36px;\
overflow: hidden;\
vertical-align: middle;\
}\
.DonateWidget_Btn:active{\
background: #f00;\
}\
</style>\
</div>';
}
,click:function(ok,isDialog,isFloat){
localStorage["DonateWidget_Close"]=new Date().toDateString();
if(isDialog){
this.close(1,"Box");
}else if(isFloat){
this.close(!ok,"Float");
ok&&DonateWidget.SetDisable(1);
};

if(ok){
this.log("谢谢支持,看好你哟~");
}else{
this.log("emmm... 加油~");
};
}
,close:function(user,cls,disableView){
var elems=document.querySelectorAll(".DonateWidget_dialog"+cls);
for(var i=0;i<elems.length;i++){
var elem=elems[i];
elem.parentNode.removeChild(elem);
};
if(!disableView && cls!="Float"){
this.view();
};
if(user && cls=="Float"){
this.log('通过命令可禁用侧边打赏挂件一天: DonateWidget.SetDisable(1) <a href="" onclick="DonateWidget.SetDisable(1);return false">exec</a>');
};
}
};

DonateWidget.SetDisable=function(disable){
localStorage["DonateWidget_SetDisable"]=disable?new Date().toDateString():"";
if(disable){
DonateWidget.cur.log("emmm...已禁用打赏挂件,禁用时长为一天");
}else{
DonateWidget.cur.view();
};
};
window.DonateWidget=DonateWidget;

})();
9 changes: 9 additions & 0 deletions assets/ztest_no_user_operation.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,14 @@
});
</script>

<!-- 加载打赏挂件 -->
<script src="zdemo.widget.donate.js"></script>
<script>
DonateWidget({
log:function(msg){reclog(msg)}
,mobElem:$(".reclog").append('<div class="DonateView"></div>').find(".DonateView")[0]
});
</script>

</body>
</html>
15 changes: 13 additions & 2 deletions assets/工具-代码运行和静态分发Runtime.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<div class="ctrlBtns"></div>
</div>

<div class="mainBox">
<div class="mainBox mainLogBox">
<audio class="LogAudioPlayer" style="width:100%"></audio>
<div class="mainLog"></div>
</div>
Expand Down Expand Up @@ -442,7 +442,7 @@
href="";
};
href&&(href+='"');
html.push('<div style="line-height:40px">'+(i+1)+'. <a '+href+' onclick="Runtime.UseDemoCode('+i+');return false">'+o.name+'</a></div>');
html.push('<div style="padding:8px 0">'+(i+1)+'. <a '+href+' onclick="Runtime.UseDemoCode('+i+');return false">'+o.name+'</a></div>');
};
$(".demoList").html(html.join("\n"));

Expand Down Expand Up @@ -920,5 +920,16 @@
</script>



<!-- 加载打赏挂件 -->
<script src="zdemo.widget.donate.js"></script>
<script>
DonateWidget({
log:function(msg){Runtime.Log(msg)}
,mobElem:$(".mainLogBox").append('<div class="DonateView"></div>').find(".DonateView")[0]
});
</script>


</body>
</html>
20 changes: 14 additions & 6 deletions assets/工具-裸PCM转WAV播放测试.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="shortcut icon" type="image/png" href="icon.png">

<title>裸(RAW、WAV)PCM转WAV播放测试和转码</title>

<style>
html,body{
height:100%;
}
</style>
</head>

<body>
Expand Down Expand Up @@ -329,5 +324,18 @@
};
};
</script>

<!-- 加载打赏挂件 -->
<div class="DonateLogs"></div>
<div class="DonateView"></div>
<div style="padding-bottom:600px"></div>
<script src="zdemo.widget.donate.js"></script>
<script>
DonateWidget({
log:function(msg){var div=document.createElement("div");div.innerHTML=msg;document.querySelector(".DonateLogs").appendChild(div)}
,mobElem:document.querySelector(".DonateView")
});
</script>

</body>
</html>
11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<!-- begin 开始copy源码 -->
<div class="demoMain">
<div class="pd gitUrl">
GitHub:<a href="https://github.com/xiangyuecn/Recorder">https://github.com/xiangyuecn/Recorder</a> , 更多Demo:<a href="https://xiangyuecn.github.io/Recorder/assets/工具-代码运行和静态分发Runtime.html">在线编辑和运行</a><a href="https://xiangyuecn.github.io/Recorder/assets/demo-vue">vue+webpack测试</a>
GitHub:<a href="https://github.com/xiangyuecn/Recorder">https://github.com/xiangyuecn/Recorder</a> , 更多Demo:<a href="https://xiangyuecn.github.io/Recorder/assets/工具-代码运行和静态分发Runtime.html" target="_blank">在线编辑和运行</a><a href="https://xiangyuecn.github.io/Recorder/assets/demo-vue" target="_blank">vue+webpack测试</a>
</div>
<div class="pd">
类型:<span class="types">
Expand Down Expand Up @@ -846,5 +846,14 @@ <h3>ConsoleX:</h3>
}catch(e){console.error(e)}})();
</script>

<!-- 加载打赏挂件 -->
<script src="assets/zdemo.widget.donate.js"></script>
<script>
DonateWidget({
log:function(msg){reclog(msg)}
,mobElem:$(".reclog").append('<div class="DonateView"></div>').find(".DonateView")[0]
});
</script>

</body>
</html>
12 changes: 7 additions & 5 deletions src/package-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ process.stdin.on('data',function(input){

function Run_minify(){
deleteFolder("../dist");
fs.mkdirSync("../dist");
!fs.existsSync("../dist")&&fs.mkdirSync("../dist");
fs.mkdirSync("../dist/engine");
fs.mkdirSync("../dist/extensions");
fs.mkdirSync("../dist/app-support");
Expand Down Expand Up @@ -94,18 +94,20 @@ src: ${srcs.join(",")}



function deleteFolder(path){
function deleteFolder(path,deep){
if(fs.existsSync(path)){
var files=fs.readdirSync(path);
files.forEach(function(file){
var p=path+"/"+file;
if(fs.statSync(p).isDirectory()){
deleteFolder(p);
deleteFolder(p,(deep||0)+1);
} else {
fs.unlinkSync(p);
}
});
fs.rmdirSync(path);
if(deep){
fs.rmdirSync(path);
};
};
};

Expand All @@ -121,7 +123,7 @@ function Run_npm(){
var npmFiles=npmHome+"/npm-files";
var npmSrc=npmFiles+"/src";
deleteFolder(npmFiles);
fs.mkdirSync(npmFiles);
!fs.existsSync(npmFiles)&&fs.mkdirSync(npmFiles);
fs.mkdirSync(npmSrc);
var srcDirs=["engine","extensions","app-support"];

Expand Down

0 comments on commit b182de2

Please sign in to comment.