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