mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 23:06:14 -04:00
Merge 556db15cbe
into 07eea0f484
This commit is contained in:
commit
f6483729f3
2 changed files with 22 additions and 4 deletions
|
@ -76,10 +76,28 @@ async function onUpload(file: File) {
|
||||||
fileInput.value = file;
|
fileInput.value = file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onPaste(event: ClipboardEvent) {
|
||||||
|
if (event.clipboardData) {
|
||||||
|
const { items } = event.clipboardData;
|
||||||
|
for (const item of items) {
|
||||||
|
if (item.kind === 'file') {
|
||||||
|
fileInput.value = item.getAsFile()!;
|
||||||
|
}
|
||||||
|
else if (item.kind === 'string' && item.type.match('^text/plain')) {
|
||||||
|
item.getAsString(s => base64Input.value = s);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.info('Unsupport clipboardData', item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<c-card title="Base64 to file">
|
<c-card title="Base64 to file" @paste="onPaste">
|
||||||
<n-grid cols="3" x-gap="12">
|
<n-grid cols="3" x-gap="12">
|
||||||
<n-gi span="2">
|
<n-gi span="2">
|
||||||
<c-input-text
|
<c-input-text
|
||||||
|
@ -121,8 +139,8 @@ async function onUpload(file: File) {
|
||||||
</div>
|
</div>
|
||||||
</c-card>
|
</c-card>
|
||||||
|
|
||||||
<c-card title="File to base64">
|
<c-card title="File to base64" @paste="onPaste">
|
||||||
<c-file-upload title="Drag and drop a file here, or click to select a file" @file-upload="onUpload" />
|
<c-file-upload title="Drag and drop a file here, Focus this card and paste a file here, or click to select a file" @file-upload="onUpload" />
|
||||||
<c-input-text :value="fileBase64" multiline readonly placeholder="File in base64 will be here" rows="5" my-2 />
|
<c-input-text :value="fileBase64" multiline readonly placeholder="File in base64 will be here" rows="5" my-2 />
|
||||||
|
|
||||||
<div flex justify-center>
|
<div flex justify-center>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"include": ["env.d.ts", "src/**/*", "src/**/*.vue", "**/*.d.ts", "node_modules/vite-plugin-pwa/client.d.ts"],
|
"include": ["env.d.ts", "src/**/*", "src/**/*.vue", "**/*.d.ts", "node_modules/vite-plugin-pwa/client.d.ts"],
|
||||||
"exclude": ["src/**/__tests__/*"],
|
"exclude": ["src/**/__tests__/*"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["ES2022"],
|
"lib": ["ES2022", "DOM.Iterable"],
|
||||||
"target": "es2022",
|
"target": "es2022",
|
||||||
"module": "es2022",
|
"module": "es2022",
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue