diff --git a/src/modules/index.ts b/src/modules/index.ts index 4c42463d..a7cbf26e 100644 --- a/src/modules/index.ts +++ b/src/modules/index.ts @@ -17,6 +17,7 @@ import Artist, { ArtistNameSpaced } from '@/pages/artist/module' import Download, { DownloadNameSpaced } from '@/pages/download/module' import LocalMusic, { LocalMusicNameSpaced } from '@/pages/music/module' import Setting, { SettingNameSpaced } from '@/pages/setting/module' +import Search, { SearchNameSpaced } from '@/pages/search/module' import Layout, { LayoutNameSpaced } from '@/layout/module' export * from '@/pages/footer/module' @@ -28,6 +29,7 @@ export * from '@/pages/list/module' export * from '@/pages/artist/module' export * from '@/pages/music/module' export * from '@/pages/setting/module' +export * from '@/pages/search/module' export * from '@/layout/module' export { @@ -44,6 +46,7 @@ export { DownloadNameSpaced, LocalMusicNameSpaced, SettingNameSpaced, + SearchNameSpaced, LayoutNameSpaced } @@ -61,7 +64,8 @@ const modules = { [ArtistNameSpaced]: Artist, [DownloadNameSpaced]: Download, [LocalMusicNameSpaced]: LocalMusic, - [SettingNameSpaced]: Setting + [SettingNameSpaced]: Setting, + [SearchNameSpaced]: Search } export default modules diff --git a/src/pages/search/children/song.tsx b/src/pages/search/children/song.tsx index f0dea45b..7acf5163 100644 --- a/src/pages/search/children/song.tsx +++ b/src/pages/search/children/song.tsx @@ -3,7 +3,14 @@ import { Table } from '@/components-business/table/index' import { effectWords } from '../logic/index' import { search } from '@/api/search' import { playMusic } from '@/shared/music-shared' -import { Pagination, SearchType, SearchSuggest, ArrayItem } from '@/interface' +import { + Pagination, + SearchType, + SearchSuggest, + ArrayItem, + SearchMutations +} from '@/interface' +import { useSearchModule } from '@/modules' type Songs = SearchSuggest['songs'] @@ -17,6 +24,7 @@ export const SearchSong = defineComponent({ total: 0, slice: 0 }) + const { useMutations } = useSearchModule() const updateList = async (words: string) => { if (words) { @@ -31,6 +39,10 @@ export const SearchSong = defineComponent({ } }) pagination.total = result.songCount + useMutations( + SearchMutations.SET_SEARCH_TITLE, + `找到 ${pagination.total} 首歌曲` + ) } } diff --git a/src/pages/search/interface.ts b/src/pages/search/interface.ts index ad6c3476..2188ecef 100644 --- a/src/pages/search/interface.ts +++ b/src/pages/search/interface.ts @@ -30,8 +30,10 @@ export const enum SearchType { } export interface SearchState { - songs: SongsDetail + searchTitle: string } export const enum SearchActions {} -export const enum SearchMutations {} +export const enum SearchMutations { + SET_SEARCH_TITLE = 'SET_SEARCH_TITLE' +} diff --git a/src/pages/search/module.ts b/src/pages/search/module.ts new file mode 100644 index 00000000..03f0db57 --- /dev/null +++ b/src/pages/search/module.ts @@ -0,0 +1,19 @@ +import { actions, mutations } from './sage' +import { state } from './state' +import { uesModuleStore } from '@/hooks/index' +import { SearchActions, SearchMutations, SearchState } from '@/interface' + +export const SearchNameSpaced = 'Search' + +export const useSearchModule = () => { + return uesModuleStore( + SearchNameSpaced + ) +} + +export default { + namespaced: true, + state, + actions, + mutations +} diff --git a/src/pages/search/sage.ts b/src/pages/search/sage.ts new file mode 100644 index 00000000..d82d8ad6 --- /dev/null +++ b/src/pages/search/sage.ts @@ -0,0 +1,11 @@ +import { MutationTree, ActionTree } from 'vuex' +import { RootState } from '@/store/index' +import { SearchMutations, SearchState } from '@/interface' + +export const actions: ActionTree = {} + +export const mutations: MutationTree = { + [SearchMutations.SET_SEARCH_TITLE](state, txt) { + state.searchTitle = txt + } +} diff --git a/src/pages/search/state.ts b/src/pages/search/state.ts new file mode 100644 index 00000000..8e68589c --- /dev/null +++ b/src/pages/search/state.ts @@ -0,0 +1,5 @@ +import { SearchState } from '@/interface/index' + +export const state: SearchState = { + searchTitle: '' +} diff --git a/src/pages/search/view/search.tsx b/src/pages/search/view/search.tsx index 755b9daa..34908157 100644 --- a/src/pages/search/view/search.tsx +++ b/src/pages/search/view/search.tsx @@ -7,16 +7,20 @@ import { renderNavList } from '@/components-business/secondary-bar/index' import './search.less' +import { useSearchModule } from '@/modules' export const Search = defineComponent({ name: 'Search', setup() { + const { useState } = useSearchModule() + const state = useState() + const nav = renderNavList(contentRouter, Search.name) return () => (
找到 {} 首歌曲
, + title: () =>
{state.searchTitle}
, head: () => , body: () => }}