import { getIsBei_Dian } from '@/webPublic/zyd_public/utils/utils';
import { getToken } from '@/webPublic/one_stop_public/utils/token';
import config from '@/config/config';
import { getInfo, transformApi } from '@/highOrderComponent/Service';
export function hrefWithToken(url) {
  if (!getIsBei_Dian()) {
    if (url.indexOf('?') > -1) {
      url = `${url}&token=${getToken()}`;
    } else {
      url = `${url}?token=${getToken()}`;
    }
  }
  getInfo({}, '/InstructorConfigApi/getCurrentDate')
    .then((response) => {
      const hrefUrl = transformApi(url);
      if (response) {
        window.open(`${hrefUrl}${url}`); // 存在问题 浏览器会自动切换内核到IE 内核导致 文件名称乱码.
        return true;
      } else {
        return false;
      }
    });
}

export function hrefWithTokenSg(url) {
  if (!getIsBei_Dian()) {
    if (url.indexOf('?') > -1) {
      url = `${url}&token=${getToken()}`;
    } else {
      url = `${url}?token=${getToken()}`;
    }
  }

  getInfo({}, '/InstructorConfigApi/getCurrentDate')
    .then((response) => {
      const hrefUrl = `${config.mockServer}/${config.gateWayUrl.zydsg}`;
      if (response) {
        let u = `${hrefUrl}${url}`;
        console.log(u);
        window.open(u); // 存在问题 浏览器会自动切换内核到IE 内核导致 文件名称乱码.
        return true;
      } else {
        return false;
      }
    });
}
