mirror of
https://gitee.com/yudaocode/yudao-mall-uniapp.git
synced 2025-12-30 01:32:26 +00:00
fix(app): iOS网络权限处理逻辑从app.vue迁移到首页page/index/index
- 在首页添加 onShow 生命周期钩子 - 检测iOS设备首次网络授权情况 - 授权通过后重新初始化应用状态 - 移除App.vue中重复的网络检测逻辑 - 优化页面滚动和下拉刷新功能 - 增强平台兼容性处理
This commit is contained in:
12
App.vue
12
App.vue
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
import { onLaunch, onShow, onError } from '@dcloudio/uni-app';
|
||||
import { sheep, ShoproInit } from '@/sheep';
|
||||
import { ShoproInit } from './sheep';
|
||||
|
||||
onLaunch(() => {
|
||||
// 隐藏原生导航栏 使用自定义底部导航
|
||||
uni.hideTabBar({
|
||||
@@ -11,7 +12,7 @@
|
||||
ShoproInit();
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
onShow(() => {
|
||||
// #ifdef APP-PLUS
|
||||
// 获取urlSchemes参数
|
||||
const args = plus.runtime.arguments;
|
||||
@@ -22,13 +23,6 @@
|
||||
uni.getClipboardData({
|
||||
success: (res) => {},
|
||||
});
|
||||
|
||||
// ios 网络授权后重新加载一次应用初始化
|
||||
if (sheep.$platform.os === 'ios') {
|
||||
if (await sheep.$platform.checkNetwork()) {
|
||||
await sheep.$store('app').init();
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
|
||||
import { onLoad, onShow, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
|
||||
import sheep from '@/sheep';
|
||||
import $share from '@/sheep/platform/share';
|
||||
// 隐藏原生tabBar
|
||||
@@ -79,6 +79,18 @@
|
||||
}
|
||||
});
|
||||
|
||||
onShow(async() => {
|
||||
// #ifdef APP-PLUS
|
||||
// ios首次授权网络,需要重新加载一次应用初始化
|
||||
// 可能需要考虑上uni.onNetworkStatusChange,uni.offNetworkStatusChange组合拳以及主动主动唤起权限申请
|
||||
if (sheep.$platform.os === 'ios') {
|
||||
if (await sheep.$platform.checkNetwork()) {
|
||||
await sheep.$store('app').init();
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
});
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh(() => {
|
||||
sheep.$store('app').init();
|
||||
|
||||
Reference in New Issue
Block a user