提交 a1a5336f 作者: 方治民

feat: 移除 APP 启动时检查更新,调整到首页进行,搭配手动关闭 splashscreen

上级 8b590b9f
<script setup lang="ts"> <script setup lang="ts">
import { checkUpgrade } from '@/utils/upgrade'
// import * as Push from '@/utils/push' // import * as Push from '@/utils/push'
onLaunch(() => { onLaunch(() => {
console.log('App Launch') console.log('App Launch')
// 版本更新检查
checkUpgrade()
// 清除消息角标 // 清除消息角标
// Push.setBadge(0) // Push.setBadge(0)
......
<script setup lang="ts"> <script setup lang="ts">
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { checkUpgrade } from '@/utils/upgrade' import { checkUpgrade, closeSplashscreenAndChechUpgrade } from '@/utils/upgrade'
import { useRuntime } from '@/hooks/app/useRuntime' import { useRuntime } from '@/hooks/app/useRuntime'
import { useConcealedExit } from '@/hooks/app/useConcealedExit' import { useConcealedExit } from '@/hooks/app/useConcealedExit'
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
const title = ref('Hello World') const title = ref('Hello World')
const version = computed(() => app.value.version) const version = computed(() => app.value.version)
onMounted(() => { onLoad(() => {
// 关闭启动页并检查更新
closeSplashscreenAndChechUpgrade()
// test API // test API
API.example.hello API.example.hello
.request() .request()
......
...@@ -22,3 +22,31 @@ export function checkUpgrade(toast = false) { ...@@ -22,3 +22,31 @@ export function checkUpgrade(toast = false) {
}) })
// #endif // #endif
} }
/**
* 关闭 splashscreen 并检查更新
*/
export function closeSplashscreenAndChechUpgrade() {
return new Promise<void>((resolve) => {
// FIXED: pages 第一路由页面为登录页,加上 splashscreen 配置控制使得用户体验更好
// #ifdef APP-PLUS
nextTick(() => {
// FIX: 延时执行,解决安卓环境下可能意外看到登录页的问题
const { platform } = uni.getSystemInfoSync()
const isAndroid = platform === 'android'
setTimeout(
() => {
plus.navigator.closeSplashscreen()
// 检查更新
checkUpgrade()
resolve()
},
isAndroid ? 1000 : 50,
)
})
// #endif
// #ifndef APP-PLUS
resolve()
// #endif
})
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论