forked from NervJS/taro
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(harmony-hybrid): 解决混合路由的bug:直接从Taro返回时,原生侧不能同步返回
解决思路: 1. 原生侧向Taro提供nativeBack() Api 2. 从Taro侧发起返回:拦截navigateBack()方法,判断当前页面的来源,来自原生则同步通知原生侧back
- Loading branch information
Showing
17 changed files
with
252 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
examples/mini-program-example/src/pages/harmony-hybrid/mix-router/detail/index.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
navigationBarTitleText: '混合路由:小程序首页', | ||
enablePullDownRefresh: false, | ||
backgroundTextStyle: 'dark', | ||
onReachBottomDistance: 50, | ||
pageOrientation: 'auto', | ||
} |
16 changes: 16 additions & 0 deletions
16
examples/mini-program-example/src/pages/harmony-hybrid/mix-router/detail/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@import "@/styles/variables.scss"; | ||
|
||
.container { | ||
width: 100%; | ||
height: 100%; | ||
background-color: #E6FFCC; | ||
} | ||
|
||
.title { | ||
font-size: 40px; | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
width: 100%; | ||
text-align: center; | ||
display: block; | ||
} |
31 changes: 31 additions & 0 deletions
31
examples/mini-program-example/src/pages/harmony-hybrid/mix-router/detail/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
import { View, Button, Text } from '@tarojs/components' | ||
import './index.scss' | ||
import Taro from "@tarojs/taro"; | ||
export default class Index extends React.Component { | ||
state = { | ||
// syncSingleResult: '', | ||
// requestSingleResult: '', | ||
// requestConcurrentResult: '', | ||
// requestHignConcurrentResult: '', | ||
// syncResult: '', | ||
// requestByJsResult: '' | ||
} | ||
|
||
render() { | ||
// const { syncSingleResult } = this.state | ||
return ( | ||
<View className='container'> | ||
<Text className='title'> | ||
混合路由测试场景:小程序详情页 | ||
</Text> | ||
<Button | ||
onClick={()=>{ | ||
Taro.navigateBack() | ||
}}> | ||
小程序端:返回 | ||
</Button> | ||
</View> | ||
) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/mini-program-example/src/pages/harmony-hybrid/mix-router/home/index.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
navigationBarTitleText: '混合路由:小程序首页', | ||
enablePullDownRefresh: false, | ||
backgroundTextStyle: 'dark', | ||
onReachBottomDistance: 50, | ||
pageOrientation: 'auto', | ||
} |
16 changes: 16 additions & 0 deletions
16
examples/mini-program-example/src/pages/harmony-hybrid/mix-router/home/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@import "@/styles/variables.scss"; | ||
|
||
.container { | ||
width: 100%; | ||
height: 100%; | ||
background-color: #FFCCCC; | ||
} | ||
|
||
.title { | ||
font-size: 40px; | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
width: 100%; | ||
text-align: center; | ||
display: block; | ||
} |
42 changes: 42 additions & 0 deletions
42
examples/mini-program-example/src/pages/harmony-hybrid/mix-router/home/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react' | ||
import { View, Button, Text } from '@tarojs/components' | ||
import './index.scss' | ||
import Taro from "@tarojs/taro"; | ||
import nativeApi from "@/util/nativeApi"; | ||
export default class Index extends React.Component { | ||
state = { | ||
// syncSingleResult: '', | ||
// requestSingleResult: '', | ||
// requestConcurrentResult: '', | ||
// requestHignConcurrentResult: '', | ||
// syncResult: '', | ||
// requestByJsResult: '' | ||
} | ||
|
||
render() { | ||
// const { syncSingleResult } = this.state | ||
return ( | ||
<View className='container'> | ||
<Text className='title'> | ||
混合路由测试场景:小程序首页 | ||
</Text> | ||
<Button | ||
onClick={()=>{ | ||
Taro.navigateTo({ | ||
url: 'pages/harmony-hybrid/mix-router/list/index' | ||
}) | ||
}}> | ||
跳转:小程序列表页 | ||
</Button> | ||
<Button | ||
onClick={()=>{ | ||
nativeApi.navigateToNative({ | ||
url: 'pages/NativeList' | ||
}) | ||
}}> | ||
跳转:原生列表页 | ||
</Button> | ||
</View> | ||
) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/mini-program-example/src/pages/harmony-hybrid/mix-router/list/index.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
navigationBarTitleText: '混合路由:小程序列表页', | ||
enablePullDownRefresh: false, | ||
backgroundTextStyle: 'dark', | ||
onReachBottomDistance: 50, | ||
pageOrientation: 'auto', | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/mini-program-example/src/pages/harmony-hybrid/mix-router/list/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@import "@/styles/variables.scss"; | ||
|
||
.title { | ||
font-size: 40px; | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
width: 100%; | ||
text-align: center; | ||
display: block; | ||
} |
33 changes: 33 additions & 0 deletions
33
examples/mini-program-example/src/pages/harmony-hybrid/mix-router/list/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react' | ||
import { View, Button, Text } from '@tarojs/components' | ||
import './index.scss' | ||
import Taro from "@tarojs/taro"; | ||
export default class Index extends React.Component { | ||
state = { | ||
// syncSingleResult: '', | ||
// requestSingleResult: '', | ||
// requestConcurrentResult: '', | ||
// requestHignConcurrentResult: '', | ||
// syncResult: '', | ||
// requestByJsResult: '' | ||
} | ||
|
||
render() { | ||
// const { syncSingleResult } = this.state | ||
return ( | ||
<View className='harmony-hybrid-page'> | ||
<Text className='title'> | ||
混合路由测试场景:小程序列表页 | ||
</Text> | ||
<Button | ||
onClick={()=>{ | ||
Taro.navigateTo({ | ||
url: 'pages/harmony-hybrid/mix-router/detail/index' | ||
}) | ||
}}> | ||
跳转:小程序详情页 | ||
</Button> | ||
</View> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters