|
@@ -7,7 +7,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { nextTick, ref, watch } from 'vue'
|
|
|
+import { nextTick, onMounted, ref, watch } from 'vue'
|
|
|
import { useAppStore } from '~src/store'
|
|
|
import { detectionBrowser, getAppVersion, useOsTheme } from 'hc-vue3-ui'
|
|
|
import { getObjValue, setElementMainColor } from 'js-fast-way'
|
|
@@ -27,6 +27,18 @@ watch(() => [
|
|
|
setUserTheme(ThemeVal, ColorVal)
|
|
|
})
|
|
|
|
|
|
+onMounted(() => {
|
|
|
+ // 监听设备连接
|
|
|
+ navigator.usb.addEventListener('connect', (event) => {
|
|
|
+ console.log('USB 设备已连接:', event.device)
|
|
|
+ })
|
|
|
+
|
|
|
+ // 监听设备断开
|
|
|
+ navigator.usb.addEventListener('disconnect', (event) => {
|
|
|
+ console.log('USB 设备已断开:', event.device)
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
const testClick1 = () => {
|
|
|
navigator.usb.requestDevice({ filters: [{ vendorId: 10367 }] }).then(device => {
|
|
|
console.log(device)
|