App.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. if (this.$store.getters.project.id) {
  13. uni.setTabBarItem({
  14. index: 2,
  15. text: '工作台'
  16. })
  17. }
  18. }
  19. if (this.$store.getters.user.userId) this.$chat.connect(this.$store.getters.user.userId);
  20. uni.$YeIM.intoApp();
  21. },
  22. // 在页面的onHide生命周期中
  23. onHide() {
  24. // 保存状态到本地存储
  25. uni.setStorageSync('vuex_state', this.$store.state);
  26. uni.$YeIM.leaveApp();
  27. uni.removeStorageSync('chatToken');
  28. }
  29. }
  30. </script>
  31. <style lang="scss">
  32. @import "@/static/scss/common.scss";
  33. @import "@/static/font/iconfont.css";
  34. // 设置整个项目的背景色
  35. page {
  36. color: $uni-main-color;
  37. font-size: 28rpx;
  38. background: $uni-background-color;
  39. .image {
  40. width: 100%;
  41. height: 100%;
  42. }
  43. }
  44. </style>