Fix: 修改代码风格 & 优化脚本结构

This commit is contained in:
2025-07-09 16:56:10 +08:00
parent 610a2e89a7
commit 6edd08b874
2 changed files with 52 additions and 64 deletions

View File

@ -15,7 +15,7 @@
rounded="xl"
>
<v-card-title class="text-h5 mb-6 d-flex align-center">
<VIcon
<v-icon
class="mr-3"
color="primary"
icon="mdi-tune"
@ -26,31 +26,31 @@
<v-row>
<v-col cols="12">
<ParamInputField
<param-input-field
v-model="paperCoreDiameter"
:label="`${$t('paperCoreDiameter')} (${paperCoreDiameter.unit})`"
/>
</v-col>
<v-col cols="12">
<ParamInputField
<param-input-field
v-model="paperRollExternalDiameter"
:label="`${$t('paperRollExternalDiameter')} (${paperRollExternalDiameter.unit})`"
/>
</v-col>
<v-col cols="12">
<ParamInputField
<param-input-field
v-model="paperRollWidth"
:label="`${$t('paperRollWidth')} (${paperRollWidth.unit})`"
/>
</v-col>
<v-col cols="12">
<ParamInputField
<param-input-field
v-model="paperDensity"
:label="`${$t('paperDensity')} (${paperDensity.unit})`"
/>
</v-col>
<v-col cols="12">
<ParamInputField
<param-input-field
v-model="paperGrammage"
:label="`${$t('paperGrammage')} (${paperGrammage.unit})`"
/>
@ -77,42 +77,42 @@
lg="5"
md="6"
>
<VCard
<v-card
class="pa-6 result-card"
elevation="8"
rounded="xl"
>
<VCardTitle class="text-h5 mb-6 d-flex align-center">
<VIcon
<v-card-title class="text-h5 mb-6 d-flex align-center">
<v-icon
class="mr-3"
color="primary"
icon="mdi-calculator"
size="large"
/>
{{ $t('results') }}
</VCardTitle>
</v-card-title>
<VRow>
<VCol cols="12">
<ResultCard
<v-row>
<v-col cols="12">
<result-card
:label="$t('paperRollWeight')"
:value="paperRollWeight"
:value="result.paperRollWeight"
/>
</VCol>
<VCol cols="12">
<ResultCard
</v-col>
<v-col cols="12">
<result-card
:label="$t('paperRollLength')"
:value="paperRollLength"
:value="result.paperRollLength"
/>
</VCol>
<VCol cols="12">
<ResultCard
</v-col>
<v-col cols="12">
<result-card
:label="$t('paperThickness')"
:value="paperThickness"
:value="result.paperThickness"
/>
</VCol>
</VRow>
</VCard>
</v-col>
</v-row>
</v-card>
</v-col>
</v-row>
</div>
@ -128,30 +128,19 @@
const paperDensity = ref<Param>(createParam(0.76, 'g/cm³'))
const paperGrammage = ref<Param>(createParam(420, 'g/m²'))
const paperThickness = computed(() => {
// 计算纸张厚度
return createParam(paperGrammage.value.value / paperDensity.value.value / 1000, 'mm')
})
const paperRollWeight = computed(() => {
// 计算纸卷总重量
const result = computed(() => {
const paperRollExternalRadius = paperRollExternalDiameter.value.value / 2
const paperCoreRadius = paperCoreDiameter.value.value / 2
const paperRollVolume = (Math.PI * Math.pow(paperRollExternalRadius, 2) - Math.PI * Math.pow(paperCoreRadius, 2)) * paperRollWidth.value.value
const weight = paperRollVolume * paperDensity.value.value / 1_000_000 // 计算重量
return createParam(weight, 'kg')
const paperThickness = paperGrammage.value.value / paperDensity.value.value / 1000 // 计算纸张厚度
const paperRollWeight = paperRollVolume * paperDensity.value.value / 1_000_000 // 计算重量
const paperRollLength = paperRollVolume / (paperThickness * paperRollWidth.value.value) / 1000 // 计算长度
return {
paperRollWeight: createParam(paperRollWeight, 'kg'),
paperRollLength: createParam(paperRollLength, 'm'),
paperThickness: createParam(paperThickness, 'mm'),
}
})
const paperRollLength = computed(() => {
// 计算纸卷长度
const paperRollExternalRadius = paperRollExternalDiameter.value.value / 2
const paperCoreRadius = paperCoreDiameter.value.value / 2
const paperRollVolume = (Math.PI * Math.pow(paperRollExternalRadius,
2) - Math.PI * Math.pow(paperCoreRadius, 2)) * paperRollWidth.value.value
const length = paperRollVolume / (paperThickness.value.value * paperRollWidth.value.value) / 1000
return createParam(length, 'm')
})
</script>
<style scoped lang="sass">