Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(type): useShareAppMessage 类型定义增强 #13303

Merged
merged 5 commits into from
Mar 3, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion packages/taro/types/taro.lifecycle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ declare module './index' {
webViewUrl?: string
}

interface ShareAppMessageReturn {
interface ShareAppMessageReturnObject {
/**
* 转发标题,默认为当前小程序名称
*/
Expand All @@ -107,6 +107,41 @@ declare module './index' {
imageUrl?: string
}

interface WeappShareAppMessageReturnObject extends ShareAppMessageReturnObject{
ZakaryCode marked this conversation as resolved.
Show resolved Hide resolved
/**
* 如果该参数存在,则以 resolve 结果为准,如果三秒内不 resolve,分享会使用上面传入的默认参数
* @supported weapp
* @since 2.12.0
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html#onShareAppMessage-Object-object
* @example
* ```tsx
* import { ShareAppMessageReturnObject, useShareAppMessage } from "@tarojs/taro";
* // ... else code
* useShareAppMessage(() => {
* const p = new Promise<ShareAppMessageReturnObject>(resolve => {
* setTimeout(() => {
* resolve({
* title: "",
* imageUrl: "",
* path: ""
* })
* }, 2000)
* })
* return {
* title: "",
* imageUrl: "",
* path: "",
* promise: p
* }
* });
* ```
*
*/
promise?: Promise<ShareAppMessageReturnObject>
}

type ShareAppMessageReturn = ShareAppMessageReturnObject | Promise<ShareAppMessageReturnObject> | WeappShareAppMessageReturnObject
ZakaryCode marked this conversation as resolved.
Show resolved Hide resolved

interface TabItemTapObject {
/**
* 被点击tabItem的序号,从 0 开始
Expand Down