diff --git a/src/langs/zh_Hans.txt b/src/langs/zh_Hans.txt index 00be850..23b858f 100644 --- a/src/langs/zh_Hans.txt +++ b/src/langs/zh_Hans.txt @@ -181,6 +181,7 @@ Invalid settings data format!=无效的设置数据格式! Data has been copied to clipboard.=数据已经复制到剪贴板中. Supported Placeholder=支持的占位符 AriaNg Title=AriaNg 标题 +Current RPC Alias=当前 RPC 别名 Downloading Count=正在下载数量 Waiting Count=正在等待数量 Stopped Count=已停止数量 diff --git a/src/langs/zh_Hant.txt b/src/langs/zh_Hant.txt index 2adbd24..e2eaec5 100644 --- a/src/langs/zh_Hant.txt +++ b/src/langs/zh_Hant.txt @@ -182,6 +182,7 @@ Data has been copied to clipboard.=資料已經複製到剪貼簿中. Supported Placeholder=支援的預留位置 AriaNg Title=AriaNg 標題 Downloading Count=正在下載數量 +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.=您已經在瀏覽器中停用通知功能. 如需使用此功能, 請修改您瀏覽器的設定. diff --git a/src/scripts/config/defaultLanguage.js b/src/scripts/config/defaultLanguage.js index 28d5758..c74da6e 100644 --- a/src/scripts/config/defaultLanguage.js +++ b/src/scripts/config/defaultLanguage.js @@ -185,6 +185,7 @@ 'Data has been copied to clipboard.': 'Data has been copied to clipboard.', 'Supported Placeholder': 'Supported Placeholder', 'AriaNg Title': 'AriaNg Title', + 'Current RPC Alias': 'Current RPC Alias', 'Downloading Count': 'Downloading Count', 'Waiting Count': 'Waiting Count', 'Stopped Count': 'Stopped Count', diff --git a/src/scripts/controllers/main.js b/src/scripts/controllers/main.js index 37331b1..b9653b3 100644 --- a/src/scripts/controllers/main.js +++ b/src/scripts/controllers/main.js @@ -6,7 +6,10 @@ var globalStatRefreshPromise = null; var refreshPageTitle = function () { - $document[0].title = ariaNgTitleService.getFinalTitleByGlobalStat($scope.globalStat); + $document[0].title = ariaNgTitleService.getFinalTitleByGlobalStat({ + globalStat: $scope.globalStat, + currentRpcProfile: getCurrentRPCProfile() + }); }; var refreshGlobalStat = function (silent, callback) { @@ -27,6 +30,21 @@ }, silent); }; + var getCurrentRPCProfile = function () { + if (!$scope.rpcSettings || $scope.rpcSettings.length < 1) { + return null; + } + + for (var i = 0; i < $scope.rpcSettings.length; i++) { + var rpcSetting = $scope.rpcSettings[i]; + if (rpcSetting.isDefault) { + return rpcSetting; + } + } + + return null; + }; + if (ariaNgSettingService.getBrowserNotification()) { ariaNgNotificationService.requestBrowserPermission(); } diff --git a/src/scripts/controllers/settings-ariang.js b/src/scripts/controllers/settings-ariang.js index d67f3a6..fb60445 100644 --- a/src/scripts/controllers/settings-ariang.js +++ b/src/scripts/controllers/settings-ariang.js @@ -6,7 +6,25 @@ var lastRefreshPageNotification = null; var getFinalTitle = function () { - return ariaNgTitleService.getFinalTitleByGlobalStat(ariaNgMonitorService.getCurrentGlobalStat()); + return ariaNgTitleService.getFinalTitleByGlobalStat({ + globalStat: ariaNgMonitorService.getCurrentGlobalStat(), + currentRpcProfile: getCurrentRPCProfile() + }); + }; + + var getCurrentRPCProfile = function () { + if (!$scope.context || !$scope.context.rpcSettings || $scope.context.rpcSettings.length < 1) { + return null; + } + + for (var i = 0; i < $scope.context.rpcSettings.length; i++) { + var rpcSetting = $scope.context.rpcSettings[i]; + if (rpcSetting.isDefault) { + return rpcSetting; + } + } + + return null; }; var setNeedRefreshPage = function () { @@ -50,6 +68,7 @@ exportSettingsCopied: false }; + $scope.context.titlePreview = getFinalTitle(); $scope.context.showDebugMode = $scope.context.sessionSettings.debugMode || extendType === 'debug'; $scope.changeGlobalTab = function () { diff --git a/src/scripts/services/ariaNgTitleService.js b/src/scripts/services/ariaNgTitleService.js index f9456b9..bf3b823 100644 --- a/src/scripts/services/ariaNgTitleService.js +++ b/src/scripts/services/ariaNgTitleService.js @@ -61,6 +61,12 @@ return title; }; + var replaceCurrentRPCAlias = function (title, value) { + return replacePlaceholders(title, 'rpcprofile', { + value: value + }); + }; + var replaceDownloadingCount = function (title, value) { return replacePlaceholders(title, 'downloading', { prefix: ariaNgLocalizationService.getLocalizedText('Downloading') + ': ', @@ -118,6 +124,7 @@ uploadSpeed: 0 }, context); + title = replaceCurrentRPCAlias(title, context.currentRPCAlias); title = replaceDownloadingCount(title, context.downloadingCount); title = replaceWaitingCount(title, context.waitingCount); title = replaceStoppedCount(title, context.stoppedCount); @@ -127,13 +134,14 @@ return title; }, - getFinalTitleByGlobalStat: function (globalStat) { + getFinalTitleByGlobalStat: function (params) { var context = { - downloadingCount: (globalStat ? globalStat.numActive : 0), - waitingCount: (globalStat ? globalStat.numWaiting : 0), - stoppedCount: (globalStat ? globalStat.numStopped : 0), - downloadSpeed: (globalStat ? globalStat.downloadSpeed : 0), - uploadSpeed: (globalStat ? globalStat.uploadSpeed : 0) + currentRPCAlias: (params && params.currentRpcProfile ? (params.currentRpcProfile.rpcAlias || (params.currentRpcProfile.rpcHost + ':' + params.currentRpcProfile.rpcPort)) : ''), + downloadingCount: (params && params.globalStat ? params.globalStat.numActive : 0), + waitingCount: (params && params.globalStat ? params.globalStat.numWaiting : 0), + stoppedCount: (params && params.globalStat ? params.globalStat.numStopped : 0), + downloadSpeed: (params && params.globalStat ? params.globalStat.downloadSpeed : 0), + uploadSpeed: (params && params.globalStat ? params.globalStat.uploadSpeed : 0) }; return this.getFinalTitle(context); diff --git a/src/views/settings-ariang.html b/src/views/settings-ariang.html index bd32c73..b67cf0c 100644 --- a/src/views/settings-ariang.html +++ b/src/views/settings-ariang.html @@ -56,6 +56,7 @@ data-trigger="hover" data-placement="auto right" data-container="body" data-html="true" data-content="{{('Supported Placeholder' | translate) + ':
' + ('AriaNg Title' | translate) + ': ${title}
' + + ('Current RPC Alias' | translate) + ': ${rpcprofile}
' + ('Downloading Count' | translate) + ': ${downloading}
' + ('Waiting Count' | translate) + ': ${waiting}
' + ('Stopped Count' | translate) + ': ${stopped}
' +