From a5a6b942575245e2495c1e37a3b168d3e998dc03 Mon Sep 17 00:00:00 2001 From: czm <2192718639@qq.com> Date: Tue, 2 Aug 2022 10:40:10 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=E6=B7=BB=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.tsx | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index afe1300..9636423 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,28 +1,49 @@ import { FC } from 'react' -import ContextBlueTooth from "@/use/contextBlueTooth" +import ContextBlueTooth from '@/use/contextBlueTooth' import { Provider } from 'react-redux' import configStore from './store' import './app.scss' -import Taro, { useDidShow} from '@tarojs/taro' +import Taro, { onAppShow, useDidShow } from '@tarojs/taro' import { shareShop } from './common/util' const store = configStore() -const App:FC = (params) => { - +const App: FC = (params) => { Taro.showShareMenu({ - withShareTicket: true + withShareTicket: true, }) //分享 shareShop() + //检查版本更新 + onAppShow(() => { + const updateManager = Taro.getUpdateManager() + updateManager.onCheckForUpdate(function (res) { + // 请求完新版本信息的回调 + console.log('版本信息:', res.hasUpdate) + }) + updateManager.onUpdateReady(function () { + Taro.showModal({ + title: '更新提示', + content: '新版本已经准备好,是否重启应用?', + success: function (res) { + if (res.confirm) { + // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 + updateManager.applyUpdate() + } + }, + }) + }) + updateManager.onUpdateFailed(function () { + console.log('新版本更新失败') + }) + }) + return ( - - - {params.children} - - + + {params.children} + ) } -export default App \ No newline at end of file +export default App