Fast keys & Bug fixes

master
cast1e 2023-12-20 14:33:29 +08:00
parent 3671f3f668
commit aa6c1bf9f9
6 changed files with 103 additions and 46 deletions

14
package-lock.json generated
View File

@ -14,7 +14,8 @@
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"node-uuid": "^1.4.8", "node-uuid": "^1.4.8",
"vue": "^3.2.13", "vue": "^3.2.13",
"vue-router": "^4.2.5" "vue-router": "^4.2.5",
"vuex": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.16", "@babel/core": "^7.12.16",
@ -10974,6 +10975,17 @@
"integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==",
"dev": true "dev": true
}, },
"node_modules/vuex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-4.1.0.tgz",
"integrity": "sha512-hmV6UerDrPcgbSy9ORAtNXDr9M4wlNP4pEFKye4ujJF8oqgFFuxDCdOLS3eNoRTtq5O3hoBDh9Doj1bQMYHRbQ==",
"dependencies": {
"@vue/devtools-api": "^6.0.0-beta.11"
},
"peerDependencies": {
"vue": "^3.2.0"
}
},
"node_modules/warning": { "node_modules/warning": {
"version": "4.0.3", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz", "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",

View File

@ -14,7 +14,8 @@
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"node-uuid": "^1.4.8", "node-uuid": "^1.4.8",
"vue": "^3.2.13", "vue": "^3.2.13",
"vue-router": "^4.2.5" "vue-router": "^4.2.5",
"vuex": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.16", "@babel/core": "^7.12.16",

View File

@ -127,8 +127,26 @@ export default {
key_listener(e) { key_listener(e) {
if (this.mode === 1) { if (this.mode === 1) {
let ctrlKey = e.ctrlKey || e.metaKey; let ctrlKey = e.ctrlKey || e.metaKey;
if (ctrlKey && e.key === 'b') { if (ctrlKey) {
switch (e.key) {
case 'b':
this.showAnswer(); this.showAnswer();
break;
case 'm':
this.skip();
break;
case 'i':
this.add_to();
break;
case 'ArrowLeft':
this.prev();
break;
case 'ArrowRight':
this.next();
break;
default:
return;
}
} }
e.preventDefault(); e.preventDefault();
return; return;
@ -179,7 +197,6 @@ export default {
onlineSets: this.online.checkedSets, onlineSets: this.online.checkedSets,
seed: seed seed: seed
})) }))
console.log(this.testWords);
this.total = this.testWords.length; this.total = this.testWords.length;
if (this.total === 0) { if (this.total === 0) {
ElMessage({ ElMessage({
@ -265,6 +282,7 @@ export default {
}); });
}, },
next() { next() {
if (this.current < this.answered) {
this.current++; this.current++;
if (this.current === this.total) { if (this.current === this.total) {
this.mode = 0; this.mode = 0;
@ -278,6 +296,11 @@ export default {
nextTick(() => { nextTick(() => {
this.show(); this.show();
}); });
}
else ElMessage({
type:"error",
message:"您还未答过该词,跳过请使用ctrl+M",
})
}, },
skip() { skip() {
ElMessage({ ElMessage({
@ -290,8 +313,14 @@ export default {
return; return;
}, },
prev() { prev() {
if(this.current>0){
this.current--; this.current--;
this.show(); this.show();
}
else ElMessage({
type:'error',
message:"已经是第一个单词"
})
}, },
showAnswer() { showAnswer() {
ElMessage(`答案:${this.word.word}`); ElMessage(`答案:${this.word.word}`);
@ -332,7 +361,10 @@ export default {
o += "_".repeat(this.word.word.length - n)); o += "_".repeat(this.word.word.length - n));
e.value = o; e.value = o;
e.setSelectionRange(n, n); e.setSelectionRange(n, n);
e.style.height = 0;
setTimeout(() => {
e.style.height = `${e.scrollHeight}px`; e.style.height = `${e.scrollHeight}px`;
}, 0);
e.focus(); e.focus();
}, },
audio_play() { audio_play() {
@ -354,6 +386,7 @@ export default {
this.$router.push("/"); this.$router.push("/");
}, },
add_to() { add_to() {
if (this.set_id) {
let data = JSON.parse(localStorage.getItem(this.set_id)); let data = JSON.parse(localStorage.getItem(this.set_id));
for (let i of data) { for (let i of data) {
if (i.word === this.word.word) { if (i.word === this.word.word) {
@ -370,6 +403,11 @@ export default {
message: `已添加 ${this.word.word} (${this.word.type})`, message: `已添加 ${this.word.word} (${this.word.type})`,
type: 'success', type: 'success',
}); });
}
else ElMessage({
message: '请先选择单词本',
type: 'error',
})
return; return;
}, },
}, },
@ -390,7 +428,6 @@ export default {
return; return;
} }
this.online_sets = res.data; this.online_sets = res.data;
console.log(this.online_sets);
for (let i in this.online_sets) { for (let i in this.online_sets) {
for (let j in this.online_sets[i]) { for (let j in this.online_sets[i]) {
for (let k in this.online_sets[i][j]) { for (let k in this.online_sets[i][j]) {

View File

@ -1,10 +1,9 @@
<template> <template>
<div class="container" style="overflow: auto;"> <div class="container" style="overflow: auto;">
<el-page-header @back="$router.push('/manage')" class="pconly"> <div class="colbox" style="justify-content: space-between;margin: 0 20px 0 20px;">
<template #content> <div>{{ editing.name }} ({{ editing.id }}) </div>
<span class="text-large font-600 mr-3"> {{ editing.name }} ({{ editing.id }}) </span> <box-icon name="x" color="var(--text-color)" style="cursor: pointer;" @click="$router.push('/manage')"></box-icon>
</template> </div>
</el-page-header>
<div class="colbox" id="main"> <div class="colbox" id="main">
<div class="rowbox"> <div class="rowbox">
<div class="card"> <div class="card">
@ -75,8 +74,6 @@ export default {
name: "NoteEditor", name: "NoteEditor",
data() { data() {
return { return {
editing: window.editing.set,
editingClass: window.editing.set_class_name,
wordsets: window.wordsets, wordsets: window.wordsets,
new_word: { new_word: {
word: "", word: "",
@ -173,7 +170,11 @@ export default {
}, },
created() { created() {
this.editing = this.$store.state.editing.set;
this.editingClass = this.$store.state.editing.set_class_name;
if(this.editing && this.editingClass){
this.table = JSON.parse(localStorage.getItem(this.editing.id)); this.table = JSON.parse(localStorage.getItem(this.editing.id));
}
}, },
} }
</script> </script>

View File

@ -40,9 +40,9 @@
</div> </div>
<div class="option"> <div class="option">
<box-icon class="btn" name='edit' color="var(--text-color)" <box-icon class="btn" name='edit' color="var(--text-color)"
@click="edit(wordset, class_name)"></box-icon> @click="edit(wordset, view_class)"></box-icon>
<box-icon class="btn" name='trash' color="var(--text-color)" <box-icon class="btn" name='trash' color="var(--text-color)"
@click="del(class_name, wordset.id, index)"></box-icon> @click="del(view_class, wordset.id, index)"></box-icon>
</div> </div>
</div> </div>
</div> </div>
@ -91,7 +91,7 @@ export default {
}); });
}, },
edit(set, set_class_name) { edit(set, set_class_name) {
window.editing = { set, set_class_name }; this.$store.state.editing = {set, set_class_name};
this.$router.push({ this.$router.push({
path: "/manage/edit", path: "/manage/edit",
}) })

View File

@ -1,5 +1,6 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import App from './App.vue' import App from './App.vue'
import { createStore } from 'vuex'
import ElementPlus from 'element-plus' import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css' import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css' import 'element-plus/theme-chalk/dark/css-vars.css'
@ -7,6 +8,11 @@ import 'boxicons'
import router from './router.js' import router from './router.js'
const app = createApp(App); const app = createApp(App);
const store = createStore({
state(){
}
});
app.use(store);
app.use(ElementPlus); app.use(ElementPlus);
app.use(router); app.use(router);
app.mount('#app'); app.mount('#app');