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 @@ + + - -