App.vue 1.4 KB

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