export function resolveFileString(str) {
  return str ? str.split(';').map((s) => resolveSingleFileString(s)) : []
}

export function resolveSingleFileString(str, sign = '|') {
  const [url, name] = str.split(sign)
  return {
    name,
    url: url.startsWith('http') ? url : window.GLOBAL_CONFIG.oss + '/' + url,
    origin: url
  }
}

// 获取完整文件地址
export function getFullUrl(url) {
  if (!url) return '';
  return url.startsWith('http') ? url : window.GLOBAL_CONFIG.oss + '/' + url
}

export function getAvatarUrl(id) {
  return window.GLOBAL_CONFIG.oss + '/user/main/user_avatar?user_id=' + id
}
