App.vue 951 B

123456789101112131415161718192021222324252627282930313233
  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. uni.removeStorageSync('chatToken');
  20. }
  21. }
  22. </script>
  23. <style lang="scss">
  24. /*每个页面公共css */
  25. @import "@/static/font/iconfont.css";
  26. @import '@/static/scss/common.scss';
  27. page {
  28. background-color: $uv-bg-color;
  29. font-size: 28rpx;
  30. }
  31. </style>