App.vue 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <script>
  2. export default {
  3. onLaunch() {
  4. console.log('App Launch')
  5. },
  6. // 在页面的onShow生命周期中
  7. onShow() {
  8. // 尝试从本地存储中恢复数据
  9. const savedState = uni.getStorageSync('vuex_state');
  10. if (savedState) {
  11. this.$store.replaceState(Object.assign({}, this.$store.state, savedState));
  12. }
  13. if (this.$store.getters.user.userId) this.$chat.connect(this.$store.getters.user.userId);
  14. uni.$YeIM.intoApp();
  15. this.$chat.listenerList();
  16. },
  17. // 在页面的onHide生命周期中
  18. onHide() {
  19. // 保存状态到本地存储
  20. uni.setStorageSync('vuex_state', this.$store.state);
  21. uni.$YeIM.leaveApp();
  22. }
  23. }
  24. </script>
  25. <style lang="scss">
  26. @import "@/static/scss/common.scss";
  27. @import "@/static/font/iconfont.css";
  28. // 设置整个项目的背景色
  29. page {
  30. color: $uni-main-color;
  31. font-size: 28rpx;
  32. background: $uni-background-color;
  33. .image {
  34. width: 100%;
  35. height: 100%;
  36. }
  37. }
  38. </style>