File tree Expand file tree Collapse file tree 4 files changed +30
-3
lines changed Expand file tree Collapse file tree 4 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " qiniu-js" ,
33 "jsName" : " qiniu" ,
4- "version" : " 2.5.1 " ,
4+ "version" : " 2.5.2 " ,
55 "private" : false ,
66 "description" : " Javascript SDK for Qiniu Resource (Cloud) Storage AP" ,
77 "main" : " dist/qiniu.min.js" ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
1414 request ,
1515 computeMd5 ,
1616 getUploadUrl ,
17+ isAndroidBrowser ,
1718 filterParams
1819} from "./utils" ;
1920
@@ -56,6 +57,7 @@ export class UploadManager {
5657 this . onError = ( ) => { } ;
5758 this . onComplete = ( ) => { } ;
5859 this . retryCount = 0 ;
60+ this . isAndroidBrowser = isAndroidBrowser ( ) ;
5961 Object . assign ( this , handlers ) ;
6062 }
6163
@@ -231,6 +233,10 @@ export class UploadManager {
231233 onProgress,
232234 onCreate
233235 } ) . then ( response => {
236+ if ( this . isAndroidBrowser ) {
237+ console . log ( "android..." ) ; // 对于低版本安卓浏览器,因为无法触发 xhr 的 progress 事件,这里 fake 下
238+ onProgress ( { loaded : chunk . size } ) ;
239+ }
234240 this . ctxList [ index ] = {
235241 time : new Date ( ) . getTime ( ) ,
236242 ctx : response . data . ctx ,
@@ -272,8 +278,15 @@ export class UploadManager {
272278 }
273279
274280 finishDirectProgress ( ) {
281+ // 对于低版本安卓浏览器,progress 为 null, 这里 fake 下
282+ if ( this . isAndroidBrowser ) {
283+ this . progress = { total : this . getProgressInfoItem ( this . file . size , this . file . size ) } ;
284+ this . onData ( this . progress ) ;
285+ return ;
286+ }
287+
275288 let total = this . progress . total ;
276- this . progress . total = this . getProgressInfoItem ( total . loaded + 1 , total . size ) ;
289+ this . progress = { total : this . getProgressInfoItem ( total . loaded + 1 , total . size ) } ;
277290 this . onData ( this . progress ) ;
278291 }
279292
Original file line number Diff line number Diff line change @@ -323,3 +323,17 @@ export function getTransform(image, orientation) {
323323 } ;
324324 }
325325}
326+
327+ // 检查低版本浏览器的措施
328+ export function isAndroidBrowser ( ) {
329+ let navU = navigator . userAgent ;
330+ // Android Mobile
331+ let isAndroidMobile = navU . indexOf ( "Android" ) > - 1
332+ && navU . indexOf ( "Mozilla/5.0" ) > - 1 && navU . indexOf ( "AppleWebKit" ) > - 1 ;
333+ // Android Browser (not Chrome)
334+ let regExAppleWebKit = new RegExp ( / A p p l e W e b K i t \/ ( [ \d . ] + ) / ) ;
335+ let resultAppleWebKitRegEx = regExAppleWebKit . exec ( navU ) ;
336+ let appleWebKitVersion = ( resultAppleWebKitRegEx === null ? null : parseFloat ( regExAppleWebKit . exec ( navU ) [ 1 ] ) ) ;
337+ let isAndroidBrowser = isAndroidMobile && appleWebKitVersion !== null && appleWebKitVersion < 537 ;
338+ return isAndroidBrowser ;
339+ }
Original file line number Diff line number Diff line change 1515 "babel-polyfill" : " ^6.26.0" ,
1616 "babel-preset-env" : " ^1.6.0" ,
1717 "babel-runtime" : " ^6.26.0" ,
18- "qiniu-js" :" ^2.0.2" ,
1918 "es3ify-loader" : " ^0.2.0" ,
2019 "open-browser-webpack-plugin" : " 0.0.5" ,
20+ "qiniu-js" : " ^2.5.1" ,
2121 "uglifyjs-webpack-plugin" : " ^1.1.6" ,
2222 "webpack" : " ^3.6.0" ,
2323 "webpack-dev-server" : " ^2.9.1"
You can’t perform that action at this time.
0 commit comments