@@ -126,6 +126,7 @@ function updateBandwidth(timestamp: number) {
126
126
}
127
127
128
128
const chunks: SliceData [] = reactive ([])
129
+
129
130
const length = computed (() => chunks .find (i => i ?.[1 ])?.[1 ] || 0 )
130
131
const id = computed (() => chunks .find (i => i ?.[0 ])?.[0 ] || 0 )
131
132
const picked = computed (() => Array .from ({ length: length .value }, (_ , idx ) => chunks [idx ]))
@@ -160,6 +161,10 @@ async function scanFrame() {
160
161
results .value .add (result .text )
161
162
const data = JSON .parse (result .text ) as SliceData
162
163
if (Array .isArray (data )) {
164
+ if (data [0 ] !== id .value ) {
165
+ chunks .length = 0
166
+ dataUrl .value = undefined
167
+ }
163
168
chunks [data [2 ]] = data
164
169
pluse (data [2 ])
165
170
@@ -196,37 +201,48 @@ watch(() => results.value.size, (size) => {
196
201
<button
197
202
v-for =" item of cameras" :key =" item.deviceId" :class =" {
198
203
'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"
200
207
>
201
208
{{ item.label }}
202
209
</button >
203
210
</div >
204
- < a v-if = " dataUrl " :href = " dataUrl " download = " foo.png " >Download</ a >
211
+
205
212
<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
+
206
233
<div relative h-full max-h-150 max-w-150 w-full >
207
234
<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 " >
224
237
{{ picked.filter(p => !!p).length }} / {{ length }}
225
- </div >
238
+ </template >
239
+ <template v-else >
240
+ No Data
241
+ </template >
226
242
</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 >
227
246
</div >
228
-
229
- <div >{{ { length, id } }}</div >
230
- <!-- <div>{{ chunks }}</div> -->
231
247
</div >
232
248
</template >
0 commit comments