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 extraNodeModules = {
react: path.resolve(__dirname, 'node_modules/react'),
'react-native': path.resolve(__dirname, 'node_modules/react-native'),
'react-native-update': path.resolve(__dirname, '../..'),
'@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'),
};
const watchFolders = [path.resolve(__dirname, '../..')];
// const extraNodeModules = {
// react: path.resolve(__dirname, 'node_modules/react'),
// 'react-native': path.resolve(__dirname, 'node_modules/react-native'),
// 'react-native-update': path.resolve(__dirname, '../..'),
// '@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'),
// };
// const watchFolders = [path.resolve(__dirname, '../..')];
module.exports = {
transformer: {
@ -17,8 +17,8 @@ module.exports = {
},
}),
},
resolver: {
extraNodeModules,
},
watchFolders,
// resolver: {
// extraNodeModules,
// },
// watchFolders,
};

View File

@ -18,7 +18,7 @@
"react-native": "0.69.8",
"react-native-paper": "^5.12.1",
"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"
},
"devDependencies": {

View File

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