Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
word_tree_config
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
word_tree_config
Commits
e63a247c
Commit
e63a247c
authored
Nov 03, 2024
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化控制
parent
1ff8bd59
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
153 additions
and
28 deletions
+153
-28
index.css
play/index.css
+108
-22
index.html
play/index.html
+27
-5
index.js
play/index.js
+18
-1
No files found.
play/index.css
View file @
e63a247c
...
@@ -59,35 +59,25 @@ body {
...
@@ -59,35 +59,25 @@ body {
.word-card-content
{
.word-card-content
{
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
justify-content
:
center
;
justify-content
:
flex-start
;
align-items
:
center
;
align-items
:
center
;
height
:
100%
;
height
:
100%
;
width
:
100%
;
width
:
100%
;
text-align
:
center
;
text-align
:
center
;
}
position
:
relative
;
padding-top
:
30px
;
.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
;
/* 悬停时变亮 */
}
}
.word-card-content
.text-en
{
.word-card-content
.text-en
{
font-size
:
24px
;
font-size
:
24px
;
font-weight
:
bold
;
font-weight
:
bold
;
margin-bottom
:
5px
;
margin-bottom
:
5px
;
height
:
30px
;
line-height
:
30px
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
width
:
100%
;
}
}
.word-card-content
.phonetic
{
.word-card-content
.phonetic
{
...
@@ -95,10 +85,39 @@ body {
...
@@ -95,10 +85,39 @@ body {
color
:
#666
;
color
:
#666
;
margin-bottom
:
10px
;
margin-bottom
:
10px
;
text-align
:
center
;
text-align
:
center
;
height
:
20px
;
line-height
:
20px
;
overflow
:
hidden
;
}
}
.word-card-content
.text-cn
{
.word-card-content
.text-cn
{
font-size
:
20px
;
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
{
.el-breadcrumb-item.is-last
{
...
@@ -149,8 +168,9 @@ body {
...
@@ -149,8 +168,9 @@ body {
.enlarged-card
.audio-icon
{
.enlarged-card
.audio-icon
{
position
:
absolute
;
position
:
absolute
;
top
:
10px
;
top
:
20px
;
right
:
10px
;
right
:
20px
;
font-size
:
50px
;
}
}
.enlarged-card
.text-en
{
.enlarged-card
.text-en
{
...
@@ -168,10 +188,31 @@ body {
...
@@ -168,10 +188,31 @@ body {
color
:
#999
;
color
:
#999
;
margin-bottom
:
20px
;
margin-bottom
:
20px
;
font-style
:
italic
;
font-style
:
italic
;
text-align
:
center
;
}
}
.enlarged-card
.text-cn
{
.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
{
.control-panel
{
...
@@ -238,3 +279,48 @@ body {
...
@@ -238,3 +279,48 @@ body {
.search-input
{
.search-input
{
width
:
300px
;
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
;
}
play/index.html
View file @
e63a247c
...
@@ -38,19 +38,19 @@
...
@@ -38,19 +38,19 @@
@
dblclick
.
native=
"showEnlargedCard(item)"
@
dblclick
.
native=
"showEnlargedCard(item)"
:class=
"{ 'parent-card': !item.text_cn, 'word-card': item.text_cn }"
: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"
>
<template
v-if=
"!item.text_cn"
>
<div
class=
"card-content parent-text"
>
{{ item.text_en }}
</div>
<div
class=
"card-content parent-text"
>
{{ item.text_en }}
</div>
</template>
</template>
<template
v-else
>
<template
v-else
>
<div
class=
"word-card-content"
>
<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
v-show=
"showEnglish"
>
<div
class=
"text-en"
>
{{ item.text_en }}
</div>
<div
class=
"text-en"
>
{{ item.text_en }}
</div>
<div
v-if=
"item.phonetic"
class=
"phonetic"
>
<div
v-if=
"item.phonetic"
class=
"phonetic"
>
{{ item.phonetic.indexOf('[')>-1?item.phonetic:`[${item.phonetic}]` }}
{{ item.phonetic.indexOf('[')>-1?item.phonetic:`[${item.phonetic}]` }}
</div>
</div>
</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>
</div>
</template>
</template>
</el-card>
</el-card>
...
@@ -60,11 +60,33 @@
...
@@ -60,11 +60,33 @@
<div
v-if=
"enlargedCard"
class=
"fullscreen-overlay"
@
click=
"hideEnlargedCard"
>
<div
v-if=
"enlargedCard"
class=
"fullscreen-overlay"
@
click=
"hideEnlargedCard"
>
<div
class=
"enlarged-card"
@
click
.
stop
>
<div
class=
"enlarged-card"
@
click
.
stop
>
<i
v-if=
"enlargedCard.audio_url"
class=
"el-icon-headset audio-icon"
@
click=
"playAudio(enlargedCard.audio_url)"
></i>
<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
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>
<div
class=
"text-cn"
v-show=
"showChinese"
>
{{ enlargedCard.text_cn }}
</div>
</div>
</div>
</div>
</div>
...
...
play/index.js
View file @
e63a247c
...
@@ -19,6 +19,10 @@ new Vue({
...
@@ -19,6 +19,10 @@ new Vue({
enlargedCard
:
null
,
enlargedCard
:
null
,
showEnglish
:
true
,
showEnglish
:
true
,
showChinese
:
true
,
showChinese
:
true
,
enlargedCardControl
:
{
showEnglish
:
true
,
showChinese
:
true
},
controlSwitchesVisible
:
false
,
controlSwitchesVisible
:
false
,
showControlPanel
:
false
,
showControlPanel
:
false
,
searchQuery
:
''
,
searchQuery
:
''
,
...
@@ -50,7 +54,7 @@ new Vue({
...
@@ -50,7 +54,7 @@ new Vue({
});
});
},
},
loadChildren
(
item
)
{
loadChildren
(
item
)
{
if
(
!
item
.
has_child
)
{
if
(
item
.
text_cn
)
{
return
;
// 如果没有子节点,则不进行操作
return
;
// 如果没有子节点,则不进行操作
}
}
$
.
ajax
({
$
.
ajax
({
...
@@ -97,6 +101,10 @@ new Vue({
...
@@ -97,6 +101,10 @@ new Vue({
return
;
return
;
}
}
this
.
enlargedCard
=
{
...
item
};
this
.
enlargedCard
=
{
...
item
};
this
.
enlargedCardControl
=
{
showEnglish
:
true
,
showChinese
:
true
};
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
adjustFontSize
();
this
.
adjustFontSize
();
});
});
...
@@ -122,6 +130,15 @@ new Vue({
...
@@ -122,6 +130,15 @@ new Vue({
textElement
.
style
.
fontSize
=
`
${
fontSize
}
px`
;
textElement
.
style
.
fontSize
=
`
${
fontSize
}
px`
;
}
}
},
},
formatChineseText
(
text
)
{
if
(
!
text
)
return
''
;
// 移除括号及其中的内容
const
str
=
text
.
replace
(
/
[
((
]
.*
[
))
]
/g
,
''
).
trim
();
if
(
!
str
)
{
return
text
;
}
return
str
;
},
playAudio
(
audioUrl
)
{
playAudio
(
audioUrl
)
{
if
(
audioUrl
)
{
if
(
audioUrl
)
{
const
audio
=
new
Audio
(
audioUrl
);
const
audio
=
new
Audio
(
audioUrl
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment