Merge branch 'feat/barcodes' into chore/all-my-stuffs

# Conflicts:
#	components.d.ts
#	package.json
#	pnpm-lock.yaml
This commit is contained in:
ShareVB committed 2024-11-02 10:31:42 +01:00
commit c8118b04fd
7 files changed
+216 -23

No files matched your search

+4 -1
View File
@@ -37,6 +37,7 @@
},
"dependencies": {
"@github/paste-markdown": "^1.5.3",
"@chenfengyuan/vue-barcode": "^2.0.2",
"@it-tools/bip39": "^0.0.4",
"@it-tools/oggen": "^1.3.0",
"@regexper/render": "^1.0.0",
@@ -52,6 +53,7 @@
"@vueuse/core": "^10.3.0",
"@vueuse/head": "^1.0.0",
"@vueuse/router": "^10.0.0",
"@zxing/library": "^0.21.0",
"bcryptjs": "^2.4.3",
"change-case": "^4.1.2",
"chatgpt-prompt-splitter": "^1.0.5",
@@ -71,7 +73,8 @@
"highlight.js": "^11.7.0",
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"js-base64": "^3.7.6",
"js-base64": "^3.7.7",
"jsbarcode": "^3.11.6",
"json5": "^2.2.3",
"jwt-decode": "^3.1.2",
"libphonenumber-js": "^1.10.28",
+3 -21
View File
@@ -5,9 +5,6 @@ settings:
excludeLinksFromLockfile: false
dependencies:
'@github/paste-markdown':
specifier: ^1.5.3
version: 1.5.3
'@it-tools/bip39':
specifier: ^0.0.4
version: 0.0.4
@@ -59,9 +56,6 @@ dependencies:
change-case:
specifier: ^4.1.2
version: 4.1.2
chatgpt-prompt-splitter:
specifier: ^1.0.5
version: 1.0.5
colord:
specifier: ^2.9.3
version: 2.9.3
@@ -2186,10 +2180,6 @@ packages:
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
/@github/paste-markdown@1.5.3:
resolution: {integrity: sha512-PzZ1b3PaqBzYqbT4fwKEhiORf38h2OcGp2+JdXNNM7inZ7egaSmfmhyNkQILpqWfS0AYtRS3CDq6z03eZ8yOMQ==}
dev: false
/@humanwhocodes/config-array@0.11.10:
resolution: {integrity: sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==}
engines: {node: '>=10.10.0'}
@@ -2676,11 +2666,9 @@ packages:
dependencies:
'@tabler/icons': 3.20.0
vue: 3.3.4
dev: false
/@tabler/icons@3.20.0:
resolution: {integrity: sha512-nXSeUzsCOxX/Of+kdUVQfxL9bG+ck8XCWNf9dGSpE+nhVexRwk/4HiDQDxFDysfT7vfgSut6GXnrZsU5M5dSlA==}
dev: false
/@tiptap/core@2.1.12(@tiptap/pm@2.1.6):
resolution: {integrity: sha512-ZGc3xrBJA9KY8kln5AYTj8y+GDrKxi7u95xIl2eccrqTY5CQeRu6HRNM1yT4mAjuSaG9jmazyjGRlQuhyxCKxQ==}
@@ -3424,7 +3412,7 @@ packages:
dependencies:
'@unhead/dom': 0.5.1
'@unhead/schema': 0.5.1
'@vueuse/shared': 11.2.0(vue@3.3.4)
'@vueuse/shared': 11.0.3(vue@3.3.4)
unhead: 0.5.1
vue: 3.3.4
transitivePeerDependencies:
@@ -4066,8 +4054,8 @@ packages:
- vue
dev: false
/@vueuse/shared@11.2.0(vue@3.3.4):
resolution: {integrity: sha512-VxFjie0EanOudYSgMErxXfq6fo8vhr5ICI+BuE3I9FnX7ePllEsVrRQ7O6Q1TLgApeLuPKcHQxAXpP+KnlrJsg==}
/@vueuse/shared@11.0.3(vue@3.3.4):
resolution: {integrity: sha512-0rY2m6HS5t27n/Vp5cTDsKTlNnimCqsbh/fmT2LgE+aaU42EMfXo8+bNX91W9I7DDmxfuACXMmrd7d79JxkqWA==}
dependencies:
vue-demi: 0.14.10(vue@3.3.4)
transitivePeerDependencies:
@@ -4513,10 +4501,6 @@ packages:
resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==}
dev: true
/chatgpt-prompt-splitter@1.0.5:
resolution: {integrity: sha512-8buXXnxZ5Y5BloPTMEhGTVld9vrVB8WVrUFrjgOpIJ4/VsT+rTnLszbaS1L1KAB0SDSCqj8GU472S2gMyhH8EA==}
dev: false
/check-error@1.0.2:
resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==}
dev: true
@@ -8252,7 +8236,6 @@ packages:
/sortablejs@1.14.0:
resolution: {integrity: sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w==}
dev: false
/source-map-js@1.0.2:
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
@@ -9386,7 +9369,6 @@ packages:
dependencies:
sortablejs: 1.14.0
vue: 3.3.4
dev: false
/vueuc@0.4.51(vue@3.3.4):
resolution: {integrity: sha512-pLiMChM4f+W8czlIClGvGBYo656lc2Y0/mXFSCydcSmnCR1izlKPGMgiYBGjbY9FDkFG8a2HEVz7t0DNzBWbDw==}
@@ -0,0 +1,109 @@
<script setup lang="ts">
import VueBarcode from '@chenfengyuan/vue-barcode';
import JsBarcode from 'jsbarcode';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const foreground = useQueryParamOrStorage({ name: 'fg', storageName: 'barcode-gen:fg', defaultValue: '#000000ff' });
const background = useQueryParamOrStorage({ name: 'bg', storageName: 'barcode-gen:bg', defaultValue: '#ffffffff' });
const width = useQueryParamOrStorage({ name: 'width', storageName: 'barcode-gen:width', defaultValue: 2 });
const height = useQueryParamOrStorage({ name: 'height', storageName: 'barcode-gen:height', defaultValue: 100 });
const margin = useQueryParamOrStorage({ name: 'margin', storageName: 'barcode-gen:margin', defaultValue: 10 });
const format = useQueryParamOrStorage({ name: 'format', storageName: 'barcode-gen:format', defaultValue: 'auto' });
const displayValue = useQueryParamOrStorage({ name: 'display', storageName: 'barcode-gen:display', defaultValue: true });
const ean128 = useQueryParamOrStorage({ name: 'ean128', storageName: 'barcode-gen:ean128', defaultValue: false });
const value = ref('123456789');
const options = computed(() => ({
lineColor: foreground.value,
background: background.value,
width: width.value,
height: height.value,
margin: margin.value,
format: format.value === 'auto' ? 'CODE128' : format.value,
displayValue: displayValue.value,
ean128: ean128.value,
text: value.value,
}));
const formats = [
'auto',
'CODE39',
'CODE128', 'CODE128A', 'CODE128B', 'CODE128C',
'EAN13', 'EAN8', 'EAN5', 'EAN2', 'UPC', 'UPCE',
'ITF14',
'ITF',
'MSI', 'MSI10', 'MSI11', 'MSI1010', 'MSI1110',
'pharmacode',
'codabar',
'GenericBarcode',
];
const barcodePNG = computed(() => {
const canvas = document.createElement('canvas');
JsBarcode(canvas, value.value, options.value);
return canvas.toDataURL('image/png');
});
const { download } = useDownloadFileFromBase64({ source: barcodePNG, filename: 'barcode.png' });
</script>
<template>
<c-card>
<n-grid x-gap="12" y-gap="12" cols="1 600:3">
<n-gi span="2">
<c-input-text
v-model:value="value"
label-position="left"
label-width="130px"
label-align="right"
label="Text:"
multiline
rows="1"
autosize
placeholder="Your text..."
mb-6
/>
<n-form label-width="130" label-placement="left">
<n-form-item label="Foreground color:">
<n-color-picker v-model:value="foreground" :modes="['hex']" />
</n-form-item>
<n-form-item label="Background color:">
<n-color-picker v-model:value="background" :modes="['hex']" />
</n-form-item>
<n-form-item label="Width:">
<n-input-number v-model:value="width" :min="0" />
</n-form-item>
<n-form-item label="Height:">
<n-input-number v-model:value="height" :min="0" />
</n-form-item>
<n-form-item label="Margin:">
<n-input-number v-model:value="margin" :min="0" />
</n-form-item>
<n-form-item label="Display text:">
<n-checkbox v-model:checked="displayValue" />
</n-form-item>
<c-select
v-model:value="format"
label="Format:"
label-position="left"
label-width="130px"
label-align="right"
:options="formats.map((value) => ({ label: value, value }))"
/>
</n-form>
</n-gi>
<n-gi>
<div flex flex-col items-center gap-3>
<VueBarcode
:options="options"
:value="value"
/>
<c-button @click="download">
Download barcode
</c-button>
</div>
</n-gi>
</n-grid>
</c-card>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { Barcode } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Barcode Generator',
path: '/barcode-generator',
description: 'Barcode generator',
keywords: ['barcode', 'generator'],
component: () => import('./barcode-generator.vue'),
icon: Barcode,
createdAt: new Date('2024-04-20'),
});
@@ -0,0 +1,66 @@
<script setup lang="ts">
import { BarcodeFormat, BrowserMultiFormatReader } from '@zxing/library';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const imageBase64 = ref('');
const barCode = computedAsync(async () => {
if (imageBase64.value === '') {
return { text: '', format: '', error: '' };
}
try {
const barcodeReader = new BrowserMultiFormatReader();
const result = (await barcodeReader.decodeFromImageUrl(imageBase64.value));
return { text: result.getText(), format: BarcodeFormat[result.getBarcodeFormat()], error: '' };
}
catch (e: any) {
return { error: e.toString(), text: '', format: '' };
}
});
function blobToBase64(blob: Blob) {
if (blob === null) {
return Promise.resolve('');
}
return new Promise<string>((resolve, _reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result as string);
reader.readAsDataURL(blob);
});
}
async function onUpload(file: File) {
if (file) {
imageBase64.value = await blobToBase64(file);
}
}
</script>
<template>
<div>
<c-file-upload
title="Drag and drop a BarCode here, or click to select a file"
:paste-image="true"
mb-3
@file-upload="onUpload"
/>
<div v-if="barCode?.text">
<n-divider />
<h3>Decoded <span v-if="barCode?.format">({{ barCode?.format }})</span></h3>
<TextareaCopyable
:value="barCode?.text"
:word-wrap="true"
/>
</div>
<c-alert v-if="barCode?.error">
{{ barCode?.error }}
</c-alert>
</div>
</template>
<style lang="less" scoped>
::v-deep(.n-upload-trigger) {
width: 100%;
}
</style>
+12
View File
@@ -0,0 +1,12 @@
import { Barcode } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Barcode Reader',
path: '/barcode-reader',
description: 'Barcode reader',
keywords: ['barcode', 'reader'],
component: () => import('./barcode-reader.vue'),
icon: Barcode,
createdAt: new Date('2024-04-20'),
});
+10 -1
View File
@@ -90,6 +90,8 @@ import { tool as uuidGenerator } from './uuid-generator';
import { tool as macAddressLookup } from './mac-address-lookup';
import { tool as xmlFormatter } from './xml-formatter';
import { tool as yamlViewer } from './yaml-viewer';
import { tool as barcodeReader } from './barcode-reader';
import { tool as barcodeGenerator } from './barcode-generator';
export const toolsByCategory: ToolCategory[] = [
{
@@ -145,7 +147,14 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Images and videos',
components: [qrCodeGenerator, wifiQrCodeGenerator, svgPlaceholderGenerator, cameraRecorder],
components: [
qrCodeGenerator,
wifiQrCodeGenerator,
svgPlaceholderGenerator,
cameraRecorder,
barcodeReader,
barcodeGenerator,
],
},
{
name: 'Development',