@@ -21,6 +21,8 @@ import {useBaseStore} from "@/stores/base";
import Footer from "@/components/Practice/Footer.vue"
import { usePracticeStore } from "@/components/Practice/usePracticeStore.ts" ;
import { useEventListener } from "@/hooks/useEvent.ts" ;
import TypeWord from "@/components/Practice/TypeWord.vue" ;
import { emitter , EventKey } from "@/utils/eventBus.ts" ;
let article1 = ` How does the older investor differ in his approach to investment from the younger investor?
There is no shortage of tipsters around offering 'get-rich-quick' opportunities. But if you are a serious private investor, leave the Las Vegas mentality to those with money to fritter. The serious investor needs a proper 'portfolio' -- a well-planned selection of investments, with a definite structure and a clear aim. But exactly how does a newcomer to the stock market go about achieving that?
@@ -59,10 +61,11 @@ const practiceStore = usePracticeStore()
let isPlay = $ref ( false )
let articleWrapperRef = $ref < HTMLInputElement > ( null )
let section Index = $ref ( 0 )
let sentence Index = $ref ( 0 )
let word Index = $ref ( 6 )
let i ndex = $ref ( 0 )
let tab Index = $ref ( 0 )
let section Index = $ref ( 1 )
let sentence Index = $ref ( 2 )
let wordI ndex = $ref ( 4 )
let stringIndex = $ref ( 0 )
let input = $ref ( '' )
let wrong = $ref ( '' )
let isSpace = $ref ( false )
@@ -73,6 +76,11 @@ let hoverIndex = $ref({
sentenceIndex : 0 ,
} )
let wordData = $ref ( {
words : [ ] ,
index : - 1
} )
let article = reactive < Article > ( {
article : article1 ,
articleTranslate : ` 上星期我去看戏。我的座位很好,戏很有意思,但我却无法欣赏。一青年男子与一青年女子坐在我的身后,大声地说着话。我非常生气,因为我听不见演员在说什么。我回过头去,怒视着那一男一女,他们却毫不理会。最后,我忍不住了,又一次回过头去,生气地说,“我一个字也听不见了!”
@@ -148,12 +156,12 @@ function play() {
window . speechSynthesis . speak ( msg ) ;
}
const currentIndex = computed ( ( ) => {
return ` ${ sectionIndex } ${ sentenceIndex } ${ wordIndex } `
} )
function onKeyDown ( e : KeyboardEvent ) {
if ( tabIndex !== 0 ) return
// console.log('keyDown', e.key, e.code, e.keyCode)
wrong = ''
let currentSection = article . sections [ sectionIndex ]
@@ -163,12 +171,11 @@ function onKeyDown(e: KeyboardEvent) {
if ( isSpace ) {
if ( e . code === 'Space' ) {
isSpace = false
i ndex = 0
stringI ndex = 0
wordIndex ++
if ( ! store . skipWordNamesWithSimpleWords . includes ( currentWord . toLowerCase ( ) ) ) {
practiceStore . inputNumber ++
}
playCorrect ( )
if ( ! currentSentence . words [ wordIndex ] ) {
wordIndex = 0
@@ -212,22 +219,33 @@ function onKeyDown(e: KeyboardEvent) {
) {
let letter = e . key
let key = currentWord [ i ndex]
console. log ( 'key' , key , )
let key = currentWord [ stringI ndex]
// console.log('key', key,)
if ( key === letter ) {
input += letter
wrong = ''
console. log ( '匹配上了')
i ndex++
// console.log( '匹配上了')
stringI ndex++
//如果当前词没有index, 说明这个词完了, 下一个是空格
if ( ! currentWord [ i ndex] ) {
if ( ! currentWord [ stringI ndex] ) {
input = wrong = ''
isSpace = true
//但如果当前句子也没有index+1, 并且当前段也没sentenceIndex+1, 说明本段完了, 不需要打空格, 直接跳到下一段吧
if ( ! currentSentence . words [ wordIndex + 1 ] && ! currentSection [ sentenceIndex + 1 ] ) {
wordIndex = sentenceIndex = i ndex = 0
wordIndex = sentenceIndex = stringI ndex = 0
sectionIndex ++
isSpace = false
if ( ! article . sections [ sectionIndex ] ) {
console . log ( '文章打完了' )
//如果有错误单词,那么就滑动到单词界面复习
if ( practiceStore . wrongWords . length ) {
tabIndex = 1
wordData . words = cloneDeep ( practiceStore . wrongWords )
wordData . index = 0
} else {
emitter . emit ( EventKey . openStatModal )
}
}
}
}
} else {
@@ -255,7 +273,7 @@ function onKeyDown(e: KeyboardEvent) {
setTimeout ( ( ) => {
wrong = ''
} , 500 )
console. log ( '未匹配')
// console.log( '未匹配')
}
playKeySound ( )
} else {
@@ -285,7 +303,6 @@ function onKeyDown(e: KeyboardEvent) {
}
}
}
// console.log(
// 'sectionIndex', sectionIndex,
// 'sentenceIndex', sentenceIndex,
@@ -355,7 +372,7 @@ function otherWord(word: string, i: number, i2: number, i3: number) {
< template >
< div class = "type-wrapper" >
< div class = "swiper-wrapper content" >
< div class = "swiper-list" >
< div class = "swiper-list" :class = "`step${tabIndex}`" >
< div class = "swiper-item" >
< div class = "article-wrapper" ref = "articleWrapperRef" >
< article @click ="focus" >
@@ -376,7 +393,7 @@ function otherWord(word: string, i: number, i2: number, i3: number) {
?'wrote' :
(sectionIndex>=indexI &&sentenceIndex>=indexJ && wordIndex>indexW)
?'wrote':
(sectionIndex>=indexI &&sentenceIndex>=indexJ && wordIndex>=indexW && i ndex>=word.length)
(sectionIndex>=indexI &&sentenceIndex>=indexJ && wordIndex>=indexW && stringI ndex>=word.length)
?'wrote':
''),
(`${indexI}${indexJ}${indexW}` === currentIndex && !isSpace && wrong )?'word-wrong':'',
@@ -412,8 +429,11 @@ function otherWord(word: string, i: number, i2: number, i3: number) {
< / div >
< / div >
< div class = "swiper-item" >
<!-- < Type2-- >
<!-- / > -- >
< TypeWord
:words = "wordData.words"
:index = "wordData.index"
v-if = "tabIndex === 1"
/ >
< / div >
< / div >
< / div >
@@ -437,10 +457,11 @@ function otherWord(word: string, i: number, i2: number, i3: number) {
. content {
width : 1000 px ;
position : relative ;
}
. article - wrapper {
position : relative ;
article {
//height: 100%;
font - size : 24 rem ;
@@ -480,8 +501,7 @@ function otherWord(word: string, i: number, i2: number, i3: number) {
color : gray ;
line - height : 2.5 ;
letter - spacing : 3 rem ;
display: none ;
// display: none;
. row {
position : absolute ;
@@ -529,13 +549,17 @@ function otherWord(word: string, i: number, i2: number, i3: number) {
. swiper - list {
transition : transform .3 s ;
//transform: translate3d(0, -100%, 0);
height : 200 % ;
. swiper - item {
height : 50 % ;
overflow : auto ;
display : flex ;
}
}
. step1 {
transform : translate3d ( 0 , - 50 % , 0 ) ;
}
}
< / style >