Skip to content

Commit

Permalink
Merge pull request #11 from zyronon/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
zyronon authored Dec 7, 2023
2 parents 187735c + 6e9c1a5 commit 8739176
Show file tree
Hide file tree
Showing 16 changed files with 1,175 additions and 845 deletions.
1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ declare module 'vue' {
Ring: typeof import('./src/components/Ring.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Setting: typeof import('./src/components/Setting.vue')['default']
SettingDialog: typeof import('./src/components/dialog/SettingDialog.vue')['default']
Slide: typeof import('./src/components/Slide.vue')['default']
Toolbar: typeof import('./src/components/toolbar/index.vue')['default']
Expand Down
27 changes: 6 additions & 21 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import {onMounted, watch} from "vue";
import {BaseState, useBaseStore} from "@/stores/base.ts";
import {Dict, DictType, SaveConfig, SaveDict} from "@/types.ts"
import Practice from "@/pages/practice/index.vue"
import {Dict, DictType} from "@/types.ts"
import {useRuntimeStore} from "@/stores/runtime.ts";
import {useSettingStore} from "@/stores/setting.ts";
import {cloneDeep} from "lodash-es";
Expand All @@ -12,35 +11,21 @@ import useTheme from "@/hooks/theme.ts";
import * as localforage from "localforage";
import SettingDialog from "@/components/dialog/SettingDialog.vue";
import ArticleContentDialog from "@/components/dialog/ArticleContentDialog.vue";
import {useStartKeyboardEventListener} from "@/hooks/event.ts";
import CollectNotice from "@/components/CollectNotice.vue";
import {SAVE_SETTING_KEY, SAVE_DICT_KEY} from "@/utils/const.ts";
import {shakeCommonDict} from "@/utils";
const store = useBaseStore()
const runtimeStore = useRuntimeStore()
const settingStore = useSettingStore()
const {setTheme} = useTheme()
watch(store.$state, (n: BaseState) => {
let data: BaseState = cloneDeep(n)
data.myDictList.map((v: Dict) => {
if (v.isCustom) {
if (v.type === DictType.article) {
v.articles.map(s => {
delete s.sections
})
}
} else {
if (v.type === DictType.word) v.originWords = []
if (v.type === DictType.article) v.articles = []
v.words = []
v.chapterWords = []
}
})
localforage.setItem(SaveDict.key, JSON.stringify({val: data, version: SaveDict.version}))
localforage.setItem(SAVE_DICT_KEY.key, JSON.stringify({val: shakeCommonDict(n), version: SAVE_DICT_KEY.version}))
})
watch(settingStore.$state, (n) => {
localStorage.setItem(SaveConfig.key, JSON.stringify({val: n, version: SaveConfig.version}))
localStorage.setItem(SAVE_SETTING_KEY.key, JSON.stringify({val: n, version: SAVE_SETTING_KEY.version}))
})
//检测几个特定词典
Expand Down Expand Up @@ -94,7 +79,7 @@ onMounted(() => {
<router-view/>
<CollectNotice/>
<ArticleContentDialog/>
<SettingDialog v-if="runtimeStore.showSettingModal" @close="runtimeStore.showSettingModal = false"/>
<SettingDialog/>
</template>

<style scoped lang="scss">
Expand Down
9 changes: 4 additions & 5 deletions src/components/CollectNotice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ let timer = -1
function toggleNotice() {
showNotice = true
settingStore.first = false
timer = setInterval(() => {
num--
if (num <= 0) {
show = settingStore.first = false
clearInterval(timer)
}
if (num <= 0) close()
}, 1000)
}
Expand Down Expand Up @@ -65,7 +63,8 @@ const isMac = /macintosh|mac os x/i.test(navigator.userAgent);
点亮它!
</div>
</div>
<div class="collect-keyboard">或使用收藏快捷键<span class="active">{{isMac?'Command':'Ctrl'}} + D</span></div>
<div class="collect-keyboard">或使用收藏快捷键<span
class="active">{{ isMac ? 'Command' : 'Ctrl' }} + D</span></div>
</div>
<BaseButton v-else size="large" @click="toggleNotice">我想收藏</BaseButton>
</transition>
Expand Down
4 changes: 1 addition & 3 deletions src/components/RightTopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const settingStore = useSettingStore()

<template>
<div class="right-bar">


<Tooltip
:title="`切换主题(快捷键:${settingStore.shortcutKeyMap[ShortcutKey.ToggleTheme]})`"
>
Expand All @@ -42,7 +40,7 @@ const settingStore = useSettingStore()
.right-bar {
position: fixed;
right: 30rem;
right: var(--space);
top: var(--space);
z-index: 1;
display: flex;
Expand Down
Loading

0 comments on commit 8739176

Please sign in to comment.