|
|
|
<script setup>
|
|
|
|
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
|
|
|
import { onBeforeMount } from 'vue'
|
|
|
|
|
|
|
|
// #ifdef APP
|
|
|
|
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
|
|
|
|
import { useSystemStore } from '@/store/system.js';
|
|
|
|
const systemStore = useSystemStore()
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
import { useUserStore } from '@/store/user.js';
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
|
|
onLaunch(() => {
|
|
|
|
console.log('App Launch')
|
|
|
|
// #ifdef APP
|
|
|
|
const appInfo = uni.getAppBaseInfo()
|
|
|
|
systemStore.setAppInfo(appInfo)
|
|
|
|
checkAppUpdate()
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
uni.getNetworkType({
|
|
|
|
success ({ networkType }) {
|
|
|
|
console.log('enter network', networkType)
|
|
|
|
if (networkType === 'none') {
|
|
|
|
uni.showModal({
|
|
|
|
title: '提示',
|
|
|
|
content: '当前无网络,请连接网络',
|
|
|
|
showCancel: false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
onShow(() => {
|
|
|
|
console.log('App Show')
|
|
|
|
})
|
|
|
|
|
|
|
|
onHide(() => {
|
|
|
|
console.log('App Hide')
|
|
|
|
})
|
|
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
|
// const userInfo = uni.getStorageSync('uInfo')
|
|
|
|
const userInfo = userStore.getUserInfo();
|
|
|
|
if (userInfo) {
|
|
|
|
userStore.setUserInfo(userInfo)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// 检查更新
|
|
|
|
function checkAppUpdate () {
|
|
|
|
// #ifdef APP
|
|
|
|
checkUpdate().then(res => {
|
|
|
|
console.log('检查更新结果:', res)
|
|
|
|
}).catch(error => {
|
|
|
|
console.log("检查更新错误:", error)
|
|
|
|
}).finally(() => {
|
|
|
|
console.log('检查更新结束')
|
|
|
|
})
|
|
|
|
// #endif
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
#app {
|
|
|
|
min-height: 100vh;
|
|
|
|
background-color: #efeff4;
|
|
|
|
/* background-color: #000; */
|
|
|
|
/* height: auto; */
|
|
|
|
}
|
|
|
|
</style>
|