浏览代码

添加老师缓存

lex 1 年之前
父节点
当前提交
7294103e23
共有 2 个文件被更改,包括 31 次插入39 次删除
  1. 29 35
      src/views/courseList/index.tsx
  2. 2 4
      src/views/coursewarePlay/index.tsx

+ 29 - 35
src/views/courseList/index.tsx

@@ -91,10 +91,7 @@ export default defineComponent({
           });
 
           // 由于ios没有对应api
-          const _list =
-            state.platformType === 'STUDENT'
-              ? await checkCoursewareCache(res.data)
-              : [];
+          const _list = await checkCoursewareCache(res.data);
           data.list = browserInfo.isApp
             ? res.data.map((item: any) => {
                 const _item = _list.find(
@@ -153,43 +150,40 @@ export default defineComponent({
         return;
       }
 
-      // 学生端需要判断缓存
-      console.log(state.platformType, 'state.platformType');
-      if (state.platformType === 'STUDENT') {
-        const isVip = handleCheckVip();
-        if (!isVip) return;
+      const isVip = handleCheckVip();
+      if (!isVip) return;
 
-        if (!item.hasCache) {
-          // const hasFree = String(item.accessScope) === '0';
-          // if (!hasFree) {
+      if (!item.hasCache) {
+        // const hasFree = String(item.accessScope) === '0';
+        // if (!hasFree) {
 
-          // 下载中不提示
-          if (item.downloadStatus == 1) {
-            // 取消下载
+        // 下载中不提示
+        if (item.downloadStatus == 1) {
+          // 取消下载
+          postMessage({ api: 'cancelDownloadCourseware' });
+          setTimeout(() => {
             postMessage({ api: 'cancelDownloadCourseware' });
-            setTimeout(() => {
-              postMessage({ api: 'cancelDownloadCourseware' });
-              item.downloadStatus = 0;
-              data.isDownloading = false;
-            }, 1000);
-            showLoadingToast({
-              message: '取消中...',
-              forbidClick: false,
-              loadingType: 'spinner',
-              duration: 1000
-            });
-            return;
-          }
-          // 重新下载
-          if (item.downloadStatus == 3) {
-            downCatch(item);
-            return;
-          }
-          data.catchStatus = true;
-          data.catchItem = item;
+            item.downloadStatus = 0;
+            data.isDownloading = false;
+          }, 1000);
+          showLoadingToast({
+            message: '取消中...',
+            forbidClick: false,
+            loadingType: 'spinner',
+            duration: 1000
+          });
           return;
         }
+        // 重新下载
+        if (item.downloadStatus == 3) {
+          downCatch(item);
+          return;
+        }
+        data.catchStatus = true;
+        data.catchItem = item;
+        return;
       }
+
       gotoPlay(item);
     };
     // 去课件播放

+ 2 - 4
src/views/coursewarePlay/index.tsx

@@ -180,10 +180,8 @@ export default defineComponent({
         const material = materialList[j];
         //请求本地缓存
         if (browserInfo.isApp && ['VIDEO', 'IMG'].includes(material.typeCode)) {
-          const localData: any =
-            state.platformType === 'STUDENT'
-              ? await getCacheFilePath(material)
-              : {};
+          const localData: any = await getCacheFilePath(material);
+
           if (localData?.content?.localPath) {
             material.url = material.content;
             material.content = localData.content.localPath;