-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 [desktop] Use the Barcode Detector
- Loading branch information
Showing
10 changed files
with
59 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,6 @@ | |
"electron": "https://esm.sh/v124/[email protected]", | ||
"extract-zip": "https://esm.sh/v124/[email protected]", | ||
"jszip": "https://esm.sh/v124/[email protected]", | ||
"jimp": "https://esm.sh/v124/[email protected]", | ||
"jsqr": "https://esm.sh/v124/[email protected]", | ||
"lit": "https://esm.sh/v124/[email protected]", | ||
"lit/": "https://esm.sh/v124/[email protected]/", | ||
"mime": "https://esm.sh/v124/[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 9 additions & 26 deletions
35
desktop-dev/src/sys/barcode-scanning/barcode-scanning.main.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,33 @@ | ||
// 模拟状态栏模块-用来提供状态UI的模块 | ||
|
||
import Jimp from "jimp"; | ||
import jsQR from "jsqr"; | ||
import { Buffer } from "node:buffer"; | ||
import { NativeMicroModule } from "../../core/micro-module.native.ts"; | ||
|
||
export class BarcodeScanningNMM extends NativeMicroModule { | ||
mmid = "barcode-scanning.sys.dweb" as const; | ||
|
||
// barcodeDetector = new BarcodeDetectorDelegate([ | ||
// Html5QrcodeSupportedFormats.QR_CODE, | ||
// Html5QrcodeSupportedFormats.CODE_39, | ||
// Html5QrcodeSupportedFormats.CODABAR, | ||
// Html5QrcodeSupportedFormats.EAN_13, | ||
// ]); | ||
_bootstrap = () => { | ||
console.always(`[${this.mmid} _bootstrap]`); | ||
let isStop = false; | ||
this.registerCommonIpcOnMessageHandler({ | ||
method: "POST", | ||
pathname: "/process", | ||
matchMode: "full", | ||
input: {}, | ||
output: "object", | ||
handler: async (_args, _client_ipc, ipcRequest) => { | ||
// 直接解析二维码 | ||
return await Jimp.read(Buffer.from(await ipcRequest.body.u8a())).then( | ||
({ bitmap }: Jimp) => { | ||
const result = jsQR( | ||
bitmap.data as unknown as Uint8ClampedArray, | ||
bitmap.width, | ||
bitmap.height | ||
); | ||
return result === null ? [] : [result.data]; | ||
} | ||
); | ||
}, | ||
handler: async (_args, _client_ipc, ipcRequest) => {}, | ||
}); | ||
|
||
this.registerCommonIpcOnMessageHandler({ | ||
method: "GET", | ||
pathname: "/stop", | ||
pathname: "/getSupportedFormats", | ||
matchMode: "full", | ||
input: {}, | ||
output: "boolean", | ||
handler: (_args, _client_ipc, _ipcRequest) => { | ||
// 停止及解析 | ||
isStop = true; | ||
handler: () => { | ||
return true; | ||
}, | ||
}); | ||
}; | ||
|
||
_shutdown() {} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters