{"size": 1022, "ext": "js", "max_stars_repo_path": "src/utils/versionUpdate.js", "max_stars_repo_name": "chris-mask/cgy-web", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/utils/versionUpdate.js", "max_issues_repo_name": "chris-mask/cgy-web", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/utils/versionUpdate.js", "max_forks_repo_name": "chris-mask/cgy-web", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.2051282051, "max_line_length": 69, "alphanum_fraction": 0.602739726}
/*
* 版本更新方法
* 作者；令溪
* */
import Vue from 'vue';
// import ajax from "element-ui/packages/upload/src/ajax";
import versionJson  from '../../static/version'
import axios from 'axios'

const vm = new Vue();
const isNewVersion = () => {
  // let url
  // if(process.env.NODE_ENV === 'production'){
  //   url = `//${ window.location.host }/admin/static/version.json`;
  // }else{
  //   url = `//${ window.location.host }/static/version.json`;
  // }

  // axios.get(url).then(res=>{
    let version = versionJson.version;
    let localVersion = localStorage.getItem('version');
    if (!localVersion || (localVersion && localVersion != version)) {
      // if (confirm("系统检测到有新版本，是否更新？")) {
      //   localStorage.setItem('version', res.data.version);
      //   window.location.reload();
      //   return;
      // }
      localStorage.setItem('version', version);
      window.location.reload();
      return;
    }else {
      localStorage.setItem('version', version);
    }
  // })
};
export default {
  isNewVersion
}
