diff --git a/src/components/TuiProgressBar.vue b/src/components/TuiProgressBar.vue index 6a8db14..bb0a98a 100644 --- a/src/components/TuiProgressBar.vue +++ b/src/components/TuiProgressBar.vue @@ -3,31 +3,45 @@ import { computed } from 'vue'; // [Props 정의] const props = defineProps({ - progress: { type: Number, required: true, default: 0 }, - total: { type: Number, default: 100 }, - status: { type: String, default: 'Initializing...' }, - barLength: { type: Number, default: 30 }, - + // 현재 진행 값 + progress: { + type: Number, + required: true, + default: 0 + }, + // 총량 + total: { + type: Number, + default: 100 + }, + // 하단에 표시할 상태 메시지 + status: { + type: String, + default: 'Initializing...' + }, + // 막대의 총 글자 길이 + barLength: { + type: Number, + default: 30 + }, + // 로그인한 유저 ID (Main.vue로부터 유기적 동기화) username: { type: String, default: 'anonymous' } }); -// [핵심 로직: Computed로 실시간 계산] -// 1. 퍼센트 계산 (0 ~ 100, 소수점 버림) +// [핵심 로직: Computed로 실시간 계산] const percentage = computed(() => { if (props.total <= 0) return 0; const percent = (props.progress / props.total) * 100; - return Math.min(Math.round(percent), 100); // 100%를 넘지 않도록 제한 + return Math.min(Math.round(percent), 100); }); -// 2. ASCII 막대 문자열 생성 (█░ 문자 조합) const barString = computed(() => { const filledCount = Math.round((props.barLength * percentage.value) / 100); const emptyCount = props.barLength - filledCount; - // '.repeat()'를 활용해 칼각 유지 const filledBar = '█'.repeat(filledCount); const emptyBar = '░'.repeat(emptyCount); @@ -57,27 +71,28 @@ const barString = computed(() => { \ No newline at end of file