mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2024-11-29 05:28:53 +03:00
fix: peers not showing up (#660)
This commit is contained in:
parent
bc5695b870
commit
d8ca97d928
2 changed files with 46 additions and 55 deletions
|
@ -1,7 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<v-card flat>
|
<v-card flat>
|
||||||
<v-card-text class="pa-0">
|
<v-card-text class="pa-0">
|
||||||
<v-data-table v-if="peers" v-model="selectedPeers" dense show-select :headers="headers" :items="peers" :items-per-page="-1" item-key="key" mobile-breakpoint="0">
|
<v-data-table v-if="peers" v-model="selectedPeers" dense show-select :headers="headers" :items="peers"
|
||||||
|
:items-per-page="-1" item-key="key" mobile-breakpoint="0">
|
||||||
<template #body="{ items }">
|
<template #body="{ items }">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="item in items" :key="item.key">
|
<tr v-for="item in items" :key="item.key">
|
||||||
|
@ -10,7 +11,8 @@
|
||||||
</td>
|
</td>
|
||||||
<td class="ip">
|
<td class="ip">
|
||||||
<template v-if="item.country_code">
|
<template v-if="item.country_code">
|
||||||
<img v-if="isWindows" class="country-flag" :title="item.country" :alt="codeToFlag(item.country_code).char" :src="codeToFlag(item.country_code).url" />
|
<img v-if="isWindows" class="country-flag" :title="item.country"
|
||||||
|
:alt="codeToFlag(item.country_code).char" :src="codeToFlag(item.country_code).url"/>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
{{ codeToFlag(item.country_code).char }}
|
{{ codeToFlag(item.country_code).char }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -46,7 +48,8 @@
|
||||||
<h3>Add Peers</h3>
|
<h3>Add Peers</h3>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-textarea v-model="newPeers" label="Peers" rows="1" required autofocus auto-grow clearable hint="One link per line" />
|
<v-textarea v-model="newPeers" label="Peers" rows="1" required autofocus auto-grow clearable
|
||||||
|
hint="One link per line"/>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-spacer/>
|
<v-spacer/>
|
||||||
|
@ -70,21 +73,15 @@ export default {
|
||||||
mixins: [FullScreenModal],
|
mixins: [FullScreenModal],
|
||||||
props: { hash: String, isActive: Boolean },
|
props: { hash: String, isActive: Boolean },
|
||||||
data: () => ({
|
data: () => ({
|
||||||
|
rid: 0,
|
||||||
peersDialog: false,
|
peersDialog: false,
|
||||||
refreshTimer: '',
|
refreshTimer: '',
|
||||||
peersObj: null,
|
peersObj: null,
|
||||||
newPeers: '',
|
newPeers: '',
|
||||||
selectedPeers: []
|
selectedPeers: [],
|
||||||
|
isWindows
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
rid: {
|
|
||||||
get() {
|
|
||||||
return this.$store.state.rid
|
|
||||||
},
|
|
||||||
set(val) {
|
|
||||||
this.$store.state.rid = val
|
|
||||||
}
|
|
||||||
},
|
|
||||||
peers() {
|
peers() {
|
||||||
return map(this.peersObj, (value, key) => merge({}, value, { key }))
|
return map(this.peersObj, (value, key) => merge({}, value, { key }))
|
||||||
},
|
},
|
||||||
|
@ -107,32 +104,24 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
isActive(active) {
|
isActive(active) {
|
||||||
if (active) {
|
if (active) {
|
||||||
this.getTorrentPeers()
|
this.refreshTimer = setInterval(() => this.getTorrentPeers(), 2000)
|
||||||
this.refreshTimer = setInterval(
|
|
||||||
function () {
|
|
||||||
this.getTorrentPeers()
|
|
||||||
}.bind(this),
|
|
||||||
2000
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(this.refreshTimer)
|
clearInterval(this.refreshTimer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
beforeDestroy() {},
|
beforeDestroy() {
|
||||||
|
clearInterval(this.refreshTimer)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
codeToFlag(val) {
|
codeToFlag(val) {
|
||||||
return codeToFlag(val)
|
return codeToFlag(val)
|
||||||
},
|
},
|
||||||
isWindows() {
|
|
||||||
return isWindows()
|
|
||||||
},
|
|
||||||
async getTorrentPeers() {
|
async getTorrentPeers() {
|
||||||
const data = await qbit.getTorrentPeers(this.hash, this.rid + 1 || undefined)
|
const data = await qbit.getTorrentPeers(this.hash, this.rid + 1 || undefined)
|
||||||
|
|
||||||
this.rid = data.rid
|
this.rid = data.rid
|
||||||
|
|
||||||
this.peersObj = data.peers
|
this.peersObj = data.peers
|
||||||
},
|
},
|
||||||
async addPeers() {
|
async addPeers() {
|
||||||
|
@ -141,9 +130,8 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
qbit.addTorrentPeers([this.hash], this.newPeers.split('\n'))
|
await qbit.addTorrentPeers([this.hash], this.newPeers.split('\n'))
|
||||||
this.newPeers = ''
|
this.newPeers = ''
|
||||||
await this.getTorrentPeers()
|
|
||||||
this.peersDialog = false
|
this.peersDialog = false
|
||||||
},
|
},
|
||||||
closeAddPeers() {
|
closeAddPeers() {
|
||||||
|
@ -153,9 +141,8 @@ export default {
|
||||||
async banPeers() {
|
async banPeers() {
|
||||||
if (this.selectedPeers.length === 0) return
|
if (this.selectedPeers.length === 0) return
|
||||||
|
|
||||||
qbit.banPeers(this.selectedPeers)
|
await qbit.banPeers(this.selectedPeers)
|
||||||
this.selectedPeers = []
|
this.selectedPeers = []
|
||||||
await this.getTorrentPeers()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,13 +170,16 @@ export default {
|
||||||
&:first-child {
|
&:first-child {
|
||||||
padding: 0 0 0 8px !important;
|
padding: 0 0 0 8px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
padding-right: 8px !important;
|
padding-right: 8px !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.v-data-table-header) {
|
:deep(.v-data-table-header) {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(td) {
|
:deep(td) {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,7 @@ export class QBitApi {
|
||||||
return this.axios.get('/sync/torrentPeers', {
|
return this.axios.get('/sync/torrentPeers', {
|
||||||
params: { hash, rid }
|
params: { hash, rid }
|
||||||
})
|
})
|
||||||
|
.then(r => r.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
async setTorrentName(hash: string, name: string): Promise<void> {
|
async setTorrentName(hash: string, name: string): Promise<void> {
|
||||||
|
|
Loading…
Reference in a new issue