Browse Source

Merge branch 'master' of https://git.cocorobo.cn/CocoRoboLabs/pbl-student-table

zengyicheng 2 years ago
parent
commit
77fc311fc3

+ 1 - 1
dist/index.html

@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>pbl-student</title><link href=./static/css/app.d279b6c29712e31bd2e0813857929776.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.3ad1d5771e9b13dbdad2.js></script><script type=text/javascript src=./static/js/vendor.17ca74dd45d81e40ec58.js></script><script type=text/javascript src=./static/js/app.402038a14f625cb2caa6.js></script></body></html><script>document.domain = "cocorobo.cn"</script>
+<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>pbl-student</title><link href=./static/css/app.a5b647b81050105536728f2c63763c6c.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.3ad1d5771e9b13dbdad2.js></script><script type=text/javascript src=./static/js/vendor.22a27a37f4a3610ee2e4.js></script><script type=text/javascript src=./static/js/app.b13f42bb3a5b0188b65e.js></script></body></html><script>document.domain = "cocorobo.cn"</script>

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


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


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


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


+ 0 - 0
dist/static/js/vendor.17ca74dd45d81e40ec58.js → dist/static/js/vendor.22a27a37f4a3610ee2e4.js


File diff suppressed because it is too large
+ 19 - 0
src/common/html2canvas.min.js


+ 94 - 0
src/common/jietu.js

@@ -0,0 +1,94 @@
+function jietu_shishi(uid, cid) {
+  html2canvas($("body")[0]).then(function (canvas) {
+    //获取截取图片路径
+
+    var base64Url = canvas.toDataURL('image/png');
+    //后台操作处理
+
+    var base64 = "<img src=" + base64Url + " />"
+    var file = dataURLtoFile_shishi(base64Url, "截图")
+    beforeUpload_shishi(file, uid, cid)
+    // $("body")[0].innerHTML = base64
+  });
+}
+
+function dataURLtoFile_shishi(dataurl, filename) {
+  let arr = dataurl.split(","),
+    mime = arr[0].match(/:(.*?);/)[1],
+    bstr = atob(arr[1]),
+    n = bstr.length,
+    u8arr = new Uint8Array(n);
+  while (n--) {
+    u8arr[n] = bstr.charCodeAt(n);
+  }
+  return new File([u8arr], filename, {
+    type: mime
+  });
+}
+
+
+function beforeUpload_shishi(nfile, uid, cid) {
+  var file = nfile;
+  var credentials = {
+    accessKeyId: "AKIATLPEDU37QV5CHLMH",
+    secretAccessKey: "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",
+  }; //秘钥形式的登录上传
+  window.AWS.config.update(credentials);
+  window.AWS.config.region = "cn-northwest-1"; //设置区域
+
+  var bucket = new window.AWS.S3({
+    params: {
+      Bucket: "ccrb"
+    }
+  }); //选择桶
+
+  if (file) {
+    var params = {
+      Key: file.name.split(".")[0] + new Date().getTime() + "." + "png",
+      ContentType: file.type,
+      Body: file,
+      "Access-Control-Allow-Credentials": "*",
+      ACL: "public-read",
+    }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
+    var options = {
+      partSize: 2048 * 1024 * 1024,
+      queueSize: 2,
+      leavePartsOnError: true,
+    };
+    bucket.upload(params, options)
+      .on("httpUploadProgress", function (evt) {
+        //这里可以写进度条
+        // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
+      }).send(function (err, data) {
+        console.log(data.Location);
+        var a = {
+          name: file.name,
+          url: data.Location,
+          uid: file.uid,
+        }
+        addSWork_shishi(uid, cid, a)
+      });
+  }
+}
+
+function addSWork_shishi(uid, cid, a) {
+  let params = {
+    uid: uid,
+    cid: cid,
+    upload: JSON.stringify([{
+      upImg: [a],
+      upVedio: [],
+      upIntro: "",
+    }]),
+    // upload: JSON.stringify(this.imgFileUp),
+  };
+  $.ajax({
+    type: 'GET',
+    url: 'https://pbl.cocorobo.cn/api/pbl/insertSWork',
+    data: params,
+    dataType: "json",
+    success: (data) => {
+      console.log("截图上传成功");
+    }
+  })
+}

