inspection-host-computer/src/views/Home.vue

238 lines
7.2 KiB
Vue
Raw Normal View History

2026-06-26 10:51:01 +08:00
<template>
<div class="common-layout">
<el-container>
2026-06-30 17:32:54 +08:00
<el-header>
<div class="header-container">
<div class="back" @click="back">&lt;&nbsp;返回</div>
2026-06-26 10:51:01 +08:00
<div class="left">
<div class="date">
<div>{{ currentTime }}</div>
<div class="week">{{ weekText }}</div>
</div>
<div class="binary-strip">{{ binaryText }}</div>
</div>
<div class="application-title">两江鱼复智能网联新能源汽车产业基地上位机</div>
<div class="right">
<div class="binary-strip">{{ binaryText }}</div>
<div class="btn-container">
<button class="nav-btn" :class="{ active: activePage === 'chassis' }" @click="handleBtn('chassis')">底盘控制</button>
<button class="nav-btn" :class="{ active: activePage === 'mechanicalArm' }" @click="handleBtn('mechanicalArm')">机械臂控制</button>
2026-06-30 17:32:54 +08:00
<button class="nav-btn" :class="{ active: activePage === 'camera' }" @click="handleBtn('camera')">相机</button>
2026-06-26 10:51:01 +08:00
</div>
</div>
</div>
</el-header>
<el-main>
2026-07-10 13:44:07 +08:00
<Chassis v-if="activePage === 'chassis'" />
2026-06-26 10:51:01 +08:00
<MechanicalArm v-if="activePage === 'mechanicalArm'" />
2026-07-21 13:31:39 +08:00
<Camera v-show="activePage === 'camera'" />
2026-06-26 10:51:01 +08:00
</el-main>
</el-container>
</div>
</template>
<script setup>
import Chassis from './chassis/Chassis.vue';
2026-06-29 16:19:37 +08:00
import MechanicalArm from './arm/MechanicalArm.vue';
2026-06-30 17:32:54 +08:00
import Camera from './camera/index.vue'
2026-07-10 13:44:07 +08:00
import { useRouter } from 'vue-router';
2026-06-30 17:32:54 +08:00
import autofit from 'autofit.js'
2026-07-22 09:37:34 +08:00
autofit.init({
designHeight: 1080,
designWidth: 1920,
renderDom: '#app',
resize: true
})
2026-06-30 17:32:54 +08:00
const router = useRouter()
2026-06-26 10:51:01 +08:00
const currentTime = ref('')
const weekText = ref('')
const binaryText = ref('13513034532438213')
const weekNames = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
const updateClock = () => {
const now = new Date();
const y = now.getFullYear();
const mo = String(now.getMonth()+1).padStart(2,'0');
const d = String(now.getDate()).padStart(2,'0');
const h = String(now.getHours()).padStart(2,'0');
const mi = String(now.getMinutes()).padStart(2,'0');
const s = String(now.getSeconds()).padStart(2,'0');
currentTime.value = `${y}-${mo}-${d} ${h}:${mi}:${s}`
weekText.value = weekNames[now.getDay()]
}
const genBinary = (len) => {
let str = '';
for (let i = 0; i < len; i++) str += Math.round(Math.random()).toString();
return str;
}
const animateBinary = () => {
binaryText.value = genBinary(30)
}
const activePage = ref('chassis')
const handleBtn = (page) => {
activePage.value = page
}
2026-06-30 17:32:54 +08:00
const back = () => {
router.back()
}
2026-07-22 09:37:34 +08:00
const resetAutoFit = () => {
autofit.destroy() // 销毁旧缩放
autofit.init({
designHeight: 1080,
designWidth: 1920,
renderDom: '#app',
resize: true
})
}
2026-06-26 10:51:01 +08:00
let clockTimer, binaryTimer;
onMounted(() => {
updateClock();
clockTimer = setInterval(updateClock, 1000);
animateBinary()
binaryTimer = setInterval(animateBinary, 400);
2026-07-22 09:37:34 +08:00
document.addEventListener('fullscreenchange', resetAutoFit)
document.addEventListener('webkitfullscreenchange', resetAutoFit)
2026-06-26 10:51:01 +08:00
})
onUnmounted(() => {
clearInterval(clockTimer)
clearInterval(binaryTimer)
})
</script>
<style lang="scss" scoped>
.common-layout {
width: 100%;
height: 100%;
2026-07-21 14:00:56 +08:00
background: $color-background-base;
color: $color-text-primary;
2026-06-26 10:51:01 +08:00
.el-container {
width: 100%;
height: 100%;
2026-07-21 14:00:56 +08:00
background: radial-gradient(circle at 50% -20%, $color-accent-radial-glow, transparent 38%), $color-background-base;
2026-06-26 10:51:01 +08:00
.el-header {
2026-07-21 14:00:56 +08:00
background: $color-background-header-translucent;
border-bottom: 1px solid $color-accent-border-header;
box-shadow: 0 6px 24px $color-shadow-header;
2026-06-26 10:51:01 +08:00
}
.header-container {
height: 100%;
display: flex;
gap: 20px;
margin: 0 20px;
2026-06-30 17:32:54 +08:00
.back {
display: flex;
align-items: center;
justify-content: center;
2026-07-21 14:00:56 +08:00
color: $color-accent-secondary;
2026-06-30 17:32:54 +08:00
cursor: pointer;
}
2026-06-26 10:51:01 +08:00
.left {
flex: 1;
display: flex;
justify-content: space-evenly;
.date {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
2026-07-21 14:00:56 +08:00
color: $color-text-accent-soft;
2026-06-26 10:51:01 +08:00
font-size: 16px;
font-weight: 600;
letter-spacing: 2px;
.week {
font-size: 18px;
}
}
}
.application-title {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 26px;
font-weight: 700;
text-align: center;
2026-07-21 14:00:56 +08:00
color: $color-text-accent-bright;
text-shadow: 0 0 18px $color-accent-border-strong;
2026-06-26 10:51:01 +08:00
letter-spacing: 4px;
white-space: nowrap;
}
.right {
flex: 1;
display: flex;
justify-content: space-evenly;
.btn-container {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px ;
.nav-btn {
2026-07-21 14:00:56 +08:00
background: $color-accent-subtle;
border: 1px solid $color-accent-border-muted;
color: $color-text-navigation;
2026-06-26 10:51:01 +08:00
padding: 6px 20px;
border-radius: 3px;
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
white-space: nowrap;
2026-07-21 14:00:56 +08:00
&:hover {
border-color: $color-accent-border-hover;
color: $color-text-accent-bright;
background: $color-accent-medium;
}
2026-06-26 10:51:01 +08:00
}
.active {
2026-07-21 14:00:56 +08:00
background: $color-accent-selected;
border-color: $color-accent-border-active;
color: $color-text-navigation-active;
box-shadow: 0 0 14px $color-accent-glow, inset 0 0 12px $color-accent-inset-glow;
2026-06-26 10:51:01 +08:00
}
}
}
.binary-strip {
display: flex;
align-items: center;
justify-content: center;
font-family: 'Orbitron', monospace;
2026-06-30 17:32:54 +08:00
font-size: 14px;
2026-07-21 14:00:56 +08:00
color: $color-accent-text-muted;
2026-06-26 10:51:01 +08:00
letter-spacing: 2px;
white-space: nowrap;
overflow: hidden;
}
}
.el-main {
padding: 0;
}
}
}
2026-07-21 14:00:56 +08:00
</style>