useDragGuidance.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { getGuidance, setGuidance } from '../../custom-plugins/guide-page/api';
  2. import { ref } from 'vue';
  3. export default function useDragGuidance() {
  4. // 引导页
  5. const guidanceShow = ref(false);
  6. let guideInfoData: Record<string, any> = {};
  7. getGuidanceShow();
  8. async function getGuidanceShow() {
  9. try {
  10. const res = await getGuidance({ guideTag: 'guideInfo' });
  11. if (res.code === 200) {
  12. if (res.data) {
  13. const guideInfo = JSON.parse(res.data?.guideValue) || null;
  14. if (guideInfo) {
  15. guideInfoData = guideInfo;
  16. guidanceShow.value = !guideInfo.teacherDrag;
  17. }
  18. } else {
  19. guidanceShow.value = true;
  20. }
  21. }
  22. } catch (e) {
  23. console.log(e);
  24. }
  25. }
  26. function setGuidanceShow() {
  27. try {
  28. setGuidance({
  29. guideTag: 'guideInfo',
  30. guideValue: JSON.stringify(
  31. Object.assign(guideInfoData, { teacherDrag: true })
  32. )
  33. });
  34. guidanceShow.value = false;
  35. } catch (e) {
  36. console.log(e);
  37. }
  38. }
  39. return {
  40. guidanceShow,
  41. setGuidanceShow
  42. };
  43. }