lex 1 rok temu
rodzic
commit
757b270589

+ 7 - 0
src/views/prepare-lessons/components/lesson-main/courseware/index.tsx

@@ -296,6 +296,11 @@ export default defineComponent({
 
         // console.log(prepareStore.getSubjectId, 'getSubjectId');
       }
+      // 保存
+      localStorage.setItem(
+        'prepareLessonSubjectId',
+        prepareStore.getSubjectId as any
+      );
     };
 
     watch(
@@ -367,6 +372,8 @@ export default defineComponent({
                   value={prepareStore.getSubjectId}
                   onUpdate:value={(val: any) => {
                     prepareStore.setSubjectId(val);
+                    // 保存
+                    localStorage.setItem('prepareLessonSubjectId', val);
                     getList();
                   }}
                 />

+ 3 - 4
src/views/prepare-lessons/components/lesson-main/train/index.tsx

@@ -121,9 +121,9 @@ export default defineComponent({
           }
         });
         forms.trainList = tempCourse || [];
-        setTimeout(()=>{
+        setTimeout(() => {
           showGuide.value = true;
-        },500)
+        }, 500);
       } catch {
         //
       }
@@ -217,8 +217,6 @@ export default defineComponent({
       // checkSubjectIds();
 
       await getList();
-
-
     });
     return () => (
       <div class={styles.coursewareModal}>
@@ -276,6 +274,7 @@ export default defineComponent({
                   value={prepareStore.getSubjectId}
                   onUpdate:value={(val: any) => {
                     prepareStore.setSubjectId(val);
+                    localStorage.setItem('prepareLessonSubjectId', val);
                   }}
                 />
               </div>

+ 17 - 2
src/views/prepare-lessons/components/resource-main/components/resource-item/index.tsx

@@ -3,7 +3,7 @@ import ResourceSearchGroup from './resource-search-group';
 import { NScrollbar, NSpin, useDialog, useMessage } from 'naive-ui';
 import styles from './index.module.less';
 import CardType from '/src/components/card-type';
-import { materialQueryPage } from '/src/views/natural-resources/api';
+import { favorite, materialQueryPage } from '/src/views/natural-resources/api';
 import TheEmpty from '/src/components/TheEmpty';
 import { usePrepareStore } from '/src/store/modules/prepareLessons';
 import { useDebounceFn, useThrottleFn } from '@vueuse/core';
@@ -186,6 +186,20 @@ export default defineComponent({
       // });
     };
 
+    // 收藏
+    const onCollect = async (item: any) => {
+      try {
+        await favorite({
+          materialId: item.id,
+          favoriteFlag: item.isCollect ? 0 : 1,
+          type: item.type
+        });
+        item.isCollect = !item.isCollect;
+      } catch {
+        //
+      }
+    };
+
     onMounted(() => {
       getList();
     });
@@ -230,13 +244,14 @@ export default defineComponent({
                     <CardType
                       isShowAdd
                       item={item}
-                      isShowCollect={false}
+                      isShowCollect={true}
                       disabledMouseHover={false}
                       onClick={() => {
                         if (item.type === 'IMG') return;
                         state.show = true;
                         state.item = item;
                       }}
+                      onCollect={(item: any) => onCollect(item)}
                       isShowAddDisabled={!prepareStore.getIsEditResource}
                       onAdd={(item: any) => onAdd(item)}
                     />

+ 6 - 3
src/views/prepare-lessons/components/resource-main/index.tsx

@@ -90,19 +90,22 @@ export default defineComponent({
                   <NTabPane
                     name="myResources"
                     tab="我的资源"
-                    displayDirective="show:lazy">
+                    // displayDirective="show:lazy"
+                  >
                     <ResourceItem type="myResources" />
                   </NTabPane>
                   <NTabPane
                     name="shareResources"
                     tab="共享资源"
-                    displayDirective="show:lazy">
+                    // displayDirective="show:lazy"
+                  >
                     <ResourceItem type="shareResources" />
                   </NTabPane>
                   <NTabPane
                     name="myCollect"
                     tab="我的收藏"
-                    displayDirective="show:lazy">
+                    // displayDirective="show:lazy"
+                  >
                     <ResourceItem type="myCollect" />
                   </NTabPane>
                 </>

+ 6 - 3
src/views/prepare-lessons/model/select-resources/index.tsx

@@ -29,19 +29,22 @@ export default defineComponent({
           <NTabPane
             name="myResources"
             tab="我的资源"
-            displayDirective="show:lazy">
+            // displayDirective="show:lazy"
+          >
             <SelectItem type="myResources" />
           </NTabPane>
           <NTabPane
             name="shareResources"
             tab="共享资源"
-            displayDirective="show:lazy">
+            // displayDirective="show:lazy"
+          >
             <SelectItem type="shareResources" />
           </NTabPane>
           <NTabPane
             name="myCollect"
             tab="我的收藏"
-            displayDirective="show:lazy">
+            // displayDirective="show:lazy"
+          >
             <SelectItem type="myCollect" />
           </NTabPane>
         </NTabs>

+ 17 - 2
src/views/prepare-lessons/model/select-resources/select-item/index.tsx

@@ -10,7 +10,7 @@ import ResourceSearchGroup from './resource-search-group';
 import { NScrollbar, NSpin, useDialog, useMessage } from 'naive-ui';
 import styles from './index.module.less';
 import CardType from '/src/components/card-type';
-import { materialQueryPage } from '/src/views/natural-resources/api';
+import { favorite, materialQueryPage } from '/src/views/natural-resources/api';
 import TheEmpty from '/src/components/TheEmpty';
 import { usePrepareStore } from '/src/store/modules/prepareLessons';
 import { saveCourseware } from '../../../api';
@@ -180,6 +180,20 @@ export default defineComponent({
       }
     );
 
+    // 收藏
+    const onCollect = async (item: any) => {
+      try {
+        await favorite({
+          materialId: item.id,
+          favoriteFlag: item.isCollect ? 0 : 1,
+          type: item.type
+        });
+        item.isCollect = !item.isCollect;
+      } catch {
+        //
+      }
+    };
+
     onMounted(() => {
       getList();
     });
@@ -220,10 +234,11 @@ export default defineComponent({
                     <CardType
                       isShowAdd
                       item={item}
-                      isShowCollect={false}
+                      isShowCollect={true}
                       isShowAddDisabled={!prepareStore.getIsEditResource}
                       onAdd={(item: any) => onAdd(item)}
                       disabledMouseHover={false}
+                      onCollect={(item: any) => onCollect(item)}
                       onClick={() => {
                         if (item.type === 'IMG') return;
                         state.show = true;