mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-04 05:19:12 -04:00
fix: better select between file and content
This commit is contained in:
parent
3f44fec8be
commit
099ecc8242
2 changed files with 21 additions and 3 deletions
4
components.d.ts
vendored
4
components.d.ts
vendored
|
@ -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']
|
||||
|
|
|
@ -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<File | null>;
|
||||
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({
|
|||
|
||||
<template>
|
||||
<div>
|
||||
<n-radio-group v-model:value="inputType" name="radiogroup" mb-2 flex justify-center>
|
||||
<n-space>
|
||||
<n-radio
|
||||
value="file"
|
||||
label="File"
|
||||
/>
|
||||
<n-radio
|
||||
value="content"
|
||||
label="Content"
|
||||
/>
|
||||
</n-space>
|
||||
</n-radio-group>
|
||||
|
||||
<c-file-upload
|
||||
v-if="inputType === 'file'"
|
||||
title="Drag and drop torrent file here, or click to select a file"
|
||||
@file-upload="onUpload"
|
||||
/>
|
||||
|
||||
<n-p text-center>OR</n-p>
|
||||
|
||||
<c-input-text
|
||||
v-if="inputType === 'content'"
|
||||
v-model:value="torrentContent"
|
||||
label="Torrent/Magnet Content"
|
||||
placeholder="Paste your Torrent/Magnet content here"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue