🎈 perf:添加新版本提示
This commit is contained in:
parent
243f50d945
commit
a5a6b94257
41
src/app.tsx
41
src/app.tsx
@ -1,27 +1,48 @@
|
|||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import ContextBlueTooth from "@/use/contextBlueTooth"
|
import ContextBlueTooth from '@/use/contextBlueTooth'
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
import configStore from './store'
|
import configStore from './store'
|
||||||
import './app.scss'
|
import './app.scss'
|
||||||
import Taro, { useDidShow} from '@tarojs/taro'
|
import Taro, { onAppShow, useDidShow } from '@tarojs/taro'
|
||||||
import { shareShop } from './common/util'
|
import { shareShop } from './common/util'
|
||||||
|
|
||||||
const store = configStore()
|
const store = configStore()
|
||||||
const App:FC = (params) => {
|
const App: FC = (params) => {
|
||||||
|
|
||||||
Taro.showShareMenu({
|
Taro.showShareMenu({
|
||||||
withShareTicket: true
|
withShareTicket: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
//分享
|
//分享
|
||||||
shareShop()
|
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 (
|
return (
|
||||||
<ContextBlueTooth>
|
<ContextBlueTooth>
|
||||||
<Provider store={store}>
|
<Provider store={store}>{params.children}</Provider>
|
||||||
{params.children}
|
</ContextBlueTooth>
|
||||||
</Provider>
|
|
||||||
</ContextBlueTooth>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user