Commit 46a1ef94 by zeven

优化打印机连接

parent 03514c94
...@@ -120,8 +120,7 @@ const CounterMixins = ComposeComponent => { ...@@ -120,8 +120,7 @@ const CounterMixins = ComposeComponent => {
await handleScan(); await handleScan();
this.barcode = ''; this.barcode = '';
}); });
const isConnected = await Printer.isConnected(); this.printerConnect();
if (!isConnected) await Printer.usbConnect(); // 尝试连接打印机模块
this.listen(); this.listen();
}; };
...@@ -132,6 +131,11 @@ const CounterMixins = ComposeComponent => { ...@@ -132,6 +131,11 @@ const CounterMixins = ComposeComponent => {
KeyEvent.removeKeyUpListener(); KeyEvent.removeKeyUpListener();
}; };
printerConnect = async () => {
const isConnected = await Printer.isConnected();
if (!isConnected) await Printer.usbConnect(); // 尝试连接打印机模块
};
setDelay = debounce(delay, true, () => { setDelay = debounce(delay, true, () => {
this.isDelay = true; this.isDelay = true;
setTimeout(() => { setTimeout(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment