add copy magnet link in task list page

This commit is contained in:
MaysWind 2019-03-28 00:41:10 +08:00
parent c2a3252a89
commit a9e47bcdda
6 changed files with 35 additions and 7 deletions

View file

@ -25,6 +25,7 @@ Select None=全部不选
Select Invert=反向选择
Display Order=显示顺序
Copy Download Url=复制下载链接
Copy Magnet Link=复制磁力链接
Help=帮助
Search=搜索
Default=默认

View file

@ -25,6 +25,7 @@ Select None=全部不選
Select Invert=反向選擇
Display Order=顯示順序
Copy Download Url=複製下載連結
Copy Magnet Link=複製磁力連結
Help=說明
Search=搜尋
Default=預設

View file

@ -29,6 +29,7 @@
'Select Invert': 'Select Invert',
'Display Order': 'Display Order',
'Copy Download Url': 'Copy Download Url',
'Copy Magnet Link': 'Copy Magnet Link',
'Help': 'Help',
'Search': 'Search',
'Default': 'Default',

View file

@ -69,13 +69,23 @@
};
$scope.isSingleUrlTaskSelected = function () {
var selectedTask = $rootScope.taskContext.getSelectedTasks();
var selectedTasks = $rootScope.taskContext.getSelectedTasks();
if (selectedTask.length !== 1) {
if (selectedTasks.length !== 1) {
return false;
}
return !!selectedTask[0].singleUrl;
return !!selectedTasks[0].singleUrl;
};
$scope.isSingleBittorrentHasInfoHashTaskSelected = function () {
var selectedTasks = $rootScope.taskContext.getSelectedTasks();
if (selectedTasks.length !== 1) {
return false;
}
return !!selectedTasks[0].bittorrent && !!selectedTasks[0].infoHash;
};
$scope.isSpecifiedTaskSelected = function () {
@ -313,10 +323,18 @@
};
$scope.copySelectedOneTaskDownloadLink = function () {
var selectedTask = $rootScope.taskContext.getSelectedTasks();
var selectedTasks = $rootScope.taskContext.getSelectedTasks();
if (selectedTask.length === 1) {
clipboard.copyText(selectedTask[0].singleUrl);
if (selectedTasks.length === 1) {
clipboard.copyText(selectedTasks[0].singleUrl);
}
};
$scope.copySelectedOneTaskMagnetLink = function () {
var selectedTasks = $rootScope.taskContext.getSelectedTasks();
if (selectedTasks.length === 1) {
clipboard.copyText('magnet:?xt=urn:btih:' + selectedTasks[0].infoHash);
}
};

View file

@ -276,6 +276,7 @@
requestParams.push('files');
requestParams.push('bittorrent');
requestParams.push('infoHash');
return requestParams;
},

View file

@ -163,13 +163,19 @@
<span translate>Select All</span>
</a>
</li>
<li class="divider" ng-if="isSingleUrlTaskSelected()"></li>
<li class="divider" ng-if="isSingleUrlTaskSelected() || isSingleBittorrentHasInfoHashTaskSelected()"></li>
<li ng-if="isSingleUrlTaskSelected()">
<a tabindex="-1" class="pointer-cursor" title="{{'Copy Download Url' | translate}}" ng-click="copySelectedOneTaskDownloadLink()">
<i class="fa fa-copy fa-fw"></i>
<span translate>Copy Download Url</span>
</a>
</li>
<li ng-if="isSingleBittorrentHasInfoHashTaskSelected()">
<a tabindex="-1" class="pointer-cursor" title="{{'Copy Magnet Link' | translate}}" ng-click="copySelectedOneTaskMagnetLink()">
<i class="fa fa-copy fa-fw"></i>
<span translate>Copy Magnet Link</span>
</a>
</li>
</ul>
</div>
</div>