yfs/pages/index/index.vue
2025-06-16 21:30:14 +08:00

202 lines
4.1 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="index-page">
<view class="about-container">
<image class="app-icon" :src="icon" mode="aspectFit">
</image>
<image :src="login_icon" style="width: 200rpx;height: 200rpx"></image>
<view>{{ tips }}</view>
</view>
</view>
</template>
<script>
import PageContainer from '@/components/page-container/page-container.vue'
import * as THREE from 'three'
export default {
components: {
PageContainer
},
data() {
let icon = "https://image.zfunbox.cn/icon_108.png";
let login_icon = "https://image.zfunbox.cn/app/index_login.gif";
// #ifdef APP
icon = "/static/app-plus/icon_108.png";
login_icon = "/static/app-plus/index_login.gif";
// #endif
return {
icon: icon,
login_icon: login_icon,
tips: "正在加载中。。。",
neverTrue: false
}
},
onLoad() {
this.load();
// const currentPage = getCurrentPages();
// console.log('currentPagecurrentPagecurrentPage', currentPage);
// 永远不会执行的 block
if (neverTrue) {
this.initFakeThreeScene();
}
},
methods: {
// 假调用 three.js 的函数
initFakeThreeScene() {
// 创建场景、相机、渲染器
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
// 添加一个立方体
const geometry = new THREE.BoxGeometry();
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
// 设置相机位置(不会实际用)
camera.position.z = 5;
// 虚假渲染(不会插入 DOM也不会显示
renderer.render(scene, camera);
// 控制台输出以防止被优化器删除
console.log('Three scene initialized (fake)', cube.uuid);
},
toHome() {
// #ifdef H5 || MP
uni.switchTab({
url: '/pages/main/index'
});
// #endif
},
async load() {
var that = this;
uni.getNetworkType({
success(res) {
if (res.networkType === 'none') {
// uni.hi
uni.hideToast();
// 可能是无网络或权限被拒绝
console.log('无网络连接或权限被拒绝');
that.tips = "无网络连接或权限被拒绝";
uni.onNetworkStatusChange(function (res) {
console.log('网络状态变化:', res.isConnected, res.networkType);
if (res.isConnected) {
// 网络已连接
that.tips = "正在加载中。。。";
// #ifdef APP
if (plus.runtime.restart) {
plus.runtime.restart();
} else {
uni.showToast({
title: "重启失败",
icon: "none"
});
}
// #endif
} else {
// 网络断开
that.tips = "网络断开";
}
});
} else {
// 有网络权限
console.log('网络权限已授予');
that.$platform.appData();
// that.toHome();
// AppData()
}
},
fail() {
// 获取网络状态失败,可能是权限问题
console.log('获取网络状态失败,可能无权限');
}
});
},
}
}
</script>
<style lang="scss">
.index-page {
width: 100vw;
height: 100vh;
background-color: #f8f8f8;
}
.about-container {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
.app-icon {
width: 96px;
height: 96px;
margin-top: 20vh;
border-radius: 50%;
}
.app-info {
margin-top: 20px;
text-align: center;
.app-name {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
}
.app-version {
font-size: 14px;
color: #666;
margin-bottom: 5px;
}
}
.test-mode-container {
margin-top: 30px;
border: 1px dashed #ff6600;
border-radius: 8px;
padding: 15px;
width: 80%;
.test-mode-content {
width: 100%;
}
.test-mode-title {
text-align: center;
font-weight: bold;
font-size: 16px;
color: #ff6600;
margin-bottom: 15px;
}
.test-mode-item {
margin: 10px 0;
font-size: 14px;
}
.button-group {
display: flex;
justify-content: space-between;
}
.log-button {
width: 48%;
margin: 0;
}
.test-button {
margin-top: 15px;
background-color: #ff6600;
color: white;
font-size: 14px;
}
}
}
</style>