function getStaticPath() {
  if (!/(http|https):\/\/([^/]+)/i.test(window.apiHostSetting.VUE_APP_BASE_URL)) {
    return location.origin + window.apiHostSetting.VUE_APP_BASE_URL
  }
  return window.apiHostSetting.VUE_APP_BASE_URL
}
export const isMobile = () => window.innerWidth <= 1100
// zimg图片服务器地址
export const zImgPath = window.apiHostSetting.VUE_APP_ZIMG_URL
// 文件存储路径地址
export const filePath = getStaticPath() + 'upload/erp'

export function delChildren(list, callback, name) {
  const key = name || 'children'
  function recursive(list, callback, index) {
    for (const iterator of list) {
      callback && callback(iterator, index)
      if (iterator.children.length > 0) {
        recursive(iterator.children, callback, index + 1)
      } else {
        delete iterator[key]
      }
    }
  }

  recursive(list, callback, 0)
  return list
}
