feat(pos): add printer settings persistence for network printing
This commit is contained in:
parent
ca6e9364a8
commit
2ea76f9d9a
1 changed files with 28 additions and 0 deletions
28
public/pos/epos-print.js
Normal file
28
public/pos/epos-print.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Network (ePOS-Print) thermal printing for Epson TM-series Ethernet
|
||||
// printers. Runs alongside the existing Web Bluetooth path in
|
||||
// receipt.html — the till picks a transport in Printer settings.
|
||||
//
|
||||
// The printer's ePOS-Print endpoint is served over HTTPS with a
|
||||
// self-signed cert and open CORS (`Access-Control-Allow-Origin: *`),
|
||||
// confirmed by direct testing against the shop's TM-T20II. Each till
|
||||
// device must visit `https://<printer-ip>` once in its browser and
|
||||
// accept the certificate warning before fetch() calls here succeed.
|
||||
window.EposPrint = (function () {
|
||||
'use strict';
|
||||
|
||||
const SETTINGS_KEY = 'pos.printerSettings';
|
||||
|
||||
function getSettings() {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(SETTINGS_KEY)) || { type: 'bluetooth', ip: '' };
|
||||
} catch (e) {
|
||||
return { type: 'bluetooth', ip: '' };
|
||||
}
|
||||
}
|
||||
|
||||
function setSettings(settings) {
|
||||
localStorage.setItem(SETTINGS_KEY, JSON.stringify(settings));
|
||||
}
|
||||
|
||||
return { getSettings, setSettings };
|
||||
})();
|
||||
Loading…
Reference in a new issue