Newer
Older
shipFront / src / utils / utils.js
[wangxitong] on 15 Oct 2021 626 bytes first commit
export function countSize (res) {
  let clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
  clientHeight = 1080
  if (!clientHeight) return
  let fontSize = 100 * (clientHeight / 1080)
  return res * fontSize
}

/**
 * @param {string} url
 * @returns {Object}
 */
export function param2Obj (url) {
  const search = url.split('?')[1]
  if (!search) {
    return {}
  }
  return JSON.parse(
    '{"' +
      decodeURIComponent(search)
        .replace(/"/g, '\\"')
        .replace(/&/g, '","')
        .replace(/=/g, '":"')
        .replace(/\+/g, ' ') +
      '"}'
  )
}