Javascript 将远程2个Zip文件合并到新的Zip文件中
小提琴: 可以在JavaScript中读取和写入zip文件 但是我想知道如何使用这个库在远程服务器上合并两个单独的zip文件?例如,假设两个Github回购协议 我的尝试如下: JavaScript:Javascript 将远程2个Zip文件合并到新的Zip文件中,javascript,arrays,jszip,Javascript,Arrays,Jszip,小提琴: 可以在JavaScript中读取和写入zip文件 但是我想知道如何使用这个库在远程服务器上合并两个单独的zip文件?例如,假设两个Github回购协议 我的尝试如下: JavaScript: // Set Sample URL document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip"; $(".loadzipurl").
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, dataFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = dataFiles;
// Download as Windows App
$(".export-app").on("click", function() {
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/assets/YourWinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("app/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, repoFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = repoFiles;
// Download as Windows App
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/zips/YourLinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("HELLOMOMMY/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
//设置示例URL
document.getElementById(“zipurl”)。值=“https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(.loadzipurl”)。在(“单击”,函数(){
if((!document.getElementById(“zipurl”).value)){
//无所事事
错误(“值为空,无法执行操作!”);
}否则{
if((document.getElementById(“zipurl”).value.toLowerCase().substring(0,7)==“http://”)| |(document.getElementById(“zipurl”).value.toLowerCase().substring(0,8)==“https://”){
JSZipUtils.getBinaryContent(document.getElementById(“zipurl”)。值,函数(错误,数据文件){
如果(错误){
抛出错误//或句柄错误
}
var webAppZipBinary=数据文件;
//作为Windows应用程序下载
$(“.export app”)。在(“单击”,函数(){
JSZipUtils.getBinaryContent(“https://mikethedj4.github.io/kodeWeave/editor/assets/YourWinApp.zip,函数(错误,数据){
如果(错误){
抛出错误//或处理错误
}
消息(“正在创建应用程序!”);
var zip=newjszip();
zip.load(数据);
//您的Web应用程序
zip.folder(“app/”).load(webAppZipBinary);
//适用于32位Windows应用程序
zip.file(“package.json”、“{\n”main:“index.html”、\n“name:“test”、\n“window:{\n”toolbar:false、\n“icon”:“app/icons/128.png”、\n“width”:1000、\n“height”:600、\n“position”:“center”\n}\n});
zip.file(“index.html”,'\n\n\n test\n\n iframe{\n位置:绝对;\n顶部:0;\n左侧:0;\n宽度:100%;\n高度:100%;\n溢出:可见;\n边框:0;\n}\n\n\n\n\n');
//导出应用程序
var content=zip.generate({type:“blob”});
saveAs(内容为“test win.zip”);
返回false;
});
});
});
}否则{
error(“错误!\”http://\”和\“https://\”URL仅受支持!”);
}
}
});
HTML:
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, dataFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = dataFiles;
// Download as Windows App
$(".export-app").on("click", function() {
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/assets/YourWinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("app/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, repoFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = repoFiles;
// Download as Windows App
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/zips/YourLinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("HELLOMOMMY/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
出口申请
小提琴:
经过几个小时的尝试和失败,我终于让它工作了
JavaScript:
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, dataFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = dataFiles;
// Download as Windows App
$(".export-app").on("click", function() {
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/assets/YourWinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("app/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, repoFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = repoFiles;
// Download as Windows App
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/zips/YourLinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("HELLOMOMMY/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
//设置示例URL
document.getElementById(“zipurl”)。值=“https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(.loadzipurl”)。在(“单击”,函数(){
if((!document.getElementById(“zipurl”).value)){
//无所事事
错误(“值为空,无法执行操作!”);
}否则{
if((document.getElementById(“zipurl”).value.toLowerCase().substring(0,7)==“http://”)| |(document.getElementById(“zipurl”).value.toLowerCase().substring(0,8)==“https://”){
JSZipUtils.getBinaryContent(document.getElementById(“zipurl”).value,函数(error,repotfiles){
如果(错误){
抛出错误//或句柄错误
}
var webAppZipBinary=repoFiles;
//作为Windows应用程序下载
JSZipUtils.getBinaryContent(“https://mikethedj4.github.io/kodeWeave/editor/zips/YourLinApp.zip,函数(错误,数据){
如果(错误){
抛出错误//或处理错误
}
消息(“正在创建应用程序!”);
var zip=newjszip();
zip.load(数据);
//您的Web应用程序
zip.folder(“hellommy/”).load(webAppZipBinary);
//适用于32位Windows应用程序
zip.file(“package.json”、“{\n”main:“index.html”、\n“name:“test”、\n“window:{\n”toolbar:false、\n“icon”:“app/icons/128.png”、\n“width”:1000、\n“height”:600、\n“position”:“center”\n}\n});
zip.file(“index.html”,'\n\n\n test\n\n iframe{\n位置:绝对;\n顶部:0;\n左侧:0;\n宽度:100%;\n高度:100%;\n溢出:可见;\n边框:0;\n}\n\n\n\n\n');
//导出应用程序
var content=zip.generate({type:“blob”});
saveAs(内容为“test win.zip”);
返回false;
});
});
}否则{
error(“错误!\”http://\”和\“https://\”URL仅受支持!”);
}
}
});
HTML:
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, dataFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = dataFiles;
// Download as Windows App
$(".export-app").on("click", function() {
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/assets/YourWinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("app/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, repoFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = repoFiles;
// Download as Windows App
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/zips/YourLinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("HELLOMOMMY/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
出口申请
小提琴:
经过几个小时的尝试和失败,我终于让它工作了
JavaScript:
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, dataFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = dataFiles;
// Download as Windows App
$(".export-app").on("click", function() {
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/assets/YourWinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("app/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
// Set Sample URL
document.getElementById("zipurl").value = "https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(".loadzipurl").on("click", function() {
if ( (!document.getElementById("zipurl").value) ) {
// Do nothing
alertify.error("Unable to perform operation as value is blank!");
} else {
if ( (document.getElementById("zipurl").value.toLowerCase().substring(0,7) === "http://" ) || (document.getElementById("zipurl").value.toLowerCase().substring(0,8) === "https://") ) {
JSZipUtils.getBinaryContent(document.getElementById("zipurl").value, function(error, repoFiles) {
if(error) {
throw error // or handle err
}
var webAppZipBinary = repoFiles;
// Download as Windows App
JSZipUtils.getBinaryContent("https://mikethedj4.github.io/kodeWeave/editor/zips/YourLinApp.zip", function(err, data) {
if(err) {
throw err // or handle err
}
alertify.message("Creating application!");
var zip = new JSZip();
zip.load(data);
// Your Web Application
zip.folder("HELLOMOMMY/").load(webAppZipBinary);
// For 32bit Windows Application
zip.file("package.json", '{\n "main" : "index.html",\n "name" : "test",\n "window": {\n "toolbar" : false,\n "icon" : "app/icons/128.png",\n "width" : 1000,\n "height" : 600,\n "position": "center"\n }\n}');
zip.file("index.html", '<!doctype html>\n<html>\n <head>\n <title>test</title>\n <style>\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n border: 0;\n }\n </style>\n </head>\n <body>\n <iframe src="app/index.html"></iframe>\n </body>\n</html>');
// Export your application
var content = zip.generate({type:"blob"});
saveAs(content, "test-win.zip");
return false;
});
});
} else {
alertify.error("Error! \"http://\" and \"https://\" urls are only supported!");
}
}
});
<input type="text" id="zipurl" placeholder="http://">
<button class="loadzipurl">Export Application</button>
//设置示例URL
document.getElementById(“zipurl”)。值=“https://mikethedj4.github.io/kodeWeave/editor/zips/font-awesome.zip";
$(.loadzipurl”)。在(“单击”,函数(){
if((!document.getElementById(“zipurl”).value)){
//无所事事
错误(“值为空,无法执行操作!”);
}否则{
if((document.getElementById(“zipurl”).value.toLowerCase().substring(0,7)==“http://”)| |(document.getElementById(“zipurl”).value.toLowerCase().substring(0,8)==“https://”){
JSZipUtils.getBinaryContent(document.getElementById(“zipurl”).value,函数(error,repotfiles){
如果(错误){
抛出错误//或句柄错误
}
var webAppZipBinary=repoFiles;
//作为Windows应用程序下载
JSZipUtils.getBinaryContent(“https://mikethedj4.github.io/kodeWeave/editor/zips/YourLinApp.zip,函数(错误,数据){
如果(错误){
抛出错误//或处理错误
}
消息(“正在创建应用程序!”);
var zip=newjszip();
zip.load(数据);
//您的Web应用程序