mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 21:33:12 +08:00 
			
		
		
		
	fix a wrong dep
This commit is contained in:
		| @@ -19,23 +19,25 @@ const UUID = '00000000-0000-0000-0000-000000000000'; | |||||||
| const DownloadUrl = | const DownloadUrl = | ||||||
|   'http://cos.pgyer.com/697913e94d7441f20c686e2b0996a1aa.apk?sign=7a8f11b1df82cba45c8ac30b1acec88c&t=1680404102&response-content-disposition=attachment%3Bfilename%3DtestHotupdate_1.0.apk'; |   'http://cos.pgyer.com/697913e94d7441f20c686e2b0996a1aa.apk?sign=7a8f11b1df82cba45c8ac30b1acec88c&t=1680404102&response-content-disposition=attachment%3Bfilename%3DtestHotupdate_1.0.apk'; | ||||||
|  |  | ||||||
|  | const CustomDialog = ({title, visible, onConfirm}) => { | ||||||
|  |   if (!visible) { | ||||||
|  |     return null; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   const CustomDialog = ({title, visible, onConfirm}) => { |   return ( | ||||||
|     if (!visible) { |     <View style={styles.overlay}> | ||||||
|       return null; |       <View style={styles.dialog}> | ||||||
|     } |         <Text style={styles.title}>{title}</Text> | ||||||
|    |         <TouchableOpacity | ||||||
|     return ( |           testID="done" | ||||||
|       <View style={styles.overlay}> |           style={styles.button} | ||||||
|         <View style={styles.dialog}> |           onLongPress={onConfirm}> | ||||||
|           <Text style={styles.title}>{title}</Text> |           <Text style={styles.buttonText}>确认</Text> | ||||||
|           <TouchableOpacity testID='done' style={styles.button} onLongPress={onConfirm}> |         </TouchableOpacity> | ||||||
|             <Text style={styles.buttonText}>确认</Text> |  | ||||||
|           </TouchableOpacity> |  | ||||||
|         </View> |  | ||||||
|       </View> |       </View> | ||||||
|     ); |     </View> | ||||||
|   }; |   ); | ||||||
|  | }; | ||||||
| export default function TestConsole({visible}) { | export default function TestConsole({visible}) { | ||||||
|   const [text, setText] = useState(''); |   const [text, setText] = useState(''); | ||||||
|   const [running, setRunning] = useState(false); |   const [running, setRunning] = useState(false); | ||||||
| @@ -132,9 +134,8 @@ export default function TestConsole({visible}) { | |||||||
|           testID={NativeTestMethod[i].name} |           testID={NativeTestMethod[i].name} | ||||||
|           onLongPress={() => { |           onLongPress={() => { | ||||||
|             NativeTestMethod[i].invoke(); |             NativeTestMethod[i].invoke(); | ||||||
|           }} |           }}> | ||||||
|         > |           <Text>{NativeTestMethod[i].name}</Text> | ||||||
|         <Text>{NativeTestMethod[i].name}</Text> |  | ||||||
|         </TouchableOpacity>, |         </TouchableOpacity>, | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
| @@ -164,8 +165,14 @@ export default function TestConsole({visible}) { | |||||||
|         /> |         /> | ||||||
|         {running && <ActivityIndicator />} |         {running && <ActivityIndicator />} | ||||||
|         <TouchableOpacity |         <TouchableOpacity | ||||||
|         style={{backgroundColor:'rgb(0,140,237)', justifyContent: 'center', |           style={{ | ||||||
|         alignItems: 'center',paddingTop:10,paddingBottom:10,marginBottom:5}} |             backgroundColor: 'rgb(0,140,237)', | ||||||
|  |             justifyContent: 'center', | ||||||
|  |             alignItems: 'center', | ||||||
|  |             paddingTop: 10, | ||||||
|  |             paddingBottom: 10, | ||||||
|  |             marginBottom: 5, | ||||||
|  |           }} | ||||||
|           testID="submit" |           testID="submit" | ||||||
|           onLongPress={async () => { |           onLongPress={async () => { | ||||||
|             setRunning(true); |             setRunning(true); | ||||||
| @@ -190,22 +197,23 @@ export default function TestConsole({visible}) { | |||||||
|               } |               } | ||||||
|               setAlertVisible(true); |               setAlertVisible(true); | ||||||
|               setAlertMsg('done'); |               setAlertMsg('done'); | ||||||
|             } catch (e: any) { |             } catch (e) { | ||||||
|               setAlertVisible(true); |               setAlertVisible(true); | ||||||
|               setAlertMsg(e.message); |               setAlertMsg(e.message); | ||||||
|             } |             } | ||||||
|             setRunning(false); |             setRunning(false); | ||||||
|           }} |           }}> | ||||||
|         > |           <Text style={{color: 'white'}}>执行</Text> | ||||||
|           <Text style={{color:'white'}}>执行</Text> |  | ||||||
|         </TouchableOpacity> |         </TouchableOpacity> | ||||||
|          <Button title="重置" onPress={() => setText('')} /> |         <Button title="重置" onPress={() => setText('')} /> | ||||||
|           {renderTestView()} |         {renderTestView()} | ||||||
|           <CustomDialog |         <CustomDialog | ||||||
|             title={alertMsg} |           title={alertMsg} | ||||||
|             visible={alertVisible} |           visible={alertVisible} | ||||||
|             onConfirm={()=>{setAlertVisible(false)}} |           onConfirm={() => { | ||||||
|       /> |             setAlertVisible(false); | ||||||
|  |           }} | ||||||
|  |         /> | ||||||
|       </SafeAreaView> |       </SafeAreaView> | ||||||
|     </Modal> |     </Modal> | ||||||
|   ); |   ); | ||||||
|   | |||||||
| @@ -32,6 +32,7 @@ export const PushyProvider = ({ | |||||||
|   const { options } = client; |   const { options } = client; | ||||||
|   const stateListener = useRef<NativeEventSubscription>(); |   const stateListener = useRef<NativeEventSubscription>(); | ||||||
|   const [updateInfo, setUpdateInfo] = useState<CheckResult>(); |   const [updateInfo, setUpdateInfo] = useState<CheckResult>(); | ||||||
|  |   const updateInfoRef = useRef(updateInfo); | ||||||
|   const [progress, setProgress] = useState<ProgressData>(); |   const [progress, setProgress] = useState<ProgressData>(); | ||||||
|   const [lastError, setLastError] = useState<Error>(); |   const [lastError, setLastError] = useState<Error>(); | ||||||
|   const lastChecking = useRef(0); |   const lastChecking = useRef(0); | ||||||
| @@ -61,37 +62,40 @@ export const PushyProvider = ({ | |||||||
|     } |     } | ||||||
|   }, [client, updateInfo]); |   }, [client, updateInfo]); | ||||||
|  |  | ||||||
|   const downloadUpdate = useCallback(async () => { |   const downloadUpdate = useCallback( | ||||||
|     if (!updateInfo || !updateInfo.update) { |     async (info: CheckResult | undefined = updateInfoRef.current) => { | ||||||
|       return; |       if (!info || !info.update) { | ||||||
|     } |  | ||||||
|     try { |  | ||||||
|       const hash = await client.downloadUpdate(updateInfo, setProgress); |  | ||||||
|       if (!hash) { |  | ||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|       stateListener.current && stateListener.current.remove(); |       try { | ||||||
|       showAlert('提示', '下载完毕,是否立即更新?', [ |         const hash = await client.downloadUpdate(info, setProgress); | ||||||
|         { |         if (!hash) { | ||||||
|           text: '下次再说', |           return; | ||||||
|           style: 'cancel', |         } | ||||||
|           onPress: () => { |         stateListener.current && stateListener.current.remove(); | ||||||
|             client.switchVersionLater(hash); |         showAlert('提示', '下载完毕,是否立即更新?', [ | ||||||
|  |           { | ||||||
|  |             text: '下次再说', | ||||||
|  |             style: 'cancel', | ||||||
|  |             onPress: () => { | ||||||
|  |               client.switchVersionLater(hash); | ||||||
|  |             }, | ||||||
|           }, |           }, | ||||||
|         }, |           { | ||||||
|         { |             text: '立即更新', | ||||||
|           text: '立即更新', |             style: 'default', | ||||||
|           style: 'default', |             onPress: () => { | ||||||
|           onPress: () => { |               client.switchVersion(hash); | ||||||
|             client.switchVersion(hash); |             }, | ||||||
|           }, |           }, | ||||||
|         }, |         ]); | ||||||
|       ]); |       } catch (e: any) { | ||||||
|     } catch (e: any) { |         setLastError(e); | ||||||
|       setLastError(e); |         showAlert('更新失败', e.message); | ||||||
|       showAlert('更新失败', e.message); |       } | ||||||
|     } |     }, | ||||||
|   }, [client, showAlert, updateInfo]); |     [client, showAlert], | ||||||
|  |   ); | ||||||
|  |  | ||||||
|   const downloadAndInstallApk = useCallback( |   const downloadAndInstallApk = useCallback( | ||||||
|     async (downloadUrl: string) => { |     async (downloadUrl: string) => { | ||||||
| @@ -116,6 +120,7 @@ export const PushyProvider = ({ | |||||||
|       showAlert('更新检查失败', e.message); |       showAlert('更新检查失败', e.message); | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  |     updateInfoRef.current = info; | ||||||
|     setUpdateInfo(info); |     setUpdateInfo(info); | ||||||
|     if (info.expired) { |     if (info.expired) { | ||||||
|       const { downloadUrl } = info; |       const { downloadUrl } = info; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm