App.vue 963 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. },
  16. // 在页面的onHide生命周期中
  17. onHide() {
  18. // 保存状态到本地存储
  19. uni.setStorageSync('vuex_state', this.$store.state);
  20. uni.$YeIM.leaveApp();
  21. }
  22. }
  23. </script>
  24. <style lang="scss">
  25. @import "@/static/scss/common.scss";
  26. @import "@/static/font/iconfont.css";
  27. // 设置整个项目的背景色
  28. page {
  29. color: $uni-main-color;
  30. font-size: 28rpx;
  31. background: $uni-background-color;
  32. .image {
  33. width: 100%;
  34. height: 100%;
  35. }
  36. }
  37. </style>