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