UNPKG

3.68 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps } from './common'
3interface CommentListProps extends StandardProps {
4 /** 评论核心参数
5 * @supported swan
6 */
7 commentParam: CommentListProps.ICommentParam
8
9 /** 底部 toolbar 的相关配置
10 * @supported swan
11 */
12 toolbarConfig?: CommentListProps.IToolbarConfig
13
14 /** 滚动方式为页面滚动,若组件作为浮层使用,该参数需设为 false
15 * @supported swan
16 * @default true
17 */
18 isPageScroll?: boolean
19
20 /** 是否需要底部 toolbar ,若使用开发者自定义的底部 toolbar ,该参数需设为 false
21 * @supported swan
22 * @default true
23 */
24 needToolbar?: boolean
25
26 /** 用于调起评论发布器发布评论,发布成功插入列表第一条,且滚动到列表顶部
27 * @supported swan
28 * @default false
29 */
30 addComment?: boolean
31
32 /** 点击单条评论跳转的详情页页面 path ,若没有配置则不会发生跳转;配置的前提是列表与详情均是页面级
33 * @supported swan
34 */
35 detailPath?: string
36
37 /** 是否折叠列表,默认全展示
38 * @supported swan
39 * @default false
40 */
41 isFolded?: boolean
42
43 /** 折叠后列表展示最大条数,默认 3 条,最多 10 条
44 * @supported swan
45 * @default 3
46 */
47 foldNum?: number
48
49 /** 传入放置评论组件的页面路径,如'/pages/list/index',组件内部会触发跳转逻辑
50 * @supported swan
51 */
52 viewMorePath?: string
53
54 /** 『全部 xx 条』的样式,目前只支持开发者自定义字体颜色
55 * @supported swan
56 */
57 viewMoreStyle?: CommentListProps.IViewMoreStyle
58
59 /** 绑定点击单条评论的事件,点击单条评论时触发,返回数据为{status, data:{srid}}
60 * @supported swan
61 */
62 onClickComment?: CommonEventFunction
63
64 /** 绑定点击更多事件,若除了页面跳转还需要其他操作,可通过该回调执行;若为浮层,也可使用该回调自定义交互逻辑
65 * @supported swan
66 */
67 onViewMore?: CommonEventFunction
68}
69namespace CommentListProps {
70 interface ICommentParam {
71 /** 被点赞的文章的 id,与 path 参数一一对应
72 * @example "20200101"
73 */
74 snid: string
75
76 /** 文章标题 */
77 title: string
78
79 /** 智能小程序内页链接,最长不能超过 194 字符
80 * @example "/pages/index/index"
81 */
82 path: string
83
84 /** 数组第一项用于收藏功能的展示图片
85 * @default ['https://b.bdstatic.com/miniapp/images/demo-dog.png']
86 */
87 images?: string[]
88 }
89 interface IToolbarConfig {
90 /** 输入框提示文字 */
91 placeholder?: string
92
93 /** 显示的互动模块,对应默认值分别是:评论数、点赞、收藏、分享
94 * @default ['comment', 'like', 'favor', 'share']
95 */
96 moduleList?: string
97
98 /** 若 moduleList 里配置了 share 模块,该参数为必填 */
99 share?: IShare
100 }
101 interface IShare {
102 /** 分享标题 */
103 title: string
104
105 /** 分享内容 */
106 content?: string
107
108 /** 分享图标 */
109 imageUrl?: string
110
111 /** 页面 path ,必须是以 / 开头的完整路径,如果 path 中参数包含中文字符,需对中文字符进行编码 */
112 path?: string
113 }
114 interface IViewMoreStyle {
115 /** 『全部 xx 条』的字体颜色,默认为视觉提供色号,开发者可传入自定义色号
116 * @default "#3388ff"
117 */
118 color?: string
119 }
120}
121
122/** 评论列表
123 * @classification open
124 * @supported swan
125 * @see https://smartprogram.baidu.com/docs/develop/extended/component-content/comment-list/
126 */
127declare const CommentList: ComponentType<CommentListProps>
128export { CommentList, CommentListProps }