model-info.vue 2.74 KB
<template>
    <section class="model-info">
        <el-icon :size="20" @click="onClickBoundingBoxVisible">
            <View v-if="isBoundingBoxVisible" />
            <Hide v-else />
        </el-icon>
        <div class="content">
            <div class="item-name">
                <span v-for="(value, key, index) in modelInfo" v-text="$t(key)" :key="index" />
            </div>
            <div class="item-info">
                <span v-for="(value, key, index) in modelInfo" v-text="value ? `${value}` : '-'" :key="index" />
            </div>
            <div class="item-unit">
                <span v-text="modelInfo.length ? 'mm' : ''" />
                <span v-text="modelInfo.width ? 'mm' : ''" />
                <span v-text="modelInfo.height ? 'mm' : ''" />
                <span v-text="modelInfo.volume ? 'ml' : ''" />
                <span v-text="modelInfo.triangles ? '' : ''" />
            </div>
        </div>
    </section>
</template>
<script setup>
import { useModelInfoStore } from '@/views//stores/useModelInfoStore';
import { View, Hide } from '@element-plus/icons-vue';
import { storeToRefs } from 'pinia';

const store = useModelInfoStore();
const { modelInfo, setBoundingBoxVisible } = store;
const { isBoundingBoxVisible } = storeToRefs(store);

const onClickBoundingBoxVisible = () => {
    setBoundingBoxVisible(!isBoundingBoxVisible.value);
};
</script>
<style lang="less">
.model-info {
    position: absolute;
    bottom: 160px;
    margin-left: 24px;
    display: flex;
    align-items: flex-start;
    width: fit-content;
    pointer-events: none;
    z-index: 10;
    background-color: @canvas-background-color;
    padding: 10px;
    .el-icon {
        cursor: pointer;
        pointer-events: initial !important;
        &:hover {
            background-color: lightgray;
        }
    }
    .content {
        width: 100%;
        display: flex;
        -webkit-box-pack: start;
        justify-content: flex-start;
        align-items: flex-start;
        visibility: initial;
        pointer-events: none;
        color: rgb(50, 50, 50);
        .item-name {
            display: flex;
            flex-direction: column;
            gap: 10px;
            -webkit-box-align: center;
            align-items: flex-end;
            margin-right: 20px;
            pointer-events: none;
            width: 80px;
            font-weight: 550;
        }
        .item-info,
        .item-unit {
            display: flex;
            flex-direction: column;
            width: 60px;
            pointer-events: initial;
            align-items: center;
            gap: 10px;
            pointer-events: none;
        }
        .item-unit {
            width: 50px;
            align-items: center;
            pointer-events: none;
        }
    }
}
</style>