From 71076caeadd296b064b6158a51100de709ba7bd2 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Fri, 23 Jun 2023 18:40:37 +0800 Subject: [PATCH] feat: add set wallpaper & adjust wallpaper mask opacity settings * feat: adjust topbar display appearance when using other wallpapers * feat: update `HorizontalScrollView` appearance after scrolling * refactor: adjust file locations of child components in the `Settings` component --- src/components/HorizontalScrollView.vue | 42 ++++++++----------- src/components/Settings/Settings.vue | 8 ++-- .../{views => components}/Appearance.vue | 34 ++++++++++++--- .../{views => components}/General.vue | 0 .../Settings/{views => components}/Home.vue | 0 src/components/Topbar/Topbar.vue | 6 ++- src/contentScripts/views/App.vue | 11 ++++- src/contentScripts/views/Home/Home.vue | 2 +- src/logic/storage.ts | 1 + src/models/models.ts | 1 + 10 files changed, 66 insertions(+), 39 deletions(-) rename src/components/Settings/{views => components}/Appearance.vue (69%) rename src/components/Settings/{views => components}/General.vue (100%) rename src/components/Settings/{views => components}/Home.vue (100%) diff --git a/src/components/HorizontalScrollView.vue b/src/components/HorizontalScrollView.vue index 06e287c4..68ab2e67 100644 --- a/src/components/HorizontalScrollView.vue +++ b/src/components/HorizontalScrollView.vue @@ -2,27 +2,23 @@ import type { Ref } from 'vue' const scrollListWrap = ref() as Ref -const showLeftMask = ref(false) -const showRightMask = ref(false) +// const showLeftMask = ref(false) +// const showRightMask = ref(false) +const showScrollMask = ref(false) onMounted(() => { scrollListWrap.value.addEventListener('scroll', () => { - if (scrollListWrap.value.scrollLeft > 0) { - showLeftMask.value = true - showRightMask.value = true - } - else { - showLeftMask.value = false - showRightMask.value = false - } + if (scrollListWrap.value.scrollLeft > 0) + showScrollMask.value = true + + else + showScrollMask.value = false if ( scrollListWrap.value.scrollLeft + scrollListWrap.value.clientWidth >= scrollListWrap.value.scrollWidth - ) { - showLeftMask.value = false - showRightMask.value = false - } + ) + showScrollMask.value = false }) scrollListWrap.value.addEventListener('wheel', (event: WheelEvent) => { @@ -34,14 +30,14 @@ onMounted(() => { diff --git a/src/components/Settings/Settings.vue b/src/components/Settings/Settings.vue index bebb0311..2086d671 100644 --- a/src/components/Settings/Settings.vue +++ b/src/components/Settings/Settings.vue @@ -1,8 +1,8 @@ @@ -52,7 +50,7 @@ function changeWallpaper(url: string) { transform: color === settings.themeColor ? 'scale(1.2)' : 'scale(1)', border: color === settings.themeColor ? '2px solid var(--bew-text-1)' : 'none', }" - ¬@click="changeThemeColor(color)" + @click="changeThemeColor(color)" /> @@ -69,13 +67,37 @@ function changeWallpaper(url: string) {
- + + + +
+ + + {{ settings.backgroundMaskOpacity }} + diff --git a/src/components/Settings/views/General.vue b/src/components/Settings/components/General.vue similarity index 100% rename from src/components/Settings/views/General.vue rename to src/components/Settings/components/General.vue diff --git a/src/components/Settings/views/Home.vue b/src/components/Settings/components/Home.vue similarity index 100% rename from src/components/Settings/views/Home.vue rename to src/components/Settings/components/Home.vue diff --git a/src/components/Topbar/Topbar.vue b/src/components/Topbar/Topbar.vue index 468e3f11..ecb93b6d 100644 --- a/src/components/Topbar/Topbar.vue +++ b/src/components/Topbar/Topbar.vue @@ -4,6 +4,7 @@ import { Transition, onMounted, watch } from 'vue' import type { UnReadDm, UnReadMessage, UserInfo } from './types' import { updateInterval } from './notify' import { getUserID } from '~/utils/main' +import { settings } from '~/logic' interface Props { showSearchBar: boolean @@ -184,7 +185,7 @@ function getNewMomentsCount() { h="160px" opacity="100" pointer-events-none - style="background: linear-gradient(var(--bew-bg), transparent)" + :style="{ background: settings.wallpaper ? 'linear-gradient(rgba(0,0,0,.4), transparent)' : `linear-gradient(var(--bew-bg), transparent)` }" /> @@ -214,7 +215,8 @@ function getNewMomentsCount() { w="!4" h="!4" m="l-4" - icon="stroke-4 fill-$bew-text-1" + icon="stroke-4" + :style="{ color: settings.wallpaper && showTopbarMask ? 'white' : 'var(--bew-text-1)' }" /> diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue index a4223741..5162cf08 100644 --- a/src/contentScripts/views/App.vue +++ b/src/contentScripts/views/App.vue @@ -81,6 +81,13 @@ watch(() => accessKey.value, () => { accessKey.value = '' }) +watch(() => settings.value.wallpaper, (newValue) => { + document.documentElement.style.backgroundImage = `url(${newValue})` + document.documentElement.style.backgroundSize = 'cover' + document.documentElement.style.backgroundAttachment = 'fixed' + document.documentElement.style.backgroundPosition = 'center' +}) + onMounted(() => { nextTick(() => { setTimeout(() => { @@ -133,12 +140,14 @@ function setAppAppearance() { mainApp.value?.classList.remove('dark') // Override Bilibili Evolved background color - document.body.style.setProperty('background-color', 'var(--bew-bg)', 'important') + document.body.style.setProperty('background-color', 'unset', 'important') document.documentElement.style.setProperty('background-color', 'var(--bew-bg)', 'important') }