-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
65 lines (60 loc) · 2.08 KB
/
App.tsx
File metadata and controls
65 lines (60 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Text, View, Image, Platform } from 'react-native';
import { HotUpdateHelper, HotUpdateButton } from 'rn-shiply-upgrade'; // 新增导入辅助类
const AppV2 = () => {
// 打印当前的平台值
console.log(`currentPlatform: ${Platform.OS}`);
// 初始化热更新配置(只需一次)
HotUpdateHelper.getInstance({
appId: Platform.select({
ios: require('./config.json').ios.appId,
android: require('./config.json').android.appId,
harmony: require('./config.json').harmony.appId
}),
appKey: Platform.select({
ios: require('./config.json').ios.appKey,
android: require('./config.json').android.appKey,
harmony: require('./config.json').harmony.appKey
}),
deviceId: '866123456789012',
appVersion: '10.0.0',
updateCheckIntervalLimit: 60 * 1000, // 60秒限制
isDebugPackage: false,
customParamsByJson: JSON.stringify({ age: '22', name: 'testName' }),
env: 'online',
shiplyResName: 'testRNExample',
eventLogger: ({ type, data }) => {
console.log(`[HotUpdate] ${type}:`, data);
}
});
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>0.72RN Default Demo 1219 </Text>
<Text>Hello World 111 local,show dog</Text>
{/*<Text>Hello World remote,show panda</Text>*/}
<Image
source={require('./dog.jpeg')}
// source={require('./panda.jpg')}
style={{ width: 200, height: 200 }}
/>
<Text style={{ fontSize: 20, marginBottom: 20 }}>热更新示例V2</Text>
{/* 默认样式按钮 */}
<HotUpdateButton />
{/* 自定义样式按钮示例 */}
<HotUpdateButton config={{
buttonStyle: {
backgroundColor: '#4CAF50',
padding: 20,
borderRadius: 10,
marginTop: 20
},
buttonTextStyle: {
color: 'white',
fontSize: 18
},
loadingColor: '#FFEB3B',
buttonText: '立即检查更新'
}} />
</View>
);
};
export default AppV2;