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
d79f162b
Commit
d79f162b
authored
Oct 26, 2024
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug
parent
edc32703
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
159 additions
and
108 deletions
+159
-108
index.css
play/index.css
+40
-81
index.html
play/index.html
+30
-15
index.js
play/index.js
+89
-12
No files found.
play/index.css
View file @
d79f162b
...
...
@@ -169,108 +169,67 @@ body {
font-size
:
28px
;
}
.control-
switches
{
.control-
panel
{
position
:
fixed
;
left
:
20px
;
bottom
:
20px
;
display
:
flex
;
flex-direction
:
column
;
gap
:
5px
;
z-index
:
1001
;
/* 确保控制开关在放大卡片之上 */
background-color
:
rgba
(
0
,
0
,
0
,
0.5
);
padding
:
10px
;
border-radius
:
5px
;
z-index
:
1001
;
}
.switch-container
{
.gear-icon
{
cursor
:
pointer
;
background-color
:
rgba
(
255
,
255
,
255
,
0.8
);
padding
:
10px
;
border-radius
:
50%
;
width
:
50px
;
height
:
50px
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
justify-content
:
space-between
;
/* 使标签和开关分布在两端 */
width
:
100px
;
/* 设置固定宽度以确保对齐 */
}
.switch-label
{
margin-right
:
10px
;
color
:
#fff
;
font-weight
:
bold
;
text-shadow
:
1px
1px
2px
rgba
(
0
,
0
,
0
,
0.5
);
}
.el-switch
{
margin
:
0
;
/* 移除可能的默认边距 */
}
/* 可能需要覆盖 Element UI 的一些默认样式 */
.el-switch__label
{
position
:
absolute
;
display
:
none
;
}
.el-switch__label
*
{
font-size
:
14px
;
}
.el-switch__label--left
{
left
:
-5px
;
}
.el-switch__label--right
{
right
:
-5px
;
}
.el-switch__label.is-active
{
display
:
block
;
}
/* 根据开关状态控制文本显示 */
.word-card-content
.text-en
{
display
:
v-bind
(
showEnglish
?
'block'
:
'none'
);
}
.word-card-content
.text-cn
{
display
:
v-bind
(
showChinese
?
'block'
:
'none'
);
box-shadow
:
0
2px
12px
0
rgba
(
0
,
0
,
0
,
0.1
);
transition
:
all
0.3s
ease
;
}
/* 同样适用于放大的卡片 */
.enlarged-card
.text-en
{
display
:
v-bind
(
showEnglish
?
'block'
:
'none'
)
;
.gear-icon
i
{
font-size
:
30px
;
color
:
#409EFF
;
}
.enlarged-card
.text-cn
{
display
:
v-bind
(
showChinese
?
'block'
:
'none'
);
.control-content
{
position
:
fixed
;
left
:
20px
;
bottom
:
80px
;
background-color
:
rgba
(
255
,
255
,
255
,
0.6
);
/* 降低不透明度 */
backdrop-filter
:
blur
(
5px
);
/* 添加模糊效果 */
-webkit-backdrop-filter
:
blur
(
5px
);
/* 为 Safari 添加前缀 */
padding
:
10px
;
border-radius
:
5px
;
box-shadow
:
0
2px
12px
0
rgba
(
0
,
0
,
0
,
0.1
);
}
.word-card-content
>
div
,
.enlarged-card
>
div
{
.control-switches
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
}
.text-en
{
font-size
:
24px
;
font-weight
:
bold
;
margin-bottom
:
5px
;
}
.phonetic
{
font-size
:
16px
;
color
:
#666
;
margin-bottom
:
10px
;
gap
:
10px
;
}
.text-cn
{
font-size
:
20px
;
.switch-container
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
}
.enlarged-card
.text-en
{
font-size
:
36px
;
.switch-label
{
margin-right
:
10px
;
color
:
#333
;
/* 确保文字颜色足够深,以便在半透明背景上清晰可见 */
font-weight
:
500
;
/* 稍微加粗文字 */
}
.enlarged-card
.phonetic
{
font-size
:
24px
;
/* 为了确保开关本身清晰可见,我们可以给它添加一个微小的阴影 */
.el-switch
{
filter
:
drop-shadow
(
0
1px
2px
rgba
(
0
,
0
,
0
,
0.1
));
}
.
enlarged-card
.text-cn
{
font-size
:
28
px
;
.
search-input
{
width
:
300
px
;
}
play/index.html
View file @
d79f162b
...
...
@@ -14,6 +14,7 @@
<link
href=
"../lib/element-ui/theme-chalk/index.css"
rel=
"stylesheet"
>
<!-- 引入组件库 -->
<script
src=
"../lib/element-ui/index.js"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"
></script>
</head>
<body>
<div
class=
"play-data"
>
...
...
@@ -67,22 +68,36 @@
</div>
<!-- 全局语言切换控制 -->
<div
v-if=
"hasWordCards"
class=
"control-switches"
>
<div
class=
"switch-container"
>
<span
class=
"switch-label"
>
EN
</span>
<el-switch
v-model=
"showEnglish"
active-color=
"#13ce66"
inactive-color=
"#ff4949"
>
</el-switch>
<div
class=
"control-panel"
>
<div
class=
"gear-icon"
@
click
.
stop=
"toggleControlPanel"
v-show=
"!showControlPanel"
>
<i
class=
"el-icon-s-tools"
></i>
</div>
<div
class=
"switch-container"
>
<span
class=
"switch-label"
>
中
</span>
<el-switch
v-model=
"showChinese"
active-color=
"#13ce66"
inactive-color=
"#ff4949"
>
</el-switch>
<div
v-if=
"showControlPanel"
class=
"control-content"
@
click
.
stop
>
<template
v-if=
"hasWordCards"
>
<div
class=
"control-switches"
>
<div
class=
"switch-container"
>
<span
class=
"switch-label"
>
EN
</span>
<el-switch
v-model=
"showEnglish"
active-color=
"#13ce66"
inactive-color=
"#ff4949"
>
</el-switch>
</div>
<div
class=
"switch-container"
>
<span
class=
"switch-label"
>
中
</span>
<el-switch
v-model=
"showChinese"
active-color=
"#13ce66"
inactive-color=
"#ff4949"
>
</el-switch>
</div>
</div>
</template>
<template
v-else
>
<el-input
v-model=
"searchQuery"
placeholder=
"输入UID"
class=
"search-input"
>
<el-button
slot=
"append"
icon=
"el-icon-search"
@
click=
"searchWords"
>
查询
</el-button>
</el-input>
</template>
</div>
</div>
</div>
...
...
play/index.js
View file @
d79f162b
...
...
@@ -19,13 +19,23 @@ new Vue({
enlargedCard
:
null
,
showEnglish
:
true
,
showChinese
:
true
,
hasWordCards
:
false
,
// 添加这个属性
controlSwitchesVisible
:
false
,
showControlPanel
:
false
,
searchQuery
:
''
,
showGearIcon
:
true
,
}
},
computed
:
{
hasWordCards
()
{
return
this
.
currentRows
.
some
(
item
=>
item
.
text_cn
);
}
return
this
.
currentRows
.
some
(
row
=>
!!
row
.
text_cn
);
},
compDomain
()
{
const
protocolStr
=
document
.
location
.
protocol
;
if
(
document
.
domain
.
indexOf
(
"
staging
"
)
<
0
&&
document
.
domain
!=
'
localhost
'
)
{
return
`
${
protocolStr
}
//openapi.iteachabc.com/`
;
}
return
`
${
protocolStr
}
//staging-openapi.iteachabc.com/`
;
},
},
methods
:
{
loadRows
()
{
...
...
@@ -55,7 +65,7 @@ new Vue({
// 检查响应是否包含预期的数据
if
(
response
&&
response
.
rows
)
{
this
.
currentRows
=
response
.
rows
;
this
.
hasWordCards
=
this
.
currentRows
.
some
(
item
=>
item
.
text_cn
);
this
.
hasWordCards
=
this
.
currentRows
.
some
(
item
=>
!!
item
.
text_cn
);
// 添加当前项到面包屑
if
(
!
this
.
breadcrumb
.
find
(
breadcrumbItem
=>
breadcrumbItem
.
id
===
item
.
id
))
{
this
.
breadcrumb
.
push
(
item
);
...
...
@@ -73,9 +83,10 @@ new Vue({
},
jumpToBreadcrumb
(
index
)
{
if
(
index
===
-
1
)
{
// 点击"
首页
"
// 点击"
Home
"
this
.
currentRows
=
this
.
rows
;
this
.
breadcrumb
=
[];
this
.
hasWordCards
=
false
;
}
else
{
// 点击其他层级
const
item
=
this
.
breadcrumb
[
index
];
...
...
@@ -97,15 +108,81 @@ new Vue({
console
.
error
(
'
音频播放失败:
'
,
error
);
});
}
}
},
showControlSwitches
()
{
// 这是显示控制开关的方法
this
.
controlSwitchesVisible
=
true
;
},
hideControlSwitches
(
event
)
{
if
(
!
this
.
$refs
.
controlSwitches
&&
!
this
.
$refs
.
gearIcon
)
{
// 如果两个元素都不存在,直接返回
return
;
}
const
controlSwitchesEl
=
this
.
$refs
.
controlSwitches
;
const
gearIconEl
=
this
.
$refs
.
gearIcon
;
if
(
(
controlSwitchesEl
&&
!
controlSwitchesEl
.
contains
(
event
.
target
))
&&
(
gearIconEl
&&
!
gearIconEl
.
contains
(
event
.
target
))
)
{
this
.
controlSwitchesVisible
=
false
;
}
},
updateCurrentRows
(
newRows
)
{
this
.
currentRows
=
newRows
;
this
.
hasWordCards
=
this
.
currentRows
.
some
(
row
=>
!!
row
.
text_cn
);
if
(
this
.
hasWordCards
)
{
this
.
showControlPanel
=
false
;
// 确保进入单词卡时只显示齿轮
}
},
toggleControlPanel
()
{
this
.
showControlPanel
=
!
this
.
showControlPanel
;
},
hideControlPanel
(
event
)
{
if
(
!
this
.
$el
.
querySelector
(
'
.control-panel
'
).
contains
(
event
.
target
))
{
this
.
showControlPanel
=
false
;
}
},
searchWords
()
{
const
encodedUid
=
btoa
(
this
.
searchQuery
);
axios
.
get
(
`https://api.iplayabc.com/ciba/api/v1/word/reviews?daylimit=20&totallimit=100&uid=
${
encodedUid
}
`
)
.
then
(
response
=>
{
if
(
response
.
data
.
code
===
200
)
{
this
.
currentRows
=
response
.
data
.
rows
;
this
.
showControlPanel
=
false
;
this
.
breadcrumb
=
[{
text_en
:
'
Search Results
'
}];
}
else
{
this
.
$message
.
error
(
'
查询失败
'
);
}
})
.
catch
(
error
=>
{
console
.
error
(
'
Error:
'
,
error
);
this
.
$message
.
error
(
'
查询出错
'
);
});
},
},
computed
:
{
compDomain
:
function
()
{
const
protocolStr
=
document
.
location
.
protocol
;
if
(
document
.
domain
.
indexOf
(
"
staging
"
)
<
0
&&
document
.
domain
!=
'
localhost
'
)
{
return
`
${
protocolStr
}
//openapi.iteachabc.com/`
;
mounted
()
{
document
.
addEventListener
(
'
click
'
,
this
.
hideControlPanel
);
},
beforeDestroy
()
{
document
.
removeEventListener
(
'
click
'
,
this
.
hideControlPanel
);
},
watch
:
{
hasWordCards
(
newValue
)
{
if
(
newValue
)
{
document
.
addEventListener
(
'
click
'
,
this
.
hideControlSwitches
);
}
else
{
document
.
removeEventListener
(
'
click
'
,
this
.
hideControlSwitches
);
}
return
`
${
protocolStr
}
//staging-openapi.iteachabc.com/`
;
},
currentRows
:
{
handler
(
newRows
)
{
this
.
hasWordCards
=
newRows
.
some
(
row
=>
'
text_cn
'
in
row
);
},
deep
:
true
}
}
});
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