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
8251d517
Commit
8251d517
authored
Oct 26, 2024
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat
parent
f00c8483
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
+32
-5
index.css
play/index.css
+9
-5
index.js
play/index.js
+23
-0
No files found.
play/index.css
View file @
8251d517
...
@@ -153,20 +153,24 @@ body {
...
@@ -153,20 +153,24 @@ body {
}
}
.enlarged-card
.text-en
{
.enlarged-card
.text-en
{
font-size
:
36px
;
font-weight
:
bold
;
font-weight
:
bold
;
margin-bottom
:
15px
;
margin-bottom
:
20px
;
width
:
100%
;
text-align
:
center
;
white-space
:
nowrap
;
overflow
:
hidden
;
/* 移除了固定的 font-size */
}
}
.enlarged-card
.phonetic
{
.enlarged-card
.phonetic
{
font-size
:
24px
;
font-size
:
30px
;
color
:
#999
;
color
:
#999
;
margin-bottom
:
15px
;
margin-bottom
:
20px
;
font-style
:
italic
;
font-style
:
italic
;
}
}
.enlarged-card
.text-cn
{
.enlarged-card
.text-cn
{
font-size
:
28px
;
font-size
:
36px
;
}
}
.control-panel
{
.control-panel
{
...
...
play/index.js
View file @
8251d517
...
@@ -100,10 +100,31 @@ new Vue({
...
@@ -100,10 +100,31 @@ new Vue({
return
;
return
;
}
}
this
.
enlargedCard
=
{
...
item
};
this
.
enlargedCard
=
{
...
item
};
this
.
$nextTick
(()
=>
{
this
.
adjustFontSize
();
});
},
},
hideEnlargedCard
()
{
hideEnlargedCard
()
{
this
.
enlargedCard
=
null
;
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
)
{
playAudio
(
audioUrl
)
{
if
(
audioUrl
)
{
if
(
audioUrl
)
{
const
audio
=
new
Audio
(
audioUrl
);
const
audio
=
new
Audio
(
audioUrl
);
...
@@ -177,9 +198,11 @@ new Vue({
...
@@ -177,9 +198,11 @@ new Vue({
},
},
mounted
()
{
mounted
()
{
document
.
addEventListener
(
'
click
'
,
this
.
hideControlPanel
);
document
.
addEventListener
(
'
click
'
,
this
.
hideControlPanel
);
window
.
addEventListener
(
'
resize
'
,
this
.
adjustFontSize
);
},
},
beforeDestroy
()
{
beforeDestroy
()
{
document
.
removeEventListener
(
'
click
'
,
this
.
hideControlPanel
);
document
.
removeEventListener
(
'
click
'
,
this
.
hideControlPanel
);
window
.
removeEventListener
(
'
resize
'
,
this
.
adjustFontSize
);
},
},
watch
:
{
watch
:
{
hasWordCards
(
newValue
)
{
hasWordCards
(
newValue
)
{
...
...
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