Kaynağa Gözat

预览地址和方式改变,教师可以查看未发布课程

dusenyao 3 yıl önce
ebeveyn
işleme
923e5ea419

+ 18 - 3
package-lock.json

@@ -11931,9 +11931,9 @@
       "integrity": "sha512-JiDODCElVHGrFyjGYwYyNi7zCbKk9va9C77w+zCPMmi4C6ix7zsX2h3ddHugmo4dOTOTCym9++b/wVW9nC0IaA=="
     },
     "js-base64": {
-      "version": "2.6.4",
-      "resolved": "https://registry.npmmirror.com/js-base64/-/js-base64-2.6.4.tgz",
-      "integrity": "sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ=="
+      "version": "3.7.2",
+      "resolved": "https://registry.npmmirror.com/js-base64/-/js-base64-3.7.2.tgz",
+      "integrity": "sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ=="
     },
     "js-beautify": {
       "version": "1.14.2",
@@ -16475,6 +16475,13 @@
       "requires": {
         "js-base64": "^2.1.8",
         "source-map": "^0.4.2"
+      },
+      "dependencies": {
+        "js-base64": {
+          "version": "2.6.4",
+          "resolved": "https://registry.npmmirror.com/js-base64/-/js-base64-2.6.4.tgz",
+          "integrity": "sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ=="
+        }
       }
     },
     "seededshuffle": {
@@ -18457,6 +18464,14 @@
             "js-base64": "^2.1.9",
             "source-map": "^0.5.6",
             "supports-color": "^3.2.3"
+          },
+          "dependencies": {
+            "js-base64": {
+              "version": "2.6.4",
+              "resolved": "https://registry.npmmirror.com/js-base64/-/js-base64-2.6.4.tgz",
+              "integrity": "sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==",
+              "dev": true
+            }
           }
         },
         "source-map": {

+ 1 - 0
package.json

@@ -22,6 +22,7 @@
     "element-ui": "^2.15.6",
     "gcls-book-question-ui": "file:../gcls-book-question-ui-0.1.0.tgz",
     "jquery": "^3.6.0",
+    "js-base64": "^3.7.2",
     "js-cookie": "^3.0.1",
     "jsplumb": "^2.15.6",
     "normalize.css": "^8.0.1",

+ 10 - 63
src/common/show_file/index.vue

@@ -1,37 +1,13 @@
 <template>
-  <el-dialog class="show-file" :visible="dialogVisibleShowFile" width="900px" @close="dialogShowFileClose">
+  <el-dialog class="show-file" :visible="dialogVisibleShowFile" width="1100px" @close="dialogShowFileClose">
     <div slot="title">{{ $t('Key322') }}【{{ fileName }}】</div>
 
-    <template v-if="fileType === 'pdf'">
-      <pdf v-for="i in numPages" :key="i" :src="pdfSrc" :page="i" />
-    </template>
-
-    <template v-else-if="isImage(fileType)">
-      <div class="image-parent">
-        <el-image fit="contain" :src="fileUrl" />
-      </div>
-    </template>
-
-    <div v-else-if="fileType === 'mp3'" class="audio-file">
-      <audio :src="fileUrl" controls />
-    </div>
-
-    <div v-else-if="fileType === 'mp4'" class="video-file">
-      <video :src="fileUrl" controls />
-    </div>
-
-    <div v-else-if="fileType === 'txt'" class="text-file">
-      <el-input v-model="text" type="textarea" :readonly="true" resize="none" />
-    </div>
-
-    <template v-else>
-      <iframe
-        :src="'https://view.officeapps.live.com/op/view.aspx?src=' + `${fileUrl}`"
-        width="100%"
-        height="490px"
-        scrolling="no"
-      />
-    </template>
+    <iframe
+      v-if="fileUrl.length > 0"
+      :src="`https://docpreview.utschool.cn/onlinePreview?url=${fileUrl}`"
+      width="100%"
+      height="540px"
+    />
 
     <div slot="footer">
       <el-button @click="dialogShowFileClose">
@@ -42,13 +18,12 @@
 </template>
 
 <script>
-import pdf from 'vue-pdf';
 import { GetFileStoreInfo } from '@/api/app';
 import { getFileType } from '@/utils/filter';
+import { encode } from 'js-base64';
 
 export default {
   name: 'ShowFile',
-  components: { pdf },
   props: {
     fileName: {
       default: '',
@@ -90,35 +65,11 @@ export default {
   },
   methods: {
     getFileStoreInfo() {
-      GetFileStoreInfo({ file_id: this.fileId }).then(({ file_url_https, file_relative_path }) => {
-        this.fileUrl = file_url_https;
-
-        if (this.fileType === 'pdf') {
-          this.getNumPages(file_relative_path);
-        }
-
-        if (this.fileType === 'txt') {
-          fetch(`${process.env.VUE_APP_PDF}${file_relative_path}`).then(async res => {
-            if (!res.ok) return;
-            this.text = await res.text();
-          });
-        }
+      GetFileStoreInfo({ file_id: this.fileId }).then(({ file_url_https }) => {
+        this.fileUrl = encodeURIComponent(encode(file_url_https));
       });
     },
 
-    getNumPages(url) {
-      const loadingTask = pdf.createLoadingTask(`${process.env.VUE_APP_PDF}${url}`);
-      loadingTask.promise
-        .then(pdf => {
-          this.pdfSrc = loadingTask;
-          this.numPages = pdf.numPages;
-        })
-        .catch(err => {
-          console.error('pdf加载失败', err);
-          this.$message.error(this.$i18n.t('Key323'));
-        });
-    },
-
     showDialog() {
       this.dialogVisibleShowFile = true;
     },
@@ -126,10 +77,6 @@ export default {
     dialogShowFileClose() {
       this.dialogVisibleShowFile = false;
       this.$emit('dialogShowFileClose');
-    },
-
-    isImage(type) {
-      return ['jpeg', 'gif', 'jpg', 'png', 'bmp', 'pic', 'svg'].includes(type);
     }
   }
 };

+ 11 - 81
src/components/live/CurMaterial.vue

@@ -76,34 +76,12 @@
     </template>
 
     <template v-else>
-      <template v-if="fileType === 'pdf'">
-        <pdf v-for="i in numPages" :key="i" :src="pdfSrc" :page="i" />
-      </template>
-
-      <template v-else-if="isImage(fileType)">
-        <el-image fit="contain" :src="file_url_https" />
-      </template>
-
-      <div v-else-if="fileType === 'mp3'" class="audio-file">
-        <audio :src="file_url_https" controls />
-      </div>
-
-      <div v-else-if="fileType === 'mp4'" class="video-file">
-        <video :src="file_url_https" controls />
-      </div>
-
-      <div v-else-if="fileType === 'txt'" class="text-file">
-        <el-input v-model="text" type="textarea" :readonly="true" resize="none" />
-      </div>
-
-      <template v-else>
-        <iframe
-          :src="'https://view.officeapps.live.com/op/view.aspx?src=' + `${file_url_https}`"
-          width="100%"
-          height="490px"
-          scrolling="no"
-        />
-      </template>
+      <iframe
+        v-if="fileUrl.length > 0"
+        :src="`https://docpreview.utschool.cn/onlinePreview?url=${fileUrl}`"
+        width="100%"
+        height="540px"
+      />
     </template>
 
     <div slot="footer">
@@ -123,17 +101,14 @@
 </template>
 
 <script>
-import pdf from 'vue-pdf';
 import { GetCoursewareContent_View, GetMaterialInfo } from '@/api/course';
 import { GetFileStoreInfo, getContentFile } from '@/api/app';
 import { FinishMyMaterial, GetCurMaterialSent, GetStudentExamAnswer_FinishMaterial } from '@/api/live';
 import { getToken } from '@/utils/auth';
+import { encode } from 'js-base64';
 
 export default {
   name: 'CurMaterial',
-  components: {
-    pdf
-  },
   props: {
     taskId: {
       default: '',
@@ -163,7 +138,7 @@ export default {
       exam_answer: '',
       ui_type: '',
       category: '',
-      file_relative_path: '',
+      fileUrl: '',
       file_url_https: '',
       pdfNum: 0,
       pdfSrc: '',
@@ -201,7 +176,7 @@ export default {
       if (!newVal) {
         this.context = null;
         this.exam_answer = '';
-        this.file_relative_path = '';
+        this.fileUrl = '';
         this.file_url_https = '';
         this.pdfSrc = '';
         this.numPages = 1;
@@ -324,21 +299,10 @@ export default {
     },
 
     getFileStoreInfo() {
-      GetFileStoreInfo({ file_id: this.material_id }).then(({ file_relative_path, file_url_https }) => {
+      GetFileStoreInfo({ file_id: this.material_id }).then(({ file_url_https }) => {
         this.category = 'file';
-        this.file_relative_path = file_relative_path;
         this.file_url_https = file_url_https;
-        const fileType = file_url_https.slice(file_url_https.lastIndexOf('.') + 1, file_url_https.length);
-        if (fileType === 'pdf') {
-          this.getNumPages(file_relative_path);
-        }
-
-        if (fileType === 'txt') {
-          fetch(`${process.env.VUE_APP_PDF}${file_relative_path}`).then(async res => {
-            if (!res.ok) return;
-            this.text = await res.text();
-          });
-        }
+        this.fileUrl = encodeURIComponent(encode(file_url_https));
       });
     },
 
@@ -362,36 +326,6 @@ export default {
       });
     },
 
-    getNumPages(url) {
-      const loading = this.$loading({ text: 'pdf 加载中...' });
-      const loadingTask = pdf.createLoadingTask(`${process.env.VUE_APP_PDF}${url}`, {
-        onProgress: ({ loaded, total }) => {
-          const progress = loaded / total;
-          if (progress < 1) return;
-          if (Number.isInteger(loaded / 1024) && progress >= 1) {
-            if (this.pdfNum === 0) {
-              this.pdfNum += 1;
-            }
-            if (this.pdfNum === 1) {
-              this.pdfNum = 0;
-              loading.close();
-            }
-          }
-        }
-      });
-      loadingTask.promise
-        .then(pdf => {
-          this.pdfSrc = loadingTask;
-          this.numPages = pdf.numPages;
-        })
-        .catch(err => {
-          console.error('pdf加载失败', err);
-          this.$message.error(this.$i18n.t('Key323'));
-          this.pdfNum = 0;
-          loading.close();
-        });
-    },
-
     handleBookUserAnswer(data) {
       this.exam_answer = data;
     },
@@ -439,10 +373,6 @@ export default {
         });
     },
 
-    isImage(type) {
-      return ['jpeg', 'gif', 'jpg', 'png', 'bmp', 'pic', 'svg'].includes(type);
-    },
-
     /**
      * 课件方法
      */

+ 8 - 1
src/views/course_details/index.vue

@@ -2,7 +2,11 @@
   <!-- 课程详情 -->
   <div class="course_info">
     <div
-      v-if="isData && CourseData.is_release === 'true' && CourseData.is_deleted === 'false'"
+      v-if="
+        isData &&
+        ($store.state.user.user_type === 'TEACHER' ||
+          (CourseData.is_release === 'true' && CourseData.is_deleted === 'false'))
+      "
       v-loading="loading"
       class="CourseDetail"
     >
@@ -484,6 +488,9 @@ export default {
 
 <style lang="scss" scoped>
 .CourseDetail {
+  width: 100vw;
+  min-height: calc(100vh - 64px);
+
   .main {
     min-height: 100%;
     padding: 52px 0 20px;

+ 10 - 60
src/views/live/teacher/CompleteList.vue

@@ -88,35 +88,12 @@
         </template>
       </template>
       <template v-else>
-        <!-- pdf -->
-        <template v-if="fileType === 'pdf'">
-          <pdf v-for="i in numPages" :key="i" :src="pdfSrc" :page="i" />
-        </template>
-
-        <template v-else-if="isImage(fileType)">
-          <el-image fit="contain" :src="file_url_https" />
-        </template>
-
-        <div v-else-if="fileType === 'mp3'" class="audio-file">
-          <audio :src="file_url_https" controls />
-        </div>
-
-        <div v-else-if="fileType === 'mp4'" class="video-file">
-          <video :src="file_url_https" controls />
-        </div>
-
-        <div v-else-if="fileType === 'txt'" class="text-file">
-          <el-input v-model="text" type="textarea" :readonly="true" resize="none" />
-        </div>
-
-        <template v-else-if="fileType !== 'pdf'">
-          <iframe
-            :src="'https://view.officeapps.live.com/op/view.aspx?src=' + `${file_url_https}`"
-            width="100%"
-            height="490px"
-            scrolling="no"
-          />
-        </template>
+        <iframe
+          v-if="fileUrl.length > 0"
+          :src="`https://docpreview.utschool.cn/onlinePreview?url=${fileUrl}`"
+          width="100%"
+          height="540px"
+        />
       </template>
     </div>
 
@@ -125,15 +102,12 @@
 </template>
 
 <script>
-import pdf from 'vue-pdf';
 import { GetCurMaterialSent, GetStudentList_FinishMaterial, GetStudentExamAnswer_FinishMaterial } from '@/api/live';
 import { GetCoursewareContent_View, GetMaterialInfo } from '@/api/course';
 import { GetFileStoreInfo, getContentFile } from '@/api/app';
+import { encode } from 'js-base64';
 
 export default {
-  components: {
-    pdf
-  },
   props: {
     dialogVisibleComplete: {
       default: false,
@@ -168,6 +142,7 @@ export default {
       count_not_done: 0,
       count_right: 0,
       count_error: 0,
+      fileUrl: '',
       file_relative_path: '',
       file_url_https: '',
       pdfSrc: '',
@@ -204,6 +179,7 @@ export default {
       if (!newVal) {
         clearInterval(this.listTimer);
         this.material_id = '';
+        this.fileUrl = '';
         this.material_name = '';
         this.student_list = [];
         this.marginLeft = 0;
@@ -309,40 +285,14 @@ export default {
       GetFileStoreInfo({ file_id: this.material_id }).then(({ file_relative_path, file_url_https }) => {
         this.file_relative_path = file_relative_path;
         this.file_url_https = file_url_https;
-        const fileType = file_url_https.slice(file_url_https.lastIndexOf('.') + 1, file_url_https.length);
-        if (fileType === 'pdf') {
-          this.getNumPages(file_relative_path);
-        }
-
-        if (fileType === 'txt') {
-          fetch(`${process.env.VUE_APP_PDF}${file_relative_path}`).then(async res => {
-            if (!res.ok) return;
-            this.text = await res.text();
-          });
-        }
+        this.fileUrl = encodeURIComponent(encode(file_url_https));
       });
     },
 
-    getNumPages(url) {
-      const loadingTask = pdf.createLoadingTask(`${process.env.VUE_APP_PDF}${url}`);
-      loadingTask.promise
-        .then(pdf => {
-          this.pdfSrc = loadingTask;
-          this.numPages = pdf.numPages;
-        })
-        .catch(err => {
-          console.error('pdf加载失败', err);
-        });
-    },
-
     dialogCompleteClose() {
       this.$emit('dialogCompleteClose');
     },
 
-    isImage(type) {
-      return ['jpeg', 'gif', 'jpg', 'png', 'bmp', 'pic', 'svg'].includes(type);
-    },
-
     // 下载文件zip
     downloadBookWriteParent(idList) {
       getContentFile('file_store_manager-StartCreateFileCompressPack', {

+ 1 - 1
src/views/main/curricula_list/teacher.vue

@@ -142,7 +142,7 @@ export default {
         finish_status: this.finish_status,
         name: this.search,
         page_capacity: this.page_capacity,
-        release_status: 1,
+        release_status: -1,
         cur_page: this.cur_page
       }).then(({ course_list, total_count }) => {
         this.courseList = course_list;