mirror of
https://github.com/CzBiX/qb-web.git
synced 2026-04-15 02:39:46 +08:00
12
src/Api.ts
12
src/Api.ts
@@ -143,15 +143,11 @@ class Api {
|
||||
}
|
||||
|
||||
public editTracker(hash: string, origUrl: string, newUrl: string) {
|
||||
const params = {
|
||||
hash,
|
||||
origUrl,
|
||||
newUrl,
|
||||
};
|
||||
return this.actionTorrents('editTracker', [hash], { origUrl, newUrl });
|
||||
}
|
||||
|
||||
return this.axios.get('/torrents/editTracker', {
|
||||
params,
|
||||
}).then(Api.handleResponse);
|
||||
public setTorrentLocation(hashes: string[], location: string) {
|
||||
return this.actionTorrents('setLocation', hashes, { location });
|
||||
}
|
||||
|
||||
public getTorrentProperties(hash: string) {
|
||||
|
||||
@@ -209,7 +209,7 @@ export default class Drawer extends Vue {
|
||||
const title = `${category.name} (${value.length})`;
|
||||
const append = `[${size}]`;
|
||||
return {
|
||||
icon: 'mdi-folder-open', title, key: category.key, append,
|
||||
icon: 'mdi-folder', title, key: category.key, append,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -257,7 +257,7 @@ export default class Drawer extends Vue {
|
||||
select: 'category',
|
||||
children: [
|
||||
{
|
||||
icon: 'mdi-folder-open', title: `${tr('all')} (${this.allTorrents.length})`, key: null, append: `[${totalSize}]`,
|
||||
icon: 'mdi-folder', title: `${tr('all')} (${this.allTorrents.length})`, key: null, append: `[${totalSize}]`,
|
||||
},
|
||||
...this.buildCategoryGroup(),
|
||||
],
|
||||
|
||||
@@ -101,6 +101,8 @@ export default {
|
||||
value.value = !!v;
|
||||
if (!v) {
|
||||
input.value = undefined
|
||||
} else {
|
||||
input.value = v.content.value
|
||||
}
|
||||
});
|
||||
watch(value, (v) => {
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
<v-btn
|
||||
icon
|
||||
v-on="on"
|
||||
:title="$t('category')"
|
||||
:title="$t('title.set_category')"
|
||||
:disabled="!hasSelected"
|
||||
>
|
||||
<v-icon>mdi-folder</v-icon>
|
||||
<v-icon>mdi-folder-star</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<v-list class="category-actions">
|
||||
@@ -66,7 +66,7 @@
|
||||
@click="setTorrentsCategory(item.key)"
|
||||
>
|
||||
<v-list-item-action>
|
||||
<v-icon>mdi-folder-open</v-icon>
|
||||
<v-icon>mdi-folder</v-icon>
|
||||
</v-list-item-action>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>
|
||||
@@ -92,6 +92,14 @@
|
||||
vertical
|
||||
inset
|
||||
/>
|
||||
<v-btn
|
||||
icon
|
||||
@click="setTorrentLocation"
|
||||
:title="$t('title.set_location')"
|
||||
:disabled="selectedRows.length == 0"
|
||||
>
|
||||
<v-icon>mdi-folder-marker</v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
icon
|
||||
@click="reannounceTorrents"
|
||||
@@ -210,8 +218,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue'
|
||||
import { mapState, mapGetters, mapMutations } from 'vuex'
|
||||
import { intersection, difference } from 'lodash'
|
||||
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
|
||||
import { intersection, difference, uniqBy } from 'lodash'
|
||||
|
||||
import { tr } from '@/locale'
|
||||
import ConfirmDeleteDialog from './dialogs/ConfirmDeleteDialog.vue'
|
||||
@@ -353,6 +361,9 @@ function getStateInfo(state: string) {
|
||||
'showDialog',
|
||||
'showSnackBar',
|
||||
]),
|
||||
...mapActions([
|
||||
'asyncShowDialog',
|
||||
]),
|
||||
},
|
||||
})
|
||||
export default class Torrents extends Vue {
|
||||
@@ -394,6 +405,7 @@ export default class Torrents extends Vue {
|
||||
updateConfig!: (_: ConfigPayload) => void
|
||||
showDialog!: (_: DialogConfig) => void
|
||||
showSnackBar!: (_: SnackBarConfig) => void
|
||||
asyncShowDialog!: (_: DialogConfig) => Promise<string | undefined>
|
||||
|
||||
get loading() {
|
||||
return !this.isDataReady;
|
||||
@@ -462,15 +474,12 @@ export default class Torrents extends Vue {
|
||||
if (!this.hasSelected) {
|
||||
this.selectedRows = this.allTorrents;
|
||||
}
|
||||
const v = await new Promise((resolve) => {
|
||||
this.showDialog({
|
||||
content: {
|
||||
title: 'Reannounce Torrents',
|
||||
text: 'Are you sure want to reannounce torrents?',
|
||||
type: DialogType.OkCancel,
|
||||
callback: resolve,
|
||||
},
|
||||
});
|
||||
const v = await this.asyncShowDialog({
|
||||
content: {
|
||||
title: 'Reannounce Torrents',
|
||||
text: 'Are you sure want to reannounce torrents?',
|
||||
type: DialogType.OkCancel,
|
||||
},
|
||||
});
|
||||
|
||||
if (!v) {
|
||||
@@ -502,6 +511,35 @@ export default class Torrents extends Vue {
|
||||
this.showSnackBar({text: 'Rechecking'});
|
||||
}
|
||||
|
||||
async setTorrentLocation() {
|
||||
const savePaths = uniqBy(this.selectedRows, 'save_path');
|
||||
|
||||
const oldPath = savePaths.length > 1 ? '' : savePaths[0].save_path
|
||||
const v = await this.asyncShowDialog({
|
||||
content: {
|
||||
title: tr('title.set_location'),
|
||||
text: '',
|
||||
type: DialogType.Input,
|
||||
value: oldPath,
|
||||
},
|
||||
});
|
||||
|
||||
if (!v) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.showSnackBar({text: tr('label.moving')});
|
||||
|
||||
try {
|
||||
await api.setTorrentLocation(this.selectedHashes, v);
|
||||
} catch (e) {
|
||||
this.showSnackBar({text: e});
|
||||
return;
|
||||
}
|
||||
|
||||
this.showSnackBar({text: tr('label.moved')});
|
||||
}
|
||||
|
||||
setTorrentsCategory(category: string) {
|
||||
this.categoryToSet = category;
|
||||
this.toSetCategory = this.selectedRows;
|
||||
|
||||
@@ -57,8 +57,9 @@ export default {
|
||||
_: 'Title',
|
||||
add_torrents: 'Add Torrents',
|
||||
delete_torrents: 'Delete Torrents',
|
||||
set_category: 'Set category',
|
||||
edit_tracker: 'Edit tracker',
|
||||
set_category: 'Set Category',
|
||||
edit_tracker: 'Edit Tracker',
|
||||
set_location: 'Set Location',
|
||||
},
|
||||
|
||||
label: {
|
||||
@@ -76,6 +77,8 @@ export default {
|
||||
adding: 'Adding…',
|
||||
reloading: 'Reloading…',
|
||||
deleting: 'Deleting…',
|
||||
moving: 'Moving…',
|
||||
moved: 'Moved',
|
||||
},
|
||||
|
||||
msg: {
|
||||
|
||||
@@ -59,6 +59,7 @@ export default {
|
||||
delete_torrents: '删除种子',
|
||||
set_category: '设置分类',
|
||||
edit_tracker: '编辑 Tracker',
|
||||
set_location: '修改文件位置',
|
||||
},
|
||||
|
||||
label: {
|
||||
@@ -76,6 +77,8 @@ export default {
|
||||
adding: '添加…',
|
||||
reloading: '刷新中…',
|
||||
deleting: '删除中…',
|
||||
moving: '移动中…',
|
||||
moved: '已移动',
|
||||
},
|
||||
|
||||
msg: {
|
||||
|
||||
@@ -42,6 +42,7 @@ export interface DialogConfig {
|
||||
|
||||
rules?: CallableFunction[];
|
||||
placeholder?: string;
|
||||
value?: string;
|
||||
};
|
||||
width?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user