Skip to content

Commit

Permalink
feat: add dark mode toggle button to reader
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyElaina committed Aug 11, 2024
1 parent 58c1ae7 commit 8114eb7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/assets/icon/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
mdiBroadcast,
mdiBroadcastOff,
mdiBell,
mdiBrightnessAuto,
mdiHistory,
mdiMessageText,
mdiCog,
Expand Down Expand Up @@ -102,6 +103,8 @@ export {
mdiContentSave,
mdiSquareEditOutline,
mdiWalletOutline,
mdiWeatherNight,
mdiWeatherSunny,
mdiAccountCog,
mdiPen,
mdiFuriganaHorizontal,
Expand Down
24 changes: 24 additions & 0 deletions src/views/Book/Read/Read.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
目录
</q-tooltip>
</q-fab-action>
<q-fab-action
@click="toggleDark"
color="primary"
:icon="
Dark.mode === 'auto' ? icon.mdiBrightnessAuto : Dark.mode ? icon.mdiWeatherNight : icon.mdiWeatherSunny
"
>
<q-tooltip transition-show="scale" transition-hide="scale" anchor="center left" self="center right">
切换颜色模式
</q-tooltip>
</q-fab-action>
<q-fab-action
v-if="$q.fullscreen.isCapable && !readSetting['hideFullScreen']"
@click="$q.fullscreen.toggle()"
Expand Down Expand Up @@ -221,6 +232,19 @@ const bgStyle = computed(() => ({
backgroundColor: readSetting.bgType === 'custom' ? readSetting.customColor : 'initial'
}))
const { dark } = storeToRefs(settingStore)
watch(dark, (newDark) => {
Dark.set(newDark)
settingStore.save()
})
function toggleDark() {
if (Dark.mode === 'auto') {
dark.value = !Dark.isActive
} else {
dark.value = !Dark.mode
}
}
const readStyle = computed(() => ({
fontSize: readSetting.fontSize + 'px',
textAlign: readSetting.justify ? 'justify' : 'initial',
Expand Down

0 comments on commit 8114eb7

Please sign in to comment.