|
- <script>
- export default {
- // 小程序:onLaunch 仅启动时调用一次
- // H5/App:onLaunch 打开网页/用户点刷新/代码热更新时均会调用;
- // 考虑到用户刷新网页时会丢失全局数据、页面栈、页面数据等,因此直接跳回首页即可
-
- async onLaunch(param) {
- // #ifdef H5 || APP-VUE
- // H5 刷新时获取当前页面路径
- const pagePath = '/' + param.path
-
- // 如果 H5 刷新后访问的不是首页/登录页/注册页,直接跳转回首页
- if (!['/pages/login', '/pages/home', '/pages/signup'].includes(pagePath)) {
- this.$nextTick(() => {
- this.TAB_TO('/pages/home')
- return
- })
- }
- // #endif
-
- // #ifdef MP-WEIXIN
- // 小程序端,处理更新 (支付宝/钉钉暂不支持)
- const updateManager = uni.getUpdateManager()
- updateManager.onUpdateReady(() => {
- this.HIDE_LOADING()
- uni.showModal({
- title: '更新提示',
- content: '小程序新版本已准备好,是否更新应用?',
- success: ({ confirm }) => {
- if (confirm) {
- updateManager.applyUpdate()
- }
- }
- })
- })
- // #endif
- }
- }
- </script>
-
- <style lang="less">
- // 现在 CSS 必须在 <style> 中引入,参考:https://ask.dcloud.net.cn/question/86907
- // 后续 uni-app 升级后可能会支持直接 import 样式,到时候可以省略下行代码
- @import '~@/components/learun-mpui/styles/index.css';
-
- page {
- background-color: #f3f3f3;
- }
- </style>
|