export function shuffle(array: any[]): any[] {
  // 随机乱序处理

  const arr = array.map(item => {
    return {
      selected: false,
      ...item,
    }
  })
  return arr.sort(() => 0.5 - Math.random())
}

export function changeSymbolPosition(arr: anyObj[]): anyObj[] {
  const answerList: anyObj[] = []
  arr.forEach(item => {
    if (item.beforeSymbol) {
      answerList.push({
        isSymbol: true,
        displaySpell: item.beforeSymbol,
      })
    }
    answerList.push({
      ...item,
    })
    if (item.afterSymbol) {
      answerList.push({
        isSymbol: true,
        displaySpell: item.afterSymbol,
      })
    }
  })
  return answerList
}

export const jumpTarget = function (url: string) {
  const link = document.createElement('a')
  link.href = url as string
  document.body.appendChild(link)
  link.click()
  setTimeout(() => {
    document.body.removeChild(link)
  }, 0)
}
