fix(App.vue): 解决鸿蒙元服务版本,TabBar 就能正常显示了;修复多平台下API调用可能不存在的报错
1. 给options.query访问增加存在性校验,避免空指针报错 2. 给uni.getUpdateManager、uni.onNetworkStatusChange调用增加兼容性判断,防止在不支持的平台抛出错误
This commit is contained in:
8
App.vue
8
App.vue
@@ -26,8 +26,8 @@
|
|||||||
configExternal.loadTheme(presetName);
|
configExternal.loadTheme(presetName);
|
||||||
|
|
||||||
// ---- 1) uniacid 立即写入(后续所有 HTTP 都要用到)
|
// ---- 1) uniacid 立即写入(后续所有 HTTP 都要用到)
|
||||||
const uniacidChanged = options.query.uniacid && String(uni.getStorageSync('uniacid') || '') !== String(options.query.uniacid);
|
const uniacidChanged = options.query && options.query.uniacid && String(uni.getStorageSync('uniacid') || '') !== String(options.query.uniacid);
|
||||||
if (options.query.uniacid) {
|
if (options.query && options.query.uniacid) {
|
||||||
uni.setStorageSync('uniacid', options.query.uniacid);
|
uni.setStorageSync('uniacid', options.query.uniacid);
|
||||||
}
|
}
|
||||||
if (uniacidChanged) {
|
if (uniacidChanged) {
|
||||||
@@ -83,6 +83,7 @@
|
|||||||
uni.hideTabBar();
|
uni.hideTabBar();
|
||||||
|
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
|
if (uni.getUpdateManager) {
|
||||||
const updateManager = uni.getUpdateManager();
|
const updateManager = uni.getUpdateManager();
|
||||||
updateManager.onCheckForUpdate(function(res) {
|
updateManager.onCheckForUpdate(function(res) {
|
||||||
// 请求完新版本信息的回调
|
// 请求完新版本信息的回调
|
||||||
@@ -104,6 +105,7 @@
|
|||||||
updateManager.onUpdateFailed(function(res) {
|
updateManager.onUpdateFailed(function(res) {
|
||||||
// 新的版本下载失败
|
// 新的版本下载失败
|
||||||
});
|
});
|
||||||
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
@@ -112,6 +114,7 @@
|
|||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
if (uni.onNetworkStatusChange) {
|
||||||
uni.onNetworkStatusChange(function(res) {
|
uni.onNetworkStatusChange(function(res) {
|
||||||
if (!res.isConnected) {
|
if (!res.isConnected) {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
@@ -121,6 +124,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// /api/config/init 拉服务器侧数据(包含真正该用的 preset name)
|
// /api/config/init 拉服务器侧数据(包含真正该用的 preset name)
|
||||||
// 内部: success 回调里再次 dispatch('applyThemeWithRemote', serverPreset)
|
// 内部: success 回调里再次 dispatch('applyThemeWithRemote', serverPreset)
|
||||||
|
|||||||
Reference in New Issue
Block a user