File tree Expand file tree Collapse file tree 3 files changed +25
-9
lines changed
Expand file tree Collapse file tree 3 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,16 @@ export function usePlayWordAudio() {
116116 return playAudio
117117}
118118
119+ function getVoicesAsync ( ) {
120+ return new Promise ( resolve => {
121+ const voices = speechSynthesis . getVoices ( )
122+ if ( voices . length ) return resolve ( voices )
123+
124+ speechSynthesis . onvoiceschanged = ( ) => {
125+ resolve ( speechSynthesis . getVoices ( ) )
126+ }
127+ } )
128+ }
119129export function useTTsPlayAudio ( ) {
120130 const settingStore = useSettingStore ( )
121131
@@ -126,11 +136,13 @@ export function useTTsPlayAudio() {
126136 msg . volume = settingStore . wordSoundVolume / 100
127137 msg . pitch = 1
128138 msg . lang = 'en-US'
129- let voiceList = speechSynthesis . getVoices ( ) . filter ( v => v . lang === 'en-US' )
130- if ( voiceList && voiceList . length ) {
131- msg . voice = voiceList . find ( v => v . name . includes ( 'Emma ' ) ) || voiceList [ 0 ]
132- }
133- speechSynthesis . speak ( msg )
139+ getVoicesAsync ( ) . then ( voices => {
140+ let voiceList = voices . filter ( v => v . lang === 'en-US' )
141+ if ( voiceList && voiceList . length ) {
142+ msg . voice = voiceList . find ( v => v . name . includes ( 'Emma' ) || v . name . includes ( 'US' ) ) ?? voiceList [ 0 ]
143+ }
144+ speechSynthesis . speak ( msg )
145+ } )
134146 }
135147
136148 return play
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { getDefaultDict } from '../types'
44import { _getStudyProgress , checkAndUpgradeSaveDict } from '../utils'
55import { shallowReactive } from 'vue'
66import { get } from 'idb-keyval'
7- import { AppEnv , DictId , SAVE_DICT_KEY } from '../config/env'
7+ import { AppEnv , DictId , IS_DEV , SAVE_DICT_KEY } from '../config/env'
88import { add2MyDict , dictListVersion , myDictList } from '../apis'
99import { Toast } from '@typewords/base'
1010import type { Card } from 'ts-fsrs'
@@ -169,7 +169,13 @@ export const useBaseStore = defineStore('base', {
169169 } )
170170 //必须先 reset, 只 $patch 无法将 state 恢复到默认值
171171 this . $reset ( )
172- this . $patch ( obj )
172+ console . time ( '$patch' )
173+ if ( IS_DEV ) {
174+ this . $state = obj
175+ } else {
176+ this . $patch ( obj )
177+ }
178+ console . timeEnd ( '$patch' )
173179 } ,
174180 async init ( ) {
175181 return new Promise ( async resolve => {
Original file line number Diff line number Diff line change @@ -33,13 +33,11 @@ export function useEventsByWatch(arrs: any[], watchVal: any) {
3333 watch (
3434 watchVal ,
3535 newVal => {
36- console . log ( 'watch' , newVal )
3736 if ( newVal ) {
3837 arrs . map ( arr => emitter . on ( arr [ 0 ] , arr [ 1 ] ) )
3938 } else {
4039 arrs . map ( arr => emitter . off ( arr [ 0 ] , arr [ 1 ] ) )
4140 }
42- console . log ( 'emitter-all' , emitter . all )
4341 } ,
4442 {
4543 immediate : true ,
You can’t perform that action at this time.
0 commit comments