SanHQin 1 周之前
父節點
當前提交
8455118483

+ 1 - 1
dist/index.html

@@ -32,7 +32,7 @@
       width: 100%;
       background: #e6eaf0;
       font-family: '黑体';
-    }</style><link href=./static/css/app.19e10df46e04112eb7be869cf2de5e22.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.23ea04dc469b57e2b4f8.js></script><script type=text/javascript src=./static/js/vendor.dfc8a8e3392292c7b8e5.js></script><script type=text/javascript src=./static/js/app.09aa0c5d2de87a831f02.js></script></body></html><script>function stopSafari() {
+    }</style><link href=./static/css/app.fe6976d512b5040136068402b1f70e70.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.23ea04dc469b57e2b4f8.js></script><script type=text/javascript src=./static/js/vendor.dfc8a8e3392292c7b8e5.js></script><script type=text/javascript src=./static/js/app.125c8b5be014104aed5a.js></script></body></html><script>function stopSafari() {
     //阻止safari浏览器双击放大功能
     let lastTouchEnd = 0  //更新手指弹起的时间
     document.documentElement.addEventListener("touchstart", function (event) {

File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.fe6976d512b5040136068402b1f70e70.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.fe6976d512b5040136068402b1f70e70.css.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.125c8b5be014104aed5a.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.125c8b5be014104aed5a.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/manifest.23ea04dc469b57e2b4f8.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/workPage-manifest.2ece51fa34be51c8610a.js.map


+ 114 - 16
src/components/pages/pptEasy/addCourse.vue

@@ -2458,6 +2458,44 @@ let converter = OpenCC.Converter({
   to: "cn"
 });
 
+const getFile = (url) => {
+  return new Promise((resolve, reject) => {
+    var credentials = {
+        accessKeyId: "AKIATLPEDU37QV5CHLMH",
+        secretAccessKey: "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",
+      }; //秘钥形式的登录上传
+      window.AWS.config.update(credentials);
+      window.AWS.config.region = "cn-northwest-1"; //设置区域
+      let url2 = url;
+      let _url2 = "";
+      if (
+        url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
+      ) {
+        _url2 = url2.split(
+          "https://view.officeapps.live.com/op/view.aspx?src="
+        )[1];
+      } else {
+        _url2 = url2;
+      }
+      var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
+      let name = decodeURIComponent(_url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1])
+      var params = {
+        Bucket: "ccrb",
+        Key: name
+      };
+      s3.getObject(params, function (err, data) {
+        if (err) {
+          console.log(err, err.stack)
+          resolve({ data: 1 });
+        }else {
+          resolve({ data: data.Body });
+          console.log(data);
+        }          // sxuccessful response
+
+      });
+  });
+};
+
 
 export default {
   mixins: [myMixin, uploadFileMixin],
@@ -2888,7 +2926,7 @@ export default {
           try {
             window.topU.U.UF.F.closeWindow(window.topU.$("#openCourseUpdate"));
           } catch (error) {
-            
+
           }
         }
         this.goTo(
@@ -5251,12 +5289,15 @@ export default {
       //  使用this.ajax.get 请求 this.line 链接,如果返回 200 则认为链接有效
       // 使用XHR请求判断页面是否可以请求到
       // 先用iframe判断能否访问contentWindow,不能再用XHR请求
-      let isValid = await new Promise((resolve) => {
+      let isValid = await new Promise(async (resolve) => {
         // 创建隐藏iframe
         let iframe = document.createElement('iframe');
         iframe.style.display = 'none';
         iframe.src = this.line;
+        let finished = false;
         let timeout = setTimeout(() => {
+          if (finished) return;
+          finished = true;
           // 超时,移除iframe,进入XHR判断
           document.body.removeChild(iframe);
           // 用XHR判断
@@ -5267,22 +5308,41 @@ export default {
               if (xhr.status === 200) {
                 resolve(true);
               } else {
-                resolve(false);
+                // 再试一次 getFile
+                getFile(typeof this.line !== 'undefined' ? this.line : iframe.src).then(res => {
+                  if (res && res.data && res.data !== 1) {
+                    resolve(true);
+                  } else {
+                    resolve(false);
+                  }
+                }).catch(() => {
+                  resolve(false);
+                });
               }
             }
-          };
+          }.bind(this);
           xhr.onerror = function() {
-            resolve(false);
-          };
+            // 再试一次 getFile
+            getFile(typeof this.line !== 'undefined' ? this.line : iframe.src).then(res => {
+              if (res && res.data && res.data !== 1) {
+                resolve(true);
+              } else {
+                resolve(false);
+              }
+            }).catch(() => {
+              resolve(false);
+            });
+          }.bind(this);
           xhr.send();
-        }, 5000); // 2秒超时
+        }, 5000);
 
         iframe.onload = function() {
+          if (finished) return;
+          finished = true;
           clearTimeout(timeout);
           try {
             // 尝试访问contentWindow.document
             let doc = iframe.contentWindow.document;
-            // 能访问说明同源,页面可用
             document.body.removeChild(iframe);
             resolve(true);
           } catch (e) {
@@ -5295,17 +5355,37 @@ export default {
                 if (xhr.status === 200) {
                   resolve(true);
                 } else {
-                  resolve(false);
+                  // 再试一次 getFile
+                  getFile(typeof this.line !== 'undefined' ? this.line : iframe.src).then(res => {
+                    if (res && res.data && res.data !== 1) {
+                      resolve(true);
+                    } else {
+                      resolve(false);
+                    }
+                  }).catch(() => {
+                    resolve(false);
+                  });
                 }
               }
-            };
+            }.bind(this);
             xhr.onerror = function() {
-              resolve(false);
-            };
+              // 再试一次 getFile
+              getFile(typeof this.line !== 'undefined' ? this.line : iframe.src).then(res => {
+                if (res && res.data && res.data !== 1) {
+                  resolve(true);
+                } else {
+                  resolve(false);
+                }
+              }).catch(() => {
+                resolve(false);
+              });
+            }.bind(this);
             xhr.send();
           }
         };
         iframe.onerror = function() {
+          if (finished) return;
+          finished = true;
           clearTimeout(timeout);
           document.body.removeChild(iframe);
           // iframe加载失败,进入XHR判断
@@ -5316,13 +5396,31 @@ export default {
               if (xhr.status === 200) {
                 resolve(true);
               } else {
-                resolve(false);
+                // 再试一次 getFile
+                getFile(typeof this.line !== 'undefined' ? this.line : iframe.src).then(res => {
+                  if (res && res.data && res.data !== 1) {
+                    resolve(true);
+                  } else {
+                    resolve(false);
+                  }
+                }).catch(() => {
+                  resolve(false);
+                });
               }
             }
-          };
+          }.bind(this);
           xhr.onerror = function() {
-            resolve(false);
-          };
+            // 再试一次 getFile
+            getFile(typeof this.line !== 'undefined' ? this.line : iframe.src).then(res => {
+              if (res && res.data && res.data !== 1) {
+                resolve(true);
+              } else {
+                resolve(false);
+              }
+            }).catch(() => {
+              resolve(false);
+            });
+          }.bind(this);
           xhr.send();
         };
         document.body.appendChild(iframe);

Some files were not shown because too many files changed in this diff