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

feat: update example

This commit is contained in:
sunnylqm 2024-01-22 15:55:52 +08:00
parent e86df57476
commit 2a3b8e5707
No known key found for this signature in database
4 changed files with 53 additions and 41 deletions

View File

@ -1,12 +1,12 @@
const path = require('path'); const path = require('path');
const extraNodeModules = { // const extraNodeModules = {
react: path.resolve(__dirname, 'node_modules/react'), // react: path.resolve(__dirname, 'node_modules/react'),
'react-native': path.resolve(__dirname, 'node_modules/react-native'), // 'react-native': path.resolve(__dirname, 'node_modules/react-native'),
'react-native-update': path.resolve(__dirname, '../..'), // 'react-native-update': path.resolve(__dirname, '../..'),
'@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'), // '@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'),
}; // };
const watchFolders = [path.resolve(__dirname, '../..')]; // const watchFolders = [path.resolve(__dirname, '../..')];
module.exports = { module.exports = {
transformer: { transformer: {
@ -17,8 +17,8 @@ module.exports = {
}, },
}), }),
}, },
resolver: { // resolver: {
extraNodeModules, // extraNodeModules,
}, // },
watchFolders, // watchFolders,
}; };

View File

@ -18,7 +18,7 @@
"react-native": "0.69.8", "react-native": "0.69.8",
"react-native-paper": "^5.12.1", "react-native-paper": "^5.12.1",
"react-native-safe-area-context": "^4.8.2", "react-native-safe-area-context": "^4.8.2",
"react-native-update": "link:../..", "react-native-update": "10.0.0-beta.1",
"react-native-vector-icons": "^10.0.3" "react-native-vector-icons": "^10.0.3"
}, },
"devDependencies": { "devDependencies": {

View File

@ -24,9 +24,12 @@ function App() {
switchVersionLater, switchVersionLater,
switchVersion, switchVersion,
updateInfo, updateInfo,
packageVersion,
currentHash,
progress: {received, total} = {}, progress: {received, total} = {},
} = usePushy(); } = usePushy();
const [useDefaultAlert, setUseDefaultAlert] = useState(true); const [useDefaultAlert, setUseDefaultAlert] = useState(true);
const [showTestConsole, setShowTestConsole] = useState(false);
const [showUpdateBanner, setShowUpdateBanner] = useState(false); const [showUpdateBanner, setShowUpdateBanner] = useState(false);
const [showUpdateSnackbar, setShowUpdateSnackbar] = useState(false); const [showUpdateSnackbar, setShowUpdateSnackbar] = useState(false);
const snackbarVisible = const snackbarVisible =
@ -37,16 +40,20 @@ function App() {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Text style={styles.welcome}>欢迎使用Pushy热更新服务</Text> <Text style={styles.welcome}>欢迎使用Pushy热更新服务</Text>
<View style={{flexDirection: 'row'}}>
<Text>
{useDefaultAlert ? '当前使用' : '当前不使用'}默认的alert更新提示
</Text>
<Switch <Switch
value={useCustomUi} value={useDefaultAlert}
onValueChange={v => { onValueChange={v => {
setUseDefaultAlert(v); setUseDefaultAlert(v);
client.setOptions({ client.setOptions({
showAlert: v, showAlert: v,
}); });
}}> }}
{useDefaultAlert ? '当前使用' : '当前不使用'}默认的alert更新提示 />
</Switch> </View>
<Image <Image
resizeMode={'contain'} resizeMode={'contain'}
source={require('./assets/shezhi.png')} source={require('./assets/shezhi.png')}
@ -56,7 +63,7 @@ function App() {
这是版本一 {'\n'} 这是版本一 {'\n'}
当前原生包版本号: {packageVersion} 当前原生包版本号: {packageVersion}
{'\n'} {'\n'}
当前热更新版本Hash: {currentVersion || '(空)'} 当前热更新版本Hash: {currentHash || '(空)'}
{'\n'} {'\n'}
</Text> </Text>
<Text> <Text>
@ -70,15 +77,16 @@ function App() {
testID="testcase" testID="testcase"
style={{marginTop: 15}} style={{marginTop: 15}}
onLongPress={() => { onLongPress={() => {
this.setState({showTestConsole: true}); setShowTestConsole(true);
}}> }}>
<Text style={styles.instructions}> <Text style={styles.instructions}>
react-native-update版本{client.version} react-native-update版本{client.version}
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
<TestConsole visible={showTestConsole} /> <TestConsole visible={showTestConsole} />
{snackbarVisible && (
<Snackbar <Snackbar
visible={snackbarVisible} visible={true}
onDismiss={() => { onDismiss={() => {
setShowUpdateSnackbar(false); setShowUpdateSnackbar(false);
}} }}
@ -90,8 +98,9 @@ function App() {
setShowUpdateBanner(true); setShowUpdateBanner(true);
}, },
}}> }}>
有新版本({updateInfo.version})可用是否更新 <Text>有新版本({updateInfo.version})可用是否更新</Text>
</Snackbar> </Snackbar>
)}
<Banner <Banner
visible={showUpdateBanner} visible={showUpdateBanner}
actions={[ actions={[

View File

@ -6231,9 +6231,12 @@ react-native-safe-area-context@^4.8.2:
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.8.2.tgz#e6b3d8acf3c6afcb4b5db03a97f9c37df7668f65" resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.8.2.tgz#e6b3d8acf3c6afcb4b5db03a97f9c37df7668f65"
integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ== integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ==
"react-native-update@link:../..": react-native-update@10.0.0-beta.1:
version "0.0.0" version "10.0.0-beta.1"
uid "" resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.0.0-beta.1.tgz#bc49a7197dd19c16ba798ea13324b4b292edd052"
integrity sha512-PFTsut8SL+vqAPtBUzPg9KKU9mFgCktKttifzM8B4puSoburlSN2UnD+eDWxLkXyIWQtoQAqAmXPE1/zA/e7dw==
dependencies:
nanoid "^3.3.3"
react-native-vector-icons@^10.0.3: react-native-vector-icons@^10.0.3:
version "10.0.3" version "10.0.3"