Commit e63a247c authored by liujiangnan's avatar liujiangnan

feat: 优化控制

parent 1ff8bd59
......@@ -59,35 +59,25 @@ body {
.word-card-content {
display: flex;
flex-direction: column;
justify-content: center;
justify-content: flex-start;
align-items: center;
height: 100%;
width: 100%;
text-align: center;
}
.audio-icon {
position: absolute;
top: 10px;
right: 10px;
font-size: 24px; /* 增大字体大小 */
color: #409EFF;
cursor: pointer;
transition: all 0.3s ease;
z-index: 1;
font-weight: bold; /* 加粗图标 */
text-shadow: 1px 1px 2px rgba(0,0,0,0.1); /* 添加轻微阴影以增加可见度 */
}
.audio-icon:hover {
transform: scale(1.2); /* 稍微增大悬停时的缩放效果 */
color: #66b1ff; /* 悬停时变亮 */
position: relative;
padding-top: 30px;
}
.word-card-content .text-en {
font-size: 24px;
font-weight: bold;
margin-bottom: 5px;
height: 30px;
line-height: 30px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
}
.word-card-content .phonetic {
......@@ -95,10 +85,39 @@ body {
color: #666;
margin-bottom: 10px;
text-align: center;
height: 20px;
line-height: 20px;
overflow: hidden;
}
.word-card-content .text-cn {
font-size: 20px;
max-height: 90px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
width: 100%;
word-break: break-all;
}
.audio-icon {
position: absolute;
top: 10px;
right: 10px;
font-size: 24px;
color: #409EFF;
cursor: pointer;
transition: all 0.3s ease;
z-index: 1;
font-weight: bold;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.audio-icon:hover {
transform: scale(1.2);
color: #66b1ff;
}
.el-breadcrumb-item.is-last {
......@@ -149,8 +168,9 @@ body {
.enlarged-card .audio-icon {
position: absolute;
top: 10px;
right: 10px;
top: 20px;
right: 20px;
font-size: 50px;
}
.enlarged-card .text-en {
......@@ -168,10 +188,31 @@ body {
color: #999;
margin-bottom: 20px;
font-style: italic;
text-align: center;
}
.enlarged-card .text-cn {
font-size: 36px;
max-height: 4.5em;
line-height: 1.5;
overflow: hidden;
text-align: center;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
font-size: 24px;
transition: font-size 0.3s ease;
}
/* 当只显示中文时的样式 */
.enlarged-card .text-cn.cn-only {
font-size: 48px;
-webkit-line-clamp: unset;
max-height: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80%;
}
.control-panel {
......@@ -238,3 +279,48 @@ body {
.search-input {
width: 300px;
}
.enlarged-card .control-switches {
position: absolute;
bottom: 20px;
right: 20px;
display: flex;
gap: 20px;
transform: scale(2);
transform-origin: bottom right;
}
.enlarged-card .switch-container {
display: flex;
align-items: center;
margin-right: 10px;
}
.enlarged-card .switch-label {
margin-right: 5px;
color: #333;
font-weight: 500;
font-size: 14px;
}
/* 确保开关在放大后不会被卡片边界切掉 */
.enlarged-card {
padding-bottom: 80px;
}
/* 小卡片中的音频图标样式 */
.word-card-content .audio-icon {
position: absolute;
top: 10px;
right: 10px;
font-size: 24px;
color: #409EFF;
cursor: pointer;
transition: all 0.3s ease;
z-index: 2;
}
.word-card-content .audio-icon:hover {
transform: scale(1.2);
color: #66b1ff;
}
......@@ -38,19 +38,19 @@
@dblclick.native="showEnlargedCard(item)"
:class="{ 'parent-card': !item.text_cn, 'word-card': item.text_cn }"
>
<i v-if="item.audio_url" class="el-icon-headset audio-icon" @click.stop="playAudio(item.audio_url)"></i>
<template v-if="!item.text_cn">
<div class="card-content parent-text">{{ item.text_en }}</div>
</template>
<template v-else>
<div class="word-card-content">
<i v-if="item.audio_url" class="el-icon-headset audio-icon" @click.stop="playAudio(item.audio_url)"></i>
<div v-show="showEnglish">
<div class="text-en">{{ item.text_en }}</div>
<div v-if="item.phonetic" class="phonetic">
{{ item.phonetic.indexOf('[')>-1?item.phonetic:`[${item.phonetic}]` }}
</div>
</div>
<div class="text-cn" v-show="showChinese">{{ item.text_cn }}</div>
<div class="text-cn" v-show="showChinese">{{ formatChineseText(item.text_cn) }}</div>
</div>
</template>
</el-card>
......@@ -60,11 +60,33 @@
<div v-if="enlargedCard" class="fullscreen-overlay" @click="hideEnlargedCard">
<div class="enlarged-card" @click.stop>
<i v-if="enlargedCard.audio_url" class="el-icon-headset audio-icon" @click="playAudio(enlargedCard.audio_url)"></i>
<div v-show="showEnglish">
<div class="control-switches">
<div class="switch-container">
<span class="switch-label">EN</span>
<el-switch
v-model="enlargedCardControl.showEnglish"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</div>
<div class="switch-container">
<span class="switch-label">中</span>
<el-switch
v-model="enlargedCardControl.showChinese"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</div>
</div>
<div v-show="enlargedCardControl.showEnglish">
<div class="text-en">{{ enlargedCard.text_en }}</div>
<div v-if="enlargedCard.phonetic" class="phonetic">[{{ enlargedCard.phonetic }}]</div>
<div v-if="enlargedCard.phonetic" class="phonetic">{{ enlargedCard.phonetic.indexOf('[')>-1?enlargedCard.phonetic:`[${enlargedCard.phonetic}]` }}</div>
</div>
<div class="text-cn"
v-show="enlargedCardControl.showChinese"
:class="{'cn-only': enlargedCardControl.showChinese && !enlargedCardControl.showEnglish}">
{{ formatChineseText(enlargedCard.text_cn) }}
</div>
<div class="text-cn" v-show="showChinese">{{ enlargedCard.text_cn }}</div>
</div>
</div>
......
......@@ -19,6 +19,10 @@ new Vue({
enlargedCard: null,
showEnglish: true,
showChinese: true,
enlargedCardControl: {
showEnglish: true,
showChinese: true
},
controlSwitchesVisible: false,
showControlPanel: false,
searchQuery: '',
......@@ -50,7 +54,7 @@ new Vue({
});
},
loadChildren(item) {
if (!item.has_child) {
if (item.text_cn) {
return; // 如果没有子节点,则不进行操作
}
$.ajax({
......@@ -97,6 +101,10 @@ new Vue({
return;
}
this.enlargedCard = { ...item };
this.enlargedCardControl = {
showEnglish: true,
showChinese: true
};
this.$nextTick(() => {
this.adjustFontSize();
});
......@@ -122,6 +130,15 @@ new Vue({
textElement.style.fontSize = `${fontSize}px`;
}
},
formatChineseText(text) {
if (!text) return '';
// 移除括号及其中的内容
const str = text.replace(/[((].*[))]/g, '').trim();
if (!str) {
return text;
}
return str;
},
playAudio(audioUrl) {
if (audioUrl) {
const audio = new Audio(audioUrl);
......
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