import './index.scss'
import NormalLogin from './src/NormalLogin.vue'
import CodeLogin from './src/CodeLogin.vue'
import ForgetLogin from './src/ForgetLogin.vue'

const components = [
  NormalLogin,
  CodeLogin,
  ForgetLogin
]

const install = function (Vue, opts = {}) {
  /* 存在国际化 */
  if (opts.i18n) {
    const msgs = opts.i18n.messages
    for (const k in msgs) {
      opts.i18n.setLocaleMessage(k, Object.assign(msgs[k], require('./assets/languages/' + k + '.json')))
    }
  }

  components.forEach(component => {
    Vue.component(component.name, component)
  })
}

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

export default {
  install,
  NormalLogin,
  CodeLogin,
  ForgetLogin
}
