import axios from 'axios'
import modal from 'ant-design-vue/es/modal'
const isNewVersion = () => {
  const url = `//${window.location.host}/version.json?t=${new Date().getTime()}`
  axios.get(url).then(res => {
    if (res.status === 200) {
      const vueVersion = res.data.version
      const message = res.data.message
      const localVueVersion = localStorage.getItem('vueVersion-iscm')
      if (localVueVersion && localVueVersion != vueVersion) {
        localStorage.setItem('vueVersion-iscm', vueVersion)
        modal.info({
          title: '提示',
          content: message,
          onOk () {
            window.location.reload()
          }
        })
      } else {
        localStorage.setItem('vueVersion-iscm', vueVersion)
      }
    }
  })
}

export default {
  isNewVersion
}
