Browse Source

merge https://github.com/mayswind/AriaNg/commit/612c652a2bf12f228de0c530ba556b100715205a

MaysWind 6 years ago
parent
commit
984889354f

+ 1 - 0
app/langs/zh_Hans.txt

@@ -200,6 +200,7 @@ Downloading Count=正在下载数量
 Waiting Count=正在等待数量
 Stopped Count=已停止数量
 You have disabled notification in your browser. You should change your browser's settings before you enable this function.=您已经在浏览器中禁用通知功能. 如需使用此功能, 请修改您浏览器的设置.
+Application cache has been updated, please reload the page for the changes to take effect.=应用缓存已经更新, 请重新加载页面使其生效.
 Language resource has been updated, please reload the page for the changes to take effect.=语言资源已经更新, 请重新加载页面使其生效.
 Configuration has been modified, please reload the page for the changes to take effect.=配置已经修改, 请重新加载页面使其生效.
 Reload AriaNg=重新加载 AriaNg

+ 1 - 0
app/langs/zh_Hant.txt

@@ -200,6 +200,7 @@ Current RPC Alias=目前 RPC 別名
 Waiting Count=正在等待數量
 Stopped Count=已停止數量
 You have disabled notification in your browser. You should change your browser's settings before you enable this function.=您已經在瀏覽器中停用通知功能. 如需使用此功能, 請修改您瀏覽器的設定.
+Application cache has been updated, please reload the page for the changes to take effect.=應用快取已經更新, 請重新載入頁面使其生效.
 Language resource has been updated, please reload the page for the changes to take effect.=語言資源已經更新, 請重新載入頁面使其生效.
 Configuration has been modified, please reload the page for the changes to take effect.=配置已經修改, 請重新載入頁面使其生效.
 Reload AriaNg=重新載入 AriaNg

+ 1 - 0
app/scripts/config/defaultLanguage.js

@@ -204,6 +204,7 @@
             'Waiting Count': 'Waiting Count',
             'Stopped Count': 'Stopped Count',
             'You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.': 'You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.',
+            'Application cache has been updated, please reload the page for the changes to take effect.': 'Application cache has been updated, please reload the page for the changes to take effect.',
             'Language resource has been updated, please reload the page for the changes to take effect.': 'Language resource has been updated, please reload the page for the changes to take effect.',
             'Configuration has been modified, please reload the page for the changes to take effect.': 'Configuration has been modified, please reload the page for the changes to take effect.',
             'Reload AriaNg': 'Reload AriaNg',

+ 8 - 0
app/scripts/core/root.js

@@ -426,6 +426,14 @@
 
         ariaNgSettingService.setDebugMode(ariaNgNativeElectronService.isDevMode());
 
+        ariaNgSettingService.onApplicationCacheUpdated(function () {
+            ariaNgLocalizationService.notifyInPage('', 'Application cache has been updated, please reload the page for the changes to take effect.', {
+                delay: false,
+                type: 'info',
+                templateUrl: 'views/notification-reloadable.html'
+            });
+        });
+
         ariaNgSettingService.onFirstAccess(function () {
             ariaNgLocalizationService.notifyInPage('', 'Tap to configure and get started with AriaNg.', {
                 delay: false,

+ 22 - 0
app/scripts/services/ariaNgSettingService.js

@@ -12,13 +12,25 @@
             };
         })();
         var browserSupportStorage = browserFeatures.localStroage || browserFeatures.cookies;
+        var browserSupportAppCache = !!$window.applicationCache;
 
+        var onAppCacheUpdatedCallbacks = [];
         var onFirstVisitCallbacks = [];
         var firstVisitCallbackFired = false;
         var sessionSettings = {
             debugMode: false
         };
 
+        if (browserSupportAppCache) {
+            var appCache = $window.applicationCache;
+            appCache.addEventListener('updateready', function (e) {
+                for (var i = 0; i < onAppCacheUpdatedCallbacks.length; i++) {
+                    var callback = onAppCacheUpdatedCallbacks[i];
+                    callback();
+                }
+            }, false);
+        }
+
         var fireFirstVisitEvent = function () {
             if (!browserSupportStorage) {
                 return;
@@ -200,6 +212,9 @@
             isBrowserSupportStorage: function () {
                 return browserSupportStorage;
             },
+            isBrowserSupportApplicationCache: function () {
+                return browserSupportAppCache;
+            },
             getBrowserFeatures: function () {
                 return browserFeatures;
             },
@@ -597,6 +612,13 @@
             resetSettings: function () {
                 clearAll();
             },
+            onApplicationCacheUpdated: function (callback) {
+                if (!callback) {
+                    return;
+                }
+
+                onAppCacheUpdatedCallbacks.push(callback);
+            },
             onFirstAccess: function (callback) {
                 if (!callback) {
                     return;