App.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <a-locale-provider :locale="locale">
  3. <div id="app">
  4. <router-view/>
  5. </div>
  6. </a-locale-provider>
  7. </template>
  8. <script>
  9. import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
  10. import { deviceEnquire, DEVICE_TYPE } from '@/utils/device'
  11. import { version } from 'ant-design-vue'
  12. export default {
  13. data () {
  14. return {
  15. locale: zhCN,
  16. version
  17. }
  18. },
  19. mounted () {
  20. const { $store } = this
  21. console.log('use Ant-Design Of Vue:', version)
  22. deviceEnquire(deviceType => {
  23. switch (deviceType) {
  24. case DEVICE_TYPE.DESKTOP:
  25. $store.commit('TOGGLE_DEVICE', 'desktop')
  26. $store.dispatch('setSidebar', true)
  27. break
  28. case DEVICE_TYPE.TABLET:
  29. console.log('tablet')
  30. $store.dispatch('ToggleDevice', 'tablet')
  31. $store.dispatch('setSidebar', false)
  32. break
  33. case DEVICE_TYPE.MOBILE:
  34. default:
  35. $store.commit('TOGGLE_DEVICE', 'mobile')
  36. $store.dispatch('setSidebar', false)
  37. break
  38. }
  39. console.log('deviceType', deviceType)
  40. })
  41. }
  42. }
  43. </script>
  44. <style>
  45. #app {
  46. height: 100%;
  47. }
  48. </style>