-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvue-resource-progressbar-interceptor.min.js
1 lines (1 loc) · 1.45 KB
/
vue-resource-progressbar-interceptor.min.js
1
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},VueResourceProgressBarInterceptor={install:function(r){function e(){t=0,n=0,s.finish()}var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=r.prototype.$Progress;if(null==s)return void console.error("vue-resouce-progressbar-interceptor: vue-progress-bar is not installed. Please install it from https://github.com/hilongjw/vue-progressbar");var t=0,n=0,a=null!=o.latencyThreshold?o.latencyThreshold:100,l=null!=o.responseLatency?o.responseLatency:50;r.http.interceptors.push(function(r,o){var u=!0;null!=r.showProgressBar&&(u=r.showProgressBar,delete r.showProgressBar),null!=r.show_progress_bar&&(u=r.show_progress_bar,delete r.show_progress_bar),null!=r.params.showProgressBar&&(u=r.params.showProgressBar,delete r.params.showProgressBar),null!=r.params.show_progress_bar&&(u=r.params.show_progress_bar,delete r.params.show_progress_bar);var p=void 0;u&&(0===t&&(0===a?s.start():setTimeout(function(){t!==n&&s.start()},a)),t++,s.$vm.RADON_LOADING_BAR.options.show&&(p=n/t*100+1,s.set(p))),o(function(r){return u?(setTimeout(function(){r&&r.ok||(s.fail(),e()),n++,n>=t?e():(p=n/t*100-10,s.set(p))},l),r):r})})}};"object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports&&(module.exports=VueResourceProgressBarInterceptor);