import { setLocalGuidance } from '@/custom-plugins/guide-page/api';
import { ref } from 'vue';

// 引导页
export const guidanceShow = ref(false);
let guideInfoData: Record<string, any> = {};
export async function getGuidanceShow() {
  try {
    // const res = await getGuidance({ guideTag: 'guideInfo' });
    // if (res.code === 200) {
    //   if (res.data) {
    //     const guideInfo = JSON.parse(res.data?.guideValue) || null;
    //     if (guideInfo) {
    //       guideInfoData = guideInfo;
    //       guidanceShow.value = !guideInfo.teacherDrag;
    //     }
    //   } else {
    //     guidanceShow.value = true;
    //   }
    // }
    const res = localStorage.getItem('guideInfo');
    if (res) {
      const guideInfo = JSON.parse(res) || null;
      if (guideInfo) {
        guideInfoData = guideInfo;
        guidanceShow.value = !guideInfo.teacherDrag;
      }
    } else {
      guidanceShow.value = true;
    }
  } catch (e) {
    console.log(e);
  }
}
export function setGuidanceShow() {
  try {
    setLocalGuidance({
      guideTag: 'guideInfo',
      guideValue: JSON.stringify(
        Object.assign(guideInfoData, { teacherDrag: true })
      )
    });
    guidanceShow.value = false;
  } catch (e) {
    console.log(e);
  }
}
