Browse Source

:art: http -> https

zhanghe 6 years ago
parent
commit
be258fab46
2 changed files with 27 additions and 16 deletions
  1. 2 2
      src/util/Consts.js
  2. 25 14
      src/util/Utils.js

+ 2 - 2
src/util/Consts.js

@@ -11,8 +11,8 @@ class Consts {
 }
 
 //图片/视频资源域名
-Consts.IMG_PATH = 'http://ljimgs.ai160.com';
-Consts.VIDEO_PATH = 'http://ljvideo.ai160.com/vs2m';
+Consts.IMG_PATH = 'https://efunimgs.ai160.com';
+Consts.VIDEO_PATH = 'https://efunvideo.ai160.com';
 
 //图片/视频资源类型代号
 Consts.TYPE_VIDEO = 0;

+ 25 - 14
src/util/Utils.js

@@ -152,13 +152,13 @@ class Utils {
        return format;
     }
 
-  static trimJsonStr(src){
-    //所有"'" 替换为"\""
-    if(typeof(src) == "string"){
-      return src.replace(new RegExp("'","gm"), "\"");
+    static trimJsonStr(src){
+        //所有"'" 替换为"\""
+        if(typeof(src) == "string"){
+            return src.replace(new RegExp("'","gm"), "\"");
+        }
+        return src;
     }
-    return src;
-  }
 
 	/**
 	 * @desc uuid生成器
@@ -187,14 +187,25 @@ class Utils {
 		return uuid.join('');
 	}
 
-  static getUuidForWeb() {
-    const uuid = Utils.uuid(32);
-    const start = uuid.slice(0,8);
-    const next = uuid.slice(8,12);
-    const nextNext = uuid.slice(13,17);
-    const last = uuid.slice(17,32);
-    return `${start}-${next}-${nextNext}-${last}`;
-  }
+    static getUuidForWeb() {
+        const uuid = Utils.uuid(32);
+        const start = uuid.slice(0,8);
+        const next = uuid.slice(8,12);
+        const nextNext = uuid.slice(13,17);
+        const last = uuid.slice(17,32);
+        return `${start}-${next}-${nextNext}-${last}`;
+    }
+
+    static videoUrlFormat(url) {
+        if (!url) { return; }
+        if (url.startsWith('http')) {
+            return url.replace('http://ljvideo.ai160.com', Consts.VIDEO_PATH);
+        } else if (url.startsWith('https')) {
+            return url;
+        } else {
+            return url;
+        }
+    }
 }
 
 export default Utils;