{"size": 1185, "ext": "js", "max_stars_repo_path": "src/utils/index.js", "max_stars_repo_name": "wlbwrx/plushe-jds-admin", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/utils/index.js", "max_issues_repo_name": "wlbwrx/plushe-jds-admin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/utils/index.js", "max_forks_repo_name": "wlbwrx/plushe-jds-admin", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.2142857143, "max_line_length": 111, "alphanum_fraction": 0.5459915612}
import { Base64 } from 'js-base64';
// productKey:  图片key值
// 
export const imageHandler = function(layout = 0, productKey) {
    if (!productKey) return;
    const resize = {
      0: {
        height: 40,
        fit: 'cover',
      },
      1: {
        fit: 'cover',
      },
    };
    const parameter = {
      bucket: process.env.VUE_APP_BUCKET || 'test-plushe', // 根据host来识别，如果是sit则填：test-plushe；如果是生产则填：pro-plushe
      key: productKey, // productKey, // 后台放回S3 图片key
      edits: {
        resize: resize[layout || 0],
      },
    };
    return `https://img.plushe.com/${Base64.encode(JSON.stringify(parameter))}`;
  };

  export const transitionTreeArray = (data, obj) => {
    const { parentId = 'parentId', parentVal = '-1,0', id = 'id' } = obj || {};
    const map = {};
    const val = [];
    const arr = JSON.parse(JSON.stringify(data));
    arr.forEach(item => {
      map[item[id]] = item;
    });
    arr.forEach(item => {
      const parent = map[item[parentId]];
      if (parent) {
        (parent.children || (parent.children = [])).push(item);
      } else if (parentVal.includes(item[parentId])) {
        val.push(item);
      }
    });
    return val;
  };