useDragGuidance.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { getGuidance, setGuidance } from "../../page-instrument/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({ guideTag: "guideInfo", guideValue: JSON.stringify(Object.assign(guideInfoData, { teacherDrag: true })) })
  29. guidanceShow.value = false
  30. } catch (e) {
  31. console.log(e)
  32. }
  33. }
  34. return {
  35. guidanceShow,
  36. setGuidanceShow
  37. }
  38. }