浏览代码

提交以下

1
mo 3 年之前
父节点
当前提交
18e4cd98ac
共有 2 个文件被更改,包括 22 次插入7 次删除
  1. 1 0
      package.json
  2. 21 7
      src/views/liveClassManager/modals/shareDetail.vue

+ 1 - 0
package.json

@@ -20,6 +20,7 @@
     "browserslist": "^4.18.1",
     "caniuse-lite": "^1.0.30001286",
     "clean-deep": "^3.3.0",
+    "clipboard": "^2.0.10",
     "copy-to-clipboard": "^3.3.1",
     "dayjs": "^1.8.35",
     "default-passive-events": "^1.0.10",

+ 21 - 7
src/views/liveClassManager/modals/shareDetail.vue

@@ -28,7 +28,7 @@
             请在电脑浏览器中打开以上链接进行直播
           </p>
         </div>
-        <div class="shareBtn" @click="copyText">复制分享内容</div>
+        <div class="shareBtn shareText" @click="copyText">复制分享内容</div>
       </div>
       <div class="codeWrap" v-if="form.shareType == 2">
         <div class="shareWrap">
@@ -46,7 +46,8 @@
 </template>
 <script>
 import { toPng } from "html-to-image";
-import copy from "copy-to-clipboard";
+// import copy from "copy-to-clipboard";
+import Clipboard from "clipboard";
 import preview from "./preview";
 import groupChat from "./groupChat";
 import { shareGroup } from "../api";
@@ -63,9 +64,13 @@ export default {
       content: "",
       url: "",
       Teacherurl: "",
+      clipboard:null
     };
   },
   mounted() {
+    this.clipboard = new Clipboard(".shareText",{
+      target:this.copyText()
+    });
     this.url =
       vaildStudentUrl() + `/#/liveClassTransfer?roomUid=${this.row.roomUid}`;
     let domain = window.location.domain;
@@ -90,12 +95,21 @@ export default {
         }\n直播地址:${this.url}\n`;
       }
 
-      if (text) {
-        copy(text);
-        this.$message.success("复制成功");
-        this.$emit("close");
-      }
+      // if (text) {
+
+      //   console.log(clipboard)
+      //   clipboard.on("success", function (e) {
+      //     console.info("Action:", e.action);
+      //     console.info("Text:", e.text);
+      //     console.info("Trigger:", e.trigger);
+      //     this.$message.success("复制成功");
+      //     this.$emit("close");
+      //     e.clearSelection();
+      //   });
+      // }
+      return text
     },
+
     shareImage() {
       var node = document.getElementById("preview");
       toPng(node)