医学道
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
video/src/app.tsx

77 lines
1.7 KiB

1 year ago
import Taro, {useDidShow, useDidHide} from '@tarojs/taro'
import './app.scss'
import {CustomWrapper} from "@tarojs/components";
import {Profile} from '@/store'
import storageDep from "@/hooks/storageDep";
1 year ago
function updateApp() {
if (Taro.canIUse('getUpdateManager.onCheckForUpdate')) {
1 year ago
const updateManager = Taro.getUpdateManager()
updateManager.onCheckForUpdate((res) => {
console.log('新版本', res.hasUpdate)
})
updateManager.onUpdateReady(() => {
Taro.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(() => {
// 新版本下载失败
Taro.showToast({title: '新版本下载失败'})
})
}
}
function App(props) {
Taro.useLaunch(() => {
1 year ago
updateApp()
storageDep.remove()
1 year ago
})
1 year ago
Taro.getSystemInfo({
success({statusBarHeight = 0, screenWidth, screenHeight, windowHeight, safeArea}) {
const isIos = Taro.getSystemInfoSync().platform === 'ios';
const {top, height} = Taro.getMenuButtonBoundingClientRect()
const textBarHeight = (top - statusBarHeight) * 2 + height
1 year ago
Taro.getApp().globalData = {
statusBarHeight,
screenWidth,
screenHeight,
windowHeight,
safeArea,
isIos,
textBarHeight,
menu: Taro.getMenuButtonBoundingClientRect(),
1 year ago
}
}
})
// 对应 onShow
useDidShow(() => {
})
// 对应 onHide
useDidHide(() => {
})
return (
<CustomWrapper>
<Profile.Provider>
{props.children}
</Profile.Provider>
1 year ago
</CustomWrapper>
)
}
export default App