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

feat(weapp/components): 微信小程序添加always-embed属性 #7739

Merged
merged 3 commits into from
Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
54 changes: 46 additions & 8 deletions packages/shared/src/components.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
import { Shortcuts } from './shortcuts'

type SelectEnvOptions = {
default?: Record<string, string>,
alipay?: Record<string, string>,
jd?: Record<string, string>,
qq?: Record<string, string>,
swan?: Record<string, string>,
tt?: Record<string, string>,
weapp?: Record<string, string>
}

function selectEnv (options: SelectEnvOptions): Record<string, any> {
let option
if (process.env.TARO_ENV === 'alipay') {
option = options.alipay
} else if (process.env.TARO_ENV === 'jd') {
option = options.jd
} else if (process.env.TARO_ENV === 'qq') {
option = options.qq
} else if (process.env.TARO_ENV === 'swan') {
option = options.swan
} else if (process.env.TARO_ENV === 'tt') {
option = options.tt
} else if (process.env.TARO_ENV === 'weapp') {
option = options.weapp
}
return option || options.default || Object.create(null)
}

export const styles = {
style: `i.${Shortcuts.Style}`,
class: `i.${Shortcuts.Class}`
Expand Down Expand Up @@ -134,13 +162,14 @@ const Button = {
bindOpenSetting: '',
bindLaunchApp: '',
scope: '',
name: ''
}

if (process.env.TARO_ENV === 'qq') {
Button['app-packagename'] = ''
Button['app-bundleid'] = ''
Button['app-connect-id'] = ''
name: '',
...selectEnv({
qq: {
'app-packagename': '',
'app-bundleid': '',
'app-connect-id': ''
}
})
}

const Checkbox = {
Expand Down Expand Up @@ -203,7 +232,16 @@ const Input = {
bindBlur: '',
bindConfirm: '',
bindKeyboardHeightChange: '',
name: ''
name: '',
...selectEnv({
alipay: {
'random-number': 'false',
controlled: 'false'
},
weapp: {
'always-embed': 'false'
}
})
}

const Label = {
Expand Down
36 changes: 30 additions & 6 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ interface ButtonProps extends StandardProps {
/** 打开 APP 时,向 APP 传递的参数
*
* 生效时机:`open-type="launchApp"`
* @supported weapp
* @supported weapp, qq
*/
appParameter?: string

/** 支付宝小程序 scope
*
*
* 生效时机:`open-type="getAuthorize"`
* @supported weapp
*/
Expand All @@ -132,6 +132,30 @@ interface ButtonProps extends StandardProps {
*/
showMessageCard?: boolean

/**
* 应用的包名 (安卓)
* 生效时机:`open-type="launchApp"`
* @supported qq
* @see https://q.qq.com/wiki/develop/miniprogram/frame/open_ability/open_app.html
*/
appPackagename: string

/**
* 应用的bundleid (iOS)
* 生效时机:`open-type="launchApp"`
* @supported qq
* @see https://q.qq.com/wiki/develop/miniprogram/frame/open_ability/open_app.html
*/
appBundleid: string

/**
* QQ互联中的AppID
* 生效时机:`open-type="launchApp"`
* @supported qq
* @see https://q.qq.com/wiki/develop/miniprogram/frame/open_ability/open_app.html
*/
appConnectId: string

/** 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致
*
* 生效时机: `open-type="getUserInfo"`
Expand All @@ -140,7 +164,7 @@ interface ButtonProps extends StandardProps {
onGetUserInfo?: CommonEventFunction<ButtonProps.onGetUserInfoEventDetail>

/** 支付宝获取会员基础信息授权回调
*
*
* 生效时机:`open-type="getAuthorize"`
* @supported alipay
*/
Expand Down Expand Up @@ -182,7 +206,7 @@ interface ButtonProps extends StandardProps {
onOpenSetting?: CommonEventFunction<ButtonProps.onOpenSettingEventDetail>

/** 打开 APP 成功的回调
*
*
* 生效时机:`open-type="launchApp"`
* @supported weapp
*/
Expand Down Expand Up @@ -343,7 +367,7 @@ declare namespace ButtonProps {
/** 小程序消息指定的查询参数 */
query: Record<string, any>
}

interface onGetPhoneNumberEventDetail {
/* 获取用户手机号的调用状态 */
errMsg: string
Expand All @@ -352,7 +376,7 @@ declare namespace ButtonProps {
/** 加密算法的初始向量 */
iv: string
}

interface onOpenSettingEventDetail {
/* 打开授权设置页的调用状态 */
errMsg: string
Expand Down
21 changes: 21 additions & 0 deletions packages/taro-components/types/Input.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ interface InputProps extends StandardProps, FormItemProps {
*/
holdKeyboard?: boolean

/**
* 强制 input 处于同层状态,默认 focus 时 input 会切到非同层状态 (仅在 iOS 下生效)
* @default false
* @supported weapp
*/
alwaysEmbed?: boolean

/**
* 当 type 为 number, digit, idcard 数字键盘是否随机排列
* @default false
* @supported alipay
*/
randomNumber?: boolean

/**
* 是否为受控组件
* @default false
* @supported alipay
*/
controlled?: boolean

/** 当键盘输入时,触发input事件,event.detail = {value, cursor, keyCode},处理函数可以直接 return 一个字符串,将替换输入框的内容。
* @supported weapp, h5, rn
*/
Expand Down