@@ -8,6 +8,7 @@ import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
8
8
const inputKeyOrCertificate = ref (' ' );
9
9
const passphrase = ref (' ' );
10
10
const fileInput = ref () as Ref <Buffer >;
11
+ const inputType = ref <' file' | ' content' >(' file' );
11
12
12
13
async function onUpload(file : File ) {
13
14
if (file ) {
@@ -37,11 +38,15 @@ function downloadX509DERFile() {
37
38
}
38
39
39
40
const parsedSections = computedAsync <LabelValue []>(async () => {
40
- const inputKeyOrCertificateValue
41
- = inputKeyOrCertificate .value !== ' '
42
- ? inputKeyOrCertificate .value
43
- : fileInput .value ;
44
-
41
+ const inputContent = inputKeyOrCertificate .value ;
42
+ const file = fileInput .value ;
43
+ let inputKeyOrCertificateValue: string | Buffer = ' ' ;
44
+ if (inputType .value === ' file' && file ) {
45
+ inputKeyOrCertificateValue = file ;
46
+ }
47
+ else if (inputType .value === ' content' && inputContent ) {
48
+ inputKeyOrCertificateValue = inputContent ;
49
+ }
45
50
const { values, certificateX509DER : certPEM } = await getKeyOrCertificateInfosAsync (inputKeyOrCertificateValue , passphrase .value );
46
51
certificateX509DER .value = certPEM || ' ' ;
47
52
return values ;
@@ -51,16 +56,27 @@ const parsedSections = computedAsync<LabelValue[]>(async () => {
51
56
<template >
52
57
<div >
53
58
<c-card >
54
- <c-file-upload title =" Drag and drop a Certificate file here, or click to select a Certificate file" @file-upload =" onUpload" />
55
- <!-- separator -->
56
- <div my-4 w-full flex items-center justify-center op-70 >
57
- <div class =" h-1px max-w-100px flex-1 bg-gray-300 op-50" />
58
- <div class =" mx-2 text-gray-400" >
59
- or
60
- </div >
61
- <div class =" h-1px max-w-100px flex-1 bg-gray-300 op-50" />
62
- </div >
59
+ <n-radio-group v-model:value =" inputType" name =" radiogroup" mb-2 flex justify-center >
60
+ <n-space >
61
+ <n-radio
62
+ value =" file"
63
+ label =" File"
64
+ />
65
+ <n-radio
66
+ value =" content"
67
+ label =" Content"
68
+ />
69
+ </n-space >
70
+ </n-radio-group >
71
+
72
+ <c-file-upload
73
+ v-if =" inputType === 'file'"
74
+ title =" Drag and drop a Certificate file here, or click to select a Certificate file"
75
+ @file-upload =" onUpload"
76
+ />
77
+
63
78
<c-input-text
79
+ v-if =" inputType === 'content'"
64
80
v-model:value =" inputKeyOrCertificate"
65
81
label =" Paste your Public Key / Private Key / Signature / Fingerprint / Certificate:"
66
82
placeholder =" Your Public Key / Private Key / Signature / Fingerprint / Certificate..."
0 commit comments