From abdb2bcd50ab1f1f8f6b40f7607af2e0d5477ee2 Mon Sep 17 00:00:00 2001 From: alger Date: Sat, 28 Dec 2024 16:43:52 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=96=B0=E5=A2=9E=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E8=89=B2=E5=88=87=E6=8D=A2=E5=8A=9F=E8=83=BD=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=BA=E6=97=A5=E9=97=B4=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=8F=AF=E5=88=87=E6=8D=A2=E5=A4=9C=E9=97=B4=20(#19=E3=80=81#2?= =?UTF-8?q?1)=20fixes=20#19=20=20#21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 2 + package.json | 2 +- src/App.vue | 9 +- src/components/Coffee.vue | 11 +- src/components/MusicList.vue | 31 +-- src/components/MvPlayer.vue | 354 ++++++------------------- src/components/PlaylistType.vue | 6 +- src/components/RecommendAlbum.vue | 4 +- src/components/RecommendSinger.vue | 10 +- src/components/RecommendSonglist.vue | 6 +- src/components/common/SongItem.vue | 75 ++++-- src/directive/loading/index.vue | 5 +- src/hooks/MusicHook.ts | 2 + src/index.css | 43 ++- src/layout/AppLayout.vue | 53 ++-- src/layout/components/AppMenu.vue | 18 +- src/layout/components/MusicFull.vue | 7 +- src/layout/components/PlayBar.vue | 64 +++-- src/layout/components/SearchBar.vue | 88 +++--- src/layout/components/TitleBar.vue | 5 +- src/store/index.ts | 10 + src/utils/linearColor.ts | 2 + src/utils/theme.ts | 19 ++ src/views/favorite/index.vue | 16 +- src/views/history/index.vue | 12 +- src/views/historyAndFavorite/index.vue | 12 +- src/views/home/index.vue | 4 +- src/views/list/index.vue | 177 +++++++------ src/views/login/index.vue | 31 ++- src/views/mv/index.vue | 65 ++--- src/views/search/index.vue | 29 +- src/views/set/index.vue | 115 ++++---- src/views/user/index.vue | 213 ++++++++------- tailwind.config.js | 30 ++- 34 files changed, 772 insertions(+), 758 deletions(-) create mode 100644 src/utils/theme.ts diff --git a/components.d.ts b/components.d.ts index 961fde7..1bea90d 100644 --- a/components.d.ts +++ b/components.d.ts @@ -29,6 +29,8 @@ declare module 'vue' { NModal: typeof import('naive-ui')['NModal'] NPagination: typeof import('naive-ui')['NPagination'] NPopover: typeof import('naive-ui')['NPopover'] + NRadioButton: typeof import('naive-ui')['NRadioButton'] + NRadioGroup: typeof import('naive-ui')['NRadioGroup'] NScrollbar: typeof import('naive-ui')['NScrollbar'] NSlider: typeof import('naive-ui')['NSlider'] NSpin: typeof import('naive-ui')['NSpin'] diff --git a/package.json b/package.json index de7613d..48f8f4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alger-music", - "version": "2.4.0", + "version": "2.5.0", "description": "这是一个用于音乐播放的应用程序。", "author": "Alger ", "main": "app.js", diff --git a/src/App.vue b/src/App.vue index 410c4b1..994cbc6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,6 @@ diff --git a/src/layout/components/AppMenu.vue b/src/layout/components/AppMenu.vue index 49f13ed..4dcdab3 100644 --- a/src/layout/components/AppMenu.vue +++ b/src/layout/components/AppMenu.vue @@ -65,9 +65,10 @@ const iconStyle = (index: number) => { diff --git a/src/store/index.ts b/src/store/index.ts index 22d4391..edddd95 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -3,6 +3,7 @@ import { createStore } from 'vuex'; import { useMusicListHook } from '@/hooks/MusicListHook'; import homeRouter from '@/router/home'; import type { SongResult } from '@/type/music'; +import { applyTheme, getCurrentTheme, ThemeType } from '@/utils/theme'; // 默认设置 const defaultSettings = { @@ -34,6 +35,7 @@ interface State { searchType: number; favoriteList: number[]; playMode: number; + theme: ThemeType; } const state: State = { @@ -52,6 +54,7 @@ const state: State = { searchType: 1, favoriteList: getLocalStorageItem('favoriteList', []), playMode: getLocalStorageItem('playMode', 0), + theme: getCurrentTheme(), }; const { handlePlayMusic, nextPlay, prevPlay } = useMusicListHook(); @@ -102,6 +105,10 @@ const mutations = { state.playMode = state.playMode === 0 ? 1 : 0; localStorage.setItem('playMode', JSON.stringify(state.playMode)); }, + toggleTheme(state: State) { + state.theme = state.theme === 'dark' ? 'light' : 'dark'; + applyTheme(state.theme); + }, }; const actions = { @@ -123,6 +130,9 @@ const actions = { } } }, + initializeTheme({ state }: { state: State }) { + applyTheme(state.theme); + }, }; const store = createStore({ diff --git a/src/utils/linearColor.ts b/src/utils/linearColor.ts index f698dec..800340d 100644 --- a/src/utils/linearColor.ts +++ b/src/utils/linearColor.ts @@ -186,6 +186,7 @@ function hslToRgb(h: number, s: number, l: number): [number, number, number] { interface ITextColors { primary: string; active: string; + theme: string; } // 添加新的函数 @@ -230,6 +231,7 @@ export const getTextColors = (gradient: string = ''): ITextColors => { return { primary: isDark ? 'rgba(0, 0, 0, 0.54)' : 'rgba(255, 255, 255, 0.54)', active: isDark ? '#000000' : '#ffffff', + theme: isDark ? 'dark' : 'light', }; }; diff --git a/src/utils/theme.ts b/src/utils/theme.ts new file mode 100644 index 0000000..d77cb61 --- /dev/null +++ b/src/utils/theme.ts @@ -0,0 +1,19 @@ +export type ThemeType = 'dark' | 'light'; + +// 应用主题 +export const applyTheme = (theme: ThemeType) => { + // 使用 Tailwind 的暗色主题类 + if (theme === 'dark') { + document.documentElement.classList.add('dark'); + } else { + document.documentElement.classList.remove('dark'); + } + + // 保存主题到本地存储 + localStorage.setItem('theme', theme); +}; + +// 获取当前主题 +export const getCurrentTheme = (): ThemeType => { + return (localStorage.getItem('theme') as ThemeType) || 'light'; +}; diff --git a/src/views/favorite/index.vue b/src/views/favorite/index.vue index 428b47b..7661d4d 100644 --- a/src/views/favorite/index.vue +++ b/src/views/favorite/index.vue @@ -151,16 +151,18 @@ const handleMore = () => { diff --git a/src/views/historyAndFavorite/index.vue b/src/views/historyAndFavorite/index.vue index 4e51d2d..8c7668c 100644 --- a/src/views/historyAndFavorite/index.vue +++ b/src/views/historyAndFavorite/index.vue @@ -1,7 +1,7 @@ @@ -10,4 +10,8 @@ import Favorite from '@/views/favorite/index.vue'; import History from '@/views/history/index.vue'; - + diff --git a/src/views/home/index.vue b/src/views/home/index.vue index ed17268..ad136b5 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -29,7 +29,7 @@ defineOptions({ diff --git a/src/views/search/index.vue b/src/views/search/index.vue index 1bde24d..37d3c33 100644 --- a/src/views/search/index.vue +++ b/src/views/search/index.vue @@ -165,21 +165,34 @@ const handlePlay = () => { .search-page { @apply flex h-full; } + .hot-search { - @apply mr-4 rounded-xl flex-1 overflow-hidden; - background-color: #0d0d0d; + @apply mr-4 rounded-xl flex-1 overflow-hidden; + @apply bg-light-100 dark:bg-dark-100; animation-duration: 0.2s; min-width: 400px; height: 100%; + &-list { @apply pb-28; } + &-item { - @apply px-4 py-3 text-lg hover:bg-gray-700 rounded-xl cursor-pointer; + @apply px-4 py-3 text-lg rounded-xl cursor-pointer; + @apply text-gray-900 dark:text-white; + transition: all 0.3s ease; + + &:hover { + @apply bg-light-100 dark:bg-dark-200; + } + &-count { - @apply text-green-500 inline-block ml-3 w-8; + @apply inline-block ml-3 w-8; + @apply text-green-500; + &-3 { - @apply text-red-600 font-bold inline-block ml-3 w-8; + @apply font-bold inline-block ml-3 w-8; + @apply text-red-500; } } } @@ -187,15 +200,17 @@ const handlePlay = () => { .search-list { @apply flex-1 rounded-xl; - background-color: #0d0d0d; + @apply bg-light-100 dark:bg-dark-100; height: 100%; + &-box { @apply pb-28; } } .title { - @apply text-gray-200 text-xl font-bold my-2 mx-4; + @apply text-xl font-bold my-2 mx-4; + @apply text-gray-900 dark:text-white; } .mobile { diff --git a/src/views/set/index.vue b/src/views/set/index.vue index 91f64d9..ff52182 100644 --- a/src/views/set/index.vue +++ b/src/views/set/index.vue @@ -1,16 +1,31 @@ - diff --git a/src/views/user/index.vue b/src/views/user/index.vue index 9ad7d06..4b9e2c1 100644 --- a/src/views/user/index.vue +++ b/src/views/user/index.vue @@ -1,3 +1,80 @@ + + - -