Authored by 周少峰

Merge branch 'release/5.3' into 'gray'

Release/5.3

增加标志调整请求速度

See merge request !28
@@ -16,6 +16,7 @@ var Captcha = function(container, options) { @@ -16,6 +16,7 @@ var Captcha = function(container, options) {
16 this.picWidth = null; 16 this.picWidth = null;
17 this.$tip = null; 17 this.$tip = null;
18 this.refreshCb = null; 18 this.refreshCb = null;
  19 + this.running = false;
19 20
20 return this; 21 return this;
21 }; 22 };
@@ -89,13 +90,19 @@ Captcha.prototype = { @@ -89,13 +90,19 @@ Captcha.prototype = {
89 var self = this; 90 var self = this;
90 var uri = this.refreshURI; 91 var uri = this.refreshURI;
91 92
  93 + if (self.running) {
  94 + return $.Deferred().reject().promise(); // eslint-disable-line
  95 + }
  96 +
  97 + self.running = true;
  98 +
92 return $.get(uri) 99 return $.get(uri)
93 .done(function(result) { 100 .done(function(result) {
94 if (result.code !== 200) { 101 if (result.code !== 200) {
95 return self.showTip(); 102 return self.showTip();
96 } 103 }
97 104
98 - var src = result.data.images; 105 + var src = result.data.images; // eslint-disable-line
99 106
100 self.render({ 107 self.render({
101 images: src 108 images: src
@@ -105,7 +112,9 @@ Captcha.prototype = { @@ -105,7 +112,9 @@ Captcha.prototype = {
105 112
106 self.refreshCb && self.refreshCb(); 113 self.refreshCb && self.refreshCb();
107 }) 114 })
108 - .fail($.noop); 115 + .always(function() {
  116 + self.running = false;
  117 + });
109 }, 118 },
110 119
111 onRefresh: function(cb) { 120 onRefresh: function(cb) {