Просмотр исходного кода

fix(a2l): transparent printer-card image + getPrinterImage resolver

  Drop the off-white background on the A2L marketing render so it composites
  cleanly on the dark theme (every other printer image in public/img/printers/
  is RGBA with transparent corners; A2L shipped as opaque #F7F7F7). Resize to
  320x320 to match the rest of the artwork.

  Also wire A2L into getPrinterImage so the printer card actually shows the new
  artwork -- without this the resolver fell through to default.png for both
  the A2L display name and the N9 internal SSDP code.

  - frontend/public/img/printers/a2l.png: new, 320x320 RGBA, transparent
  - frontend/src/utils/printer.ts: A2L / N9 -> a2l.png, placed above the a1mini
    branch
  - frontend/src/__tests__/utils/printer.test.ts: 4 cases mirroring the X2D
    shape -- display name, case-insensitive variants, N9 internal code,
    regression guard against accidentally matching A2M / A1 / A1 Mini
maziggy 3 месяцев назад
Родитель
Сommit
f898556941

BIN
frontend/public/img/printers/a2l.png


+ 24 - 0
frontend/src/__tests__/utils/printer.test.ts

@@ -32,6 +32,30 @@ describe('getPrinterImage', () => {
     });
   });
 
+  describe('A2L (#1684)', () => {
+    it('resolves display name "A2L" to a2l.png', () => {
+      expect(getPrinterImage('A2L')).toBe('/img/printers/a2l.png');
+    });
+
+    it('resolves case-insensitive variants', () => {
+      expect(getPrinterImage('a2l')).toBe('/img/printers/a2l.png');
+      expect(getPrinterImage(' A2L ')).toBe('/img/printers/a2l.png');
+    });
+
+    it('resolves the internal SSDP code "N9" to a2l.png', () => {
+      expect(getPrinterImage('N9')).toBe('/img/printers/a2l.png');
+    });
+
+    it('does not match A2L on unrelated A-series strings', () => {
+      // Regression guard: a hypothetical future "A2M" or similar must not
+      // silently pick up a2l.png until it's explicitly mapped, and "A1" /
+      // "A1 Mini" must still resolve to their own artwork.
+      expect(getPrinterImage('A2M')).toBe('/img/printers/default.png');
+      expect(getPrinterImage('A1')).toBe('/img/printers/a1.png');
+      expect(getPrinterImage('A1 Mini')).toBe('/img/printers/a1mini.png');
+    });
+  });
+
   describe('regression: existing families unchanged', () => {
     it('X1C → x1c.png', () => {
       expect(getPrinterImage('X1C')).toBe('/img/printers/x1c.png');

+ 1 - 0
frontend/src/utils/printer.ts

@@ -12,6 +12,7 @@ export function getPrinterImage(model: string | null | undefined): string {
   if (m.includes('p2s')) return '/img/printers/p1s.png';
   if (m.includes('p1s')) return '/img/printers/p1s.png';
   if (m.includes('p1p')) return '/img/printers/p1p.png';
+  if (m.includes('a2l') || m === 'n9') return '/img/printers/a2l.png';
   if (m.includes('a1mini')) return '/img/printers/a1mini.png';
   if (m.includes('a1')) return '/img/printers/a1.png';
   return '/img/printers/default.png';

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/index-OCdsEuOz.js


BIN
static/img/printers/a2l.png


+ 1 - 1
static/index.html

@@ -26,7 +26,7 @@
 
     <!-- Splash screens for iOS -->
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
-    <script type="module" crossorigin src="/assets/index-lbRfAnFB.js"></script>
+    <script type="module" crossorigin src="/assets/index-OCdsEuOz.js"></script>
     <link rel="stylesheet" crossorigin href="/assets/index-7s3X35pi.css">
   </head>
   <body>

Некоторые файлы не были показаны из-за большого количества измененных файлов