guyu/pages/index/index.vue
2025-07-23 23:42:09 +08:00

97 lines
1.8 KiB
Vue

<template>
<view class="content">
<image src="/static/index/bj.png" class="background-image"></image>
<image src="/static/index/logo.png" class="logo-image"></image>
</view>
</template>
<script setup>
import { appInit } from "@/common/system/system";
onLoad(async () => {
// 记录开始时间
const startTime = Date.now();
// 检查网络状态
const network = await uni.getNetworkType();
if (network.networkType === "none") {
tips_text.value = "请检查网络连接";
// 监听网络状态变化
uni.onNetworkStatusChange(checkNetwork);
return;
}
let res = await appInit();
// 计算总耗时
const endTime = Date.now();
const duration = endTime - startTime;
let endTimeF = 800 - duration;
console.log(`应用初始化成功,耗时: ${duration}ms,距离动画结束还需要${endTimeF}ms`);
if (endTimeF > 50) {
await sleep(endTimeF);
}
gy.navigateTo("/pages/home/home-page");
});
/**
* 检查网络状态
* @param {Object} res 网络状态
*/
function checkNetwork(res) {
console.log("网络状态变化:", res.isConnected, res.networkType);
if (res.isConnected) {
// #ifdef APP
plus.runtime.restart();
// #endif
}
}
</script>
<style lang="scss">
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
width: 100vw;
height: 100vh;
}
.background-image {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 1;
}
.logo-image {
width: 274rpx;
height: 292rpx;
z-index: 2;
animation: bounceInDown 0.5s ease 0.1s forwards;
opacity: 0;
}
@keyframes bounceInDown {
0% {
opacity: 0;
transform: translateY(-500px);
}
60% {
opacity: 1;
transform: translateY(30px);
}
80% {
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
</style>