File diff suppressed because it is too large
+ 1 - 0
src/common/jquery-3.6.0.min.js


+ 113 - 31
src/components/liveProjectDetail.vue

@@ -188,7 +188,7 @@
             >
             >
               <div
               <div
                 v-if="toolsList[0].tools.indexOf(1) != -1"
                 v-if="toolsList[0].tools.indexOf(1) != -1"
-                @click="(isBlock = 2), (toolCount = 1)"
+                @click="checkTools(1)"
                 class="toolCss"
                 class="toolCss"
               >
               >
                 <!-- <iframe
                 <!-- <iframe
@@ -202,7 +202,7 @@
               </div>
               </div>
               <div
               <div
                 v-if="toolsList[0].tools.indexOf(2) != -1"
                 v-if="toolsList[0].tools.indexOf(2) != -1"
-                @click="(isBlock = 2), (toolCount = 2)"
+                @click="checkTools(2)"
                 class="toolCss"
                 class="toolCss"
               >
               >
                 <!-- <iframe
                 <!-- <iframe
@@ -216,7 +216,7 @@
               </div>
               </div>
               <div
               <div
                 v-if="toolsList[0].tools.indexOf(3) != -1"
                 v-if="toolsList[0].tools.indexOf(3) != -1"
-                @click="(isBlock = 2), (toolCount = 3)"
+                @click="checkTools(3)"
                 class="toolCss"
                 class="toolCss"
               >
               >
                 <!-- <iframe
                 <!-- <iframe
@@ -230,7 +230,7 @@
               </div>
               </div>
               <div
               <div
                 v-if="toolsList[0].tools.indexOf(4) != -1"
                 v-if="toolsList[0].tools.indexOf(4) != -1"
-                @click="(isBlock = 2), (toolCount = 4)"
+                @click="checkTools(4)"
                 class="toolCss"
                 class="toolCss"
               >
               >
                 <!-- <iframe
                 <!-- <iframe
@@ -244,7 +244,7 @@
               </div>
               </div>
               <div
               <div
                 v-if="toolsList[0].tools.indexOf(6) != -1"
                 v-if="toolsList[0].tools.indexOf(6) != -1"
-                @click="(isBlock = 2), (toolCount = 6)"
+                @click="checkTools(6)"
                 class="toolCss"
                 class="toolCss"
               >
               >
                 <!-- <iframe
                 <!-- <iframe
@@ -258,7 +258,7 @@
               </div>
               </div>
               <div
               <div
                 v-if="toolsList[0].tools.indexOf(7) != -1"
                 v-if="toolsList[0].tools.indexOf(7) != -1"
-                @click="(isBlock = 2), (toolCount = 7)"
+                @click="checkTools(7)"
                 class="toolCss"
                 class="toolCss"
               >
               >
                 <!-- <iframe
                 <!-- <iframe
@@ -272,7 +272,7 @@
               </div>
               </div>
               <div
               <div
                 v-if="toolsList[0].tools.indexOf(8) != -1"
                 v-if="toolsList[0].tools.indexOf(8) != -1"
-                @click="(isBlock = 2), (toolCount = 8)"
+                @click="checkTools(8)"
                 class="toolCss"
                 class="toolCss"
               >
               >
                 <!-- <iframe
                 <!-- <iframe
@@ -469,14 +469,14 @@
                 </div>-->
                 </div>-->
                 <div class="nextStepOne" @click="isBlock = 4">返回</div>
                 <div class="nextStepOne" @click="isBlock = 4">返回</div>
               </div>
               </div>
-              <!-- <div
+              <div
                 class="nextStepOne"
                 class="nextStepOne"
                 style="float: right"
                 style="float: right"
                 @click="getImg"
                 @click="getImg"
                 v-if="toolCount == 1 || toolCount == 3 || toolCount == 7"
                 v-if="toolCount == 1 || toolCount == 3 || toolCount == 7"
               >
               >
                 截图
                 截图
-              </div>-->
+              </div>
               <div
               <div
                 class="nextStepOne"
                 class="nextStepOne"
                 style="float: right"
                 style="float: right"
