App.vue 873 B

12345678910111213141516171819202122232425262728293031
  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/scss/common.scss';
  25. page {
  26. background-color: $uv-bg-color;
  27. font-size: 28rpx;
  28. }
  29. </style>