Skip to content

Commit 6d61960

Browse files
committed
feat(new tool): QRCode decoder
Fix CorentinTh#656
1 parent a07806c commit 6d61960

File tree

5 files changed

+87
-7
lines changed

5 files changed

+87
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"pinia": "^2.0.34",
7979
"plausible-tracker": "^0.3.8",
8080
"qrcode": "^1.5.1",
81+
"qrcode-parser": "^2.1.3",
8182
"sql-formatter": "^13.0.0",
8283
"ua-parser-js": "^1.0.35",
8384
"ulid": "^2.3.0",

pnpm-lock.yaml

Lines changed: 19 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
22
import { tool as base64StringConverter } from './base64-string-converter';
33
import { tool as basicAuthGenerator } from './basic-auth-generator';
44
import { tool as textToUnicode } from './text-to-unicode';
5+
import { tool as qrCodeDecoder } from './qr-code-decoder';
56
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
67
import { tool as numeronymGenerator } from './numeronym-generator';
78
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -127,7 +128,13 @@ export const toolsByCategory: ToolCategory[] = [
127128
},
128129
{
129130
name: 'Images and videos',
130-
components: [qrCodeGenerator, wifiQrCodeGenerator, svgPlaceholderGenerator, cameraRecorder],
131+
components: [
132+
qrCodeGenerator,
133+
wifiQrCodeGenerator,
134+
qrCodeDecoder,
135+
svgPlaceholderGenerator,
136+
cameraRecorder,
137+
],
131138
},
132139
{
133140
name: 'Development',

src/tools/qr-code-decoder/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Qrcode } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'QRCode decoder',
6+
path: '/qr-code-decoder',
7+
description: 'QR Code Reader',
8+
keywords: ['qrcode', 'qr-code', 'decoder', 'reader'],
9+
component: () => import('./qr-code-decoder.vue'),
10+
icon: Qrcode,
11+
createdAt: new Date('2024-01-17'),
12+
});
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<script setup lang="ts">
2+
import type { Ref } from 'vue';
3+
import qrcodeParser from 'qrcode-parser';
4+
import TextareaCopyable from '@/components/TextareaCopyable.vue';
5+
6+
const fileInput = ref() as Ref<File>;
7+
const qrCode = computedAsync(async () => {
8+
try {
9+
return (await qrcodeParser(fileInput.value));
10+
}
11+
catch (e: any) {
12+
return e.toString();
13+
}
14+
});
15+
16+
async function onUpload(file: File) {
17+
if (file) {
18+
fileInput.value = file;
19+
}
20+
}
21+
</script>
22+
23+
<template>
24+
<div>
25+
<c-file-upload
26+
title="Drag and drop a QR Code here, or click to select a file"
27+
:paste-image="true"
28+
@file-upload="onUpload"
29+
/>
30+
31+
<n-divider />
32+
33+
<div>
34+
<h3>Decoded</h3>
35+
<TextareaCopyable
36+
:value="qrCode"
37+
:word-wrap="true"
38+
/>
39+
</div>
40+
</div>
41+
</template>
42+
43+
<style lang="less" scoped>
44+
::v-deep(.n-upload-trigger) {
45+
width: 100%;
46+
}
47+
</style>

0 commit comments

Comments
 (0)