@@ -799,7 +799,7 @@ export default {
         "", //倒计时
         "", //倒计时
         "", //问答题
         "", //问答题
         "", //问答题
         "", //问答题
-        { tools: [1] }, //思维导图/电子白板
+        { tools: [1, 7] }, //思维导图/电子白板
         { tools: [12] }, //选人回答
         { tools: [12] }, //选人回答
         "", //倒计时、分小组
         "", //倒计时、分小组
         { tools: [3] }, //思维导图/电子白板/思维网格
         { tools: [3] }, //思维导图/电子白板/思维网格
@@ -1097,7 +1097,7 @@ export default {
         .get(this.$store.state.api + "insertSWork", params)
         .get(this.$store.state.api + "insertSWork", params)
         .then((res) => {
         .then((res) => {
           // this.isNoHomeWork = true;
           // this.isNoHomeWork = true;
-          this.dialogVisible = true;
+          // this.dialogVisible = true;
           // this.selectSWork(); // this.upload = res.data[0][0].upload;
           // this.selectSWork(); // this.upload = res.data[0][0].upload;
           this.$message({
           this.$message({
             message: "截图上传成功",
             message: "截图上传成功",
@@ -1142,28 +1142,57 @@ export default {
       iframeIh.innerHTML = this.iframeInnerHtml;
       iframeIh.innerHTML = this.iframeInnerHtml;
       this.$forceUpdate();
       this.$forceUpdate();
       console.log(iframeIh);
       console.log(iframeIh);
+
       // var iframeHtml = this.$refs.whiteBoard;
       // var iframeHtml = this.$refs.whiteBoard;
+
+      var _ajs = iframeHtml.contentWindow.document.createElement("script");
+      _ajs.type = "text/javascript";
+      _ajs.innerHTML =
+        'var _js = document.createElement("script");\n' +
+        '_js.type="text/javascript";\n' +
+        '_js.src="https://html2canvas.hertzen.com/dist/html2canvas.min.js";\n' +
+        "_js.onload = function(){\n" +
+        " html2canvas(document.body).then(canvas => {\n" +
+        '  var base64Url = canvas.toDataURL("image/png");\n' +
+        'var base64 = "<img src=" + base64Url + " />"\n' +
+        'var file = dataURLtoFile_shishi(base64Url, "截图")\n' +
+        "beforeUpload_shishi(file," +
+        "'" +
+        this.userid +
+        "'" +
+        ", " +
+        "'" +
+        this.cid +
+        "'" +
+        ")\n" +
+        " });\n" +
+        "}\n" +
+        "document.head.appendChild(_js);\n";
+      iframeHtml.contentWindow.document.head.appendChild(_ajs);
+
+      // iframeHtml.contentWindow.jietu_shishi(this.userid, this.cid);
+
       // 第一个参数是需要生成截图的元素,第二个是自己需要配置的参数,宽高等
       // 第一个参数是需要生成截图的元素,第二个是自己需要配置的参数,宽高等
-      html2canvas(iframeBody, {
-        allowTaint: true,
-        backgroundColor: null, //画出来的图片有白色的边框,不要可设置背景为透明色(null)
-        useCORS: true, //支持图片跨域
-        scale: 1, //设置放大的倍数
-      }).then((canvas) => {
-        // 把生成的base64位图片上传到服务器,生成在线图片地址
-        let url = canvas.toDataURL("image/png"); // toDataURL: 图片格式转成 base64
-        this.imgUrl = url; //将图片下载到本地
-        let a = document.createElement("a"); // 生成一个a元素
-        let event = new MouseEvent("click"); // 创建一个单击事件
-        a.download = "作业"; // 设置图片名称没有设置则为默认
-        a.href = this.imgUrl; // 将生成的URL设置为a.href属性
-        a.dispatchEvent(event); // 触发a的单击事件
-        let file = this.dataURLtoFile(url, "作业");
-        this.imgFile = file;
-        this.beforeUpload2(this.imgFile);
-        this.addSWork();
-        console.log(this.imgFile);
-      });
+      // html2canvas(iframeBody, {
+      //   allowTaint: true,
+      //   backgroundColor: null, //画出来的图片有白色的边框,不要可设置背景为透明色(null)
+      //   useCORS: true, //支持图片跨域
+      //   scale: 1, //设置放大的倍数
+      // }).then((canvas) => {
+      //   // 把生成的base64位图片上传到服务器,生成在线图片地址
+      //   let url = canvas.toDataURL("image/png"); // toDataURL: 图片格式转成 base64
+      //   this.imgUrl = url; //将图片下载到本地
+      //   let a = document.createElement("a"); // 生成一个a元素
+      //   let event = new MouseEvent("click"); // 创建一个单击事件
+      //   a.download = "作业"; // 设置图片名称没有设置则为默认
+      //   a.href = this.imgUrl; // 将生成的URL设置为a.href属性
+      //   a.dispatchEvent(event); // 触发a的单击事件
+      //   let file = this.dataURLtoFile(url, "作业");
+      //   this.imgFile = file;
+      //   this.beforeUpload2(this.imgFile);
+      //   this.addSWork();
+      //   console.log(this.imgFile);
+      // });
     },
     },
     dataURLtoFile(dataurl, filename) {
     dataURLtoFile(dataurl, filename) {
       let arr = dataurl.split(","),
       let arr = dataurl.split(","),
@@ -1252,10 +1281,57 @@ export default {
     fullTools() {
     fullTools() {
       this.full = !this.full;
       this.full = !this.full;
     },
     },
+    checkTools(tcount) {
+      this.isBlock = 2;
+      this.toolCount = tcount;
+      let _this = this;
+      _this.$nextTick(() => {
+        setTimeout(() => {
+          const script1 = document.createElement("script");
+          script1.type = "text/javascript";
+          script1.src =
+            "https://pbl.cocorobo.cn/pbl-student-table/dist/jquery-3.6.0.min.js";
+          const script2 = document.createElement("script");
+          script2.type = "text/javascript";
+          script2.src =
+            "https://pbl.cocorobo.cn/pbl-student-table/dist/aws-sdk-2.235.1.min.js";
+          const script3 = document.createElement("script");
+          script3.type = "text/javascript";
+          script3.src = "https://html2canvas.hertzen.com/dist/html2canvas.min.js";
+          const script4 = document.createElement("script");
+          script4.type = "text/javascript";
+          script4.src = "https://pbl.cocorobo.cn/pbl-student-table/dist/jietu.js";
+
+          if (_this.toolCount == 1) {
+            _this.$refs.whiteBoard.onload = () => {
+              _this.$refs.whiteBoard.contentWindow.document.body.appendChild(script1);
+              _this.$refs.whiteBoard.contentWindow.document.body.appendChild(script2);
+              // _this.$refs.whiteBoard.contentWindow.document.body.appendChild(script3);
+              _this.$refs.whiteBoard.contentWindow.document.body.appendChild(script4);
+            };
+          } else if (_this.toolCount == 3) {
+            _this.$refs.mind.onload = () => {
+              _this.$refs.mind.contentWindow.document.body.appendChild(script1);
+              _this.$refs.mind.contentWindow.document.body.appendChild(script2);
+              // _this.$refs.mind.contentWindow.document.body.appendChild(script3);
+              _this.$refs.mind.contentWindow.document.body.appendChild(script4);
+            };
+          } else if (_this.toolCount == 7) {
+            _this.$refs.grid.onload = () => {
+              _this.$refs.grid.contentWindow.document.body.appendChild(script1);
+              _this.$refs.grid.contentWindow.document.body.appendChild(script2);
+              // _this.$refs.grid.contentWindow.document.body.appendChild(script3);
+              _this.$refs.grid.contentWindow.document.body.appendChild(script4);
+            };
+          }
+        }, 0);
+      });
+    },
   },
   },
   beforeDestroy() {
   beforeDestroy() {
     clearInterval(this.timer);
     clearInterval(this.timer);
     this.timer = null;
     this.timer = null;
+    // window.removeEventListener("message");
   },
   },
   created() {
   created() {
     // this.selectSWork();
     // this.selectSWork();
@@ -1263,6 +1339,12 @@ export default {
     this.timer = setInterval(() => {
     this.timer = setInterval(() => {
       _this.setPage();
       _this.setPage();
     }, 1000);
     }, 1000);
+    // window.addEventListener("message", function (e) {
+    //   // 监听 message 事件
+    //   if (e.data.type && e.data.type == "shishi_canvas") {
+    //     console.log(e.data.data);
+    //   }
+    // });
   },
   },
 };
 };
 </script>
 </script>

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