UNPKG

4.27 kBTypeScriptView Raw
1import Taro from '../../index'
2
3declare module '../../index' {
4 namespace setPageInfo {
5 interface Option {
6 /** 页面标题 */
7 title: string
8 /** 页面关键字 */
9 keywords: string
10 /** 页面描述信息 */
11 description: string
12 /** 原始发布时间(年-月-日 时:分:秒 带有前导零) */
13 releaseDate?: string
14 /** 文章(内容)标题(适用于当前页面是图文、视频类的展示形式,文章标题需要准确标识当前文章的主要信息点;至少6个字,不可以全英文。) */
15 articleTitle?: string
16 /** 图片线上地址,用于信息流投放后的封面显示,最多3张,单图片最大2M;封面图建议尺寸:高>=210px & 宽>=375px;最小尺寸:高>=146px & 宽>=218px。多张图时,用数组表示 */
17 image?: string | Array<string>
18 /** 视频信息,多个视频时,用数组表示 */
19 video?: Video
20 /** 浏览信息 */
21 visit?: Visit
22 /** 点赞量,若页面未统计可为空 */
23 likes?: string
24 /** 评论量,若页面未统计可为空 */
25 comments?: string
26 /** 收藏量,若页面未统计可为空 */
27 collects?: string
28 /** 分享量,若页面未统计可为空 */
29 shares?: string
30 /** 关注量,若页面未统计可为空 */
31 followers?: string
32 /** 接口调用成功的回调函数 */
33 success?: () => any
34 /** 接口调用失败的回调函数 */
35 fail?: (err: any) => any
36 /** 接口调用结束的回调函数(调用成功、失败都会执行) */
37 complete?: () => any
38 }
39 type Video = {
40 /** 视频地址 */
41 url: string
42 /** 视频时长(单位为秒) */
43 duration: string
44 /** 视频封面图 */
45 image: string
46 }
47 type Visit = {
48 /** 页面的浏览量(不去重用户) */
49 pv?: string
50 /** 页面的点击量(去重用户) */
51 uv?: string
52 /** 页面的用户人均停留时长,以秒为单位。 */
53 sessionDuration?: string
54 }
55 }
56
57 interface TaroStatic {
58 /**
59 * 百度智能小程序可接入百度搜索和百度 App,setPageInfo 负责为小程序设置各类页面基础信息,包括标题、关键字、页面描述以及图片信息、视频信息等。开发者为智能小程序设置完备的页面基础信息,有助于智能小程序在搜索引擎和信息流中得到更加有效的展示和分发。
60 * @supported swan
61 * @example
62 * ```tsx
63 * Taro.setPageInfo({
64 * title: '晒元宵节活动红包,爱奇艺60张年卡、600张季卡等你拿!-百度贴吧',
65 * keywords: '百度,百度贴吧,好运中国年,60,晒元,宵节',
66 * description: '晒元宵节活动红包,爱..昨天的百度APP元宵节活动中,共发出2亿现金红包、含151万个手气现金大奖和240辆红旗轿车,谁是好运锦鲤,快来分享!马上惊喜升级~摇中红包的锦鲤们即刻晒出红包金额截图,我们将会抽取660位好运锦鲤',
67 * articleTitle: '晒元宵节活动红包,爱奇艺60张年卡、600张季卡等你拿!',
68 * releaseDate: '2019-01-02 12:01:30',
69 * image: [
70 * 'https://c.hiphotos.baidu.com/forum/w%3D480/sign=73c62dda83b1cb133e693d1bed5456da/f33725109313b07e8dee163d02d7912396dd8cfe.jpg',
71 * 'https://hiphotos.baidu.com/fex/%70%69%63/item/43a7d933c895d143e7b745607ef082025baf07ab.jpg'
72 * ],
73 * video: [{
74 * url: 'https://www.baidu.com/mx/v12.mp4',
75 * duration: '100',
76 * image: 'https://smartprogram.baidu.com/docs/img/image-scaleToFill.png'
77 * }],
78 * visit: {
79 * pv: '1000',
80 * uv: '100',
81 * sessionDuration: '130'
82 * },
83 * likes: '75',
84 * comments: '13',
85 * collects: '23',
86 * shares: '8',
87 * followers: '35',
88 * success: res => {
89 * console.log('setPageInfo success');
90 * },
91 * fail: err => {
92 * console.log('setPageInfo fail', err);
93 * }
94 * })
95 * ```
96 * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-setPageInfo/
97 */
98 setPageInfo(option: setPageInfo.Option): void
99 }
100}