1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-11-03 06:43:10 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

chore: cleanup

This commit is contained in:
sunnylqm
2023-09-02 22:40:55 +08:00
parent 6d01ce5152
commit 094eb3f267
2 changed files with 11 additions and 6 deletions

View File

@@ -125,7 +125,6 @@ export const cInfo = {
}; };
function assertRelease() { function assertRelease() {
// @ts-expect-error
if (__DEV__) { if (__DEV__) {
throw new Error('react-native-update 只能在 RELEASE 版本中运行.'); throw new Error('react-native-update 只能在 RELEASE 版本中运行.');
} }

View File

@@ -1,5 +1,11 @@
import React, { PureComponent } from 'react'; import React, { PureComponent, ComponentType } from 'react';
import { Platform, Alert, Linking, AppState } from 'react-native'; import {
Platform,
Alert,
Linking,
AppState,
NativeEventSubscription,
} from 'react-native';
import { import {
isFirstTime, isFirstTime,
@@ -15,7 +21,7 @@ import {
import { UpdateEventsListener } from './type'; import { UpdateEventsListener } from './type';
export function simpleUpdate( export function simpleUpdate(
WrappedComponent: JSX.Element, WrappedComponent: ComponentType,
options: { appKey?: string; onEvents?: UpdateEventsListener } = {}, options: { appKey?: string; onEvents?: UpdateEventsListener } = {},
) { ) {
const { appKey, onEvents: eventListeners } = options; const { appKey, onEvents: eventListeners } = options;
@@ -25,10 +31,10 @@ export function simpleUpdate(
if (typeof eventListeners === 'function') { if (typeof eventListeners === 'function') {
onEvents(eventListeners); onEvents(eventListeners);
} }
// @ts-expect-error
return __DEV__ return __DEV__
? WrappedComponent ? WrappedComponent
: class AppUpdate extends PureComponent { : class AppUpdate extends PureComponent {
stateListener: NativeEventSubscription;
componentDidMount() { componentDidMount() {
if (isRolledBack) { if (isRolledBack) {
Alert.alert('抱歉', '刚刚更新遭遇错误,已为您恢复到更新前版本'); Alert.alert('抱歉', '刚刚更新遭遇错误,已为您恢复到更新前版本');
@@ -79,7 +85,7 @@ export function simpleUpdate(
checkUpdate = async () => { checkUpdate = async () => {
let info; let info;
try { try {
info = await checkUpdate(appKey); info = await checkUpdate(appKey!);
} catch (err) { } catch (err) {
Alert.alert('更新检查失败', err.message); Alert.alert('更新检查失败', err.message);
return; return;