import { parseHrefParam } from "../plugins/utils";
const MD5 = require("js-md5");

export const APP_TITLE = '试卷电子化';

// domain
let domain;
if (process.env.VUE_APP_SELF_DEFINE_DOMAIN === "true") {
  domain = window.localStorage.getItem("domain_in_url");
}
if (!domain) {
  const ipFormat = new RegExp(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/);
  const hostname = window.location.hostname;
  if (ipFormat.test(hostname)) {
    domain = parseHrefParam(window.location.href, "code");
  } else {
    domain = hostname.split(".")[0];
  }
}
export const ORG_CODE = domain;

const ADMIN_CODE = "admin";

export const IS_ADMIN_SYSTEM = ADMIN_CODE === ORG_CODE;

export const PLATFORM = "WEB";

if (!localStorage.getItem("deviceId")) {
  localStorage.setItem("deviceId", MD5(Math.random() + "-" + Date.now()));
}
export const DEVICE_ID = localStorage.getItem("deviceId");
