Authored by 周少峰

format

@@ -3,8 +3,10 @@ @@ -3,8 +3,10 @@
3 var cdnDomains = require('../../../../config/dns-prefetch'); 3 var cdnDomains = require('../../../../config/dns-prefetch');
4 4
5 function cdnReplace(cdn, imgUrl) { 5 function cdnReplace(cdn, imgUrl) {
  6 + var key;
  7 +
6 if (cdn === 'qcloud') { 8 if (cdn === 'qcloud') {
7 - for (var key in cdnDomains) { 9 + for (key in cdnDomains) {
8 if (imgUrl.indexOf(key) >= 0) { 10 if (imgUrl.indexOf(key) >= 0) {
9 imgUrl = imgUrl.replace(key, cdnDomains[key]); 11 imgUrl = imgUrl.replace(key, cdnDomains[key]);
10 } 12 }
@@ -15,12 +17,13 @@ function cdnReplace(cdn, imgUrl) { @@ -15,12 +17,13 @@ function cdnReplace(cdn, imgUrl) {
15 17
16 module.exports = function(imageUrl, opts) { 18 module.exports = function(imageUrl, opts) {
17 var cdn = window.cdn; 19 var cdn = window.cdn;
  20 + var params, urls, query, uri;
18 21
19 if (imageUrl) { 22 if (imageUrl) {
20 - var params = opts.hash;  
21 - var urls = imageUrl.split('?');  
22 - var query = urls[1] || '';  
23 - var uri = urls[0]; 23 + params = opts.hash;
  24 + urls = imageUrl.split('?');
  25 + query = urls[1] || '';
  26 + uri = urls[0];
24 27
25 if (uri.indexOf('http:') === 0) { 28 if (uri.indexOf('http:') === 0) {
26 uri = uri.replace('http:', ''); 29 uri = uri.replace('http:', '');
@@ -29,7 +32,8 @@ module.exports = function(imageUrl, opts) { @@ -29,7 +32,8 @@ module.exports = function(imageUrl, opts) {
29 uri = cdnReplace(cdn, uri); 32 uri = cdnReplace(cdn, uri);
30 33
31 if (query) { 34 if (query) {
32 - query = query.replace(/{width}/g, params.w).replace(/{height}/g, params.h).replace(/{mode}/g, (params.mode || 2)); 35 + query = query.replace(/{width}/g, params.w).replace(/{height}/g,
  36 + params.h).replace(/{mode}/g, (params.mode || 2));
33 37
34 if (query.indexOf('imageView2') === 0) { 38 if (query.indexOf('imageView2') === 0) {
35 if (params.q && query.indexOf('/q/') > 0) { 39 if (params.q && query.indexOf('/q/') > 0) {
@@ -57,7 +61,7 @@ module.exports = function(imageUrl, opts) { @@ -57,7 +61,7 @@ module.exports = function(imageUrl, opts) {
57 } else { 61 } else {
58 query = 'imageView2/2/interlace/1/q/' + (params.q || 75); 62 query = 'imageView2/2/interlace/1/q/' + (params.q || 75);
59 } 63 }
60 - return uri + '?' + query; 64 + return uri + '?' + query + '&imageslim';
61 } else { 65 } else {
62 return imageUrl; 66 return imageUrl;
63 } 67 }
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 // const url = require('url'); 3 // const url = require('url');
4 const _ = require('lodash'); 4 const _ = require('lodash');
  5 +
5 // const config = require('../config/common'); 6 // const config = require('../config/common');
6 7
7 // const assetUrl = config.assetUrl; 8 // const assetUrl = config.assetUrl;