This commit is contained in:
zyronon
2023-12-20 09:23:35 +08:00
parent fe705d6154
commit 7d2cd00ca2
11 changed files with 299 additions and 44 deletions

View File

@@ -103,7 +103,7 @@ onMounted(() => {
})
function selectDict(val: { dict: DictResource | Dict, index: number }) {
console.log('val', val)
// console.log('val', val)
router.push({
path: '/mobile/set-dict-plan', query: {id: val.dict.id}
})

View File

@@ -11,16 +11,16 @@ import {dictionaryResources} from "@/assets/dictionary.ts";
import {useBaseStore} from "@/stores/base.ts";
import {useRuntimeStore} from "@/stores/runtime.ts";
import {useSettingStore} from "@/stores/setting.ts";
import {$ref} from "vue/macros";
const store = useBaseStore()
const runtimeStore = useRuntimeStore()
const settingStore = useSettingStore()
const route = useRoute()
let load = $ref(false)
onMounted(() => {
const route = useRoute()
console.log('route', route.query.id)
// console.log('route', route.query.id)
let item = dictionaryResources.find(v => v.id === route.query.id)
let find: Dict = store.myDictList.find((v: Dict) => v.id === item.id)
if (find) {
@@ -34,13 +34,14 @@ onMounted(() => {
//设置默认章节单词数
runtimeStore.editDict.chapterWordNumber = settingStore.chapterWordNumber
}
load = true
})
</script>
<template>
<div class="mobile-page">
<NavBar title="设置任务量"/>
<DictPlan/>
<DictPlan v-if="load"/>
</div>
</template>

View File

@@ -6,28 +6,73 @@ import 'vant/lib/index.css'
import {onMounted} from "vue";
import BaseButton from "@/components/BaseButton.vue";
import {useRuntimeStore} from "@/stores/runtime.ts";
import {useSettingStore} from "@/stores/setting.ts";
const store = useBaseStore()
const runtimeStore = useRuntimeStore()
const settingStore = useSettingStore()
let columns = $ref([])
let columns2 = $ref([])
let chapterWordNumber = $ref([runtimeStore.editDict.chapterWordNumber])
let length = $ref(runtimeStore.editDict.length)
let days = $ref([Math.ceil(length / chapterWordNumber)])
const onChange = ({selectedValues}) => {
showToast(`当前值: ${selectedValues.join(',')}`);
chapterWordNumber = selectedValues
days = [Math.ceil(length / chapterWordNumber[0])]
console.log('days', days, chapterWordNumber)
};
const onChange2 = ({selectedValues}) => {
days = selectedValues
chapterWordNumber = [Math.ceil(length / days[0])]
console.log('days', days, chapterWordNumber)
};
onMounted(() => {
columns = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200].map(value => {
console.log('runtimeStore.editDict.length',runtimeStore.editDict.length)
let list = []
if (length > 50) {
list = Array.from({length: 10}).map((v, i) => (i + 1) * 5)
}
if (length > 100) {
list = list.concat(Array.from({length: 5}).map((v, i) => 50 + (i + 1) * 10))
}
if (length > 200) {
list = list.concat(Array.from({length: 4}).map((v, i) => 100 + (i + 1) * 25))
}
if (length > 500) {
list = list.concat(Array.from({length: 6}).map((v, i) => 200 + (i + 1) * 50))
}
let d = Math.floor((length - 500) / 100)
console.log('d', d)
if (d) {
list = list.concat(Array.from({length: d}).map((v, i) => 500 + (i + 1) * 100))
}
list.push(length)
// if (runtimeStore.editDict.length < 50) {
// } else if (runtimeStore.editDict.length < 100) {
// list = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200]
// }
console.log('list', length, list)
columns = list.map(value => {
return {
text: value,
value,
}
})
columns2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200].map(value => {
columns2 = columns.map(v => {
let value = Math.ceil(length / v.value)
// console.log('v', v.value, value)
return {
text: value,
value,
value
}
})
})
@@ -39,7 +84,7 @@ onMounted(() => {
<div class="content">
<div class="dict">
<div class="name">{{ runtimeStore.editDict.name }}</div>
<div class="chapter">每日{{ runtimeStore.editDict.chapterWordNumber }} 剩余100</div>
<div class="chapter">每日{{ chapterWordNumber[0] }} 剩余{{ days[0] }}</div>
<el-progress
:show-text="false"
:percentage="90"
@@ -62,13 +107,15 @@ onMounted(() => {
<div class="picker-wrapper">
<Picker
:show-toolbar="false"
:model-value="chapterWordNumber"
:columns="columns"
@change="onChange"
/>
<Picker
:show-toolbar="false"
:model-value="days"
:columns="columns2"
@change="onChange"
@change="onChange2"
/>
</div>
</div>

View File

@@ -5,9 +5,17 @@ import SlideItem from "@/components/slide/SlideItem.vue";
import Home from "@/pages/mobile/Home.vue";
import DictListManage from "@/pages/mobile/DictListManage.vue";
import Setting from "@/pages/mobile/Setting.vue";
import {onMounted} from "vue";
defineOptions({
name: 'Practice'
})
let index = $ref(1)
onMounted(() => {
console.log('onMounted')
})
</script>
<template>
<div class="mobile-page mobile">

View File

@@ -13,6 +13,11 @@ import {ShortcutKey} from "@/types.ts";
import {useStartKeyboardEventListener} from "@/hooks/event.ts";
import useTheme from "@/hooks/theme.ts";
defineOptions({
name: 'PracticeWord'
})
const practiceStore = usePracticeStore()
const store = useBaseStore()
const settingStore = useSettingStore()

View File

@@ -60,19 +60,20 @@ router.beforeEach((to, from) => {
if (toDepth > fromDepth) {
if (to.matched && to.matched.length) {
let toComponentName = to.matched[0].components.default.name
let def = to.matched[0].components.default
let toComponentName = def.name ?? def.__name
runtimeStore.updateExcludeRoutes({type: 'remove', value: toComponentName})
// console.log('to', toComponentName)
// console.log('删除', toComponentName)
// console.log('前进')
// console.log('删除', toComponentName)
}
} else {
if (from.matched && from.matched.length) {
let fromComponentName = from.matched[0].components.default.name
let def = from.matched[0].components.default
let fromComponentName = def.name ?? def.__name
runtimeStore.updateExcludeRoutes({type: 'add', value: fromComponentName})
// console.log('后退')
// console.log('添加', fromComponentName)
// console.log('后退')
}
}
// ...

View File

@@ -24,6 +24,7 @@ export const useRuntimeStore = defineStore('runtime', {
},
actions: {
updateExcludeRoutes(val: any) {
// console.log('val', val)
if (val.type === 'add') {
if (!this.excludeRoutes.find(v => v === val.value)) {
this.excludeRoutes.push(val.value)