App.vue 912 B

1234567891011121314151617181920212223242526272829303132
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. // 设备高度
  5. const systemInfo = uni.getWindowInfo();
  6. uni.$windowHeight = systemInfo.windowHeight;
  7. },
  8. // 在页面的onShow生命周期中
  9. onShow() {
  10. // 尝试从本地存储中恢复数据
  11. const savedState = uni.getStorageSync('vuex_state');
  12. if (savedState) this.$store.replaceState(Object.assign({}, this.$store.state, savedState));
  13. if (this.$store.getters.user.userId) this.$chat.connect('workark' + this.$store.getters.user.userId);
  14. },
  15. // 在页面的onHide生命周期中
  16. onHide() {
  17. // 保存状态到本地存储
  18. uni.setStorageSync('vuex_state', this.$store.state);
  19. }
  20. }
  21. </script>
  22. <style lang="scss">
  23. /*每个页面公共css */
  24. @import "@/static/font/iconfont.css";
  25. @import '@/static/scss/common.scss';
  26. page {
  27. background-color: $uv-bg-color;
  28. font-size: 28rpx;
  29. }
  30. </style>