Skip to content

Commit 099ecc8

Browse files
committed
fix: better select between file and content
1 parent 3f44fec commit 099ecc8

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

components.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,12 @@ declare module '@vue/runtime-core' {
144144
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
145145
NMenu: typeof import('naive-ui')['NMenu']
146146
NP: typeof import('naive-ui')['NP']
147+
NRadio: typeof import('naive-ui')['NRadio']
148+
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
147149
NScrollbar: typeof import('naive-ui')['NScrollbar']
150+
NSpace: typeof import('naive-ui')['NSpace']
148151
NSpin: typeof import('naive-ui')['NSpin']
152+
NStatistic: typeof import('naive-ui')['NStatistic']
149153
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
150154
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
151155
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']

src/tools/torrent-to-magnet/torrent-to-magnet.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import parseTorrent, { toMagnetURI } from 'parse-torrent';
44
import { withDefaultOnError } from '@/utils/defaults';
55
import { useValidation } from '@/composable/validation';
66
7+
const inputType = ref<'file' | 'content'>('file');
78
const torrentContent = ref('');
89
const fileInput = ref() as Ref<File | null>;
910
const torrentInfosRaw = computedAsync(async () => {
1011
const file = fileInput.value;
1112
const content = torrentContent.value;
1213
try {
13-
if (file) {
14+
if (inputType.value === 'file' && file) {
1415
return await parseTorrent(new Uint8Array(await file.arrayBuffer()));
1516
}
1617
else {
@@ -53,14 +54,27 @@ const { attrs: validationAttrs } = useValidation({
5354

5455
<template>
5556
<div>
57+
<n-radio-group v-model:value="inputType" name="radiogroup" mb-2 flex justify-center>
58+
<n-space>
59+
<n-radio
60+
value="file"
61+
label="File"
62+
/>
63+
<n-radio
64+
value="content"
65+
label="Content"
66+
/>
67+
</n-space>
68+
</n-radio-group>
69+
5670
<c-file-upload
71+
v-if="inputType === 'file'"
5772
title="Drag and drop torrent file here, or click to select a file"
5873
@file-upload="onUpload"
5974
/>
6075

61-
<n-p text-center>OR</n-p>
62-
6376
<c-input-text
77+
v-if="inputType === 'content'"
6478
v-model:value="torrentContent"
6579
label="Torrent/Magnet Content"
6680
placeholder="Paste your Torrent/Magnet content here"

0 commit comments

Comments
 (0)