| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <script>
- import Vue from 'vue'
- import config from '@/config.js'
- Vue.prototype.$config = config
- export default {
- onLaunch: function(options) {
- console.log('App Launch', options)
- // 从 storage 恢复登录态到 store,保证 state 与 storage 一致
- this.$store.dispatch('restore')
- },
- onShow: function(options) {
- console.log('App Show', options)
- // 热启动兜底:若 store 空但 storage 有 token(如 HBuilderX 热更新后 store 重置),重新恢复
- if (!this.$store.state.token && uni.getStorageSync('token')) {
- this.$store.dispatch('restore')
- }
- },
- onHide: function() {
- console.log('App Hide')
- }
- }
- </script>
- <style>
- page {
- background-color: #F5F5F5;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI',
- 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
- 'Helvetica Neue', Helvetica, Arial, sans-serif;
- color: #1E293B;
- font-size: 28rpx;
- line-height: 1.6;
- -webkit-font-smoothing: antialiased;
- }
- .page {
- padding: 0 32rpx 32rpx;
- min-height: 100vh;
- }
- .safe-area-bottom {
- padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
- padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
- }
- </style>
|