Skip to content

Commit

Permalink
feat: the song author at the bottom can jump directly to the singer page
Browse files Browse the repository at this point in the history
  • Loading branch information
Linkontoask committed Dec 12, 2020
1 parent a9a22f9 commit 7ea601a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
28 changes: 13 additions & 15 deletions src/pages/footer/sage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,24 @@ export const getters: GetterTree<FooterState, RootState> = {
},
musicDes(state) {
if (state.music) {
if (state.music) {
const author = state.music.ar
if (author[0]) {
const title = state.music.name
dominateMediaSession(
title,
author.map(o => o.name).join(' / '),
'',
state.music.al.picUrl
)
return {
author: author.map(o => o.name).join(' / '),
title: title
}
const author = state.music.ar
if (author.length) {
const title = state.music.name
dominateMediaSession(
title,
author.map(o => o.name).join(' / '),
'',
state.music.al.picUrl
)
return {
author: author,
title: title
}
}
}

return {
author: '',
author: [],
title: ''
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/footer/state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SongsDetail } from '@/interface/index'
import { Albums, Artists, SongsDetail } from '@/interface/index'
import { PostData } from './components/lyrice-float/electron-lyrice'
import { Size } from '@/layout/module'
import { storage } from '@/utils/index'
Expand Down Expand Up @@ -76,7 +76,7 @@ export interface Getter {
volume: number
musicLyrics: Lyrics[]
musicDes: {
author: string
author: Artists[]
title: string
}
}
11 changes: 10 additions & 1 deletion src/pages/footer/view/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
&-left {
display: flex;
align-items: center;
width: var(--sidebar-width);
// width: var(--sidebar-width);
height: 100%;
padding: 0 20px;
}
Expand Down Expand Up @@ -47,7 +47,16 @@
font-size: 16px;
}
&--author {
display: flex;
align-items: center;
font-size: 13px;
div {
margin-right: 4px;
cursor: pointer;
&:not(:last-child)::after {
content: '/';
}
}
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/pages/footer/view/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineComponent, ref, toRefs, computed } from 'vue'
import { NAMESPACED, State, LayoutActions } from '@/layout/module'
import { uesModuleStore } from '@/hooks/index'
import { uesModuleStore, useRouter } from '@/hooks/index'
import { MusicControl } from '../components/music-controller'
import { VolumeAndHistory } from '../components/volume-history/index'
import {
Expand All @@ -22,6 +22,7 @@ import { AsyncComponent } from '../components/lyrice-embed/index'
import { BrowserLyriceFlash } from '../components/lyrice-float/browser-lyrice'
import classnames from 'classnames'
import './index.less'
import { Artists } from '@/interface'

// Fix JSX element type "AsyncComponent" does not have any construction signature or call signature.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -32,6 +33,7 @@ export const Footer = defineComponent({
setup() {
const visibleLyrice = ref(false)

const router = useRouter()
const { useState, useMutations } = uesModuleStore<State>(NAMESPACED)
const FooterModule = uesModuleStore<FooterState, FooterGetter>(
FooterNamespace
Expand Down Expand Up @@ -60,6 +62,12 @@ export const Footer = defineComponent({
}
}

const toArtist = (artist: Artists) => {
router.push({
path: '/artist/' + artist.id + '/album'
})
}

return () => (
<footer class="footer">
<div class="footer-left">
Expand All @@ -76,7 +84,9 @@ export const Footer = defineComponent({
<div class="footer-music-des">
<div class="footer-music-des--title">{musicDes.value.title}</div>
<div class="footer-music-des--author">
{musicDes.value.author}
{musicDes.value.author.map(artist => (
<div onClick={() => toArtist(artist)}>{artist.name}</div>
))}
</div>
</div>
</div>
Expand Down

0 comments on commit 7ea601a

Please sign in to comment.