与打印插件获取的打印机做交互

This commit is contained in:
geht
2026-04-17 19:31:09 +08:00
parent efb6a9f838
commit 93b2208675
3 changed files with 75 additions and 7 deletions

View File

@@ -212,6 +212,7 @@
} from './utils/printDotBridge';
import { normalizeImportedNativeSchema } from './native/core/nativeSchemaNormalize';
import { renderNativePrintHtml } from './native/core/printRenderer';
import { PRINT_TEMPLATE_SELECTED_PRINTER_KEY } from './utils/printNativeViaPrintDot';
defineOptions({ name: 'PrintTemplateList' });
@@ -304,7 +305,6 @@
});
let hiprint: any = null;
const PRINTER_STORAGE_KEY = 'print_template_selected_printer';
function resolveHiprint(module: any) {
const defaultExport = module?.default || {};
hiprint = module?.hiprint || defaultExport?.hiprint || (window as any)?.hiprint;
@@ -1637,10 +1637,10 @@
selectedPrinterName,
(value) => {
if (!value) {
localStorage.removeItem(PRINTER_STORAGE_KEY);
localStorage.removeItem(PRINT_TEMPLATE_SELECTED_PRINTER_KEY);
return;
}
localStorage.setItem(PRINTER_STORAGE_KEY, value);
localStorage.setItem(PRINT_TEMPLATE_SELECTED_PRINTER_KEY, value);
},
{ immediate: false },
);
@@ -1651,7 +1651,7 @@
} catch (_error) {
// ignore
}
selectedPrinterName.value = localStorage.getItem(PRINTER_STORAGE_KEY) || '__system_default__';
selectedPrinterName.value = localStorage.getItem(PRINT_TEMPLATE_SELECTED_PRINTER_KEY) || '__system_default__';
await refreshPrinterOptions(false);
if (!selectedPrinterName.value) {
selectedPrinterName.value = '__system_default__';