Commit 81fe3f6a by qinjianhui

fix: 添加打印日志

parent 8bfd9fb8
......@@ -1993,15 +1993,34 @@ const printOrder = async (
}
if (data.filePath) {
const strURL = filePath + data.filePath
console.log('strURL', strURL, data)
const isHttpsPdf = /(https):\/\/([^/]+)/i.test(strURL)
console.log('[printOrder] label source', {
id: data.id,
hasFilePath: !!data.filePath,
hasFileData: !!data.fileData,
isHttpsPdf,
strURL,
})
const pdfPayload = isHttpsPdf ? downloadPDF(strURL) : strURL
console.log('[printOrder] pdf payload meta', {
mode: isHttpsPdf ? 'base64' : 'url',
length: pdfPayload?.length || 0,
preview: pdfPayload?.slice(0, 30),
})
lodop.ADD_PRINT_PDF(
0,
0,
'100%',
'100%',
/(https):\/\/([^/]+)/i.test(strURL) ? downloadPDF(strURL) : strURL,
pdfPayload,
)
} else {
console.log('[printOrder] raw payload meta', {
id: data.id,
hasFilePath: !!data.filePath,
fileDataLength: data.fileData?.length || 0,
fileDataPreview: data.fileData?.slice(0, 30),
})
lodop.SEND_PRINT_RAWDATA(data.fileData || '')
}
console.log('lodop.CVERSION', lodop.CVERSION)
......@@ -2100,7 +2119,22 @@ const downloadPDF = (url: string) => {
xhr.overrideMimeType('text/plain; charset=x-user-defined')
}
xhr.send(null)
console.log('[downloadPDF] response meta', {
url,
status: xhr.status,
readyState: xhr.readyState,
contentType: xhr.getResponseHeader?.('content-type'),
responseType: xhr.responseType,
})
const data = xhr.response || xhr.responseBody
const dataByteLength = arrybuffer
? (data as ArrayBuffer | null)?.byteLength || 0
: (data as string | null)?.length || 0
console.log('[downloadPDF] data length', {
url,
arrybuffer,
dataByteLength,
})
if (typeof Uint8Array !== 'undefined') {
if (arrybuffer) {
dataArray = new Uint8Array(data)
......@@ -2131,6 +2165,11 @@ const downloadPDF = (url: string) => {
digits.substring(d3, d3 + 1) +
digits.substring(d4, d4 + 1)
}
console.log('[downloadPDF] base64 meta', {
url,
base64Length: strData.length,
base64Preview: strData.slice(0, 30),
})
return strData
}
const handleDownloadMaterial = async () => {
......
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