From eaa0eae7f17ffcfbc11c1b251df58d187fb0955e Mon Sep 17 00:00:00 2001 From: onelong Date: Fri, 2 Aug 2019 16:39:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=A8FC=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=EF=BC=8C=E6=96=B0=E5=A2=9E=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=AE=9A=E4=B9=89SFC=EF=BC=8CsetPageInfo=20(#4031)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 补全FC类型,新增SFC类型 * chore(lint): 格式化taro/types/index.d.ts * feat: 新增百度setPageInfo的API定义 * Revert "chore(lint): 格式化taro/types/index.d.ts" This reverts commit efc6535be3d86a1649d86db5b5514ce4125afba2. --- packages/taro/types/index.d.ts | 123 +++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/packages/taro/types/index.d.ts b/packages/taro/types/index.d.ts index 962f3b8c0082..066f1b8ca022 100644 --- a/packages/taro/types/index.d.ts +++ b/packages/taro/types/index.d.ts @@ -360,9 +360,18 @@ declare namespace Taro { interface FunctionComponent

{ (props: Readonly

): JSX.Element defaultProps?: Partial

+ config?: Config options?: ComponentOptions } + type FC

= FunctionComponent

+ + interface StatelessFunctionComponent { + (): JSX.Element + } + + type SFC = StatelessFunctionComponent + interface ComponentClass

extends StaticLifecycle { new (...args: any[]): Component propTypes?: any @@ -11681,6 +11690,120 @@ declare namespace Taro { */ function onAudioInterruptionBegin(callback: () => void): void + namespace setPageInfo { + type Param = { + /** + * 页面标题 + */ + title: string + /** + * 页面关键字 + */ + keywords: string + /** + * 页面描述信息 + */ + description: string + /** + * 原始发布时间(年-月-日 时:分:秒 带有前导零) + */ + releaseDate?: string + /** + * 文章(内容)标题(适用于当前页面是图文、视频类的展示形式,文章标题需要准确标识当前文章的主要信息点;至少6个字,不可以全英文。) + */ + articleTitle?: string + /** + * 图片线上地址,用于信息流投放后的封面显示,最多3张,单图片最大2M;封面图建议尺寸:高>=210px & 宽>=375px;最小尺寸:高>=146px & 宽>=218px。多张图时,用数组表示 + */ + image?: string | Array + /** + * 视频信息,多个视频时,用数组表示 + */ + video?: Video + /** + * 浏览信息。最低支持版本3.40.6。 + */ + visit?: Visit + /** + * 点赞量,若页面未统计可为空。最低支持版本3.40.6。 + */ + likes?: string + /** + * 评论量,若页面未统计可为空。最低支持版本3.40.6。 + */ + comments?: string + /** + * 收藏量,若页面未统计可为空。最低支持版本3.40.6。 + */ + collects?: string + /** + * 分享量,若页面未统计可为空。最低支持版本3.40.6。 + */ + shares?: string + /** + * 关注量,若页面未统计可为空。最低支持版本3.40.6。 + */ + followers?: string + /** + * 接口调用成功的回调函数 + */ + success?: ParamPropSuccess + /** + * 接口调用失败的回调函数 + */ + fail?: ParamPropFail + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: ParamPropComplete + } + type Video = { + /** + * 视频地址 + */ + url: string + /** + * 视频时长(单位为秒) + */ + duration: string + /** + * 视频封面图 + */ + image: string + } + type Visit = { + /** + * 页面的浏览量(不去重用户) + */ + pv?: string + /** + * 页面的点击量(去重用户) + */ + uv?: string + /** + * 页面的用户人均停留时长,以秒为单位。 + */ + sessionDuration?: string + } + /** + * 接口调用成功的回调函数 + */ + type ParamPropSuccess = () => any + /** + * 接口调用失败的回调函数 + */ + type ParamPropFail = (err: any) => any + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + type ParamPropComplete = () => any + } + + /** + * 百度智能小程序可接入百度搜索和百度 App,setPageInfo 负责为小程序设置各类页面基础信息,包括标题、关键字、页面描述以及图片信息、视频信息等。开发者为智能小程序设置完备的页面基础信息,有助于智能小程序在搜索引擎和信息流中得到更加有效的展示和分发。 + */ + function setPageInfo(OBJECT: setPageInfo.Param): void + namespace cloud { interface ICloudConfig { env?: string | object