add: 点击时间更换显示大小

This commit is contained in:
MKStoler1024 2024-08-23 10:22:25 +08:00 committed by GitHub
parent 18c2b5b5fa
commit d7a35cdf72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
<template> <template>
<v-card class="mx-auto" max-width="600"> <v-card class="mx-auto" max-width="750">
<v-card-text class="text-center"> <v-card-text class="text-center">
<div class="display-1 font-weight-bold"> <div class="display-1 font-weight-bold" @click="cycleFontSize">
{{ formattedTime }} {{ formattedTime }}
</div> </div>
</v-card-text> </v-card-text>
@ -15,13 +15,15 @@ import moment from 'moment';
// 使ref // 使ref
const formattedTime = ref(''); const formattedTime = ref('');
const fontSizeIndex = ref(2); // 7rem
const fontSizes = ['3rem', '5rem', '7rem'];//使
// //
onMounted(() => { onMounted(() => {
updateTime(); updateTime();
}); });
const formatDateTime = (isoString) => moment(isoString).format('HH:mm:ss'); const formatDateTime = (isoString: moment.MomentInput) => moment(isoString).format('HH:mm:ss');
// //
function updateTime() { function updateTime() {
@ -31,10 +33,15 @@ function updateTime() {
// //
useIntervalFn(updateTime, 250); useIntervalFn(updateTime, 250);
//
function cycleFontSize() {
fontSizeIndex.value = (fontSizeIndex.value + 1) % fontSizes.length;
}
</script> </script>
<style scoped> <style scoped>
.display-1 { .display-1 {
font-size: 5rem; /* 调整字号以适应大屏幕 */ font-size: v-bind(fontSizes[fontSizeIndex]); /* 动态绑定字体大小 */
} }
</style> </style>