Appearance
功能: 评论回复、点赞、支持表情包、删除评论、图片上传
Comment完整前后端代码实例地址
<template> <el-dropdown trigger="click" @command="onCommand"> <div class="operation-warp"> <u-icon> <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"> <path d="M586.624 234.624a74.624 74.624 0 1 1-149.184 0 74.624 74.624 0 0 1 149.12 0z m0 554.624a74.624 74.624 0 1 1-149.248 0 74.624 74.624 0 0 1 149.248 0zM512 586.624a74.624 74.624 0 1 0 0-149.248 74.624 74.624 0 0 0 0 149.248z" fill="currentColor" ></path> </svg> </u-icon> </div> <template #dropdown> <el-dropdown-menu> <el-dropdown-item command="report">举报</el-dropdown-item> <el-dropdown-item command="remove">删除</el-dropdown-item> <el-dropdown-item divided command="copy">复制</el-dropdown-item> </el-dropdown-menu> </template> </el-dropdown> </template> <script setup lang="ts"> import { useClipboard } from '@vueuse/core' import { CommentApi, ElDropdown, ElDropdownItem, ElDropdownMenu, UToast} from 'undraw-ui' interface Props { comment: CommentApi } const props = defineProps<Props>() const emit = defineEmits<{ (e: 'remove', comment: CommentApi): void }>() const { copy } = useClipboard() const onCommand = (command: any) => { switch(command) { case 'remove': emit('remove', props.comment) break case 'report': UToast({type: 'info', message: '举报成功: ' + props.comment.id}) break case 'copy': copy(props.comment.content) UToast({type: 'info', message: '复制成功'}) } } </script> <style lang="scss" scoped> .el-dropdown { position: absolute; top: 50%; transform: translateY(-50%); right: 0; } .operation-warp { font-size: 16px; color: #9499a0; cursor: pointer; position: relative; } .operation-warp:hover { color: #00aeec; } </style>
滚动样式受到文档样式影响,体验效果请在本地使用
export interface CommentApi { id: string | number; parentId: string | number | null; uid: string | number; address?: string; content: string; likes?: number; contentImg?: string; createTime: string; user: CommentUserApi; reply?: ReplyApi | null; } export interface ReplyApi { total: number; list: CommentApi[]; } export interface CommentUserApi { username: string; avatar: string; level?: number; homeLink?: string; } export interface UserApi { id: string | number; username: string; avatar: string; likeIds?: string[] | number[]; } export interface ConfigApi { user: UserApi; emoji: EmojiApi; comments: CommentApi[]; replyShowSize?: number; showForm?: boolean; showContent?: boolean; showLevel?: boolean; showLikes?: boolean; showAddress?: boolean; showHomeLink?: boolean; showReply?: boolean; placeholder?: string; aTarget?: '_blank' | '_parent' | '_self' | '_top'; mentionConfig?: { isLoading?: boolean; show?: boolean; userIdKey?: string; userNameKey?: string; userAvatarKey?: string; mentionColor?: string; userArr?: any[]; showAvatar?: boolean; }; } export interface SubmitParamApi { content: string; parentId: string | null; files?: any[]; reply?: CommentApi; finish: (comment?: CommentApi) => void; mentionList?: any[]; } export interface ReplyPageParamApi { parentId: string; pageNum: number; pageSize: number; finish: (reply: ReplyApi) => void; }
Comment 评论
功能: 评论回复、点赞、支持表情包、删除评论、图片上传
Comment完整前后端代码实例地址
基础用法
图片上传
回复分页
用户信息卡片
工具栏
操作栏实例->operate.vue
导航栏排序
评论滚动
滚动样式受到文档样式影响,体验效果请在本地使用
@mention提及
Comment 属性
config 属性
Comment 事件
接口类型