123456789101112131415161718192021222324252627282930313233343536373839 |
- <script>
- export default {
- onLaunch() {
- console.log('App Launch')
- },
- // 在页面的onShow生命周期中
- onShow() {
- // 尝试从本地存储中恢复数据
- const savedState = uni.getStorageSync('vuex_state');
- if (savedState) {
- this.$store.replaceState(Object.assign({}, this.$store.state, savedState));
- }
- if (this.$store.getters.user.userId) this.$chat.connect(this.$store.getters.user.userId);
- },
- // 在页面的onHide生命周期中
- onHide() {
- // 保存状态到本地存储
- uni.setStorageSync('vuex_state', this.$store.state);
- uni.removeStorageSync('chatToken');
- }
- }
- </script>
- <style lang="scss">
- @import "@/static/scss/common.scss";
- @import "@/static/font/iconfont.css";
- // 设置整个项目的背景色
- page {
- color: $uni-main-color;
- font-size: 28rpx;
- background: $uni-background-color;
- .image {
- width: 100%;
- height: 100%;
- }
- }
- </style>
|