This commit is contained in:
zyronon
2023-10-17 01:53:33 +08:00
parent e229a1dee0
commit ef486c545c
4 changed files with 332556 additions and 161593 deletions

51
format.cjs Normal file
View File

@@ -0,0 +1,51 @@
const { log } = require('console');
const fs = require('fs');
try {
const str = fs.readFileSync('./public/dicts/coca20000.json', 'utf8');
let dicts = JSON.parse(str)
console.log(dicts[0]);
let a = [
'n.',
'v.',
'vt.& vi.',
'pron.',
'adj.',
'adv.',
'num.',
'interj.',
'art.',
'aux.',
'conj.',
'prep.',
]
dicts.map(v => {
v.trans = v.trans.map(s => {
s = s.replaceAll(',', "")
a.map(b => {
s = s.replaceAll(b, `${b}`)
})
if (s[0] === '') {
s = s.substr(1)
}
let c = [
'vt.',
'vi.',
]
s = s.split('').filter(v => v)
return s
})
v.trans = v.trans.flat()
return v
})
// console.log(dicts);
fs.writeFileSync('./public/dicts/coca20000.json', JSON.stringify(dicts, null, 2));
} catch (err) {
console.error(err);
}

File diff suppressed because it is too large Load Diff

161571
public/dicts/coca20000_old.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -75,7 +75,19 @@ watch(() => data.index, (n) => {
}
})
let allList = $ref([])
const word = $computed(() => {
let w = data.words[data.index]
let s = allList.find(s => s.name === w.name)
if (s) return s
else return w ?? {
trans: [],
name: '',
usphone: '',
ukphone: '',
}
return data.words[data.index] ?? {
trans: [],
name: '',
@@ -96,10 +108,17 @@ let resetWord = $computed(() => {
return word.name.slice(input.length + wrong.length)
})
onMounted(() => {
emitter.on(EventKey.resetWord, () => {
wrong = input = ''
})
fetch('./dicts/coca20000.json').then(r => {
r.json().then(v => {
console.log('v', v)
allList = v
})
})
})
function next(isTyping: boolean = true) {
@@ -314,7 +333,8 @@ useOnKeyboardEventListener(onKeyDown, onKeyUp)
fontSize: settingStore.fontSize.wordTranslateFontSize +'rem',
opacity: settingStore.translate ? 1 : 0
}"
>{{ word.trans.join('') }}
>
<div v-for="i in word.trans">{{i}}</div>
</div>
<div class="word-wrapper">
<div class="word"