fix: 测试联调四项修复
- 授权码并入加密狗行,password 掩码,窄宽样式 - 打印机信息仅调用 SAPI_GetPrinterInfo,移除 Ex 避免崩溃 - net_info 改为 JSON 数组,修复双重编码 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -68,7 +68,7 @@ export function registerIpcHandlers(): void {
|
||||
return ok({
|
||||
...cached,
|
||||
fromCache: true,
|
||||
liveError: r.code <= 0 ? '未连接打印机' : `GetPrinterInfoEx code=${r.code}`
|
||||
liveError: r.code <= 0 ? '未连接打印机' : `GetPrinterInfo code=${r.code}`
|
||||
})
|
||||
}
|
||||
return fail(0, '未连接打印机')
|
||||
|
||||
@@ -24,10 +24,6 @@ let SAPI_Init: any = null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let SAPI_GetPrinterInfo: any = null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let SAPI_GetPrinterInfoEx: any = null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let SAPI_FreePrinterInfo: any = null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let SAPI_GetPrinterErrorStr: any = null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let SAPI_RestJobEx: any = null
|
||||
@@ -56,7 +52,6 @@ let hasCardPositionApi = false
|
||||
let hasCheckstatusApi = false
|
||||
let hasCancelApi = false
|
||||
let hasUploadApi = false
|
||||
let hasPrinterInfoEx = false
|
||||
let hasUsbReaderApi = false
|
||||
let loggedCancelMissing = false
|
||||
let loggedRejectMissing = false
|
||||
@@ -95,15 +90,7 @@ function readPrinterJsonFromOutPtr(len: number, outPtr: Buffer): { code: number;
|
||||
return { code: len }
|
||||
}
|
||||
} finally {
|
||||
if (SAPI_FreePrinterInfo) {
|
||||
try {
|
||||
SAPI_FreePrinterInfo(ptr)
|
||||
} catch (e) {
|
||||
log.warn('SAPI_FreePrinterInfo', e)
|
||||
}
|
||||
} else {
|
||||
koffi.free(ptr)
|
||||
}
|
||||
koffi.free(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,16 +110,6 @@ function loadLibrary(): void {
|
||||
SAPI_GetUsbCopyState = lib.func('int __stdcall SAPI_GetUsbCopyState(_Out_ int *, _Out_ int *)')
|
||||
SAPI_PrinterResetprinter = lib.func('int __stdcall SAPI_PrinterResetprinter()')
|
||||
|
||||
try {
|
||||
SAPI_GetPrinterInfoEx = lib.func('int __stdcall SAPI_GetPrinterInfoEx(_Out_ void **)')
|
||||
SAPI_FreePrinterInfo = lib.func('void __stdcall SAPI_FreePrinterInfo(void *)')
|
||||
hasPrinterInfoEx = true
|
||||
} catch {
|
||||
SAPI_GetPrinterInfoEx = null
|
||||
SAPI_FreePrinterInfo = null
|
||||
hasPrinterInfoEx = false
|
||||
}
|
||||
|
||||
try {
|
||||
SAPI_UploadFile = lib.func('int __stdcall SAPI_UploadFile(str, str, str)')
|
||||
hasUploadApi = true
|
||||
@@ -194,7 +171,6 @@ function loadLibrary(): void {
|
||||
|
||||
log.info('workDll loaded', {
|
||||
upload: hasUploadApi,
|
||||
printerInfoEx: hasPrinterInfoEx,
|
||||
cancel: hasCancelApi,
|
||||
reject: hasRejectApi,
|
||||
usbReader: hasUsbReaderApi,
|
||||
@@ -263,7 +239,7 @@ export function dllInit(params: InitParams): number {
|
||||
}
|
||||
|
||||
function dllGetPrinterInfoInternal(
|
||||
apiName: 'SAPI_GetPrinterInfo' | 'SAPI_GetPrinterInfoEx',
|
||||
apiName: 'SAPI_GetPrinterInfo',
|
||||
fn: (outPtr: Buffer) => number
|
||||
): { code: number; json?: Record<string, unknown> } {
|
||||
return traceCall(apiName, undefined, () => {
|
||||
@@ -279,13 +255,6 @@ function dllGetPrinterInfoInternal(
|
||||
}
|
||||
|
||||
export function dllGetPrinterInfo(): { code: number; json?: Record<string, unknown> } {
|
||||
loadLibrary()
|
||||
if (hasPrinterInfoEx && SAPI_GetPrinterInfoEx) {
|
||||
const ex = dllGetPrinterInfoInternal('SAPI_GetPrinterInfoEx', (p) => SAPI_GetPrinterInfoEx!(p))
|
||||
if (ex.json && Object.keys(ex.json).length > 0) {
|
||||
return ex
|
||||
}
|
||||
}
|
||||
return dllGetPrinterInfoInternal('SAPI_GetPrinterInfo', (p) => SAPI_GetPrinterInfo!(p))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user