{"hidden":false,"children":[{"configs":{"itemId":"module","serverScript":"var lastModified, urlFile = new File(Base.path, 'wb/system/url.json'),\n  IOUtilsCopy = org.apache.commons.io.IOUtils.copy,\n  ZipEntry = com.syspatch.zip.ZipEntry;\n\nif (app.get('lastModified') == -1)\n  lastModified = null;\nelse\n  lastModified = app.getJavaDate('lastModified');\nresponse.setHeader(\"content-type\", \"application/force-download\");\nresponse.setHeader(\"content-disposition\", \"attachment;\" + WebUtil.encodeFilename(request, FileUtil.addExtension(app.get('filename'), 'zip')));\nzipModules([urlFile].concat(Java.from(Base.modulePath.listFiles())), response.getOutputStream(), lastModified);\nresponse.flushBuffer();\n\n//导出指定修改日期的所有模块到输出流\nfunction zipModules(files, outputStream, lastModified) {\n  var zipStream = new com.syspatch.zip.ZipOutputStream(outputStream);\n\n  zipStream.fileCharset = Var.getString(\"sys.locale.filenameCharset\");\n  try {\n    Wb.each(files, function(file) {\n      zip(file, zipStream, file.getName(), lastModified);\n    });\n  } finally {\n    zipStream.close();\n  }\n}\n\n//导出指定修改日期的文件到压缩文件流\nfunction zip(source, zipStream, base, lastModified) {\n  var entry;\n\n  if (lastModified && source != urlFile && !FileUtil.checkLastModified(source, lastModified))\n    return;\n  if (source.isDirectory()) {\n    entry = new ZipEntry(base + '/');\n    entry.setTime(source.lastModified());\n    zipStream.putNextEntry(entry);\n    if (!StringUtil.isEmpty(base))\n      base += '/';\n    var fileList = FileUtil.listFiles(source);\n    Wb.each(fileList, function(file) {\n      zip(file, zipStream, base + file.getName(), lastModified);\n    });\n  } else {\n    entry = new ZipEntry(base);\n    entry.setTime(source.lastModified());\n    zipStream.putNextEntry(entry);\n    var inputStream = new java.io.FileInputStream(source);\n    try {\n      IOUtilsCopy(inputStream, zipStream);\n    } finally {\n      inputStream.close();\n    }\n  }\n}"},"expanded":false,"children":[],"type":"module"}],"roles":{},"title":"导出模块","iconCls":"","inframe":false,"pageLink":""}