diff --git a/packages/devui-vue/devui/comment/index.ts b/packages/devui-vue/devui/comment/index.ts index a7d191829c13b2d848ec3b45d907fda964834447..d9fb1203f04f06645116fc237156a7098e95f71f 100644 --- a/packages/devui-vue/devui/comment/index.ts +++ b/packages/devui-vue/devui/comment/index.ts @@ -10,8 +10,8 @@ export { Comment } export default { title: 'Comment 评论', category: '数据展示', - status: '50%', // TODO: 组件若开发完成则填入"已完成",并删除该注释 + status: '70%', // TODO: 组件若开发完成则填入"已完成",并删除该注释 install(app: App): void { - app.use(Comment as any) + app.use(Comment as any) } } diff --git a/packages/devui-vue/devui/comment/src/comment-types.ts b/packages/devui-vue/devui/comment/src/comment-types.ts index 520f1e16141bf930ba9679bdea95842434f68fba..4c9ad684d759c3773d92eb260f664c254cc234c0 100644 --- a/packages/devui-vue/devui/comment/src/comment-types.ts +++ b/packages/devui-vue/devui/comment/src/comment-types.ts @@ -1,23 +1,29 @@ -import type { PropType, ExtractPropTypes } from 'vue' +import type { PropType, ExtractPropTypes, VNode } from 'vue' +export interface IcommentProps { + [prop: string]: any +} export const commentProps = { actions: { - - }, + type:Object as PropType, + default:null + }, author: { - + type:Object as PropType, + default:null + }, + avatar: { + type:Object as PropType, + default:null }, - avatar: {}, - content: { - - } , - prefixCls: { - + type:Object as PropType, + default:null }, datetime: { - - } + type:Object as PropType, + default:null + }, } as const diff --git a/packages/devui-vue/devui/comment/src/comment.scss b/packages/devui-vue/devui/comment/src/comment.scss index 5fa8c85f57ee56f9e29901c1a05af3162d346deb..fb2752bd938029ed8c205a1dacc8694189c14d95 100644 --- a/packages/devui-vue/devui/comment/src/comment.scss +++ b/packages/devui-vue/devui/comment/src/comment.scss @@ -25,6 +25,7 @@ font-size: $devui-text; } &-actions{ + list-style-type: none; margin: 12px 0 0; } } diff --git a/packages/devui-vue/devui/comment/src/comment.tsx b/packages/devui-vue/devui/comment/src/comment.tsx index 0c6e8d0c24b78c3c35605f8a83e50eead728d3ec..aeec79fefd7ae3eeec7f124a42c36abe0784ccb3 100644 --- a/packages/devui-vue/devui/comment/src/comment.tsx +++ b/packages/devui-vue/devui/comment/src/comment.tsx @@ -9,30 +9,30 @@ export default defineComponent({ slots: ['actions', 'author', 'avatar', 'content', 'datetime'], setup(props, { slots }) { return () => { - const getSlots = function (className: string) { - return ( -
- {slots[className]?.()} -
- ) - } - const setSlot = function (vnode: any) { - let vnodeEnum = Object.keys(vnode) - vnodeEnum.forEach((item: any) => { - getSlots(item) - }) - } + const getAction = (actions:any) => { + if (!actions || !actions.length) { + return null; + } + const actionList = actions.map((action:any, index:number) =>
  • {action}
  • ); + return actionList; + }; const actions = props.actions ?? slots.actions?.(); + const author = props.author ?? slots.author?.(); const avatar = props.avatar ?? slots.avatar?.(); const content = props.content ?? slots.content?.(); const datetime = props.datetime ?? slots.datetime?.(); - + const avatarDom = ( +
    + {typeof avatar === 'string' ? comment-avatar : avatar} +
    + ); + const actionDom = actions ? ( +
      {getAction(Array.isArray(actions) ? actions : [actions])}
    + ) : null; return (
    -
    - {avatar} -
    + {avatarDom}
    @@ -45,9 +45,7 @@ export default defineComponent({
    {content}
    -
    - {actions} -
    + {actionDom}
    )