Commit d79f162b authored by liujiangnan's avatar liujiangnan

debug

parent edc32703
...@@ -169,108 +169,67 @@ body { ...@@ -169,108 +169,67 @@ body {
font-size: 28px; font-size: 28px;
} }
.control-switches { .control-panel {
position: fixed; position: fixed;
left: 20px; left: 20px;
bottom: 20px; bottom: 20px;
display: flex; z-index: 1001;
flex-direction: column;
gap: 5px;
z-index: 1001; /* 确保控制开关在放大卡片之上 */
background-color: rgba(0, 0, 0, 0.5);
padding: 10px;
border-radius: 5px;
} }
.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; display: flex;
justify-content: center;
align-items: center; align-items: center;
justify-content: space-between; /* 使标签和开关分布在两端 */ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
width: 100px; /* 设置固定宽度以确保对齐 */ transition: all 0.3s ease;
}
.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');
} }
/* 同样适用于放大的卡片 */ .gear-icon i {
.enlarged-card .text-en { font-size: 30px;
display: v-bind(showEnglish ? 'block' : 'none'); color: #409EFF;
} }
.enlarged-card .text-cn { .control-content {
display: v-bind(showChinese ? 'block' : 'none'); 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, .control-switches {
.enlarged-card > div {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; gap: 10px;
}
.text-en {
font-size: 24px;
font-weight: bold;
margin-bottom: 5px;
}
.phonetic {
font-size: 16px;
color: #666;
margin-bottom: 10px;
} }
.text-cn { .switch-container {
font-size: 20px; display: flex;
align-items: center;
justify-content: space-between;
} }
.enlarged-card .text-en { .switch-label {
font-size: 36px; 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 { .search-input {
font-size: 28px; width: 300px;
} }
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<link href="../lib/element-ui/theme-chalk/index.css" rel="stylesheet"> <link href="../lib/element-ui/theme-chalk/index.css" rel="stylesheet">
<!-- 引入组件库 --> <!-- 引入组件库 -->
<script src="../lib/element-ui/index.js"></script> <script src="../lib/element-ui/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head> </head>
<body> <body>
<div class="play-data"> <div class="play-data">
...@@ -67,7 +68,13 @@ ...@@ -67,7 +68,13 @@
</div> </div>
<!-- 全局语言切换控制 --> <!-- 全局语言切换控制 -->
<div v-if="hasWordCards" class="control-switches"> <div class="control-panel">
<div class="gear-icon" @click.stop="toggleControlPanel" v-show="!showControlPanel">
<i class="el-icon-s-tools"></i>
</div>
<div v-if="showControlPanel" class="control-content" @click.stop>
<template v-if="hasWordCards">
<div class="control-switches">
<div class="switch-container"> <div class="switch-container">
<span class="switch-label">EN</span> <span class="switch-label">EN</span>
<el-switch <el-switch
...@@ -85,6 +92,14 @@ ...@@ -85,6 +92,14 @@
</el-switch> </el-switch>
</div> </div>
</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> </div>
</body> </body>
<script src="./index.js"></script> <script src="./index.js"></script>
......
...@@ -19,13 +19,23 @@ new Vue({ ...@@ -19,13 +19,23 @@ new Vue({
enlargedCard: null, enlargedCard: null,
showEnglish: true, showEnglish: true,
showChinese: true, showChinese: true,
hasWordCards: false, // 添加这个属性 controlSwitchesVisible: false,
showControlPanel: false,
searchQuery: '',
showGearIcon: true,
} }
}, },
computed: { computed: {
hasWordCards() { 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: { methods: {
loadRows() { loadRows() {
...@@ -55,7 +65,7 @@ new Vue({ ...@@ -55,7 +65,7 @@ new Vue({
// 检查响应是否包含预期的数据 // 检查响应是否包含预期的数据
if (response && response.rows) { if (response && response.rows) {
this.currentRows = 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)) { if (!this.breadcrumb.find(breadcrumbItem => breadcrumbItem.id === item.id)) {
this.breadcrumb.push(item); this.breadcrumb.push(item);
...@@ -73,9 +83,10 @@ new Vue({ ...@@ -73,9 +83,10 @@ new Vue({
}, },
jumpToBreadcrumb(index) { jumpToBreadcrumb(index) {
if (index === -1) { if (index === -1) {
// 点击"首页" // 点击"Home"
this.currentRows = this.rows; this.currentRows = this.rows;
this.breadcrumb = []; this.breadcrumb = [];
this.hasWordCards = false;
} else { } else {
// 点击其他层级 // 点击其他层级
const item = this.breadcrumb[index]; const item = this.breadcrumb[index];
...@@ -97,15 +108,81 @@ new Vue({ ...@@ -97,15 +108,81 @@ new Vue({
console.error('音频播放失败:', error); 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;
} }
}, },
computed: {
compDomain: function () { updateCurrentRows(newRows) {
const protocolStr = document.location.protocol; this.currentRows = newRows;
if (document.domain.indexOf("staging") < 0 && document.domain != 'localhost') { this.hasWordCards = this.currentRows.some(row => !!row.text_cn);
return `${protocolStr}//openapi.iteachabc.com/`; if (this.hasWordCards) {
this.showControlPanel = false; // 确保进入单词卡时只显示齿轮
} }
return `${protocolStr}//staging-openapi.iteachabc.com/`;
}, },
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('查询出错');
});
},
},
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);
}
},
currentRows: {
handler(newRows) {
this.hasWordCards = newRows.some(row => 'text_cn' in row);
},
deep: true
}
} }
}); });
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