与打印插件获取的打印机做交互
This commit is contained in:
@@ -3,7 +3,8 @@ import { renderNativePrintHtml } from '../native/core/printRenderer';
|
||||
import { buildPdfBase64FromHtmlFragment, extractBodyInnerHtmlFromFullDocument } from './printHtmlToPdfBase64';
|
||||
import { fetchPrintDotPrinters, printDotSendPdf, resolvePrintDotPrinterName } from './printDotBridge';
|
||||
|
||||
const PRINTER_STORAGE_KEY = 'print_template_selected_printer';
|
||||
/** 与模板列表页共用,便于设计器与列表选择同一台 PrintDot 打印机 */
|
||||
export const PRINT_TEMPLATE_SELECTED_PRINTER_KEY = 'print_template_selected_printer';
|
||||
|
||||
/**
|
||||
* 原生模板:渲染 HTML → 转 PDF → 经 PrintDot 本地桥接器送打印机
|
||||
@@ -21,7 +22,8 @@ export async function printNativeSchemaViaPrintDot(params: {
|
||||
paginate: true,
|
||||
});
|
||||
const printers = await fetchPrintDotPrinters();
|
||||
const fromStore = params.printerSelection ?? localStorage.getItem(PRINTER_STORAGE_KEY) ?? '__system_default__';
|
||||
const fromStore =
|
||||
params.printerSelection ?? localStorage.getItem(PRINT_TEMPLATE_SELECTED_PRINTER_KEY) ?? '__system_default__';
|
||||
const resolved = resolvePrintDotPrinterName(fromStore, printers);
|
||||
if (!resolved) {
|
||||
throw new Error('未解析到可用打印机:请在模板列表选择打印机,或启动 PrintDot 后刷新打印机列表');
|
||||
|
||||
Reference in New Issue
Block a user