2 changed files with 92 additions and 26 deletions
-
55src/web/src/pages/main/contents/OperationAcidBuckets.vue
-
63src/web/src/pages/main/contents/OperationCamera.vue
@ -0,0 +1,55 @@ |
|||
<template> |
|||
<div class="flex flex-row justify-evenly rounded-2xl p-5" style="background-color: #EEF5FF;"> |
|||
<div v-for="acidBucket in acidBuckets" :key="acidBucket.index"> |
|||
<div class="w-full relative"> |
|||
<div class="h-full w-full text-center"> |
|||
<img class="w-1/2" src="../../../assets/icon/bucket-full.svg" /> |
|||
</div> |
|||
<div class="h-full w-full text-center absolute top-0 overflow-hidden" |
|||
:style="{height:`${100-acidBucket.volume/acidBucket.maxVolume*100}%`}" |
|||
> |
|||
<img class="w-1/2" src="../../../assets/icon/bucket-empty.svg" /> |
|||
</div> |
|||
</div> |
|||
<div class="mx-2 p-2 mt-3 rounded-2xl text-center" style="background:#D2DFEF;color:#8799AB;"> |
|||
<span class="inline-block p-1 px-2 rounded-2xl mr-1" style="background:#DCE8F7;color: #0FDD6B;">{{acidBucket.volume}}</span> |
|||
<span class="inline-block py-1 ml-1">{{acidBucket.maxVolume}}</span> |
|||
</div> |
|||
<div class="text-center mt-2" style="color:#8799AB">{{acidBucket.acidName}}</div> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
<script setup> |
|||
import ApiClient from '@/utils/ApiClient'; |
|||
import { onMounted, onUnmounted, ref } from 'vue'; |
|||
/** @var {Array} */ |
|||
const acidBuckets = ref([]); |
|||
/** @var {Number} */ |
|||
let refreshTimer = null; |
|||
// on mounted |
|||
onMounted(mounted) |
|||
// on unmounted |
|||
onUnmounted(unmounted); |
|||
|
|||
// mounted |
|||
async function mounted() { |
|||
refresh(); |
|||
} |
|||
|
|||
// unmounted |
|||
async function unmounted() { |
|||
clearTimeout(refreshTimer); |
|||
} |
|||
|
|||
// refresh |
|||
async function refresh() { |
|||
let client = ApiClient.getClient(); |
|||
let response = await client.resourceDataGet('Acid'); |
|||
acidBuckets.value = structuredClone(response); |
|||
let acidTypeMap = {hydrochloric:'盐酸',nitric:'硝酸',sulfuric:'硫酸',hydrofluoric:'氢氟酸',perchloric:'高氯酸',hydrobromic:'液溴',phosphoric:'磷酸',tartaric:'酒石酸'}; |
|||
for ( let acidBucket of acidBuckets.value ) { |
|||
acidBucket.acidName = acidTypeMap[acidBucket.acidType]; |
|||
} |
|||
refreshTimer = setTimeout(refresh, 5000); |
|||
} |
|||
</script> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue