// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'

import router from './router'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import { axios } from '@/common/http'

Vue.use(ElementUI);

Vue.prototype.$http = axios

Vue.prototype.$cdnUrl = "https://oss-xiaoan.oss-cn-shenzhen.aliyuncs.com/"

Vue.config.productionTip = false

import { format } from 'date-fns'

// 将 yyyy-MM-yy 变成 yyyy年mm月dd日
Vue.filter('dateFormat', function (value, formatStr = 'yyyy-MM-yy HH:mm:ss') {
  value = new Date(value)
  let newVale = format(value, formatStr);
  // let reg =/(\d{4})\-(\d{2})\-(\d{2})/; newVale.replace(reg,"$1年$2月$3日")
  return newVale
})
Vue.filter('dateFormat1', function (value, formatStr = 'yyyy-MM-yy HH:mm:ss') {
  value = new Date(value)
  let newVale = format(value, formatStr);
  let reg =/(\d{4})\-(\d{2})\-(\d{2})/; 
  return newVale.replace(reg,"$1年$2月$3日")
})
Vue.filter('dateFormat2', function (value, formatStr = 'yyyy-MM-yy HH:mm:ss') {
  value = new Date(value)
  let newVale = format(value, formatStr);
  let reg =/(\d{4})\-(\d{2})\-(\d{2})/; 
  return newVale.replace(reg,"$1年$2月$3日").slice(5)
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
