-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support playlist display and playback
- Loading branch information
Showing
27 changed files
with
582 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@prefix: ~'more-then'; | ||
|
||
.@{prefix} { | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { | ||
defineComponent, | ||
nextTick, | ||
onMounted, | ||
onUpdated, | ||
PropType, | ||
ref, | ||
toRefs, | ||
watch | ||
} from 'vue' | ||
import './index.less' | ||
|
||
const prefix = 'more-then' | ||
|
||
// Use the rendered node to calculate the height, and then determine whether to shrink | ||
export const MoreThen = defineComponent({ | ||
name: 'MoreThen', | ||
props: { | ||
equal: { | ||
type: Number as PropType<number>, | ||
required: true | ||
}, | ||
rely: { | ||
type: [String] as PropType<string>, | ||
required: true | ||
} | ||
}, | ||
setup(props, context) { | ||
const { equal, rely } = toRefs(props) | ||
const contenier = ref<HTMLElement | null>(null) | ||
const visible = ref(true) | ||
const more = ref(false) | ||
|
||
const calcHeight = () => { | ||
if (contenier.value && contenier.value.offsetHeight > equal.value) { | ||
visible.value = false | ||
more.value = true | ||
} | ||
} | ||
|
||
watch(rely, rely => { | ||
if (rely) { | ||
nextTick().then(calcHeight) | ||
} | ||
}) | ||
|
||
return () => ( | ||
<div class={`${prefix}`}> | ||
{visible.value && ( | ||
<div ref={contenier}> | ||
{context.slots.default && context.slots.default()} | ||
</div> | ||
)} | ||
{more.value && ( | ||
<ve-button | ||
type="text" | ||
onClick={() => (visible.value = !visible.value)} | ||
> | ||
{visible.value ? '隐藏' : '显示更多'} | ||
</ve-button> | ||
)} | ||
</div> | ||
) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@prefix: ~'table'; | ||
|
||
.@{prefix} { | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { defineComponent, PropType, toRefs, ref } from 'vue' | ||
import { SongInteface } from '@/interface/index' | ||
import { Table as ATable } from 'ant-design-vue' | ||
import { noop } from '@/utils/index' | ||
import './index.less' | ||
|
||
const prefix = 'table' | ||
|
||
export const Table = defineComponent({ | ||
name: 'Table', | ||
props: { | ||
list: { | ||
type: Array as PropType<SongInteface.Tracks[]>, | ||
required: true | ||
}, | ||
columns: { | ||
type: Array as PropType<{}[]>, | ||
required: true | ||
}, | ||
onDblClick: { | ||
type: Function as PropType<(item: SongInteface.Tracks) => void>, | ||
default: noop | ||
} | ||
}, | ||
setup(props) { | ||
const { list, columns, onDblClick } = toRefs(props) | ||
|
||
return () => ( | ||
<div class={`${prefix}`}> | ||
<div class={`${prefix}-header`}></div> | ||
<div class={`${prefix}-body`}> | ||
<ATable | ||
rowKey="id" | ||
pagination={false} | ||
columns={columns.value} | ||
dataSource={list.value} | ||
customRow={record => { | ||
// There is a problem with the ant design vue document, please refer to the link below | ||
// https://v3.vuejs.org/guide/migration/render-function-api.html#_3-x-syntax-3 | ||
// https://github.com/vueComponent/ant-design-vue/blob/28aeea6f0b142ed68950a3738f7cf2c1581a7a5b/components/table/Table.tsx#L465 | ||
return { | ||
onClick: (e: Event) => { | ||
e.preventDefault() | ||
}, | ||
onDblclick: (e: Event) => { | ||
e.preventDefault() | ||
if (onDblClick) { | ||
onDblClick.value(record) | ||
} | ||
} | ||
} | ||
}} | ||
/> | ||
</div> | ||
{/* <div class={`${prefix}-pagination`}> | ||
<Pagination | ||
v-model={[current.value, 'current']} | ||
total={list.value.length} | ||
/> | ||
</div> */} | ||
</div> | ||
) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface Avatar { | ||
avatarUrl: string | ||
city: number | ||
birthday: number | ||
userId: number | ||
nickname: string | ||
backgroundUrl: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// eslint-disable-next-line prettier/prettier | ||
export * as FindMusicInteface from './news/index' | ||
export * as FooterInteface from './footer/index' | ||
export * as SongInteface from './song/index' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { get } from '@/utils/http' | ||
import {} from '@/interface/index' | ||
import { State } from '../state' | ||
|
||
export const getPlayList = async (id: number): Promise<State['playlist'][]> => { | ||
const data = await get<{ playlist: State['playlist'][] }>( | ||
'/api/playlist/detail', | ||
{ | ||
id | ||
} | ||
) | ||
return data.playlist | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './sage' | ||
export * from './state' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { actions, mutations } from './sage' | ||
import { state } from './state' | ||
|
||
export * from './state' | ||
export * from './sage' | ||
|
||
export const NAMESPACED = 'Song' | ||
|
||
export default { | ||
namespaced: true, | ||
state, | ||
actions, | ||
mutations | ||
} |
Oops, something went wrong.