diff --git a/App.vue b/App.vue index ae9a76e..9945a8b 100644 --- a/App.vue +++ b/App.vue @@ -26,8 +26,8 @@ configExternal.loadTheme(presetName); // ---- 1) uniacid 立即写入(后续所有 HTTP 都要用到) - const uniacidChanged = options.query.uniacid && String(uni.getStorageSync('uniacid') || '') !== String(options.query.uniacid); - if (options.query.uniacid) { + const uniacidChanged = options.query && options.query.uniacid && String(uni.getStorageSync('uniacid') || '') !== String(options.query.uniacid); + if (options.query && options.query.uniacid) { uni.setStorageSync('uniacid', options.query.uniacid); } if (uniacidChanged) { @@ -83,27 +83,29 @@ uni.hideTabBar(); // #ifdef MP - const updateManager = uni.getUpdateManager(); - updateManager.onCheckForUpdate(function(res) { - // 请求完新版本信息的回调 - }); - - updateManager.onUpdateReady(function(res) { - uni.showModal({ - title: '更新提示', - content: '新版本已经准备好,是否重启应用?', - success(res) { - if (res.confirm) { - // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 - updateManager.applyUpdate(); - } - } + if (uni.getUpdateManager) { + const updateManager = uni.getUpdateManager(); + updateManager.onCheckForUpdate(function(res) { + // 请求完新版本信息的回调 }); - }); - updateManager.onUpdateFailed(function(res) { - // 新的版本下载失败 - }); + updateManager.onUpdateReady(function(res) { + uni.showModal({ + title: '更新提示', + content: '新版本已经准备好,是否重启应用?', + success(res) { + if (res.confirm) { + // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 + updateManager.applyUpdate(); + } + } + }); + }); + + updateManager.onUpdateFailed(function(res) { + // 新的版本下载失败 + }); + } // #endif // #ifdef H5 @@ -112,15 +114,17 @@ } // #endif - uni.onNetworkStatusChange(function(res) { - if (!res.isConnected) { - uni.showModal({ - title: '网络失去链接', - content: '请检查网络链接', - showCancel: false - }); - } - }); + if (uni.onNetworkStatusChange) { + uni.onNetworkStatusChange(function(res) { + if (!res.isConnected) { + uni.showModal({ + title: '网络失去链接', + content: '请检查网络链接', + showCancel: false + }); + } + }); + } // /api/config/init 拉服务器侧数据(包含真正该用的 preset name) // 内部: success 回调里再次 dispatch('applyThemeWithRemote', serverPreset)