App.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <a-config-provider :locale="locale">
  3. <div id="app">
  4. <router-view/>
  5. </div>
  6. </a-config-provider>
  7. </template>
  8. <script>
  9. import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
  10. import enquireScreen from '@/utils/device'
  11. export default {
  12. data () {
  13. return {
  14. locale: zhCN,
  15. }
  16. },
  17. created () {
  18. let that = this
  19. enquireScreen(deviceType => {
  20. // tablet
  21. if (deviceType === 0) {
  22. // that.$store.commit('TOGGLE_DEVICE', 'mobile')
  23. that.$store.commit('TOGGLE_DEVICE', 'desktop')
  24. that.$store.dispatch('setSidebar', false)
  25. }
  26. // mobile
  27. else if (deviceType === 1) {
  28. // that.$store.commit('TOGGLE_DEVICE', 'mobile')
  29. that.$store.commit('TOGGLE_DEVICE', 'desktop')
  30. that.$store.dispatch('setSidebar', false)
  31. }
  32. else {
  33. that.$store.commit('TOGGLE_DEVICE', 'desktop')
  34. that.$store.dispatch('setSidebar', true)
  35. }
  36. })
  37. }
  38. }
  39. </script>
  40. <style>
  41. #app {
  42. height: 100%;
  43. }
  44. </style>