Skip to content

Commit

Permalink
feat: tag jump
Browse files Browse the repository at this point in the history
  • Loading branch information
hq001 committed Nov 30, 2020
1 parent ff2f8d8 commit 39d923b
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export const getSongUrl = async (
id: number | number[]
): Promise<SongsBase[]> => {
const data = await get<{ data: SongsBase[] }>('/api/song/url', {
id: typeof id === 'number' ? id : id.join(',')
id: typeof id === 'number' ? id : id.join(','),
br: 3.2e5
})
return data.data
}
Expand Down
8 changes: 1 addition & 7 deletions src/pages/footer/component/lyrice-flash/browser-lyrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const BrowserLyriceFlash = defineComponent({
)
const LayoutModule = uesModuleStore<LayoutState>(LayoutNamespace)

const { currentTime, playing, visibleFlash, musicUrl } = toRefs(useState())
const { currentTime, playing, visibleFlash } = toRefs(useState())
const { screenSize } = toRefs(LayoutModule.useState())

if (VUE_APP_PLATFORM === Platform.ELECTRON) {
Expand All @@ -50,12 +50,6 @@ export const BrowserLyriceFlash = defineComponent({
useGetter('musicLyrics').filter(value => value.lyric)
)

watch(screenSize, v => {
if (musicUrl.value) {
useMutations(Mutations.VISIBLE_FLASH, v === Size.SM)
}
})

const index = computed(() => {
if (visibleFlash.value) {
const len = lyrice.value.length
Expand Down
4 changes: 1 addition & 3 deletions src/pages/footer/component/music-controller/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ export const MusicControl = defineComponent({

const handleVisibleFlash = () => {
if (VUE_APP_PLATFORM === Platform.BROWSER) {
if (screenSize.value === Size.SM) {
useMutations(Mutations.VISIBLE_FLASH, !visibleFlash.value)
}
useMutations(Mutations.VISIBLE_FLASH, !visibleFlash.value)
}
if (VUE_APP_PLATFORM === Platform.ELECTRON) {
importIpc()
Expand Down
3 changes: 3 additions & 0 deletions src/pages/footer/component/volume-history/history.less
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

.history-music-browser {
height: calc(100vh - 400px);
.history-music-content {
height: calc(100% - 44px);
}
.ant-table:not(.ant-table-empty) {
height: calc(100vh - 450px);
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/footer/sage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ export const actions: ActionTree<State, RootState> = {
const data = await getSongUrl(id)
if (state.sourceElement && state.audioElement) {
if (data.length) {
const url = data[0].url
const url =
data[0].url ||
`https://music.163.com/song/media/outer/url?id=${id}.mp3`
state.musicUrl = url
commit(Mutations.CAN_PLAY, false)
await dispatch(Actions.SET_MUSIC_DEFAILT, id)
Expand Down
3 changes: 3 additions & 0 deletions src/pages/news/children/song-list/view/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
li {
margin: 0 4px;
cursor: pointer;
&.active-tag {
color: var(--base-color);
}
}
}
}
Expand Down
17 changes: 13 additions & 4 deletions src/pages/news/children/song-list/view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { uesModuleStore, useRoute, useRouter } from '@/hooks/index'
import { ProvideInject } from '@/pages/news/constant'
import { noop } from '@/utils/index'
import { SongListState, NAMESPACED, SongListActions, Tags } from '../module'
import classnames from 'classnames'
import './index.less'

export const SongList = defineComponent({
Expand All @@ -16,7 +17,8 @@ export const SongList = defineComponent({
const { songList, tagsHot } = toRefs(useState())

useActions(SongListActions.SET_ACTION_SONG_LIST, {
limit: 30
limit: 30,
cat: route.query.tag
})
useActions(SongListActions.SET_ACTION_TAGS)
useActions(SongListActions.SET_ACTION_HOT_TAGS)
Expand Down Expand Up @@ -49,9 +51,16 @@ export const SongList = defineComponent({
<a-button shape="round">全部歌单</a-button>
<div class="find-music-songlist--hot">
<ul>
{tagsHot.value.map(tag => {
return <li onClick={() => switchPlaylist(tag)}>{tag.name}</li>
})}
{tagsHot.value.map(tag => (
<li
class={classnames({
'active-tag': route.query.tag === tag.name
})}
onClick={() => switchPlaylist(tag)}
>
{tag.name}
</li>
))}
</ul>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/pages/song/view/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
div {
margin-right: 10px;
}
a {
margin-right: 10px;
}
}
&-description {
display: flex;
Expand Down
29 changes: 24 additions & 5 deletions src/pages/song/view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@/pages/footer/module'
import { getSongUrl } from '@/api/index'
import './index.less'
import { RouterLink } from 'vue-router'

const renderClass = (name: string) => `song-list-${name}`

Expand Down Expand Up @@ -80,10 +81,16 @@ export default defineComponent({
const playAll = async () => {
const tracks = toRaw(playlist.value.tracks)
const tracksDetail = await getSongUrl(tracks.map(item => item.id))
const stack = tracks.map(item => ({
...item,
url: tracksDetail.find(o => o.id === item.id)?.url
}))
const stack = tracks.map(item => {
const urlItem = tracksDetail.find(o => o.id === item.id)
const url = urlItem
? urlItem.url
: ` https://music.163.com/song/media/outer/url?${item.id}=id.mp3`
return {
...item,
url: url
}
})
footerStore.useMutations(FooterMutations.SET_PLAYLIST_TO_STACK, stack)

const { music } = footerStore.useState()
Expand Down Expand Up @@ -132,7 +139,19 @@ export default defineComponent({
<div>播放:{playlist.value.playCount}</div>
</div>
<div class="a-tracks-count">
标签:{playlist.value.tags.join('/')}
标签:
{playlist.value.tags.map(tag => (
<RouterLink
to={{
name: 'songlist',
query: {
tag: tag
}
}}
>
{tag}
</RouterLink>
))}
</div>

<div class="a-description">
Expand Down
4 changes: 4 additions & 0 deletions src/theme/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
@extra-light-border: 0.5px solid lighten(@base-border-color, 6%);

@drank-border: 0.5px solid darken(@base-border-color, 40%);

button.easy-button-text {
color: #1890ff !important;
}
1 change: 1 addition & 0 deletions src/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import './color.less'
import './index.less'
import './index.css'

0 comments on commit 39d923b

Please sign in to comment.