Skip to content

Commit 15a38fe

Browse files
authored
Merge branch 'master' into fix-rn-view-linear
2 parents 68deb03 + 5b1708d commit 15a38fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+968
-170
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
jd: 'readonly',
1717
qa: 'readonly',
1818
dd: 'readonly',
19+
ks: 'readonly',
1920
Component: 'readonly',
2021
Page: 'readonly',
2122
App: 'readonly',

docs-vitepress/api/composition-api.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,67 @@ createComponent({
128128
`Function`
129129

130130
小程序页面 onLoad 事件,监听页面加载。
131+
::: tip 注意
132+
在页面拼接参数时,不同平台对 URL 参数的处理方式存在差异:
133+
- **微信、QQ、字节跳动、RN**:参数透传,保持原始格式
134+
- **其他平台**:会自动对 encode 后的参数进行 decode
135+
136+
为了提供统一的参数处理方式,`onLoad` 钩子额外提供了一个经过 encode 处理的参数对象,方便业务使用统一的参数格式,同时不影响各平台原有的参数返回。
137+
138+
**微信、QQ、字节跳动、RN下的效果:**
139+
```js
140+
// A页面
141+
...
142+
createPage({
143+
methods: {
144+
jumpPage () {
145+
mpx.navigateTo({
146+
url: `./pages/test?name=${encodeURIComponent('')}&encode=true`
147+
})
148+
}
149+
}
150+
})
151+
...
152+
153+
// test页面
154+
...
155+
createPage({
156+
onLoad(rawQuery, decodedQuery) {
157+
// rawQuery = {name: "%E6%88%91", encode: "true"}
158+
// decodedQuery = {name: "我", encode: "true"}
159+
...
160+
}
161+
})
162+
...
163+
```
164+
**其他平台的效果:**
165+
```js
166+
// A页面
167+
...
168+
createPage({
169+
methods: {
170+
jumpPage () {
171+
mpx.navigateTo({
172+
url: `./pages/test?name=${encodeURIComponent('')}&encode=true`
173+
})
174+
}
175+
}
176+
})
177+
...
178+
179+
// test页面
180+
...
181+
createPage({
182+
onLoad(rawQuery, decodedQuery) {
183+
// rawQuery = {name: "我", encode: "true"}
184+
// decodedQuery = {name: "我", encode: "true"}
185+
...
186+
}
187+
})
188+
...
189+
```
190+
191+
:::
131192

132193
### onShow
133194
`Function`

docs-vitepress/guide/rn/style.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,10 @@ transform: scale(1.2) skewX(10deg);
13691369
/* RN 数组格式,仅 rn 支持 */
13701370
transform: [{translateX: 50}, {rotate: '45deg'}];
13711371
```
1372+
> [!tip] 注意
1373+
>
1374+
> 1.RN transform 不支持 scaleZ/scale3d/translateZ/translate3d/rotate3d/matrix3d
1375+
> 2.skew/skewX/skewY 在 RN Android 上不生效
13721376

13731377
### transform-origin
13741378

packages/api-proxy/src/platform/api/route/index.ios.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function isLock (navigationHelper, type, options) {
2525
clearTimeout(timerId)
2626
timerId = setTimeout(() => {
2727
if (navigationHelper.lastSuccessCallback && navigationHelper.lastFailCallback) {
28-
navigationHelper.lastFailCallback('timeout')
28+
navigationHelper.lastFailCallback(`${type}:fail timeout ${options.url || ''}`)
2929
navigationHelper.lastFailCallback = null
3030
}
3131
}, 1000)
@@ -43,7 +43,7 @@ function navigateTo (options = {}) {
4343
if (options.events) {
4444
eventChannel._addListeners(options.events)
4545
}
46-
const { path, queryObj } = parseUrl(options.url)
46+
const { path, queryObj } = parseUrl(options.url, true)
4747
const basePath = getBasePath(navigation)
4848
const finalPath = resolvePath(path, basePath).slice(1)
4949

@@ -70,7 +70,7 @@ function redirectTo (options = {}) {
7070
return
7171
}
7272
if (navigation && navigationHelper) {
73-
const { path, queryObj } = parseUrl(options.url)
73+
const { path, queryObj } = parseUrl(options.url, true)
7474
const basePath = getBasePath(navigation)
7575
const finalPath = resolvePath(path, basePath).slice(1)
7676
navigation.replace(finalPath, queryObj)
@@ -120,7 +120,7 @@ function reLaunch (options = {}) {
120120
return
121121
}
122122
if (navigation && navigationHelper) {
123-
const { path, queryObj } = parseUrl(options.url)
123+
const { path, queryObj } = parseUrl(options.url, true)
124124
const basePath = getBasePath(navigation)
125125
const finalPath = resolvePath(path, basePath).slice(1)
126126
navigation.reset({

packages/core/@types/global.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// declaration for mpx mode
2-
declare let __mpx_mode__: 'wx' | 'ali' | 'swan' | 'qq' | 'tt' | 'web' | 'dd' | 'qa' | 'jd' | 'android' | 'ios' | 'harmony'
2+
declare let __mpx_mode__: 'wx' | 'ali' | 'swan' | 'qq' | 'tt' | 'web' | 'dd' | 'qa' | 'jd' | 'android' | 'ios' | 'harmony' | 'ks'
33

44
// declaration for mpx env
55
declare let __mpx_env__: string

packages/core/@types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ interface MpxConfig {
412412
rnConfig: RnConfig,
413413
}
414414

415-
type SupportedMode = 'wx' | 'ali' | 'qq' | 'swan' | 'tt' | 'web' | 'qa'
415+
type SupportedMode = 'wx' | 'ali' | 'qq' | 'swan' | 'tt' | 'web' | 'qa'| 'ks' | 'jd' | 'dd'
416416

417417
interface ImplementOptions {
418418
modes?: Array<SupportedMode>

packages/core/src/convertor/convertor.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import wxToTtRule from './wxToTt'
99
import wxToDdRule from './wxToDd'
1010
import wxToJdRule from './wxToJd'
1111
import wxToReactRule from './wxToReact'
12+
import wxToKsRule from './wxToKs'
1213

1314
/**
1415
* 转换规则包含四点
@@ -38,7 +39,8 @@ const rulesMap = {
3839
wxToJd: extend({}, defaultConvertRule, wxToJdRule),
3940
wxToIos: extend({}, defaultConvertRule, wxToReactRule),
4041
wxToAndroid: extend({}, defaultConvertRule, wxToReactRule),
41-
wxToHarmony: extend({}, defaultConvertRule, wxToReactRule)
42+
wxToHarmony: extend({}, defaultConvertRule, wxToReactRule),
43+
wxToKs: extend({}, defaultConvertRule, wxToKsRule)
4244
}
4345

4446
export function getConvertRule (convertMode) {

packages/core/src/convertor/getConvertMode.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const convertModes = {
88
'wx-dd': 'wxToDd',
99
'wx-ios': 'wxToIos',
1010
'wx-android': 'wxToAndroid',
11-
'wx-harmony': 'wxToHarmony'
11+
'wx-harmony': 'wxToHarmony',
12+
'wx-ks': 'wxToKs'
1213
}
1314

1415
export function getConvertMode (srcMode) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { error } from '@mpxjs/utils'
2+
3+
const BEHAVIORS_MAP = [
4+
'wx://form-field',
5+
'wx://form-field-group',
6+
'wx://form-field-button',
7+
'wx://component-export'
8+
]
9+
10+
export default {
11+
convert (options) {
12+
if (options.behaviors) {
13+
options.behaviors.forEach((behavior, idx) => {
14+
if (BEHAVIORS_MAP.includes(behavior)) {
15+
error(`Built-in behavior "${behavior}" is not supported in ks environment!`, global.currentResource || global.currentModuleId)
16+
options.behaviors.splice(idx, 1)
17+
}
18+
})
19+
}
20+
}
21+
}

packages/core/src/convertor/wxToWeb.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
diffAndCloneA,
77
error,
88
hasOwn,
9-
isDev
9+
isDev,
10+
getDefaultValueByType
1011
} from '@mpxjs/utils'
1112
import { implemented } from '../core/implement'
1213

@@ -56,6 +57,12 @@ export default {
5657
return diffAndCloneA(prop.value).clone
5758
}
5859
: prop.value
60+
} else {
61+
// 没有显式设置value时,根据type自动添加默认值,与微信小程序原生行为保持一致
62+
const defaultValue = getDefaultValueByType(prop.type, 'web')
63+
if (defaultValue !== undefined) {
64+
newProp.default = defaultValue
65+
}
5966
}
6067
props[key] = newProp
6168
} else {

0 commit comments

Comments
 (0)