<template>
  <sd-config-provider>
    <router-view></router-view>
  </sd-config-provider>
</template>

<script>
import Vue from 'vue'
import { ConfigProvider } from 'ant-design-vue'
import moment from 'moment'
import 'moment/locale/zh-cn'
import SdConfigProvider from '@/common/components/sd-config-provider.vue'
import store from './common/store'

moment.locale('zh-cn')
Vue.use(ConfigProvider)

export default {
  name: 'App',
  components: {
    'sd-config-provider': SdConfigProvider,
  },
  data() {
    return {
      lastTitle: undefined,
    }
  },

  metaInfo: {
    titleTemplate: function(title) {
      // 保存上次的title，因为有时候切换过程会清空title：首页->''->工作台
      if (!title) title = this.lastTitle
      else this.lastTitle = title

      if (title) return title + ' | ' + store.state.sd.common.appTitle
      else return store.state.sd.common.appTitle
    },
  },
}
</script>
