parse.min.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. var packageParser = function () {
  2. return function () {
  3. var e = {
  4. singleAllow: 314572800,
  5. openLargeAppUpload: 0,
  6. qndomain: "",
  7. gettoken: "/qiniuoss/getToken",
  8. flash_swf_url: "/static/default/images/Moxie.swf",
  9. autoClickUploadStart: 0,
  10. mime_types: [{title: "app files", extensions: "apk"}, {title: "ipa files", extensions: "ipa"}, {title: "mobileconfig files", extensions: "mobileconfig"}],
  11. postField: {},
  12. upload: "",
  13. saveCallback: function () {
  14. },
  15. parseCallback: function () {
  16. }
  17. };
  18. this.init = function (i) {
  19. e = $.extend(e, i);
  20. var a = {};
  21. $.ajax({
  22. type: "GET", url: e.gettoken, success: function (i) {
  23. var o = Qiniu.uploader({
  24. runtimes: "html5,flash,html4",
  25. browse_button: "uploadstart",
  26. uptoken: i,
  27. unique_names: !0,
  28. save_key: !1,
  29. domain: e.qndomain,
  30. get_new_uptoken: !1,
  31. container: "container",
  32. flash_swf_url: e.flash_swf_url,
  33. max_retries: 3,
  34. dragdrop: !0,
  35. drop_element: "container",
  36. chunk_size: "4mb",
  37. auto_start: !1,
  38. multi_selection: !1,
  39. filters: {max_file_size: "5000mb", prevent_duplicates: !0, mime_types: e.mime_types},
  40. init: {
  41. PostInit: function (i, a) {
  42. 0 != e.autoClickUploadStart && (console.log("autoupload"), $("#uploadstart").click())
  43. }, FilesAdded: function (i, n) {
  44. if(n[0].name&&n[0].name.indexOf('mobileconfig')>-1){
  45. console.log(n[0]);o.start()
  46. }else{
  47. console.log(n), plupload.each(n, function (i) {
  48. new AppInfoParser(i.getNative()).parse().then(n => {
  49. a.icon = n.icon, a.fileSize = i.size, a.originalName = i.name, n.package ? (a.appName = "string" == typeof n.application.label ? n.application.label : n.application.label[0], a.version = n.versionName, a.versionCode = n.versionCode, a.packageName = n.package, a.ext = "apk", a.minSdkVersion = n.usesSdk.minSdkVersion) : (a.appName = n.CFBundleDisplayName ? n.CFBundleDisplayName : n.CFBundleName, a.version = n.CFBundleShortVersionString, a.versionCode = n.CFBundleVersion, a.packageName = n.CFBundleIdentifier, a.ext = "ipa", a.minSdkVersion = n.MinimumOSVersion, a.teamName = n.mobileProvision.TeamName, a.udids = "", a.teamId = n.mobileProvision.TeamIdentifier, n.mobileProvision.ProvisionsAllDevices ? a.teamType = 1 : n.mobileProvision.ProvisionedDevices ? (n.mobileProvision.Entitlements["get-task-allow"] ? a.teamType = 2 : a.teamType = 3, a.udids = n.mobileProvision.ProvisionedDevices) : a.teamType = 4), e.parseCallback(i, a), $(".upload-app-icon").find("img").attr("src", a.icon), $("#upload-app-name").text(a.appName), o.start()
  50. }).catch(e => {
  51. alert(e, function () {
  52. try {
  53. o.splice(0, 1)
  54. } catch (e) {
  55. }
  56. })
  57. })
  58. })
  59. }
  60. }, BeforeUpload: function (e, i) {
  61. $(".tolsize").html("<span class='process100' style='width: auto;font-size: 14px;'></span> / " + (i.size / 1024 / 1024).toFixed(2) + "MB"), $("#upprocess").show(), $("#upbtn").hide()
  62. }, UploadProgress: function (e, i) {
  63. $(".progress-bar").css("width", i.percent + "%"), $(".process100").html(i.percent + "%"), $(".moxie-shim").hide()
  64. }, FileUploaded: function (i, o, n) {
  65. var t = i.getOption("domain"), s = JSON.parse(n.response), l = t + s.key;
  66. console.log(s), a.apkName = s.key, a.downLink = l, function (i) {
  67. var a = $.extend({
  68. apkName: i.apkName,
  69. originalName: i.originalName,
  70. icon: i.icon,
  71. hext: i.ext,
  72. happName: i.appName,
  73. hversion: i.version,
  74. hpackageName: i.packageName,
  75. hversionCode: i.versionCode,
  76. sDownLink: i.downLink,
  77. iAppSize: i.fileSize,
  78. TeamName: i.teamName,
  79. TeamType: i.teamType,
  80. TeamId: i.teamId,
  81. udids: i.udids,
  82. MinimumOSVersion: i.minSdkVersion
  83. }, e.postField);
  84. if(i.apkName&&i.apkName.indexOf('mobileconfig')>-1){
  85. console.log(e.upload), $.post('/upload/index/mobileconfig', a, e.saveCallback, "json")
  86. }else{
  87. console.log(a), $.post(e.upload, a, e.saveCallback, "json")
  88. }
  89. }(a)
  90. }, Error: function (e, i, a) {
  91. return alert(a), !1
  92. }, UploadComplete: function () {
  93. }, Key: function (e, i) {
  94. return i.name
  95. }
  96. }
  97. });
  98. $("#changest").click(function () {
  99. $(this).hasClass("pause") ? (o.start(), $(this).removeClass("pause"), $(this).text("暂停上传")) : ($(this).addClass("pause"), $(this).text("恢复上传"), o.stop())
  100. })
  101. }, error: function () {
  102. }
  103. })
  104. }
  105. }
  106. }();