dusenyao před 3 roky
rodič
revize
9482a4718b

+ 2 - 1
.eslintrc.js

@@ -14,7 +14,8 @@ module.exports = {
   },
 
   globals: {
-    Rtc: true
+    Rtc: true,
+    DocumentUpload: true
   },
 
   env: {

+ 24 - 0
src/views/live/student/live.js

@@ -335,4 +335,28 @@ export function initListener(vue) {
       vue.connectStudent = data.connectStudent;
     }
   });
+
+  // 文档翻页事件
+  rtc.on('page_change', data => {
+    const pageData = JSON.parse(data);
+    console.log(pageData);
+  });
+
+  // 文档变更事件
+  rtc.on('flipMessage', data => {
+    const action = data.action;
+    if (action === 'changeDoc') {
+      console.log('changeDoc', data);
+    } else if (action === 'flip') {
+      console.log('flip', data);
+    } else if (action === 'scale') {
+      console.log('scale', data);
+    } else if (action === 'history') {
+      console.log('history', data);
+    }
+  });
+}
+
+export function flip() {
+  rtc.flip();
 }

+ 57 - 2
src/views/live/teacher/index.vue

@@ -3,7 +3,7 @@
     <!--顶部-->
     <div class="live-top">
       <div class="live-title">
-        <div
+      <div
           class="live-title-name nowrap-ellipsis"
           :title="`${roomInfo.course_name} - ${roomInfo.cs_item_name} - ${roomInfo.task_name}`"
         >
@@ -22,6 +22,14 @@
           <el-button @click="setDevice(true)">
             {{ $t('Key398') }}
           </el-button>
+          <el-button @click="getAllDocument">获取文档列表</el-button>
+          <el-button @click="docChange">切换文档</el-button>
+          <el-button @click="docChangeBoard('addBoard')">切换白板</el-button>
+          <el-button @click="docChangeBoard('pre')">上一页</el-button>
+          <el-button @click="docChangeBoard('next')">下一页</el-button>
+          <el-upload action="no" :http-request="upload" :show-file-list="false">
+            <el-button><svg-icon icon-class="upload" /> {{ $t('Key152') }}</el-button>
+          </el-upload>
         </div>
       </div>
     </div>
@@ -356,7 +364,8 @@ export default {
       hasAudio: false,
       material_list: [],
       materialId: '',
-      materialType: ''
+      materialType: '',
+      docListInfo: null
     };
   },
   computed: {
@@ -838,6 +847,52 @@ export default {
       this.dialogVisibleComplete = false;
       this.materialId = '';
       this.materialType = '';
+    },
+
+    upload(file) {
+      console.log(file);
+      const uploadObject = new DocumentUpload({
+        files: file.file,
+        uploadCallbackBefore: () => {},
+        uploadCallbackSuccess: (data, time) => {
+          console.log(data, time);
+        },
+        uploadCallbackFailed: () => {
+          this.$message.warning('上传文档失败');
+        }
+      });
+    },
+
+    getAllDocument() {
+      common.getInstructionAllDocument(
+        data => {
+          this.docListInfo = data;
+        },
+        err => {
+          console.log(err);
+        }
+      );
+    },
+
+    docChange() {
+      const doc = this.docListInfo.docs[0];
+      common.docChange({
+        action: 'changeDoc',
+        data: {
+          name: doc.name,
+          id: doc.id,
+          totalpage: doc.pageSize,
+          docFromRoomId: doc.roomId,
+          mode: doc.mode,
+          useSDK: false
+        }
+      });
+    },
+
+    docChangeBoard(action) {
+      common.docChange({
+        action
+      });
     }
   }
 };

+ 22 - 0
src/views/live/teacher/live.js

@@ -439,3 +439,25 @@ export function liveRecord(status) {
 export function invite(object) {
   rtc.invite(object);
 }
+
+// 文档
+
+// 获取文档列表
+export function getInstructionAllDocument(success, failed) {
+  rtc.getInstructionAllDocument({
+    getInstructionAllDocumentSuccess: success,
+    getInstructionAllDocumentFailed: failed
+  });
+}
+
+// 获取单个文档详情
+export function getSingleDocument(docId, callback) {
+  rtc.getSingleDocument({
+    docId,
+    getSingleDocumentCallback: callback
+  });
+}
+
+export function docChange(obj) {
+  rtc.docChange(obj);
+}