26 lines
493 B
TypeScript
26 lines
493 B
TypeScript
import printJS from 'print-js';
|
|
|
|
export async function printPDF(urls: string[]) {
|
|
let index = 0;
|
|
|
|
function next() {
|
|
if (index >= urls.length) return;
|
|
printJS({
|
|
printable: urls[index],
|
|
type: 'pdf',
|
|
showModal: true,
|
|
onPrintDialogClose: () => {
|
|
index++;
|
|
setTimeout(next, 1000); // 等待下一个
|
|
},
|
|
onError: (err) => {
|
|
console.error('打印失败:', err);
|
|
index++;
|
|
next();
|
|
},
|
|
});
|
|
}
|
|
|
|
next();
|
|
}
|