From fa29e9839bbf66d48c7f8e62ee9118e5014758b8 Mon Sep 17 00:00:00 2001 From: WRXinYue <3322543587@qq.com> Date: Fri, 23 Aug 2024 16:04:43 +0800 Subject: [PATCH] feat: add wallpaper video player --- demo/valaxy.config.ts | 2 + theme/assets/icon/pause@32x32.png | Bin 0 -> 721 bytes .../{play-video.png => icon/play@32x32.png} | Bin theme/components/SakuraBackgroundDisplay.vue | 83 +++++++++++++++--- theme/components/SakuraBanner.vue | 10 ++- .../themes/InfoOverlayThemeSakura.vue | 12 ++- theme/node/config.ts | 2 + theme/stores/wallpaper.ts | 4 +- theme/types/index.d.ts | 8 ++ 9 files changed, 105 insertions(+), 16 deletions(-) create mode 100644 theme/assets/icon/pause@32x32.png rename theme/assets/{play-video.png => icon/play@32x32.png} (100%) diff --git a/demo/valaxy.config.ts b/demo/valaxy.config.ts index 5ed73a9d..7bec65ae 100644 --- a/demo/valaxy.config.ts +++ b/demo/valaxy.config.ts @@ -30,6 +30,8 @@ export default defineConfig({ 'https://wrxinyue-images.s3.bitiful.net/wallpaper/Genshin Impact - Yae Miko (4) Cybust PC.mp4', 'https://wrxinyue-images.s3.bitiful.net/pc-wallpaper/wallhaven-yxwy7k.jpg', ], + playerUrl: 'https://valaxy-theme-sakura.s3.bitiful.net/PV/563098369-1-208.mp4', + // playerUrl: 'https://valaxy-theme-sakura.s3.bitiful.net/PV/Original PV Little love song MONGOL 800 cover by Amatsuki.mp4', style: '', typewriter: true, diff --git a/theme/assets/icon/pause@32x32.png b/theme/assets/icon/pause@32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..22b719ab30a3d1b28efa90131a2c3a16689ee0c7 GIT binary patch literal 721 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyTLOGST!D0~Pe{C97!bwzh5`|U zjZC5m!nq&bKfZtGa#eQT#`#l#f}cJ<-M41m%jb6iIGs~L{1X?)cLe_3`G!trK+^JJ>`}6<* z>(fpz-BSCuCgFav`sS1G)?7<6c_Zw6{rM7mnaukarDs^BWKLQl`Qq7v>z?<0k3Bd# zJNCuz#C@H%2FuFLkINsh7Hu+gTluTw(UZnf)gu1~H4C&l1?F(O@uw?%KU>LEeey+C zs8ExGhO8vx%+Rm$3GxQ7Zq12nWEG5fYO7W-O{1UbI!|Te$?(RF-<_F%1v#~sP`OrFLA+GZ>na;M)R1Ze3msPPiy|l|K zcui96im!=>GdwNi)^l>@FxU2`Si9wmUOPU$Ys2Y|v?Yn22PVfl&5)Wk@5dI!60ZRJ zi~rTmY;-wLc|*}e)nnRfOO`y}75d&+KSa!%_-p1G-H#8au$)_2rDo<;62Ebc2#Z-( zN)_wxomY9H?@C^~w>HUIXKnf)yS&Gzr(Zs0F!iC-;Tz&JrcK+dz?Bh@))M{vr*uSr zZ>DnROfl`O{R=arZ^zHGyzfzopr02xnRL;wH) literal 0 HcmV?d00001 diff --git a/theme/assets/play-video.png b/theme/assets/icon/play@32x32.png similarity index 100% rename from theme/assets/play-video.png rename to theme/assets/icon/play@32x32.png diff --git a/theme/components/SakuraBackgroundDisplay.vue b/theme/components/SakuraBackgroundDisplay.vue index 7cca14a0..a39076db 100644 --- a/theme/components/SakuraBackgroundDisplay.vue +++ b/theme/components/SakuraBackgroundDisplay.vue @@ -4,6 +4,8 @@ import { isVideoUrl } from '../utils' import { getLocalStorageItem, setLocalStorageItem } from '../utils/storage' import { useSakuraAppStore } from '../stores' import { useThemeConfig } from '../composables' +import playIconUrl from '../assets/icon/play@32x32.png' +import pauseIconUrl from '../assets/icon/pause@32x32.png' const props = withDefaults(defineProps<{ urls?: string[] | string @@ -21,6 +23,8 @@ const themeConfig = useThemeConfig() const urls = computed(() => props.urls || themeConfig.value.banner.urls || '') const currentWallpaperUrl = computed(() => typeof urls.value === 'string' ? urls.value : urls.value[currentIndex.value]) const isCurrentMediaVideo = computed(() => isVideoUrl(currentWallpaperUrl.value)) +const currentIconUrl = computed(() => sakura.isPlaying ? pauseIconUrl : playIconUrl) +const banner = computed(() => themeConfig.value.banner) watch(() => sakura.wallpaperIndex[storageKey], (newIndex) => { setLocalStorageItem(storageKey, newIndex!) @@ -31,6 +35,10 @@ watch(() => urls.value.length, async (length) => { sakura.wallpaperLength[storageKey] = length }) +function togglePlayPause() { + sakura.isPlaying = !sakura.isPlaying +} + onMounted(() => { currentIndex.value = getLocalStorageItem(storageKey) || 0 sakura.wallpaperIndex[storageKey] = currentIndex.value @@ -39,16 +47,69 @@ onMounted(() => { + + diff --git a/theme/components/SakuraBanner.vue b/theme/components/SakuraBanner.vue index 29cc6d39..035a6ab0 100644 --- a/theme/components/SakuraBanner.vue +++ b/theme/components/SakuraBanner.vue @@ -1,6 +1,7 @@