Skip to content

Commit e246a47

Browse files
committed
feat: improve ui a bit
1 parent d67a892 commit e246a47

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

app/components/Scan.vue

+38-22
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ function updateBandwidth(timestamp: number) {
126126
}
127127
128128
const chunks: SliceData[] = reactive([])
129+
129130
const length = computed(() => chunks.find(i => i?.[1])?.[1] || 0)
130131
const id = computed(() => chunks.find(i => i?.[0])?.[0] || 0)
131132
const picked = computed(() => Array.from({ length: length.value }, (_, idx) => chunks[idx]))
@@ -160,6 +161,10 @@ async function scanFrame() {
160161
results.value.add(result.text)
161162
const data = JSON.parse(result.text) as SliceData
162163
if (Array.isArray(data)) {
164+
if (data[0] !== id.value) {
165+
chunks.length = 0
166+
dataUrl.value = undefined
167+
}
163168
chunks[data[2]] = data
164169
pluse(data[2])
165170
@@ -196,37 +201,48 @@ watch(() => results.value.size, (size) => {
196201
<button
197202
v-for="item of cameras" :key="item.deviceId" :class="{
198203
'text-blue': selectedCamera === item.deviceId,
199-
}" class="border rounded-md px2 py1 text-sm shadow-sm" @click="selectedCamera = item.deviceId"
204+
}"
205+
class="border rounded-md px2 py1 text-sm shadow-sm"
206+
@click="selectedCamera = item.deviceId"
200207
>
201208
{{ item.label }}
202209
</button>
203210
</div>
204-
<a v-if="dataUrl" :href="dataUrl" download="foo.png">Download</a>
211+
205212
<pre v-if="error" text-red v-text="error" />
213+
<div border="~ gray/25 rounded-lg" flex="~ col gap-2" mb--4 max-w-150 p2>
214+
<div flex="~ gap-0.4 wrap">
215+
<div
216+
v-for="x, idx in picked"
217+
:key="idx"
218+
ref="dots"
219+
h-4
220+
w-4
221+
border="~ gray rounded"
222+
:class="x ? 'bg-green border-green4' : 'bg-gray:50'"
223+
/>
224+
</div>
225+
<a
226+
v-if="dataUrl"
227+
class="w-max border border-gray:50 rounded-md px2 py1 text-sm hover:bg-gray:10"
228+
:href="dataUrl"
229+
download="foo.png"
230+
>Download</a>
231+
</div>
232+
206233
<div relative h-full max-h-150 max-w-150 w-full>
207234
<video ref="video" autoplay muted playsinline aspect-ratio-1 h-full w-full rounded-lg controls="false" />
208-
<p absolute bottom-1 right-1 border rounded-md bg-black px2 py1 text-white font-mono shadow>
209-
{{ fps.toFixed(0) }}hz | {{ shutterCount }} | {{ currentBandwidthFormatted }}
210-
</p>
211-
<div absolute left-1 right-1 top-1>
212-
<div flex="~ gap-0.4 wrap">
213-
<div
214-
v-for="x, idx in picked"
215-
:key="idx"
216-
ref="dots"
217-
h-4
218-
w-4
219-
border="~ gray rounded"
220-
:class="x ? 'bg-green border-green4' : 'bg-gray:50'"
221-
/>
222-
</div>
223-
<div mt-1 w-max rounded bg-black:40 px1 text-sm>
235+
<div absolute left-1 top-1 border border-gray:50 rounded-md bg-black:75 px2 py1 text-sm text-white font-mono shadow>
236+
<template v-if="length">
224237
{{ picked.filter(p => !!p).length }} / {{ length }}
225-
</div>
238+
</template>
239+
<template v-else>
240+
No Data
241+
</template>
226242
</div>
243+
<p absolute right-1 top-1 border border-gray:50 rounded-md bg-black:75 px2 py1 text-sm text-white font-mono shadow>
244+
{{ fps.toFixed(0) }}hz | {{ shutterCount }} | {{ currentBandwidthFormatted }}
245+
</p>
227246
</div>
228-
229-
<div>{{ { length, id } }}</div>
230-
<!-- <div>{{ chunks }}</div> -->
231247
</div>
232248
</template>

0 commit comments

Comments
 (0)