From 099ecc824267f315e60781c4a6a0cb9cc961d19d Mon Sep 17 00:00:00 2001 From: ShareVB Date: Sun, 25 Aug 2024 22:17:54 +0200 Subject: [PATCH] fix: better select between file and content --- components.d.ts | 4 ++++ .../torrent-to-magnet/torrent-to-magnet.vue | 20 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/components.d.ts b/components.d.ts index 9a2af312..2935ad8e 100644 --- a/components.d.ts +++ b/components.d.ts @@ -144,8 +144,12 @@ declare module '@vue/runtime-core' { NLayoutSider: typeof import('naive-ui')['NLayoutSider'] NMenu: typeof import('naive-ui')['NMenu'] NP: typeof import('naive-ui')['NP'] + NRadio: typeof import('naive-ui')['NRadio'] + NRadioGroup: typeof import('naive-ui')['NRadioGroup'] NScrollbar: typeof import('naive-ui')['NScrollbar'] + NSpace: typeof import('naive-ui')['NSpace'] NSpin: typeof import('naive-ui')['NSpin'] + NStatistic: typeof import('naive-ui')['NStatistic'] NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default'] OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default'] PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default'] diff --git a/src/tools/torrent-to-magnet/torrent-to-magnet.vue b/src/tools/torrent-to-magnet/torrent-to-magnet.vue index 34ed6b0b..113a33b6 100644 --- a/src/tools/torrent-to-magnet/torrent-to-magnet.vue +++ b/src/tools/torrent-to-magnet/torrent-to-magnet.vue @@ -4,13 +4,14 @@ import parseTorrent, { toMagnetURI } from 'parse-torrent'; import { withDefaultOnError } from '@/utils/defaults'; import { useValidation } from '@/composable/validation'; +const inputType = ref<'file' | 'content'>('file'); const torrentContent = ref(''); const fileInput = ref() as Ref; const torrentInfosRaw = computedAsync(async () => { const file = fileInput.value; const content = torrentContent.value; try { - if (file) { + if (inputType.value === 'file' && file) { return await parseTorrent(new Uint8Array(await file.arrayBuffer())); } else { @@ -53,14 +54,27 @@ const { attrs: validationAttrs } = useValidation({