<template>
|
<div class="instrument-content">
|
<div class="left-img">
|
<div class="valueBox">{{ props?.options?.pitchAngle || 0 }}°</div>
|
<img src="@/assets/images/rightmapidentification.png" alt="" />
|
<div class="triangle" :style="pitchAngleStyle"></div>
|
<div class="nameBox">俯仰角度</div>
|
</div>
|
|
<div class="instrument-center">
|
<div class="compass-box" :style="compassStyle">
|
<div v-for="(item, index) in str" :key="index" class="scale" :style="{ '--rotate': 30 * index + 'deg' }">
|
<span class="text">{{ item }}</span>
|
</div>
|
</div>
|
<div class="center-show">
|
<img src="@/assets/images/mapidentification.png" alt="" />
|
</div>
|
</div>
|
|
<div class="right-img">
|
<div class="valueBox">{{ props.options?.trueAltitude }}m</div>
|
<img src="@/assets/images/leftmapidentification.png" alt="" />
|
<div class="rightTriangle" :style="trueAltitudeStyle"></div>
|
<div class="nameBox">真空高度</div>
|
</div>
|
</div>
|
</template>
|
|
<script setup>
|
const str = ['W', 30, 33, 'N', 3, 6, 'E', 12, 15, 'S', 21, 24]
|
|
const props = defineProps(['options'])
|
|
const pitchAngleStyle = computed(() => {
|
const pitchAngle = props?.options?.pitchAngle || 0
|
// 将 [-90, 90] 映射到 [0%, 100%]
|
const percentage = (((pitchAngle + 90) / 180) * 100).toFixed(2)
|
return {
|
bottom: `${percentage}%`,
|
}
|
})
|
|
const compassStyle = computed(() => {
|
return { transform: `rotate(${props?.options?.yawAngle || 0}deg)` }
|
})
|
|
const trueAltitudeStyle = computed(() => {
|
const trueAltitude = props?.options?.trueAltitude || 0
|
// 将 [0,240] 映射到 [0%, 100%]
|
const percentage = ((trueAltitude / 240) * 100).toFixed(2)
|
return {
|
bottom: `${percentage}%`,
|
}
|
})
|
</script>
|
|
<style lang="scss" scoped>
|
.instrument-content {
|
height: 100%;
|
width: 100%;
|
display: flex;
|
gap: 0 30px;
|
justify-content: center;
|
align-items: center;
|
position: relative;
|
|
.left-img,
|
.right-img {
|
position: relative;
|
width: 9px;
|
height: 127px;
|
|
img {
|
width: 100%;
|
height: 100%;
|
}
|
|
.triangle {
|
width: 0px;
|
height: 0px;
|
margin: auto;
|
border: 6px solid transparent;
|
border-left-color: #0fff7b;
|
position: absolute;
|
left: -10px;
|
|
transform: translateY(50%);
|
}
|
|
.rightTriangle {
|
width: 0px;
|
height: 0px;
|
margin: auto;
|
border: 6px solid transparent;
|
border-left-color: #0fff7b;
|
position: absolute;
|
right: -10px;
|
transform: translateY(50%) rotate(180deg);
|
}
|
|
.valueBox {
|
position: absolute;
|
top: -20px;
|
left: 50%;
|
transform: translateX(-50%);
|
}
|
|
.nameBox {
|
position: absolute;
|
bottom: -20px;
|
left: 50%;
|
width: auto;
|
transform: translateX(-50%);
|
font-family: Segoe UI, Segoe UI;
|
font-weight: 400;
|
font-size: 12px;
|
white-space: nowrap;
|
color: #ffffff;
|
}
|
}
|
|
.instrument-center {
|
position: relative;
|
|
.compass-box {
|
width: 180px;
|
height: 180px;
|
border-radius: 50%;
|
position: relative;
|
border: 30px solid rgba($color: #323931, $alpha: 0.5);
|
box-shadow: 0 2px 12px 0 #158aff;
|
user-select: none;
|
|
.scale {
|
width: 135%;
|
position: absolute;
|
top: 50%;
|
left: 50%;
|
font-weight: bold;
|
color: #c1c3c4;
|
text-align: left;
|
transform: translate(-50%, -50%) rotate(var(--rotate));
|
|
&:nth-child(3n - 2) {
|
color: #fff;
|
font-weight: bolder;
|
font-size: 20px;
|
}
|
}
|
|
.scale {
|
.text {
|
display: inline-block;
|
// rotate: -90deg;
|
transform: rotate(-90deg);
|
-ms-transform: rotate(-90deg);
|
-moz-transform: rotate(-90deg);
|
-webkit-transform: rotate(-90deg);
|
-o-transform: rotate(-90deg);
|
}
|
}
|
}
|
|
.rotat-btn {
|
width: 16px;
|
height: 16px;
|
background-color: rgba($color: #1fa3f6, $alpha: 1);
|
position: absolute;
|
top: 10px;
|
left: 50%;
|
transform: translateX(-50%);
|
|
&::before {
|
content: '';
|
display: block;
|
width: 0;
|
height: 0;
|
border-left: 8px solid transparent;
|
border-right: 8px solid transparent;
|
border-bottom: 8px solid #1fa3f6;
|
position: absolute;
|
bottom: 100%;
|
}
|
}
|
|
.center-show {
|
width: 30px;
|
height: 40px;
|
position: absolute;
|
left: 50%;
|
top: 50%;
|
transform: translate(-50%, -50%);
|
|
img {
|
width: 100%;
|
height: 100%;
|
transform: rotate(var(--rotate));
|
transition: all 0.5s linear;
|
}
|
}
|
|
&::after {
|
content: '';
|
position: absolute;
|
width: 40px;
|
top: 50%;
|
left: 0;
|
z-index: 99;
|
}
|
|
&::before {
|
content: '';
|
position: absolute;
|
width: 40px;
|
top: 50%;
|
right: 0;
|
z-index: 99;
|
}
|
}
|
}
|
</style>
|