From 2f9c84cf0e0c03a8e3bf07d3924ccdf791070b77 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 16 十月 2026 17:45:21 +0800
Subject: [PATCH] feat(mobile): 添加移动端自动托盘生成功能和追溯定位功能
---
src/views/mobile/scanner.vue | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/views/mobile/scanner.vue b/src/views/mobile/scanner.vue
index e01c066..55ceff2 100644
--- a/src/views/mobile/scanner.vue
+++ b/src/views/mobile/scanner.vue
@@ -1,12 +1,13 @@
<script setup lang="ts">
-import { onBeforeUnmount, onDeactivated, onMounted, ref } from 'vue';
+import { nextTick, onBeforeUnmount, onDeactivated, onMounted, ref, watch } from 'vue';
import Icon from '#/mobile/icon.vue';
-const props=defineProps<{disabled?:boolean}>();
+const props=defineProps<{disabled?:boolean;continuous?:boolean}>();
const emit=defineEmits<{code:[value:string]}>();
-const input=ref(''),error=ref(''),active=ref(false),starting=ref(false),video=ref<HTMLVideoElement>();
+const input=ref(''),error=ref(''),active=ref(false),starting=ref(false),video=ref<HTMLVideoElement>(),codeInput=ref<HTMLInputElement>();
let stream:MediaStream|undefined,frame=0,generation=0,last=0;
function stop(){generation++;active.value=false;starting.value=false;cancelAnimationFrame(frame);stream?.getTracks().forEach(t=>t.stop());stream=undefined;if(video.value)video.value.srcObject=null;}
-function accept(value:string){if(props.disabled)return;stop();input.value=value;emit('code',value);}
+function accept(value:string){if(props.disabled)return;stop();input.value=props.continuous?'':value;emit('code',value);}
+watch([()=>props.disabled,()=>props.continuous],async ([disabled,continuous])=>{if(!disabled&&continuous){await nextTick();codeInput.value?.focus();}});
async function start(){
error.value='';stop();const ticket=generation;starting.value=true;
try{
@@ -52,7 +53,7 @@
<template v-else><video ref="video" class="m-camera" muted playsinline aria-label="浜岀淮鐮佸彇鏅�"/><button type="button" class="m-secondary" @click="stop">鍏抽棴鎽勫儚澶�</button></template>
<p v-if="error" class="m-error" role="alert">{{error}}</p>
<form @submit.prevent="accept(input)">
- <label class="m-field" style="margin-top:16px"><span>鐮佸�� / 婧簮閾炬帴</span><input v-model="input" autocomplete="off" :disabled="disabled" placeholder="鎵嬪姩杈撳叆鎴栦娇鐢ㄦ壂鐮佽澶�" maxlength="2048" /></label>
+ <label class="m-field" style="margin-top:16px"><span>鐮佸�� / 婧簮閾炬帴</span><input ref="codeInput" v-model="input" autocomplete="off" :disabled="disabled" placeholder="鎵嬪姩杈撳叆鎴栦娇鐢ㄦ壂鐮佽澶�" maxlength="2048" /></label>
<button class="m-secondary" :disabled="disabled||!input.trim()" type="submit">{{disabled?'姝e湪澶勭悊鈥�':'璇嗗埆鐮佸��'}}</button>
</form>
</div>
--
Gitblit v1.9.3