import {onMounted, onUnmounted} from "vue";

export const useBackgroundHook = () => {


  let bodyList = document.getElementsByTagName('body');
  let body = bodyList[0]
  let bodyBackground = body.style.background


  const setBodyBackground = (option?: {mounted?: Function | undefined, unmounted?: Function | undefined}) => {
    let {mounted, unmounted} = option || {}

    onMounted(() => {
      body.style.background = 'linear-gradient(167.96deg, #E6FAE1 0%, #F2E7B7 98.44%) no-repeat'
      mounted && mounted()
    })

    onUnmounted(() => {
      body.style.background = bodyBackground
      unmounted && unmounted()
    })
  }

  return { setBodyBackground }
}