This commit is contained in:
libccy 2017-03-26 23:36:08 +08:00
parent b5284e7d92
commit fefb3e88c6
2 changed files with 14 additions and 5 deletions

View File

@ -6207,12 +6207,18 @@
} }
}); });
} }
game.download=function(url,folder,onsuccess,onerror,dev){ game.download=function(url,folder,onsuccess,onerror,dev,onprogress){
if(url.indexOf('http')!=0){ if(url.indexOf('http')!=0){
url=get.url(dev)+url; url=get.url(dev)+url;
} }
var fileTransfer = new FileTransfer(); var fileTransfer = new FileTransfer();
folder=lib.assetURL+folder; folder=lib.assetURL+folder;
game.print(typeof onprogress);
if(onprogress){
fileTransfer.onprogress=function(progressEvent){
onprogress(progressEvent.loaded,progressEvent.total);
};
}
fileTransfer.download(encodeURI(url),encodeURI(folder),onsuccess,onerror); fileTransfer.download(encodeURI(url),encodeURI(folder),onsuccess,onerror);
}; };
game.readFile=function(filename,callback,onerror){ game.readFile=function(filename,callback,onerror){
@ -20263,7 +20269,8 @@
download(); download();
}, },
fetch:function(url,onload,onerror,onprogress){ fetch:function(url,onload,onerror,onprogress){
var tmpName=get.id(); var tmpName='_tmp_'+get.id();
game.saveConfig('downloadedFile',true);
game.download(encodeURI(url),tmpName,function(){ game.download(encodeURI(url),tmpName,function(){
game.readFile(tmpName,function(data){ game.readFile(tmpName,function(data){
onload(data); onload(data);
@ -30569,7 +30576,10 @@
},function(){ },function(){
that.innerHTML='下载失败'; that.innerHTML='下载失败';
that.classList.add('nopointer'); that.classList.add('nopointer');
},function(byte){ },function(byte,total){
if(total){
size=total;
}
if(byte==-1){ if(byte==-1){
byte=size; byte=size;
} }

View File

@ -1,9 +1,8 @@
window.noname_update={ window.noname_update={
version:'1.9.16.1', version:'1.9.16',
update:'1.9.15', update:'1.9.15',
changeLog:[ changeLog:[
'bug修复', 'bug修复',
'扩展下载进度'
], ],
files:[ files:[
'game/game.js', 'game/game.js',