Skip to content

Commit

Permalink
faet: 修复单词不在词典中的切换频繁的问题;pc版详情页宽度控制
Browse files Browse the repository at this point in the history
  • Loading branch information
simply-none committed Jan 7, 2024
1 parent bded443 commit 4a8461c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/hooks/useVoca.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export function useVoca() {

let bookItemBeforeSearch = ref(null)

let isWordNotInDict = ref(false)

watch(
[() => basicData.value.currentBook, () => basicData.value.currentRange, () => basicData.value.studyMode, () => basicData.value.studyCount],
() => {
Expand Down Expand Up @@ -173,7 +175,11 @@ export function useVoca() {
console.log(todayStudyWords.value.length , basicData.value.studyCount, '比较,切换count')

if (basicData.value.studyMode === 'study' && moreThanPlan) {
couldStudyWordNameList.value = toRaw(todayStudyWords.value)
if (!isWordNotInDict.value) {
couldStudyWordNameList.value = toRaw(todayStudyWords.value)
} else {
isWordNotInDict.value = false
}
!isMorethanTodayPlan.value && setNotify(
"今日单词计划已完成,已备份数据到本地,将开启今日学习复习模式!",
"success",
Expand Down Expand Up @@ -233,17 +239,20 @@ export function useVoca() {
async function showVocabularyCard(isForward) {
let random = generateRandom(isForward);
// 根据标识在总数据表中获取该标识对应的数据
console.log(random, couldStudyWordNameList.value[random], couldStudyWordNameList.value.length, 'randoim')
let vocabularycard = await table.value.get({
n: couldStudyWordNameList.value[random],
});
if (!vocabularycard) {
// 当前单词在词典中未找到,将过滤掉所有找不到的单词,重新获取下一个
setNotify('由于单词本和词典数据不匹配,正在重新获取能够复习的单词数据...', 'warning')
setNotify('由于单词【' + couldStudyWordNameList.value[random]+ '】在词典中找不到,将跳转到下一个单词...', 'warning')
let d = await table.value.toArray()
d = d.map(dn => dn.n)
couldStudyWordNameList.value = couldStudyWordNameList.value.filter(c => {
return d.includes(c)
})
isWordNotInDict.value = true
console.log(couldStudyWordNameList.value.length)

clearNotify()

Expand Down
16 changes: 16 additions & 0 deletions src/views/wordMainPage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<el-card
class="voca-card"
:class="{ pc: isPC }"
v-loading.fullscreen.lock="fullscreenLoading"
element-loading-text="应用正在加载中..."
element-loading-background="#eee"
Expand Down Expand Up @@ -78,6 +79,18 @@ if (router.currentRoute.value.query && router.currentRoute.value.query.reload) {
location.href = './'
}
function isPC () {
let mobile = ['iphone', 'android']
let userAgent = window.navigator.userAgent
if (userAgent.toLocaleLowerCase(mobile)) {
return false
}
else {
return true
}
}
function OpenSetting () {
drawer.value = true
bookItemBeforeSearch.value = null
Expand Down Expand Up @@ -127,6 +140,9 @@ onUnmounted(() => {
</script>

<style scoped lang="scss">
.pc {
max-width: 520px;
}
.voca {
&-card {
height: 100%;
Expand Down

0 comments on commit 4a8461c

Please sign in to comment.