Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/devui-vue/devui/comment/src/comment-types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { PropType, ExtractPropTypes } from 'vue';

export interface IcommentProps {
[prop: string]: any;
actions?: [];
author?: [];
avatar?: [];
content?: [];
datetime?: [];
}

// TODO: props 参数的类型需要明确定义
Expand Down
8 changes: 4 additions & 4 deletions packages/devui-vue/devui/comment/src/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ export default defineComponent({
slots: ['actions', 'author', 'avatar', 'content', 'datetime'],
setup(props: CommentProps, { slots }) {
return () => {
const getAction = (actions: any) => {
const getAction = (actions: []) => {
if (!actions || !actions.length) {
return null;
}
const actionList = actions.map((action: any, index: number) => (
const actionList = actions.map((action: [], index: number) => (
<li key={`devui-comment-action-${index}`} class={`devui-comment-action-${index}`}>
{action}
</li>
));
return actionList;
};

const actions = props.actions ?? slots.actions?.();
const author = props.author ?? slots.author?.();
const avatar = props.avatar ?? slots.avatar?.();
Expand All @@ -42,7 +41,8 @@ export default defineComponent({
const avatarDom = (
<div class={`devui-comment-avatar`}>{typeof avatar === 'string' ? <img src={avatar} alt="comment-avatar" /> : avatar}</div>
);
const actionDom = actions ? <ul class={`devui-comment-actions`}>{getAction(Array.isArray(actions) ? actions : [actions])}</ul> : null;
const actionsList = Array.isArray(actions) ? actions : [actions];
const actionDom = actions ? <ul class={`devui-comment-actions`}>{getAction(actionsList)}</ul> : null;
return (
<div class="devui-comment">
{avatarDom}
Expand Down