{"hidden":false,"children":[{"configs":{"itemId":"module","serverScript":"if (!app.get('file__name').toLowerCase().endsWith('.zip'))\n  throw '模块文件包格式须为 \".zip\"。';\nvar zipStream = new com.syspatch.zip.ZipInputStream(app.get('file')),\n  UrlBuffer = com.wb.common.UrlBuffer,\n  mergeUrl, mergePerm, mergeFolder, urlMap, srcModule, dstModule, z, f, name, urlAdded, relPath;\n\ntry {\n  zipStream.fileCharset = Var.getString(\"sys.locale.filenameCharset\");\n  mergeUrl = app.getBool('mergeUrl');\n  mergePerm = app.getBool('mergePerm');\n  mergeFolder = app.getBool('mergeFolder');\n  while ((z = zipStream.getNextEntry()) !== null) {\n    name = z.getName();\n    if (z.isDirectory()) {\n      name = name.substring(0, name.length() - 1);\n      f = new File(Base.modulePath, name);\n      if (!f.exists())\n        FileUtil.syncCreate(f, true);\n    } else {\n      if (!urlMap && name == 'url.json') {\n        urlMap = getUrlMap(zipStream);\n        continue;\n      }\n      f = new File(Base.modulePath, name);\n      //导入url捷径\n      if (mergeUrl && urlMap) {\n        relPath = FileUtil.getModulePath(f);\n        url = urlMap[relPath];\n        if (!Wb.isEmpty(url)) {\n          if (!urlAdded) urlAdded = true;\n          UrlBuffer.put(url, relPath);\n        }\n      }\n      if (f.exists()) {\n        if (name == 'folder.json' || name.endsWith('/folder.json')) {\n          if (!mergeFolder)\n            continue;\n        } else if (!mergePerm && name.endsWith('.xwl')) {\n          //覆盖模块权限\n          srcModule = Wb.readJson(f);\n          dstModule = Wb.decode(StringUtil.getStringA(zipStream));\n          dstModule.roles = srcModule.roles;\n          FileUtil.syncSave(f, Wb.encode(dstModule));\n          continue;\n        }\n      } else\n        FileUtil.syncCreate(f, false);\n      FileUtil.syncSave(f, StringUtil.getStringA(zipStream));\n    }\n  }\n  if (urlAdded)\n    UrlBuffer.save();\n} finally {\n  zipStream.close();\n}\n\n//获取以文件名为key,url为value的对象\nfunction getUrlMap(stream) {\n  var object = Wb.decode(StringUtil.getStringA(stream));\n  map = {};\n  Wb.each(object, function(k, v) {\n    map[v] = k;\n  });\n  return map;\n}"},"expanded":false,"children":[],"type":"module"}],"roles":{},"title":"导入模块","iconCls":"","inframe":false,"pageLink":""}