import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from './components/element-ui'

import './styles/index.scss'

Vue.config.productionTip = false

Vue.use(ElementUI)

const title = document.title
Vue.prototype.$setTitle = (t) => {
  if (!title) {
    document.title = title
  } else {
    document.title = `${t} - ${title}`
  }
}
router.afterEach((to) => {
  if (to.meta?.title) {
    Vue.prototype.$setTitle(to.meta.title)
  }
})

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app')
