1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

feat: new version

This commit is contained in:
sunnylqm 2024-01-21 22:23:51 +08:00
parent 36533d43c4
commit 1afc896306
No known key found for this signature in database
5 changed files with 4302 additions and 3135 deletions

View File

@ -8,15 +8,12 @@ import {
Image, Image,
Switch, Switch,
} from 'react-native'; } from 'react-native';
import {Icon, PaperProvider} from 'react-native-paper'; import {Icon, PaperProvider, Snackbar, Banner} from 'react-native-paper';
import {Snackbar, Banner} from 'react-native-paper';
import TestConsole from './TestConsole'; import TestConsole from './TestConsole';
import _updateConfig from '../update.json'; import _updateConfig from '../update.json';
import {PushyProvider} from '../../../src/provider'; import {PushyProvider, Pushy, usePushy} from 'react-native-update';
import {Pushy} from '../../../src/client';
import {usePushy} from '../../../src/context';
const {appKey} = _updateConfig[Platform.OS]; const {appKey} = _updateConfig[Platform.OS];
function App() { function App() {

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"name": "react-native-update", "name": "react-native-update",
"version": "9.1.6", "version": "9.1.6",
"description": "react-native hot update", "description": "react-native hot update",
"main": "lib/index.ts", "main": "src/index.ts",
"scripts": { "scripts": {
"prepublish": "yarn submodule", "prepublish": "yarn submodule",
"submodule": "git submodule update --init --recursive", "submodule": "git submodule update --init --recursive",
@ -39,6 +39,7 @@
"url": "https://github.com/reactnativecn/react-native-pushy/issues" "url": "https://github.com/reactnativecn/react-native-pushy/issues"
}, },
"peerDependencies": { "peerDependencies": {
"react": ">=16.8.0",
"react-native": ">=0.57.0" "react-native": ">=0.57.0"
}, },
"homepage": "https://github.com/reactnativecn/react-native-pushy#readme", "homepage": "https://github.com/reactnativecn/react-native-pushy#readme",
@ -59,8 +60,8 @@
"@types/react": "^18.2.46", "@types/react": "^18.2.46",
"eslint": "^8.56.0", "eslint": "^8.56.0",
"prettier": "^2", "prettier": "^2",
"react": "18.2.0", "react": "18.0.0",
"react-native": "0.73", "react-native": "0.69.8",
"typescript": "^5.3.3", "typescript": "^5.3.3",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/jest": "^29.2.1", "@types/jest": "^29.2.1",

View File

@ -66,7 +66,7 @@ export const PushyProvider = ({
return; return;
} }
stateListener.current && stateListener.current.remove(); stateListener.current && stateListener.current.remove();
showAlert('Download complete', 'Do you want to apply the update now?', [ showAlert('提示', '下载完毕,是否立即更新?', [
{ {
text: '下次再说', text: '下次再说',
style: 'cancel', style: 'cancel',
@ -84,7 +84,7 @@ export const PushyProvider = ({
]); ]);
} catch (err) { } catch (err) {
setLastError(err); setLastError(err);
showAlert('Failed to update', err.message); showAlert('更新失败', err.message);
} }
}, [client, showAlert, updateInfo]); }, [client, showAlert, updateInfo]);
@ -94,30 +94,26 @@ export const PushyProvider = ({
info = await client.checkUpdate(); info = await client.checkUpdate();
} catch (err) { } catch (err) {
setLastError(err); setLastError(err);
showAlert('Failed to check update', err.message); showAlert('更新检查失败', err.message);
return; return;
} }
setUpdateInfo(info); setUpdateInfo(info);
if ('expired' in info) { if ('expired' in info) {
const { downloadUrl } = info; const { downloadUrl } = info;
showAlert( showAlert('提示', '您的应用版本已更新,点击更新下载安装新版本', [
'Major update', {
'A full update is required to download and install to continue.', text: '更新',
[ onPress: () => {
{ if (downloadUrl) {
text: '更新', if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) {
onPress: () => { client.downloadAndInstallApk(downloadUrl);
if (downloadUrl) { } else {
if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) { Linking.openURL(downloadUrl);
client.downloadAndInstallApk(downloadUrl);
} else {
Linking.openURL(downloadUrl);
}
} }
}, }
}, },
], },
); ]);
} else if ('update' in info) { } else if ('update' in info) {
showAlert( showAlert(
'提示', '提示',

2494
yarn.lock

File diff suppressed because it is too large Load Diff