UNPKG

2.66 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps } from './common'
3interface LikeProps extends StandardProps {
4 /** 是否已被点赞
5 * @supported swan
6 * @default false
7 */
8 isLiked?: boolean
9
10 /** 按钮模式。icon:表示仅有图标;mixture:表示图标文字结合
11 * @supported swan
12 * @default "icon"
13 */
14 mode?: string
15
16 /** 图标类型。hand:表示手形;heart:表示心形
17 * @supported swan
18 * @default "hand"
19 */
20 iconType?: string
21
22 /** 点赞按钮上的文案。默认为赞,仅在 mode 属性值为'mixture'时有效
23 * @supported swan
24 * @default "赞"
25 */
26 likeText?: string
27
28 /** 点赞数量
29 * @supported swan
30 * @default 0
31 */
32 likeNum?: number
33
34 /** 被点赞的对象类型。0:表示对文章内容进行点赞;1:表示对评论内容进行点赞
35 * @supported swan
36 * @default 0
37 */
38 likeType?: number
39
40 /** 点赞动效形式。0:无动效;1:轻动效;2:强动效
41 * @supported swan
42 * @default 1
43 */
44 animationType?: number
45
46 /** 点赞后是否弹出 toast 提示
47 * @supported swan
48 * @default false
49 */
50 isShowToast?: boolean
51
52 /** toast 文案,默认为已点赞、已取消
53 * @supported swan
54 * @default ['已点赞', '已取消']
55 */
56 toastText?: string[]
57
58 /** 点赞服务需要的必要参数
59 * @supported swan
60 */
61 likeParam: LikeProps.ILikeParam
62
63 /** 使用 npm 方式引入点赞组件时,点击按钮时在用户未登录状态下会触发此事件;使用动态库方式引入点赞组件时,点击按钮时在用户未登录状态下不会触发此事件
64 * @supported swan
65 */
66 onError?: CommonEventFunction
67
68 /** 点击点赞按钮,在点赞服务成功后将状态返回给使用组件者
69 * @supported swan
70 */
71 onSuccess?: CommonEventFunction
72
73 /** 点击点赞按钮,在点赞服务失败后将状态返回给使用组件者
74 * @supported swan
75 */
76 onFail?: CommonEventFunction
77}
78declare namespace LikeProps {
79 interface ILikeParam {
80 /** 用户身份唯一标识 */
81 openid: string
82
83 /** 被点赞的文章的 id,与 path 参数一一对应
84 * @example "20200101"
85 */
86 snid: string
87
88 /** 被点赞的评论 id */
89 spid?: string
90
91 /** 文章标题 */
92 title: string
93
94 /** 智能小程序内页链接,最长不能超过 194 字符
95 * @example "/pages/index/index"
96 */
97 path: string
98 }
99}
100
101/** 点赞
102 * @classification open
103 * @supported swan
104 * @see https://smartprogram.baidu.com/docs/develop/extended/component-content/like/
105 */
106declare const Like: ComponentType<LikeProps>
107export { Like, LikeProps }