ZaiZai 1 ano atrás
pai
commit
a16ece5506
1 arquivos alterados com 11 adições e 8 exclusões
  1. 11 8
      src/App.vue

+ 11 - 8
src/App.vue

@@ -1,7 +1,8 @@
 <template>
     <hc-app-config>
         <router-view />
-        <div class="absolute top-0 w-full text-center" @click="testClick">测试</div>
+        <div class="absolute top-60px z-9999 w-full text-center" @click="testClick1">测试1</div>
+        <div class="absolute top-90px z-9999 w-full text-center" @click="testClick2">测试2</div>
     </hc-app-config>
 </template>
 
@@ -26,15 +27,17 @@ watch(() => [
     setUserTheme(ThemeVal, ColorVal)
 })
 
-const testClick = () => {
-    navigator.usb.requestDevice({ filters: [{}] }).then(device => {
+const testClick1 = () => {
+    navigator.usb.requestDevice({ filters: [{ vendorId: 10367 }] }).then(device => {
         console.log(device)
-        // 设备已授权
-        navigator.usb.getDevices().then(devices => {
-            console.log(devices)
-        })
     }).catch(error => {
-        console.error('设备选择失败', error)
+        console.log('未选择')
+    })
+}
+
+const testClick2 = () => {
+    navigator.usb.getDevices().then(devices => {
+        console.log(devices)
     })
 }