| | |
| | | <div class="resultBox" v-if="searchResult.length > 0"> |
| | | <div v-for="result in searchResult" :key="result.id"> |
| | | <div class="phone_con"> |
| | | <div class="per-phone">英 /<span>{{result.ukPhone}}</span>/</div> |
| | | <div class="per-phone">美 /<span>{{result.usPhone}}</span>/</div> |
| | | <div class="per-phone"> |
| | | 英 <span>/{{ result.ukPhone }}/</span |
| | | ><img |
| | | :src="sound" |
| | | class="soundBtn hover" |
| | | @click="soundWord(result.ukPhone)" |
| | | /> |
| | | </div> |
| | | <div class="per-phone"> |
| | | 美 <span>/{{ result.usPhone }}/</span |
| | | ><img |
| | | :src="sound" |
| | | class="soundBtn hover" |
| | | @click="soundWord(result.usPhone)" |
| | | /> |
| | | </div> |
| | | </div> |
| | | <div class="trans"> |
| | | <div v-for="item in result.trans" :key="item"> |
| | |
| | | <div class="title">例句</div> |
| | | <div v-for="(item,index) in result.sentence" :key="item"> |
| | | <div class="itemList1"> |
| | | <div class="pos"><span class="index">{{index +1}}</span>{{item.sContent}}</div> |
| | | <div class="pos"> |
| | | <span class="index">{{ index + 1 }}</span |
| | | >{{ item.sContent }} |
| | | </div> |
| | | <div class="tranCn">{{item.sCn}}</div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="noResultBox" v-else> |
| | | 暂无内容 |
| | | </div> |
| | | <div class="noResultBox" v-else>暂无内容</div> |
| | | </div> |
| | | </template> |
| | | <script setup lang="ts"> |
| | | import { ref, reactive, watch, onMounted, inject } from 'vue' |
| | | import sound from '@/assets/images/operation/sound.png' |
| | | const MG: any = inject('MG') |
| | | const searchContent = ref('') |
| | | const isFull = ref(false) |
| | | |
| | | onMounted(() => { |
| | | }) |
| | | onMounted(() => {}) |
| | | |
| | | const searchResult = ref([]) |
| | | |
| | | |
| | | const getSearchResult = () => { |
| | | if (searchContent.value) { |
| | | MG.edu.findWords([{ |
| | | MG.edu |
| | | .findWords([ |
| | | { |
| | | word: searchContent.value, |
| | | isFull: isFull.value |
| | | }]).then((res) => { |
| | | } |
| | | ]) |
| | | .then((res) => { |
| | | console.log(res) |
| | | if (res.length > 0) { |
| | | res[0].map((item) => { |
| | |
| | | }) |
| | | } |
| | | } |
| | | |
| | | const soundWord =(word)=>{ |
| | | window.speechSynthesis.cancel() |
| | | const synth = window.speechSynthesis |
| | | const utterances = new SpeechSynthesisUtterance(searchContent.value) |
| | | // utterances.lang = 'EN' // 设置语言为中文 |
| | | synth.speak(utterances) |
| | | |
| | | } |
| | | </script> |
| | | |
| | | <style lang="less"> |
| | | .page{ |
| | | height:100%; |
| | | overflow-y:auto |
| | | overflow-y: auto; |
| | | } |
| | | .search-Box { |
| | | width: 400px; |
| | | width: 90%; |
| | | margin: 0 auto; |
| | | .custom-input { |
| | | height: 40px; |
| | |
| | | padding:20px; |
| | | .phone_con{ |
| | | .per-phone{ |
| | | width:150px; |
| | | width: 200px; |
| | | align-items: center; |
| | | background: #f4f5f7; |
| | | border-radius: 15px; |
| | |
| | | font-weight: 500; |
| | | margin-right: 10px; |
| | | margin-top: 10px; |
| | | // max-width: 100%; |
| | | max-width: 100%; |
| | | padding: 8px 10px; |
| | | span{ |
| | | margin:0 10px; |
| | | flex: 1; |
| | | } |
| | | .soundBtn { |
| | | width: 18px; |
| | | height: 16px; |
| | | } |
| | | } |
| | | } |