From 18732f2761a0f5d1d2b9a455fe7c69f0b11ae27d Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期五, 16 十月 2026 18:07:17 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_新疆_塔河种业' into dev_新疆_塔河种业

---
 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