mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-03 06:43:10 +08:00
chore: cleanup
This commit is contained in:
@@ -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 版本中运行.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user