mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-03-22 17:45:55 +03:00
chore: add ability to inject fake torrents
This commit is contained in:
parent
c50f1df4d6
commit
35849b3346
2 changed files with 12 additions and 7 deletions
|
@ -1,2 +1,5 @@
|
|||
VITE_QBITTORRENT_TARGET='http://127.0.0.1'
|
||||
VITE_QBITTORRENT_PORT=8080
|
||||
|
||||
VITE_USE_FAKE_TORRENTS=true
|
||||
VITE_FAKE_TORRENT_COUNT=10
|
||||
|
|
|
@ -10,8 +10,11 @@ import { useVueTorrentStore } from '@/stores/vuetorrent'
|
|||
import { Category, ServerState } from '@/types/qbit/models'
|
||||
import { AddTorrentPayload } from '@/types/qbit/payloads'
|
||||
import { Torrent } from '@/types/vuetorrent'
|
||||
import { generateMultiple } from '@/utils/faker'
|
||||
import { defineStore } from 'pinia'
|
||||
import { MaybeRefOrGetter, ref, toValue } from 'vue'
|
||||
import { MaybeRefOrGetter, computed, ref, toValue } from 'vue'
|
||||
|
||||
const isProduction = computed(() => process.env.NODE_ENV === 'production')
|
||||
|
||||
export const useMaindataStore = defineStore('maindata', () => {
|
||||
const categories = ref<Category[]>([])
|
||||
|
@ -158,12 +161,11 @@ export const useMaindataStore = defineStore('maindata', () => {
|
|||
// update torrents
|
||||
torrents.value = data.map(t => torrentBuilder.buildFromQbit(t))
|
||||
|
||||
// TODO: load fake torrents if enabled
|
||||
// if (!isProduction()) {
|
||||
// if (import.meta.env.VITE_USE_FAKE_TORRENTS === 'false') return
|
||||
// const count = import.meta.env.VITE_FAKE_TORRENT_COUNT
|
||||
// store.state.torrents.push(...generateMultiple(count))
|
||||
// }
|
||||
if (!isProduction.value) {
|
||||
if (import.meta.env.VITE_USE_FAKE_TORRENTS === 'false') return
|
||||
const count = import.meta.env.VITE_FAKE_TORRENT_COUNT
|
||||
torrents.value.push(...generateMultiple(count).map(t => torrentBuilder.buildFromQbit(t)))
|
||||
}
|
||||
|
||||
// filter out deleted torrents from selection
|
||||
const hash_index = torrents.value.map(torrent => torrent.hash)
|
||||
|
|
Loading…
Add table
Reference in a new issue