App.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <a-config-provider :locale="locale">
  3. <div id="app">
  4. <div v-if="envtips!=''&&$route.path.indexOf('bigScreen')<0" class="envtipsBox">{{ envtips }}</div>
  5. <router-view/>
  6. </div>
  7. </a-config-provider>
  8. </template>
  9. <script>
  10. import zhCN from 'ant-design-vue/es/locale/zh_CN'
  11. import { AppDeviceEnquire } from '@/utils/mixin'
  12. import moment from 'moment'
  13. import 'moment/locale/zh-cn'
  14. export default {
  15. mixins: [AppDeviceEnquire],
  16. data () {
  17. return {
  18. locale: zhCN,
  19. envtips: '',
  20. moment
  21. }
  22. },
  23. created () {
  24. this.envtips = process.env.VUE_APP_ENVTIPS
  25. console.log(this.$route.path)
  26. // 在页面加载时读取sessionStorage
  27. if (sessionStorage.getItem('store')) {
  28. const data = JSON.parse(sessionStorage.getItem('store'))
  29. sessionStorage.setItem('Access-Token', data.user.token)
  30. this.$store.replaceState(Object.assign({}, this.$store.state, data))
  31. }
  32. // 在页面刷新时将store保存到sessionStorage里
  33. window.addEventListener('beforeunload', () => {
  34. sessionStorage.setItem('store', JSON.stringify(this.$store.state))
  35. })
  36. this.$message.config({
  37. top: `100px`,
  38. duration: 5,
  39. maxCount: 3
  40. })
  41. }
  42. }
  43. </script>
  44. <style>
  45. #app {
  46. height: 100%;
  47. }
  48. .envtipsBox{
  49. position: fixed;
  50. z-index: 100000;
  51. background: red;
  52. width: 230px;
  53. text-align: center;
  54. color: #fff;
  55. font-size: 30px;
  56. top: 0;
  57. left: 0;
  58. width: 50%;
  59. margin-left: 25%;
  60. }
  61. </style>