save
This commit is contained in:
@@ -8,9 +8,11 @@ import AddArticle from "@/components/Practice/AddArticle.vue";
|
||||
import {useEventListener, useStartKeyboardEventListener} from "@/hooks/event.ts";
|
||||
import {emitter, EventKey} from "@/utils/eventBus.ts";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {useSettingStore} from "@/stores/setting.ts";
|
||||
|
||||
const store = useBaseStore()
|
||||
const runtimeStore = useRuntimeStore()
|
||||
const settingStore = useSettingStore()
|
||||
|
||||
// 查询当前系统主题颜色
|
||||
const match: MediaQueryList = window.matchMedia("(prefers-color-scheme: dark)")
|
||||
@@ -31,8 +33,8 @@ useStartKeyboardEventListener()
|
||||
|
||||
onMounted(() => {
|
||||
store.init()
|
||||
if (store.theme !== 'auto') {
|
||||
document.documentElement.setAttribute('data-theme', store.theme)
|
||||
if (settingStore.theme !== 'auto') {
|
||||
document.documentElement.setAttribute('data-theme', settingStore.theme)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -58,8 +58,9 @@ watch(() => store.load, n => {
|
||||
})
|
||||
|
||||
function getCurrentPractice() {
|
||||
console.log('store.currentDict',store.currentDict)
|
||||
if (store.isArticle) {
|
||||
return
|
||||
// return
|
||||
let tempArticle = {...DefaultArticle, ...store.currentDict.articles[store.currentDict.chapterIndex]}
|
||||
console.log('article', tempArticle)
|
||||
if (tempArticle.sections.length) {
|
||||
|
||||
@@ -7,22 +7,24 @@ import {usePracticeStore} from "@/stores/practice.ts";
|
||||
import TypeWord from "@/components/Practice/TypeWord.vue";
|
||||
import {useSettingStore} from "@/stores/setting.ts";
|
||||
import {usePlayBeep, usePlayCorrect, usePlayKeyboardAudio, usePlayWordAudio} from "@/hooks/sound.ts";
|
||||
import {useEventListener, useOnKeyboardEventListener} from "@/hooks/event.ts";
|
||||
import {useOnKeyboardEventListener} from "@/hooks/event.ts";
|
||||
import {cloneDeep} from "lodash-es";
|
||||
|
||||
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?
|
||||
Well, if you go to five reputable stock brokers and ask them what you should do with your money, you're likely to get five different answers, -- even if you give all the relevant information about your age age, family, finances and what you want from your investments. Moral? There is no one 'right' way to structure a portfolio. However, there are undoubtedly some wrong ways, and you can be sure that none of our five advisers would have suggested sinking all (or perhaps any) of your money into Periwigs*.
|
||||
So what should you do? We'll assume that you have sorted out the basics -- like mortgages, pensions, insurance and access to sufficient cash reserves. You should then establish your own individual aims. These are partly a matter of personal circumstances, partly a matter of psychology.
|
||||
For instance, if you are older you have less time to recover from any major losses, and you may well wish to boost your pension income. So preserving your capital and generating extra income are your main priorities. In this case, you'd probably construct a portfolio with some shares (but not high risk ones), along with gilts, cash deposits, and perhaps convertibles or the income shares of split capital investment trusts.
|
||||
If you are younger, and in a solid financial position, you may decide to take an aggressive approach -- but only if you're blessed with a sanguine disposition and won't suffer sleepless nights over share prices. If portfolio, alongside your more pedestrian in vestments. Once you have decided on your investment aims, you can then decide where to put your money. The golden rule here is spread your risk -- if you put all of your money into Periwigs International, you're setting yourself up as a hostage to fortune.
|
||||
*'Periwigs' is the name of a fictitious company.
|
||||
INVESTOR'S CHRONICLE, March 23 1990`
|
||||
interface IProps {
|
||||
article: Article,
|
||||
sectionIndex: number,
|
||||
sentenceIndex: number,
|
||||
wordIndex: number,
|
||||
stringIndex: number,
|
||||
}
|
||||
|
||||
article1 = `How does the older investor differ in his approach to investment from the younger investor?`
|
||||
article1 = `Last week I went to the theatre. I had a very good seat. The play was very interesting. I did not enjoy it. A young man and a young woman were sitting behind me. They were talking loudly. I got very angry. I could not hear the actors. I turned round. I looked at the man and the woman angrily. They did not pay any attention. In the end, I could not bear it. I turned round again. ‘I can't hear a word!’ I said angrily.
|
||||
‘It's none of your business, ’ the young man said rudely. ‘This is a private conversation!’`
|
||||
// article1 = `Last week I went to the theatre. I had a very good seat. The play was very interesting. I did not enjoy it.`
|
||||
const props = withDefaults(defineProps<IProps>(), {
|
||||
article: () => cloneDeep(DefaultArticle),
|
||||
sectionIndex: 0,
|
||||
sentenceIndex: 0,
|
||||
wordIndex: 0,
|
||||
stringIndex: 0,
|
||||
})
|
||||
|
||||
const playBeep = usePlayBeep()
|
||||
const playCorrect = usePlayCorrect()
|
||||
@@ -46,28 +48,14 @@ let hoverIndex = $ref({
|
||||
sectionIndex: -1,
|
||||
sentenceIndex: -1,
|
||||
})
|
||||
|
||||
const currentIndex = computed(() => {
|
||||
return `${sectionIndex}${sentenceIndex}${wordIndex}`
|
||||
})
|
||||
let wordData = $ref({
|
||||
words: [],
|
||||
index: -1
|
||||
})
|
||||
|
||||
interface IProps {
|
||||
article: Article,
|
||||
sectionIndex: number,
|
||||
sentenceIndex: number,
|
||||
wordIndex: number,
|
||||
stringIndex: number,
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<IProps>(), {
|
||||
article: () => cloneDeep(DefaultArticle),
|
||||
sectionIndex: 0,
|
||||
sentenceIndex: 0,
|
||||
wordIndex: 0,
|
||||
stringIndex: 0,
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
sectionIndex = props.sectionIndex
|
||||
sentenceIndex = props.sentenceIndex
|
||||
@@ -118,13 +106,13 @@ function calcTranslateLocation() {
|
||||
}
|
||||
|
||||
function play() {
|
||||
return playWordAudio(article1)
|
||||
return playWordAudio('article1')
|
||||
if (isPlay) {
|
||||
isPlay = false
|
||||
return window.speechSynthesis.pause();
|
||||
}
|
||||
let msg = new SpeechSynthesisUtterance();
|
||||
msg.text = article1
|
||||
msg.text = 'article1'
|
||||
msg.rate = 0.5;
|
||||
msg.pitch = 1;
|
||||
msg.lang = 'en-US';
|
||||
@@ -133,10 +121,6 @@ function play() {
|
||||
window.speechSynthesis.speak(msg);
|
||||
}
|
||||
|
||||
const currentIndex = computed(() => {
|
||||
return `${sectionIndex}${sentenceIndex}${wordIndex}`
|
||||
})
|
||||
|
||||
function onKeyDown(e: KeyboardEvent) {
|
||||
if (tabIndex !== 0) return
|
||||
if (!props.article.sections.length) return
|
||||
@@ -169,6 +153,28 @@ function onKeyDown(e: KeyboardEvent) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const nextSentence = () => {
|
||||
isSpace = false
|
||||
stringIndex = 0
|
||||
wordIndex = 0
|
||||
|
||||
//todo 计得把略过的单词加上统计里面去
|
||||
// if (!store.skipWordNamesWithSimpleWords.includes(currentWord.name.toLowerCase()) && !currentWord.isSymbol) {
|
||||
// practiceStore.inputNumber++
|
||||
// }
|
||||
|
||||
sentenceIndex++
|
||||
if (!currentSection[sentenceIndex]) {
|
||||
sentenceIndex = 0
|
||||
sectionIndex++
|
||||
} else {
|
||||
if (settingStore.dictation) {
|
||||
calcTranslateLocation()
|
||||
}
|
||||
playWordAudio(currentSection[sentenceIndex].text)
|
||||
}
|
||||
}
|
||||
//非英文模式下,输入区域的 keyCode 均为 229时,
|
||||
if ((e.keyCode >= 65 && e.keyCode <= 90)
|
||||
|| (e.keyCode >= 48 && e.keyCode <= 57)
|
||||
@@ -263,10 +269,9 @@ function onKeyDown(e: KeyboardEvent) {
|
||||
|
||||
break
|
||||
case ShortKeyMap.Remove:
|
||||
|
||||
break
|
||||
case ShortKeyMap.Ignore:
|
||||
|
||||
nextSentence()
|
||||
break
|
||||
case ShortKeyMap.Show:
|
||||
if (settingStore.allowWordTip) {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import {useBaseStore} from "@/stores/base.ts";
|
||||
import {useSettingStore} from "@/stores/setting.ts";
|
||||
|
||||
export default function useTheme() {
|
||||
const store = useBaseStore()
|
||||
const settingStore = useSettingStore()
|
||||
|
||||
function toggle() {
|
||||
if (store.theme === 'auto') {
|
||||
store.theme = 'dark'
|
||||
if (settingStore.theme === 'auto') {
|
||||
settingStore.theme = 'dark'
|
||||
} else {
|
||||
store.theme = store.theme === 'light' ? 'dark' : 'light'
|
||||
settingStore.theme = settingStore.theme === 'light' ? 'dark' : 'light'
|
||||
}
|
||||
document.documentElement.setAttribute('data-theme', store.theme)
|
||||
document.documentElement.setAttribute('data-theme', settingStore.theme)
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -76,25 +76,28 @@ export const useBaseStore = defineStore('base', {
|
||||
statistics: [],
|
||||
url: '/articles/NCE_2.json',
|
||||
},
|
||||
oldDicts: [],
|
||||
myDicts: [
|
||||
{
|
||||
name: '新概念英语-2',
|
||||
sort: Sort.normal,
|
||||
type: DictType.publicArticle,
|
||||
originWords: [],
|
||||
articles: [],
|
||||
words: [],
|
||||
chapterWordNumber: 15,
|
||||
chapterWords: [],
|
||||
chapterIndex: 0,
|
||||
chapterWordIndex: 0,
|
||||
statistics: [],
|
||||
url: '/articles/NCE_2.json',
|
||||
}
|
||||
],
|
||||
current: {
|
||||
dictType: DictType.publicArticle,
|
||||
words: [],
|
||||
index: -1,
|
||||
wrongWords: [],
|
||||
originWrongWords: [],
|
||||
index: 0,
|
||||
repeatNumber: 0,
|
||||
statistics: {
|
||||
startDate: -1,
|
||||
endDate: -1,
|
||||
spend: -1,
|
||||
total: -1,
|
||||
correctRate: -1,
|
||||
wrongWordNumber: -1,
|
||||
}
|
||||
},
|
||||
sideIsOpen: false,
|
||||
isDictation: true,
|
||||
simpleWords: [
|
||||
'a', 'an', 'of', 'and',
|
||||
'i', 'my', 'you', 'your',
|
||||
@@ -103,7 +106,6 @@ export const useBaseStore = defineStore('base', {
|
||||
'not', 'did', 'were', 'can', 'could', 'it',
|
||||
'the', 'to'
|
||||
],
|
||||
theme: 'auto',
|
||||
load: false
|
||||
}
|
||||
},
|
||||
@@ -115,7 +117,10 @@ export const useBaseStore = defineStore('base', {
|
||||
return state.skipWordDict.originWords.map(v => v.name.toLowerCase()).concat(state.simpleWords)
|
||||
},
|
||||
isArticle(state: State): boolean {
|
||||
return [DictType.publicArticle, DictType.customArticle].includes(state.current.dictType)
|
||||
return [
|
||||
DictType.publicArticle,
|
||||
DictType.customArticle
|
||||
].includes(state.current.dictType)
|
||||
},
|
||||
currentDict(state: State): Dict {
|
||||
switch (state.current.dictType) {
|
||||
@@ -128,7 +133,8 @@ export const useBaseStore = defineStore('base', {
|
||||
case DictType.publicDict:
|
||||
case DictType.publicArticle:
|
||||
case DictType.customDict:
|
||||
return state.dict
|
||||
case DictType.customArticle:
|
||||
return this.myDicts[this.current.index]
|
||||
}
|
||||
},
|
||||
wordIndex(state: State): number {
|
||||
@@ -137,13 +143,9 @@ export const useBaseStore = defineStore('base', {
|
||||
chapter(state: State): Word[] {
|
||||
return this.currentDict.chapterWords[this.currentDict.chapterIndex] ?? []
|
||||
},
|
||||
//TODO 废弃
|
||||
word(state: State): Word {
|
||||
return state.current.words[state.current.index] ?? {
|
||||
trans: [],
|
||||
name: '',
|
||||
usphone: '',
|
||||
ukphone: '',
|
||||
}
|
||||
return {trans: [], name: '', usphone: '', ukphone: '',}
|
||||
},
|
||||
dictTitle(state: State) {
|
||||
let title = this.currentDict.name
|
||||
@@ -160,52 +162,47 @@ export const useBaseStore = defineStore('base', {
|
||||
}
|
||||
// console.log('this/', this)
|
||||
},
|
||||
setCurrentWord(words: Word[], restart: boolean = false, index: number = 0) {
|
||||
this.current.words = cloneDeep(words)
|
||||
if (restart) {
|
||||
this.current.repeatNumber = 0
|
||||
this.current.originWrongWords = []
|
||||
this.current.statistics = {
|
||||
startDate: Date.now(),
|
||||
endDate: -1,
|
||||
spend: -1,
|
||||
wordNumber: words.length,
|
||||
correctRate: -1,
|
||||
wrongWordNumber: -1,
|
||||
}
|
||||
} else {
|
||||
this.current.repeatNumber++
|
||||
if (!this.current.originWrongWords.length) {
|
||||
this.current.originWrongWords = cloneDeep(this.current.wrongWords)
|
||||
}
|
||||
this.current.statistics.correctRate = -1
|
||||
this.current.statistics.wrongWordNumber = -1
|
||||
}
|
||||
this.current.index = index
|
||||
this.current.wrongWords = []
|
||||
},
|
||||
async init() {
|
||||
// let configStr = localStorage.getItem(SaveKey)
|
||||
// if (configStr) {
|
||||
// let obj: Config = JSON.parse(configStr)
|
||||
// this.setState(obj)
|
||||
// }
|
||||
if (this.current.dictType === DictType.publicDict) {
|
||||
let r = await fetch(`/public/${this.dict.url}`)
|
||||
r.json().then(v => {
|
||||
this.dict.originWords = cloneDeep(v)
|
||||
this.dict.words = cloneDeep(v)
|
||||
this.dict.chapterWords = chunk(this.dict.words, this.dict.chapterWordNumber)
|
||||
this.setCurrentWord(this.chapter, true)
|
||||
this.load = true
|
||||
})
|
||||
}
|
||||
if (this.current.dictType === DictType.publicArticle) {
|
||||
let r = await fetch(`/public/${this.dict.url}`)
|
||||
r.json().then(v => {
|
||||
this.dict.articles = cloneDeep(v)
|
||||
this.load = true
|
||||
})
|
||||
|
||||
if ([
|
||||
DictType.newDict,
|
||||
DictType.wrongDict,
|
||||
DictType.skipDict,
|
||||
].includes(this.current.dictType)) {
|
||||
|
||||
} else {
|
||||
if ([
|
||||
DictType.publicDict,
|
||||
DictType.customDict,
|
||||
].includes(this.current.dictType)) {
|
||||
if (!this.currentDict.originWords.length) {
|
||||
let r = await fetch(`/public/${this.dict.url}`)
|
||||
r.json().then(v => {
|
||||
this.currentDict.originWords = cloneDeep(v)
|
||||
this.currentDict.words = cloneDeep(v)
|
||||
this.currentDict.chapterWords = chunk(this.dict.words, this.dict.chapterWordNumber)
|
||||
this.load = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if ([
|
||||
DictType.publicArticle,
|
||||
DictType.customArticle,
|
||||
].includes(this.current.dictType)) {
|
||||
if (!this.currentDict.articles.length) {
|
||||
let r = await fetch(`/public/${this.dict.url}`)
|
||||
r.json().then(v => {
|
||||
this.currentDict.articles = cloneDeep(v)
|
||||
this.load = true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
saveStatistics(statistics: Statistics) {
|
||||
@@ -234,7 +231,6 @@ export const useBaseStore = defineStore('base', {
|
||||
this.dict.chapterIndex = chapterIndex
|
||||
this.dict.chapterWordIndex = chapterWordIndex
|
||||
}
|
||||
this.setCurrentWord(this.chapter, true, chapterWordIndex)
|
||||
emitter.emit(EventKey.resetWord)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface SettingState {
|
||||
wordTranslateFontSize: number,
|
||||
},
|
||||
|
||||
theme: string,
|
||||
}
|
||||
|
||||
export const useSettingStore = defineStore('setting', {
|
||||
@@ -65,6 +66,7 @@ export const useSettingStore = defineStore('setting', {
|
||||
},
|
||||
waitTimeForChangeWord: 300,
|
||||
|
||||
theme: 'auto',
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -195,20 +195,14 @@ export interface State {
|
||||
skipWordDict: Dict,
|
||||
wrongWordDict: Dict,
|
||||
dict: Dict,
|
||||
oldDicts: Dict[],
|
||||
myDicts: Dict[],
|
||||
current: {
|
||||
dictType: DictType,
|
||||
words: Word[],
|
||||
index: number,
|
||||
wrongWords: Word[],
|
||||
originWrongWords: Word[],
|
||||
repeatNumber: number,
|
||||
statistics: Statistics
|
||||
},
|
||||
simpleWords: string[],
|
||||
sideIsOpen: boolean,
|
||||
isDictation: boolean,
|
||||
theme: string,
|
||||
load: boolean
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user