UNPKG

2.52 kBTypeScriptView Raw
1import { ComponentType } from 'react'
2import { StandardProps, CommonEventFunction } from './common'
3interface OpenDataProps extends StandardProps {
4 /** 开放数据类型
5 * @supported weapp, swan, tt, qq
6 */
7 type: keyof OpenDataProps.Type
8 /** 当 type="groupName" 时生效, 群id
9 * @supported weapp
10 */
11 openGid?: string
12 /** 当 type="user*" 时生效,以哪种语言展示 userInfo
13 * @default "en"
14 * @supported weapp, qq
15 */
16 lang?: keyof OpenDataProps.Lang
17 /** 数据为空时的默认文案
18 * @supported weapp, tt
19 */
20 defaultText?: string
21 /** 用户头像为空时的默认图片,支持相对路径和网络图片路径
22 * @supported weapp, tt
23 */
24 defaultAvatar?: string
25 /** 当数据为空且未设置默认值时,是否显示官方默认值
26 * @supported tt
27 */
28 useEmptyValue?: string
29 /** 当 type=groupCloudStorage 时有效,群分享对应的 shareTicket
30 * @supported qq
31 */
32 shareTicket?: string
33 /** 当 type=*CloudStorage 时有效,指定要拉取的 key 列表
34 * @supported qq
35 */
36 keyList?: string
37 /** 当 type=*CloudStorage 时有效,从主域透传给开放数据域的数据,会自动注入到自定义开放数据域组件的 properties 中
38 * @supported qq
39 */
40 componentData?: string
41 /** 群名称或用户信息为空时触发
42 * @supported weapp, tt, qq
43 */
44 onError?: CommonEventFunction
45}
46declare namespace OpenDataProps {
47 /** type 的合法值 */
48 interface Type {
49 /** 拉取群名称 */
50 groupName
51 /** 用户昵称 */
52 userNickName
53 /** 用户头像 */
54 userAvatarUrl
55 /** 用户性别 */
56 userGender
57 /** 用户所在城市 */
58 userCity
59 /** 用户所在省份 */
60 userProvince
61 /** 用户所在国家 */
62 userCountry
63 /** 用户的语言 */
64 userLanguage
65 }
66 /** lang 的合法值 */
67 interface Lang {
68 /** 英文 */
69 en
70 /** 简体中文 */
71 zh_CN
72 /** 繁体中文 */
73 zh_TW
74 }
75}
76/** 用于展示平台开放的数据
77 * @classification open
78 * @supported weapp, swan, tt, qq
79 * @example_react
80 * ```tsx
81 * class App extends Component {
82 * render () {
83 * return (
84 * <OpenData type='userAvatarUrl'/>
85 * )
86 * }
87 * }
88 * ```
89 * @example_vue
90 * ```html
91 * <template>
92 * <open-data type="userAvatarUrl" />
93 * </template>
94 * ```
95 * @see https://developers.weixin.qq.com/miniprogram/dev/component/open-data.html
96 */
97declare const OpenData: ComponentType<OpenDataProps>
98export { OpenData, OpenDataProps }