2025-06-22 23:08:40 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="calculator-result">
|
2025-10-05 14:50:34 +08:00
|
|
|
<!-- <div class="calc-header">
|
2025-06-22 23:08:40 +08:00
|
|
|
<h4><NumberOutlined /> 计算结果</h4>
|
2025-10-05 14:50:34 +08:00
|
|
|
</div> -->
|
2025-06-22 23:08:40 +08:00
|
|
|
|
|
|
|
|
<div class="calc-display">
|
|
|
|
|
<div class="result-container">
|
|
|
|
|
<div class="result-value">{{ formatNumber(data) }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2025-08-27 09:57:29 +08:00
|
|
|
import { NumberOutlined } from '@ant-design/icons-vue'
|
2025-06-22 23:08:40 +08:00
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
data: {
|
|
|
|
|
type: Number,
|
|
|
|
|
required: true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 方法
|
|
|
|
|
const formatNumber = (num) => {
|
|
|
|
|
if (typeof num !== 'number') return String(num)
|
|
|
|
|
|
|
|
|
|
// 处理特殊值
|
|
|
|
|
if (!isFinite(num)) {
|
|
|
|
|
if (num === Infinity) return '∞'
|
|
|
|
|
if (num === -Infinity) return '-∞'
|
|
|
|
|
if (isNaN(num)) return 'NaN'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 使用本地化格式
|
|
|
|
|
return new Intl.NumberFormat('zh-CN', {
|
|
|
|
|
maximumFractionDigits: 10,
|
|
|
|
|
useGrouping: true
|
|
|
|
|
}).format(num)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.calculator-result {
|
2025-08-27 09:57:29 +08:00
|
|
|
background: var(--gray-25);
|
2025-06-22 23:08:40 +08:00
|
|
|
border-radius: 8px;
|
|
|
|
|
|
|
|
|
|
.calc-header {
|
|
|
|
|
padding: 12px 16px;
|
|
|
|
|
|
|
|
|
|
h4 {
|
|
|
|
|
margin: 0;
|
|
|
|
|
color: var(--main-color);
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.calc-display {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
|
|
.result-container {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
|
|
.result-label {
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
color: var(--gray-600);
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.result-value {
|
2025-10-05 14:50:34 +08:00
|
|
|
font-size: 1rem;
|
2025-06-22 23:08:40 +08:00
|
|
|
font-weight: 600;
|
|
|
|
|
color: var(--main-color);
|
|
|
|
|
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.result-actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|