Skip to content

Commit

Permalink
feat: support click on the lyrics to jump to the specified location
Browse files Browse the repository at this point in the history
  • Loading branch information
Linkontoask committed Apr 7, 2021
1 parent 459fd78 commit e775210
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fs.readdirSync(path.join(__dirname, 'module'))
})
})

const port = process.env.PORT || 3000
const port = process.env.PORT || 32768
const host = process.env.HOST || ''

app.server = app.listen(port, host, () => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/footer/components/lyrics-embed/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
line-height: 50px;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
}
.lyrics-active {
font-size: 16px;
Expand Down
12 changes: 11 additions & 1 deletion src/pages/footer/components/lyrics-embed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import { on, off, maxChildrenScollWidth } from '@/utils/index'
import { TeleportToAny } from '@/components/teleport-layout/index'
import { useFooterModule, useLayoutModule, useDownloadModule } from '@/modules'
import { Image } from '@/components/image'
import { LayoutSize, FooterMutations, DownloadActions } from '@/interface'
import {
LayoutSize,
FooterMutations,
DownloadActions,
Lyrics
} from '@/interface'
import { useSubscribe } from '@/shared/subscribe'
import debounce from 'lodash/debounce'
import classnams from 'classnames'
Expand Down Expand Up @@ -113,6 +118,10 @@ export const PlayLyrics = defineComponent({
}
}

const handleFlyTime = (item: Lyrics) => {
useMutations(FooterMutations.CURRENT_TIME, item.time)
}

onMounted(() => {
on(window, 'resize', resize)
})
Expand Down Expand Up @@ -184,6 +193,7 @@ export const PlayLyrics = defineComponent({
'lyrics-active': index.value === i
})}
data-time={item.time}
onClick={() => handleFlyTime(item)}
>
{item.lyric}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/footer/sage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export const mutations: MutationTree<FooterState> = {
[FooterMutations.CURRENT_TIME](state, time: number) {
if (state.audioElement && isNumber(time)) {
state.audioElement.currentTime = time
state.currentTime = time
}
},
[FooterMutations.UPDATE_CURRENT_TIME](state, time: number) {
Expand Down

0 comments on commit e775210

Please sign in to comment.