mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 13:23:12 +08:00 
			
		
		
		
	Implement download progress
This commit is contained in:
		| @@ -27,6 +27,10 @@ import _updateConfig from '../update.json'; | ||||
| const {appKey} = _updateConfig[Platform.OS]; | ||||
|  | ||||
| export default class App extends Component { | ||||
|   state = { | ||||
|     received: 0, | ||||
|     total: 0, | ||||
|   }; | ||||
|   componentDidMount() { | ||||
|     if (isRolledBack) { | ||||
|       Alert.alert('提示', '刚刚更新失败了,版本被回滚.'); | ||||
| @@ -51,9 +55,16 @@ export default class App extends Component { | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
|   doUpdate = async info => { | ||||
|   doUpdate = async (info) => { | ||||
|     try { | ||||
|       const hash = await downloadUpdate(info); | ||||
|       const hash = await downloadUpdate(info, { | ||||
|         onDownloadProgress: ({received, total}) => { | ||||
|           setState({ | ||||
|             received, | ||||
|             total, | ||||
|           }); | ||||
|         }, | ||||
|       }); | ||||
|       Alert.alert('提示', '下载完毕,是否重启应用?', [ | ||||
|         { | ||||
|           text: '是', | ||||
| @@ -126,6 +137,9 @@ export default class App extends Component { | ||||
|           当前热更新版本Hash: {currentVersion || '(空)'} | ||||
|           {'\n'} | ||||
|         </Text> | ||||
|         <Text> | ||||
|           下载进度:{received} / {total} | ||||
|         </Text> | ||||
|         <TouchableOpacity onPress={this.checkUpdate}> | ||||
|           <Text style={styles.instructions}>点击这里检查更新</Text> | ||||
|         </TouchableOpacity> | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm