Переглянути джерело

[升级][修改]:优化升级组件使用方式

tags/jenkins-front-end-screenad-192-v106^0
hupeng 5 роки тому
джерело
коміт
5cab2a84c4
1 змінених файлів з 10 додано та 7 видалено
  1. +10
    -7
      App.js

+ 10
- 7
App.js Переглянути файл

@@ -82,6 +82,7 @@ let codePushOptions = {
};

export default class MyPage extends Component {
constructor(props) {
super(props);
this.state = {
@@ -105,7 +106,7 @@ export default class MyPage extends Component {

//更新函数
async codePushUpdate() {
CodePush.allowRestart();
await CodePush.getUpdateMetadata(CodePush.UpdateState.RUNNING)
.then((metadata: LocalPackage) => {
this.setState({ versionInfo: metadata ? 'b'+NativeModules.BuildConfig.versionCode+"-" + metadata.label : 'b'+ NativeModules.BuildConfig.versionCode});
@@ -114,15 +115,18 @@ async codePushUpdate() {
this.setState({ versionInfo: "Unknown"});
versionInfo = this.state.versionInfo;
});
await CodePush.disallowRestart();
await CodePush.sync(
{ mandatoryInstallMode: CodePush.InstallMode.IMMEDIATE,
installMode: CodePush.InstallMode.IMMEDIATE},
this.codePushStatusDidChange.bind(this),
this.codePushDownloadDidProgress.bind(this)
);
await CodePush.allowRestart();
).then((status: SyncStatus) => {
if(status!=CodePush.SyncStatus.UP_TO_DATE){
CodePush.restartApp();
}
}, (error: any) => {
CodePush.restartApp();
});
}


@@ -527,7 +531,7 @@ render() {
return this.getAdView();
}
}
MyPage = CodePush(codePushOptions)(MyPage);
const styles = StyleSheet.create({
updatePage:{
flex: 2,
@@ -892,5 +896,4 @@ render() {
textDecorationLine: 'line-through',
color : 'gray'
},

});

Завантаження…
Відмінити
Зберегти