App.vue 4.11 KB
<!--
 * @Author: 前端 qianduan01@didihu.com.cn
 * @Date: 2024-04-07 17:09:53
 * @LastEditors: 前端 qianduan01@didihu.com.cn
 * @LastEditTime: 2024-09-24 11:01:24
 * @FilePath: \gl_tape\App.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script>
const PATH = ['/pages/common/caseDetail']
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js'
import { mapState } from 'vuex'
import utils from '@/utils/utils'
export default {
  computed: {
    ...mapState('audio', ['isEnd', 'isStart'])
  },
  onLaunch: async function () {
    // this.init()
    this.setAPPVersion()
    setTimeout(() => {
      plus.screen.unlockOrientation() //解除锁定屏幕方向
      plus.screen.lockOrientation('landscape-primary')
    }, 300)
    uni.setKeepScreenOn({
      keepScreenOn: true
    })
  },
  methods: {
    async handleCheck() {
      const { textList, tempFileURL, version } = uni.$storage.get('mock_data')
      const res = utils.compareVersions(plus?.runtime?.version, version)
      if (res > -1) {
        return
      }
      const e = {
        result: {
          is_silently: false,
          is_mandatory: true,
          name: '',
          title: '',
          contents: textList.join('\n'),
          version: version,
          url: tempFileURL,
          stable_publish: true
        }
      }
      checkUpdate(e)
    },
    init() {
      uni.addInterceptor('navigateTo', {
        //监听跳转

        invoke(e) {
          console.log('******** invoke-navigateTo ********', e.url.split('?').shift())
          if (PATH.includes(e.url.split('?').shift())) {
            console.log(888)
          }
        }
      })

      //2

      uni.addInterceptor('redirectTo', {
        //监听关闭本页面跳转

        invoke(e) {
          console.log('******** redirectTo ********', e.url)
        }
      })

      uni.addInterceptor('switchTab', {
        //监听tabBar跳转

        invoke(e) {
          console.log('******** switchTab ********', e.url)
        }
      })

      //4

      uni.addInterceptor('navigateBack', {
        //监听返回

        invoke(e) {
          console.log('******** navigateBack ********', e)
        }
      })
    },
    setAPPVersion() {
      let version = plus.runtime.version
      let storageVersion = uni.$storage.get('storageVersion')
      console.log(storageVersion, version)
      if (storageVersion != version) {
        uni.$storage.rm('userInfo')
        uni.$storage.rm('noSignInUuid')
      }
      uni.$storage.set('storageVersion', version)
    }
  },

  onShow: async function () {
    this.handleCheck()
    // const systemInfo = await uni.$api.systemApi.getMockData();
    // if (systemInfo.isCheckedUpdate) {
    //   checkUpdate();
    // }
    // let version = plus.runtime.version;
    // uni.$api.commonApi.getAPPVersion().then((res) => {
    //   if (res != version && !systemInfo.isCheckedUpdate)
    //     this.$store.dispatch("openUpdateModal");
    // });
  },
  onHide: function () {},
  onError: function (e) {
    this.$sendSentry(e)
  }
}
</script>

<style lang="scss">
body {
  // overflow: hidden;
}

page {
  font-size: 28rpx;
  height: 100%;
  min-height: 100%;
}

view,
navigator,
image,
text,
scroll-view,
swiper,
swiper-item,
input,
textarea,
button {
  box-sizing: border-box;
}

/* 文字避头尾法则 */
.btw {
  table-layout: fixed;
  word-wrap: break-word;
  word-break: normal;
  text-align: justify;
  text-justify: inter-ideograph;
}

.bg-white {
  background: #fff;
}

.font-weight {
  font-weight: bold;
}

.u-flex-center {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
}

button {
  margin: 0;
  padding: 0;
  line-height: 1.5;
  font-size: 28rpx;
  background-color: transparent;
  border-radius: 0;
  position: relative;
}

button::after {
  border: none;
}

// 指定按钮按下去的样式类
.button-hover {
  transform: translate(1rpx, 1rpx);
}

.webview-container {
  position: absolute;
  width: 100rpx;
  height: 100rpx;
  top: 0rpx;
  left: 0rpx;
}
</style>