Skip to content

Commit

Permalink
Merge branch 'fix-drn' of https://github.com/didi/mpx into fix-drn
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcuijuan committed Jan 14, 2025
2 parents 73b5696 + be28759 commit 5a6339a
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 167 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/platform/patch/getDefaultOptions.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,12 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
if (!global.__mpxAppHotLaunched && global.__mpxAppOnLaunch) {
global.__mpxAppOnLaunch(props.navigation)
}
// 此处拿到的props.route.params内属性的value被进行过了一次decode, 不符合预期,此处额外进行一次encode来与微信对齐
if (isObject(props.route.params)) {
for (let key in props.route.params) {
props.route.params[key] = encodeURIComponent(props.route.params[key])
}
}
proxy.callHook(ONLOAD, [props.route.params || {}])
}
proxy.mounted()
Expand Down
25 changes: 12 additions & 13 deletions packages/webpack-plugin/lib/runtime/components/react/mpx-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import {
NativeSyntheticEvent
} from 'react-native'
import { warn } from '@mpxjs/utils'
import { GestureDetector } from 'react-native-gesture-handler'
import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useHoverStyle } from './utils'
import { GestureDetector, PanGesture } from 'react-native-gesture-handler'
import { getCurrentPage, splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useHover } from './utils'
import useInnerProps, { getCustomEvent } from './getInnerListeners'
import useNodesRef, { HandlerRef } from './useNodesRef'
import { RouteContext, FormContext } from './context'
Expand Down Expand Up @@ -223,7 +223,8 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro

const formContext = useContext(FormContext)

const { isHover, enableHoverStyle, gesture } = useHoverStyle({ hoverStyle, hoverStartTime, hoverStayTime, disabled })
const enableHover = hoverClass !== 'none'
const { isHover, gesture } = useHover({ enableHover, hoverStartTime, hoverStayTime, disabled })

let submitFn: () => void | undefined
let resetFn: () => void | undefined
Expand All @@ -235,30 +236,28 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro

const isMiniSize = size === 'mini'

const applyHoverEffect = isHover && hoverClass !== 'none'

const [color, hoverColor, plainColor, disabledColor] = TypeColorMap[type]

const normalBackgroundColor = disabled ? disabledColor : applyHoverEffect || loading ? hoverColor : color
const normalBackgroundColor = disabled ? disabledColor : isHover || loading ? hoverColor : color

const plainBorderColor = disabled
? 'rgba(0, 0, 0, .2)'
: applyHoverEffect
: isHover
? `rgba(${plainColor},.6)`
: `rgb(${plainColor})`

const normalBorderColor = type === 'default' ? 'rgba(0, 0, 0, .2)' : normalBackgroundColor

const plainTextColor = disabled
? 'rgba(0, 0, 0, .2)'
: applyHoverEffect
: isHover
? `rgba(${plainColor}, .6)`
: `rgb(${plainColor})`

const normalTextColor =
type === 'default'
? `rgba(0, 0, 0, ${disabled ? 0.3 : applyHoverEffect || loading ? 0.6 : 1})`
: `rgba(255 ,255 ,255 , ${disabled || applyHoverEffect || loading ? 0.6 : 1})`
? `rgba(0, 0, 0, ${disabled ? 0.3 : isHover || loading ? 0.6 : 1})`
: `rgba(255 ,255 ,255 , ${disabled || isHover || loading ? 0.6 : 1})`

const viewStyle = {
borderWidth: 1,
Expand Down Expand Up @@ -287,7 +286,7 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
{},
defaultStyle,
style,
applyHoverEffect ? hoverStyle : {}
isHover ? hoverStyle : {}
)

const {
Expand Down Expand Up @@ -414,8 +413,8 @@ const Button = forwardRef<HandlerRef<View, ButtonProps>, ButtonProps>((buttonPro
)
)

return enableHoverStyle
? createElement(GestureDetector, { gesture }, baseButton)
return enableHover
? createElement(GestureDetector, { gesture: gesture as PanGesture }, baseButton)
: baseButton
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp

_SwiperItem.displayName = 'MpxSwiperItem'

export default _SwiperItem
export default _SwiperItem
Loading

0 comments on commit 5a6339a

Please sign in to comment.