Skip to content

Commit eeb8306

Browse files
committed
feat: custom slice size
1 parent e1cde59 commit eeb8306

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

app/components/Generate.vue

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
22
import { fromUint8Array } from 'js-base64'
3-
import { blockToBinary, createEncoder, type EncodedBlock } from 'luby-transform'
3+
import { blockToBinary, createEncoder, type EncodedBlock, type LtEncoder } from 'luby-transform'
44
import { renderSVG } from 'uqr'
55
import { useKiloBytesNumberFormat } from '~/composables/intlNumberFormat'
66
@@ -9,12 +9,17 @@ const props = withDefaults(defineProps<{
99
filename?: string
1010
contentType?: string
1111
maxScansPerSecond: number
12+
sliceSize: number
1213
}>(), {
1314
maxScansPerSecond: 20,
15+
sliceSize: 1000,
1416
})
1517
1618
const count = ref(0)
17-
const encoder = createEncoder(props.data, 1000)
19+
let encoder: LtEncoder
20+
watch(() => [props.data, props.sliceSize], () => {
21+
encoder = createEncoder(props.data, props.sliceSize)
22+
}, { immediate: true })
1823
const svg = ref<string>()
1924
const block = shallowRef<EncodedBlock>()
2025

app/layouts/default.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div max-w="full sm:250" mx-auto h-full w-full flex flex-col>
2+
<div max-w="full sm:250" mx-auto w-full flex flex-col pb-20>
33
<header flex flex-col gap-4 px-4 pb-4 pt-4>
44
<nav flex items-center>
55
<div w-40 flex="~" items-center gap-2 text-4xl>

app/pages/index.vue

+16-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ enum ReadPhase {
1010
1111
const error = ref<any>()
1212
const fps = ref(20)
13+
const sliceSize = ref(1000)
1314
const throttledFps = useDebounce(fps, 500)
1415
const readPhase = ref<ReadPhase>(ReadPhase.Idle)
1516
@@ -70,13 +71,27 @@ async function onFileChange(file?: File) {
7071
w-full flex-1
7172
/>
7273
</div>
74+
<div w-full inline-flex flex-row items-center>
75+
<span min-w-30>
76+
<span pr-2 text-neutral-400>Slice Size</span>
77+
</span>
78+
<input
79+
v-model.lazy="sliceSize"
80+
type="number"
81+
:min="1"
82+
:max="2000"
83+
border="~ gray/25 rounded-lg"
84+
w-full flex-1 bg-transparent px2 py1 text-sm shadow-sm
85+
>
86+
</div>
7387
</div>
7488
<div
7589
v-if="readPhase === ReadPhase.Ready && data"
7690
h-full w-full flex justify-center
7791
>
7892
<Generate
7993
:max-scans-per-second="throttledFps"
94+
:slice-size="sliceSize"
8095
:data="data"
8196
:filename="filename"
8297
:content-type="contentType"
@@ -85,8 +100,8 @@ async function onFileChange(file?: File) {
85100
</div>
86101
<InputFile
87102
v-else
88-
h-full w-full
89103
text="neutral-600 dark:neutral-400"
104+
aspect-1 h-full w-full rounded-lg
90105
@file="onFileChange"
91106
/>
92107
<DropZone text="Drop File Here" @file="onFileChange" />

0 commit comments

Comments
 (0)