fix: better select between file and content
This commit is contained in:
		
							parent
							
								
									3f44fec8be
								
							
						
					
					
						commit
						099ecc8242
					
				
							
								
								
									
										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'] |     NLayoutSider: typeof import('naive-ui')['NLayoutSider'] | ||||||
|     NMenu: typeof import('naive-ui')['NMenu'] |     NMenu: typeof import('naive-ui')['NMenu'] | ||||||
|     NP: typeof import('naive-ui')['NP'] |     NP: typeof import('naive-ui')['NP'] | ||||||
|  |     NRadio: typeof import('naive-ui')['NRadio'] | ||||||
|  |     NRadioGroup: typeof import('naive-ui')['NRadioGroup'] | ||||||
|     NScrollbar: typeof import('naive-ui')['NScrollbar'] |     NScrollbar: typeof import('naive-ui')['NScrollbar'] | ||||||
|  |     NSpace: typeof import('naive-ui')['NSpace'] | ||||||
|     NSpin: typeof import('naive-ui')['NSpin'] |     NSpin: typeof import('naive-ui')['NSpin'] | ||||||
|  |     NStatistic: typeof import('naive-ui')['NStatistic'] | ||||||
|     NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default'] |     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'] |     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'] |     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 { withDefaultOnError } from '@/utils/defaults'; | ||||||
| import { useValidation } from '@/composable/validation'; | import { useValidation } from '@/composable/validation'; | ||||||
| 
 | 
 | ||||||
|  | const inputType = ref<'file' | 'content'>('file'); | ||||||
| const torrentContent = ref(''); | const torrentContent = ref(''); | ||||||
| const fileInput = ref() as Ref<File | null>; | const fileInput = ref() as Ref<File | null>; | ||||||
| const torrentInfosRaw = computedAsync(async () => { | const torrentInfosRaw = computedAsync(async () => { | ||||||
|   const file = fileInput.value; |   const file = fileInput.value; | ||||||
|   const content = torrentContent.value; |   const content = torrentContent.value; | ||||||
|   try { |   try { | ||||||
|     if (file) { |     if (inputType.value === 'file' && file) { | ||||||
|       return await parseTorrent(new Uint8Array(await file.arrayBuffer())); |       return await parseTorrent(new Uint8Array(await file.arrayBuffer())); | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
| @ -53,14 +54,27 @@ const { attrs: validationAttrs } = useValidation({ | |||||||
| 
 | 
 | ||||||
| <template> | <template> | ||||||
|   <div> |   <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 |     <c-file-upload | ||||||
|  |       v-if="inputType === 'file'" | ||||||
|       title="Drag and drop torrent file here, or click to select a file" |       title="Drag and drop torrent file here, or click to select a file" | ||||||
|       @file-upload="onUpload" |       @file-upload="onUpload" | ||||||
|     /> |     /> | ||||||
| 
 | 
 | ||||||
|     <n-p text-center>OR</n-p> |  | ||||||
| 
 |  | ||||||
|     <c-input-text |     <c-input-text | ||||||
|  |       v-if="inputType === 'content'" | ||||||
|       v-model:value="torrentContent" |       v-model:value="torrentContent" | ||||||
|       label="Torrent/Magnet Content" |       label="Torrent/Magnet Content" | ||||||
|       placeholder="Paste your Torrent/Magnet content here" |       placeholder="Paste your Torrent/Magnet content here" | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user