xiongzhu 4 лет назад
Родитель
Сommit
fa2a773bec
1 измененных файлов с 27 добавлено и 21 удалено
  1. 27 21
      src/main.js

+ 27 - 21
src/main.js

@@ -121,6 +121,7 @@ const loadSplash = (onload, onerror) =>
         const splash = document.createElement('img');
         splash.className = 'splash-screen';
         splash.onload = () => {
+            console.log('splash onload');
             onload && onload();
             setTimeout(() => {
                 hideSplash();
@@ -133,7 +134,7 @@ const loadSplash = (onload, onerror) =>
         setTimeout(() => {
             hideSplash();
         }, 5000);
-        splash.src = 'https://cdn.raex.vip/splash.jpg?ts=' + new Date().getTime();
+        splash.src = 'https://cdn.raex.vip/splash.jpg';
         document.body.append(splash);
     });
 
@@ -142,15 +143,37 @@ if (navigator.userAgent.includes('#cordova#')) {
         'deviceready',
         function () {
             StatusBar.overlaysWebView(true);
-            window.$vm = app.mount('#app');
+
+            function mountApp() {
+                window.$vm = app.mount('#app');
+                http.http
+                    .get('/appVersion/checkUpdate', {
+                        platform: window.cordova.platformId,
+                        version: navigator.appInfo.version
+                    })
+                    .then(res => {
+                        if (res.needUpdate) {
+                            window.$vm.$dialog.alert({
+                                message: '检测到新版本,请下载更新',
+                                confirmButtonText: '下载更新',
+                                beforeClose(action, done) {
+                                    console.log(action);
+                                    location.href = 'http://download.raex.vip';
+                                }
+                            });
+                        }
+                    });
+            }
             loadSplash(
                 () => {
                     setTimeout(() => {
                         navigator.splashscreen.hide();
                     }, 100);
+                    mountApp();
                 },
                 () => {
                     navigator.splashscreen.hide();
+                    mountApp();
                 }
             ).then(res => {
                 StatusBar.overlaysWebView(false);
@@ -158,7 +181,7 @@ if (navigator.userAgent.includes('#cordova#')) {
                 StatusBar.styleDefault();
             });
 
-            if (/iphone|ipad|ipod/i.test(navigator.userAgent)) {
+            if ('ios' === window.cordova.platformId) {
                 style.setProperty('--safe-top', 'env(safe-area-inset-top)');
                 style.setProperty('--safe-bottom', 'env(safe-area-inset-bottom)');
                 style.setProperty('--safe-left', 'env(safe-area-inset-left)');
@@ -216,24 +239,7 @@ if (navigator.userAgent.includes('#cordova#')) {
                 false
             );
 
-            if (!(/.+\.raex\.vip/.test(location.host) || /192\.168/.test(location.host))) {
-                if (!/iphone|ipad|ipod|Macintosh/i.test(navigator.userAgent)) {
-                    window.$vm.$dialog.alert({
-                        message: '检测到新版本,请下载更新',
-                        confirmButtonText: '下载更新',
-                        beforeClose(action, done) {
-                            console.log(action);
-                            if (/iphone|ipad|ipod|Macintosh/i.test(navigator.userAgent)) {
-                                //location.href = 'https://apps.apple.com/cn/app/id1598469798';
-                            } else {
-                                location.href = 'http://download.raex.vip';
-                            }
-                        }
-                    });
-                }
-            }
-
-            if (window.store && /iphone|ipad|ipod|Macintosh/i.test(navigator.userAgent)) {
+            if ('ios' === window.cordova.platformId) {
                 window.store.register({
                     id: '358',
                     alias: '358',