-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add MusciDetail component, comment, simi songlist, simi songs l…
…ogic
- Loading branch information
Showing
31 changed files
with
1,118 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import axios from 'helpers/axios' | ||
|
||
enum COMMENT_TYPE { | ||
MUSIC = 0, | ||
MV = 1, | ||
SONGLIST = 2, | ||
ALBUM = 3, | ||
RADIO_STATION = 4, | ||
VIDEO = 5 | ||
} | ||
|
||
interface ILikeUnlikeCommentRequest { | ||
likeOrUnlike: number, | ||
type?: COMMENT_TYPE, | ||
id: number, | ||
commentId: number | ||
} | ||
|
||
type Params = Omit<ILikeUnlikeCommentRequest, 'likeOrUnlike'> | ||
|
||
type LikeUnlikeCommentFn = (params: ILikeUnlikeCommentRequest) => Promise<any> | ||
type LikeCommentFn = (params: Params, callback?: Function) => Promise<any> | ||
type UnlikeCommentFn = (params: Params, callback?: Function) => Promise<any> | ||
|
||
const likeUnlikeComment: LikeUnlikeCommentFn = async ({ likeOrUnlike, type, id, commentId }) => { | ||
const response = await axios({ | ||
method: 'get', | ||
url: '/comment/like', | ||
params: { | ||
id, | ||
type, | ||
t: likeOrUnlike, | ||
cid: commentId | ||
} | ||
}) | ||
return response | ||
} | ||
|
||
const likeComment: LikeCommentFn = async ({ id, commentId, type = COMMENT_TYPE.MUSIC }) => { | ||
const response = await likeUnlikeComment({ | ||
likeOrUnlike: 1, | ||
type, | ||
id, | ||
commentId | ||
}) | ||
return response | ||
} | ||
|
||
const unlikeComment: UnlikeCommentFn = async ({ id, commentId, type = COMMENT_TYPE.MUSIC }) => { | ||
const response = await likeUnlikeComment({ | ||
likeOrUnlike: 2, | ||
type, | ||
id, | ||
commentId | ||
}) | ||
return response | ||
} | ||
|
||
export default { | ||
likeUnlikeComment, | ||
likeComment, | ||
unlikeComment | ||
} |
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,29 @@ | ||
export interface IUser { | ||
anonym: number, | ||
authStatus: number, | ||
avatarUrl: string, | ||
nickname: string, | ||
userId: number, | ||
userType: number, | ||
vipType: number | ||
} | ||
|
||
export interface IReply { | ||
beRepliedCommentId: number, | ||
content: string, | ||
status: number, | ||
user: IUser | ||
} | ||
|
||
export interface IComment { | ||
beReplied: IReply[], | ||
commentId: number, | ||
commentLocationType: number, | ||
content: string, | ||
liked: boolean, | ||
likedCount: number, | ||
parentCommentId: number, | ||
status: number, | ||
time: number, | ||
user: IUser | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,60 @@ | ||
import React from 'react' | ||
import { Icon } from '@blueprintjs/core' | ||
import cn from 'classnames' | ||
|
||
import { IComment } from 'apis/types/comment' | ||
import { formatDatetime } from 'helpers/time' | ||
import styles from './style.module.css' | ||
|
||
interface IProps { | ||
data: IComment, | ||
onLikeChange: (comment: IComment) => void | ||
} | ||
|
||
const Comment: React.FC<IProps> = ({ data, onLikeChange }) => { | ||
const { user, content, beReplied, time, likedCount, liked } = data | ||
|
||
const likeUnlike = async () => { | ||
await onLikeChange(data) | ||
} | ||
|
||
return ( | ||
<div className={styles.root}> | ||
<div className={styles.avatar}> | ||
<img src={`${user.avatarUrl}?param=35y35`} loading='lazy' /> | ||
</div> | ||
|
||
<div className={styles.info}> | ||
<div className={styles.comment}> | ||
<span className={styles.nickname}>{user.nickname}: </span> | ||
<span>{content}</span> | ||
</div> | ||
|
||
<div className={styles.reply}> | ||
{beReplied.map(({ content, user }, index) => { | ||
return ( | ||
<div className={styles.item} key={index}> | ||
<span className={styles.nickname}>{user.nickname}: </span> | ||
<span>{content}</span> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
|
||
<div className={styles.others}> | ||
<div className={styles.time}> | ||
{formatDatetime(time, true)} | ||
</div> | ||
<div className={styles.operations}> | ||
<div className={cn(styles.like, liked && 'active')} onClick={likeUnlike}> | ||
<Icon icon='thumbs-up' iconSize={14} /> | ||
{!!likedCount && <span>{likedCount}</span>} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Comment |
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,63 @@ | ||
@value colors: "~styles/colors.module.css"; | ||
@value blue, tipsHoverColor from colors; | ||
|
||
.root { | ||
display: flex; | ||
} | ||
|
||
.avatar { | ||
width: 35px; | ||
height: 35px; | ||
margin-right: 20px; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
border-radius: 50%; | ||
|
||
img { | ||
border-radius: 50%; | ||
} | ||
} | ||
|
||
.info { | ||
flex: 1; | ||
padding-bottom: 10px; | ||
margin-bottom: 10px; | ||
border-bottom: 1px solid #ededed; | ||
|
||
.comment { | ||
margin-bottom: 8px; | ||
font-size: 0.95em; | ||
} | ||
|
||
.reply { | ||
margin-bottom: 10px; | ||
font-size: 0.9em; | ||
.item { | ||
width: 100%; | ||
padding: 8px 10px; | ||
border-radius: 3px; | ||
background-color: #f0f0f0; | ||
} | ||
} | ||
|
||
.nickname { | ||
color: blue; | ||
} | ||
|
||
.others { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
font-size: 0.9em; | ||
color: tipsHoverColor; | ||
|
||
.operations { | ||
display: flex; | ||
|
||
.like { | ||
display: flex; | ||
align-items: center; | ||
cursor: pointer; | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.