mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 14:56:17 -04:00
refactor(ui): replaced legacy n-upload with c-file-upload (#747)
This commit is contained in:
parent
16ffe6b5c9
commit
7fe47b3be4
1 changed files with 3 additions and 17 deletions
|
@ -1,7 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Upload } from '@vicons/tabler';
|
|
||||||
import { useBase64 } from '@vueuse/core';
|
import { useBase64 } from '@vueuse/core';
|
||||||
import type { UploadFileInfo } from 'naive-ui';
|
|
||||||
import type { Ref } from 'vue';
|
import type { Ref } from 'vue';
|
||||||
import { useCopy } from '@/composable/copy';
|
import { useCopy } from '@/composable/copy';
|
||||||
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
||||||
|
@ -33,14 +31,12 @@ function downloadFile() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileList = ref();
|
|
||||||
const fileInput = ref() as Ref<File>;
|
const fileInput = ref() as Ref<File>;
|
||||||
const { base64: fileBase64 } = useBase64(fileInput);
|
const { base64: fileBase64 } = useBase64(fileInput);
|
||||||
const { copy: copyFileBase64 } = useCopy({ source: fileBase64, text: 'Base64 string copied to the clipboard' });
|
const { copy: copyFileBase64 } = useCopy({ source: fileBase64, text: 'Base64 string copied to the clipboard' });
|
||||||
|
|
||||||
async function onUpload({ file: { file } }: { file: UploadFileInfo }) {
|
async function onUpload(file: File) {
|
||||||
if (file) {
|
if (file) {
|
||||||
fileList.value = [];
|
|
||||||
fileInput.value = file;
|
fileInput.value = file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,18 +61,8 @@ async function onUpload({ file: { file } }: { file: UploadFileInfo }) {
|
||||||
</c-card>
|
</c-card>
|
||||||
|
|
||||||
<c-card title="File to base64">
|
<c-card title="File to base64">
|
||||||
<n-upload v-model:file-list="fileList" :show-file-list="true" :on-before-upload="onUpload" list-type="image">
|
<c-file-upload title="Drag and drop a file here, or click to select a file" @file-upload="onUpload" />
|
||||||
<n-upload-dragger>
|
<c-input-text :value="fileBase64" multiline readonly placeholder="File in base64 will be here" rows="5" my-2 />
|
||||||
<div mb-2>
|
|
||||||
<n-icon size="35" :depth="3" :component="Upload" />
|
|
||||||
</div>
|
|
||||||
<div op-60>
|
|
||||||
Click or drag a file to this area to upload
|
|
||||||
</div>
|
|
||||||
</n-upload-dragger>
|
|
||||||
</n-upload>
|
|
||||||
|
|
||||||
<c-input-text :value="fileBase64" multiline readonly placeholder="File in base64 will be here" rows="5" mb-2 />
|
|
||||||
|
|
||||||
<div flex justify-center>
|
<div flex justify-center>
|
||||||
<c-button @click="copyFileBase64()">
|
<c-button @click="copyFileBase64()">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue