xiongzhu 4 gadi atpakaļ
vecāks
revīzija
03b4fb4a85
1 mainītis faili ar 40 papildinājumiem un 46 dzēšanām
  1. 40 46
      src/main.js

+ 40 - 46
src/main.js

@@ -134,54 +134,48 @@ if (navigator.userAgent.includes('#cordova#')) {
                 },
                 false
             );
-            window.codePush.sync(
-                function (syncStatus) {
-                    switch (syncStatus) {
-                        // Result (final) statuses
-                        case SyncStatus.UPDATE_INSTALLED:
-                            console.log(
-                                'The update was installed successfully. For InstallMode.ON_NEXT_RESTART, the changes will be visible after application restart. '
-                            );
-                            break;
-                        case SyncStatus.UP_TO_DATE:
-                            console.log('The application is up to date.');
-                            break;
-                        case SyncStatus.UPDATE_IGNORED:
-                            console.log('The user decided not to install the optional update.');
-                            break;
-                        case SyncStatus.ERROR:
-                            console.log('An error occured while checking for updates');
-                            break;
 
-                        // Intermediate (non final) statuses
-                        case SyncStatus.CHECKING_FOR_UPDATE:
-                            console.log('Checking for update.');
-                            break;
-                        case SyncStatus.AWAITING_USER_ACTION:
-                            console.log('Alerting user.');
-                            break;
-                        case SyncStatus.DOWNLOADING_PACKAGE:
-                            console.log('Downloading package.');
-                            break;
-                        case SyncStatus.INSTALLING_UPDATE:
-                            console.log('Installing update');
-                            break;
+            if (!(location.host === 'www.raex.vip' || location.host === 'test.raex.vip')) {
+                window.$vm.$dialog
+                    .alert({
+                        message: '检测到新版本,请下载更新',
+                        beforeClose(action, done) {
+                            if (action === 'confirm') {
+                                setTimeout(done, 1000);
+                            } else {
+                                done();
+                            }
+                        }
+                    })
+                    .then(() => {
+                        if (/iphone|ipad|ipod/.test(navigator.userAgent)) {
+                            //location.href = 'https://apps.apple.com/cn/app/id1598469798';
+                        } else {
+                            location.href = 'http://download.raex.vip';
+                        }
+                    });
+            }
+
+            if (
+                !(
+                    location.host === 'www.raex.vip' ||
+                    location.host === 'test.raex.vip' ||
+                    /^http:\/\/192\.168\.\d{1,3}\.\d{1,3}((:\d+)?)$/.test(location.host)
+                )
+            ) {
+                window.$vm.$dialog.alert({
+                    message: '检测到新版本,请下载更新',
+                    confirmButtonText: '下载更新',
+                    beforeClose(action, done) {
+                        console.log(action);
+                        if (/iphone|ipad|ipod/.test(navigator.userAgent)) {
+                            //location.href = 'https://apps.apple.com/cn/app/id1598469798';
+                        } else {
+                            location.href = 'http://download.raex.vip';
+                        }
                     }
-                },
-                {
-                    installMode: InstallMode.IMMEDIATE,
-                    updateDialog: false
-                },
-                function (downloadProgress) {
-                    console.log(
-                        'Downloading ' +
-                            downloadProgress.receivedBytes +
-                            ' of ' +
-                            downloadProgress.totalBytes +
-                            ' bytes.'
-                    );
-                }
-            );
+                });
+            }
         },
         false
     );