// utils/px2rem.js
export const px2rem = (px, rootValue = 192) => {
  return `${px / rootValue}rem`;
};

export const px2remDirective = (el, binding) => {
  const rootValue = 192; // 与 postcss-pxtorem 一致
  const pxValue = binding.value;
  el.style[binding.arg] = `${pxValue / rootValue}rem`;
};


import store from "@/store/index.js";  //  sessionStorage.getItem
export const dictLabel = (type) => {
  // console.log(store.getters.dictList, "store.state.getters");
  
   const dictList =
     store.getters.dictList ||
     JSON.parse(sessionStorage.getItem("dictList"));

    let label = "";
  // if (dictList && dictList.length > 0) {
    const dictObj = dictList.find((el) => el.dictLabel == type);
    // console.log(dictObj, "dictObj");
    if (dictObj && dictObj.dictValue) {
      label = dictObj.dictValue;
    } 
  // } else {
  //   const query = {
  //     pageNum: 1,
  //     pageSize: 100,
  //     dictType: "sys_title",
  //   };
  //   store
  //     .dispatch("getDict", query)
  //     .then((res) => {
  //       const dictList = res.rows
  //       sessionStorage.setItem("dictList", JSON.stringify(dictList));
  //       const dictObj = dictList.find((el) => el.dictLabel == type);
  //       console.log(dictObj, "dictObj");

  //       let label = "";
  //       if (dictObj && dictObj.dictValue) {
  //         label = dictObj.dictValue;
  //       }
  //     })
  //     .catch(() => {});
  // }


  return label;
};


