Commit 8251d517 authored by liujiangnan's avatar liujiangnan

feat

parent f00c8483
......@@ -153,20 +153,24 @@ body {
}
.enlarged-card .text-en {
font-size: 36px;
font-weight: bold;
margin-bottom: 15px;
margin-bottom: 20px;
width: 100%;
text-align: center;
white-space: nowrap;
overflow: hidden;
/* 移除了固定的 font-size */
}
.enlarged-card .phonetic {
font-size: 24px;
font-size: 30px;
color: #999;
margin-bottom: 15px;
margin-bottom: 20px;
font-style: italic;
}
.enlarged-card .text-cn {
font-size: 28px;
font-size: 36px;
}
.control-panel {
......
......@@ -100,10 +100,31 @@ new Vue({
return;
}
this.enlargedCard = { ...item };
this.$nextTick(() => {
this.adjustFontSize();
});
},
hideEnlargedCard() {
this.enlargedCard = null;
},
adjustFontSize() {
if (!this.enlargedCard) return;
const cardElement = this.$el.querySelector('.enlarged-card');
const textElement = cardElement.querySelector('.text-en');
if (!textElement) return;
const cardWidth = cardElement.offsetWidth;
const targetWidth = cardWidth * 0.8; // 目标宽度为卡片宽度的60%
let fontSize = 148; // 开始的字体大小
textElement.style.fontSize = `${fontSize}px`;
while (textElement.offsetWidth > targetWidth && fontSize > 12) {
fontSize--;
textElement.style.fontSize = `${fontSize}px`;
}
},
playAudio(audioUrl) {
if (audioUrl) {
const audio = new Audio(audioUrl);
......@@ -177,9 +198,11 @@ new Vue({
},
mounted() {
document.addEventListener('click', this.hideControlPanel);
window.addEventListener('resize', this.adjustFontSize);
},
beforeDestroy() {
document.removeEventListener('click', this.hideControlPanel);
window.removeEventListener('resize', this.adjustFontSize);
},
watch: {
hasWordCards(newValue) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment