Browse Source

提交.老师端引导页修复完毕

1
mo 1 year ago
parent
commit
4200631ac6

+ 6 - 1
src/custom-plugins/guide-page/shareResources-guide.tsx

@@ -169,7 +169,12 @@ export default defineComponent({
       } else {
         guideInfo.value.shareResourcesGuide = true;
       }
-      localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo));
+      // localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo));
+      try{
+        const res = await setGuidance({guideTag:'teacher-guideInfo',guideValue:JSON.stringify(guideInfo.value)})
+      }catch(e){
+        console.log(e)
+      }
       tipShow.value = false;
       //  localStorage.setItem('endC')
     };

+ 35 - 12
src/custom-plugins/guide-page/student-guide.tsx

@@ -11,6 +11,7 @@ import {
 import styles from './index.module.less';
 import { getImage } from './images';
 import {px2vw,px2vwH} from '@/utils/index'
+import {getGuidance,setGuidance} from './api'
 export default defineComponent({
   name: 'coai-guide',
   emits: ['close'],
@@ -79,12 +80,29 @@ export default defineComponent({
       step: 0
     });
     const tipShow = ref(false);
-    const guideInfo = localStorage.getItem('teacher-guideInfo');
-    if (guideInfo && JSON.parse(guideInfo).studentGuide) {
-      tipShow.value = false;
-    } else {
-      tipShow.value = true;
+    const guideInfo = ref({} as any)
+    const getAllGuidance = async()=>{
+      try{
+        const res = await getGuidance({guideTag:'teacher-guideInfo'})
+        guideInfo.value = JSON.parse(res.data?.guideValue)
+        if (guideInfo.value && guideInfo.value.studentGuide) {
+          tipShow.value = false;
+        } else {
+          tipShow.value = true;
+        }
+      }catch(e){
+        console.log(e)
+      }
+      // const guideInfo = localStorage.getItem('teacher-guideInfo');
+
     }
+    getAllGuidance()
+    // const guideInfo = localStorage.getItem('teacher-guideInfo');
+    // if (guideInfo && JSON.parse(guideInfo).studentGuide) {
+    //   tipShow.value = false;
+    // } else {
+    //   tipShow.value = true;
+    // }
     const getStepELe = () => {
 
       const ele: HTMLElement = document.getElementById(`student-${data.step}`)!;
@@ -127,15 +145,20 @@ export default defineComponent({
       getStepELe();
     };
 
-    const endGuide = () => {
-      let guideInfo =
-        JSON.parse(localStorage.getItem('teacher-guideInfo') || '{}') || null;
-      if (!guideInfo) {
-        guideInfo = { studentGuide: true };
+    const endGuide = async() => {
+      // let guideInfo =
+      //   JSON.parse(localStorage.getItem('teacher-guideInfo') || '{}') || null;
+      if (!guideInfo.value) {
+        guideInfo.value = { studentGuide: true };
       } else {
-        guideInfo.studentGuide = true;
+        guideInfo.value.studentGuide = true;
+      }
+      // localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo));
+      try{
+        const res = await setGuidance({guideTag:'teacher-guideInfo',guideValue:JSON.stringify(guideInfo.value)})
+      }catch(e){
+        console.log(e)
       }
-      localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo));
       tipShow.value = false;
       //  localStorage.setItem('endC')
     };

+ 36 - 12
src/custom-plugins/guide-page/teacher-guide.tsx

@@ -11,6 +11,7 @@ import {
 import styles from './index.module.less';
 import { getImage } from './images';
 import {px2vw,px2vwH} from '@/utils/index'
+import {getGuidance,setGuidance} from './api'
 export default defineComponent({
   name: 'teacher-guide',
   emits: ['close'],
@@ -81,12 +82,30 @@ export default defineComponent({
       step: 0
     });
     const tipShow = ref(false);
-    const guideInfo = localStorage.getItem('teacher-guideInfo');
-    if (guideInfo && JSON.parse(guideInfo).teacherGuide) {
-      tipShow.value = false;
-    } else {
-      tipShow.value = true;
+    // const guideInfo = localStorage.getItem('teacher-guideInfo');
+    // if (guideInfo && JSON.parse(guideInfo).teacherGuide) {
+    //   tipShow.value = false;
+    // } else {
+    //   tipShow.value = true;
+    // }
+
+    const guideInfo = ref({} as any)
+    const getAllGuidance = async()=>{
+      try{
+        const res = await getGuidance({guideTag:'teacher-guideInfo'})
+        guideInfo.value = JSON.parse(res.data?.guideValue)
+        if (guideInfo.value && guideInfo.value.teacherGuide) {
+          tipShow.value = false;
+        } else {
+          tipShow.value = true;
+        }
+      }catch(e){
+        console.log(e)
+      }
+      // const guideInfo = localStorage.getItem('teacher-guideInfo');
+
     }
+    getAllGuidance()
     const getStepELe = () => {
 
       const ele: HTMLElement = document.getElementById(`teacher-${data.step}`)!;
@@ -130,15 +149,20 @@ export default defineComponent({
       getStepELe();
     };
 
-    const endGuide = () => {
-      let guideInfo =
-        JSON.parse(localStorage.getItem('teacher-guideInfo') || '{}') || null;
-      if (!guideInfo) {
-        guideInfo = { teacherGuide: true };
+    const endGuide = async() => {
+      // let guideInfo =
+      //   JSON.parse(localStorage.getItem('teacher-guideInfo') || '{}') || null;
+      if (!guideInfo.value) {
+        guideInfo.value = { teacherGuide: true };
       } else {
-        guideInfo.teacherGuide = true;
+        guideInfo.value.teacherGuide = true;
+      }
+      // localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo));
+      try{
+        const res = await setGuidance({guideTag:'teacher-guideInfo',guideValue:JSON.stringify(guideInfo.value)})
+      }catch(e){
+        console.log(e)
       }
-      localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo));
       tipShow.value = false;
       //  localStorage.setItem('endC')
     };

+ 35 - 12
src/custom-plugins/guide-page/train-guide.tsx

@@ -11,6 +11,7 @@ import {
 import styles from './index.module.less';
 import { getImage } from './images';
 import {px2vw,px2vwH} from '@/utils/index'
+import {getGuidance,setGuidance} from './api'
 export default defineComponent({
   name: 'train-guide',
   emits: ['close'],
@@ -56,12 +57,29 @@ export default defineComponent({
       step: 0
     });
     const tipShow = ref(false);
-    const guideInfo = localStorage.getItem('teacher-guideInfo');
-    if (guideInfo && JSON.parse(guideInfo).trainGuide) {
-      tipShow.value = false;
-    } else {
-      tipShow.value = true;
+    const guideInfo = ref({} as any)
+    const getAllGuidance = async()=>{
+      try{
+        const res = await getGuidance({guideTag:'teacher-guideInfo'})
+        guideInfo.value = JSON.parse(res.data?.guideValue)
+        if (guideInfo.value && guideInfo.value.trainGuide) {
+          tipShow.value = false;
+        } else {
+          tipShow.value = true;
+        }
+      }catch(e){
+        console.log(e)
+      }
+      // const guideInfo = localStorage.getItem('teacher-guideInfo');
+
     }
+    getAllGuidance()
+    // const guideInfo = localStorage.getItem('teacher-guideInfo');
+    // if (guideInfo && JSON.parse(guideInfo).trainGuide) {
+    //   tipShow.value = false;
+    // } else {
+    //   tipShow.value = true;
+    // }
     const getStepELe = () => {
 
       const ele: HTMLElement = document.getElementById(`train-${data.step}`)!;
@@ -104,15 +122,20 @@ export default defineComponent({
       getStepELe();
     };
 
-    const endGuide = () => {
-      let guideInfo =
-        JSON.parse(localStorage.getItem('teacher-guideInfo') || '{}') || null;
-      if (!guideInfo) {
-        guideInfo = { trainGuide: true };
+    const endGuide = async() => {
+      // let guideInfo =
+      //   JSON.parse(localStorage.getItem('teacher-guideInfo') || '{}') || null;
+      if (!guideInfo.value) {
+        guideInfo.value = { trainGuide: true };
       } else {
-        guideInfo.trainGuide = true;
+        guideInfo.value.trainGuide = true;
+      }
+      try{
+        const res = await setGuidance({guideTag:'teacher-guideInfo',guideValue:JSON.stringify(guideInfo.value)})
+      }catch(e){
+        console.log(e)
       }
-      localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo));
+      // localStorage.setItem('teacher-guideInfo', JSON.stringify(guideInfo));
       tipShow.value = false;
       //  localStorage.setItem('endC')
     };