App.vue 898 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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.dispatch('setSidebar', false)
  24. }
  25. // mobile
  26. else if (deviceType === 1) {
  27. that.$store.commit('TOGGLE_DEVICE', 'mobile')
  28. that.$store.dispatch('setSidebar', false)
  29. } else {
  30. that.$store.commit('TOGGLE_DEVICE', 'desktop')
  31. that.$store.dispatch('setSidebar', true)
  32. }
  33. })
  34. },
  35. }
  36. </script>
  37. <style>
  38. #app {
  39. height: 100%;
  40. }
  41. </style>