Tre proposte grafiche da scegliere (#28)

Prima di toccare l'interfaccia, Alberto sceglie da immagini: Aste, Impostazioni
e Puntate gratis nello stile di Febe, di Khaemhat e di Anubis, in chiaro e in
scuro, con lo stesso contenuto (docs/mockup/redesign). Mimante.Schermate ha la
modalità --mockup che le fotografa e compone il foglio di confronto. I caratteri
(Archivo, Instrument Sans) sono copiati in locale con le loro licenze OFL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-24 11:57:46 +01:00
1 parent 9d89624434
commit ef30e5563e
40 files changed
+1164 -56

No files matched your search

+102 -56
View File
@@ -5,17 +5,23 @@ using Mimante.Session.Cdp;
// Esempio: dotnet run --project tools/Mimante.Schermate -- http://localhost:8080 dev docs/schermate
// Il bot deve girare sul simulatore (--simulatore) per avere aste da fotografare.
// Esce con 1 se una pagina ha errori JavaScript.
//
// Proposte grafiche: dotnet run --project tools/Mimante.Schermate -- --mockup [cartella]
// (predefinita docs/mockup/redesign): fotografa ogni <variante>/<pagina>.html in chiaro e in scuro
// in <cartella>/immagini, poi il foglio di confronto (confronto.html) se c'è.
if (args.Length < 3)
var mockup = args.Length >= 1 && args[0] == "--mockup";
if (!mockup && args.Length < 3)
{
Console.Error.WriteLine("Uso: Screenshots <indirizzo> <password> <cartella>");
Console.Error.WriteLine("Uso: Mimante.Schermate <indirizzo> <password> <cartella> | --mockup [cartella]");
return 2;
}
var baseUrl = args[0].TrimEnd('/');
var password = args[1];
var baseUrl = mockup ? "" : args[0].TrimEnd('/');
var password = mockup ? "" : args[1];
// Un percorso relativo vale dalla radice del repository: `dotnet run` parte nella cartella del progetto.
var outDir = Path.IsPathRooted(args[2]) ? args[2] : Path.GetFullPath(Path.Combine(RepoRoot(), args[2]));
var dirArg = mockup ? (args.Length > 1 ? args[1] : "docs/mockup/redesign") : args[2];
var outDir = Path.IsPathRooted(dirArg) ? dirArg : Path.GetFullPath(Path.Combine(RepoRoot(), dirArg));
Directory.CreateDirectory(outDir);
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5));
@@ -82,67 +88,107 @@ async Task Shot(string name, string hash, string? script = null, int waitMs = 25
await Eval(script);
await Task.Delay(1500, ct);
}
var png = await cdp.SendAsync("Page.captureScreenshot", new { format = "png" }, session, ct);
var file = Path.Combine(outDir, name + ".png");
await File.WriteAllBytesAsync(file, Convert.FromBase64String(png.GetProperty("data").GetString()!), ct);
await Capture(Path.Combine(outDir, name + ".png"));
Console.WriteLine($"{name}.png{(errors.Count > before ? $" ({errors.Count - before} errori)" : "")}");
}
await Viewport(1600, 1000);
await Navigate(baseUrl + "/accesso");
await Shot("00-accesso-interfaccia", "", null, 500);
await Eval($"document.querySelector('input[type=password]').value = {JsonSerializer.Serialize(password)}; document.querySelector('form').submit();");
await loaded.WaitAsync(TimeSpan.FromSeconds(20), ct);
await Task.Delay(1500, ct);
async Task Capture(string file)
{
var png = await cdp.SendAsync("Page.captureScreenshot", new { format = "png" }, session, ct);
await File.WriteAllBytesAsync(file, Convert.FromBase64String(png.GetProperty("data").GetString()!), ct);
}
const string clickFirst = "document.querySelector('.split tbody tr[data-id]')?.click()";
await Shot("01-aste", "#/aste", clickFirst, 4000);
await Shot("12-aste-registro", "#/aste", "document.querySelector('.panel .panel-mode button[data-mode=registro]')?.click()", 500);
await Shot("14-aste-puntate", "#/aste", "document.querySelector('.panel .tabs button[data-tab=puntate]')?.click()", 500);
await Eval("document.querySelector('.panel .tabs button[data-tab=auto]')?.click()");
await Shot("02-apprendimento", "#/apprendimento", null, 3500);
await Shot("03-browser", "#/browser");
if (args.Contains("--accesso-assistito"))
if (mockup)
{
// Apre il browser del bot (Chromium dentro il bot) e aspetta il primo fotogramma.
await Eval("document.querySelector('.browser .idle button')?.click()");
var frame = false;
for (var i = 0; i < 40 && !frame; i++)
var images = Path.Combine(outDir, "immagini");
Directory.CreateDirectory(images);
await Viewport(1600, 1000);
foreach (var variant in Directory.GetDirectories(outDir).Where(d => File.Exists(Path.Combine(d, "stile.css"))).Order())
{
await Task.Delay(500, ct);
frame = (await Eval("!document.querySelector('.browser canvas').hidden")).ValueKind == JsonValueKind.True;
foreach (var page in new[] { "aste", "impostazioni", "puntate-gratis" })
{
foreach (var (theme, label) in new[] { ("light", "chiaro"), ("dark", "scuro") })
{
var before = errors.Count;
await Navigate(new Uri(Path.Combine(variant, page + ".html")).AbsoluteUri + "?tema=" + theme);
await Eval("document.fonts.ready.then(() => true)");
await Task.Delay(300, ct);
var name = $"{Path.GetFileName(variant)}-{page}-{label}.png";
await Capture(Path.Combine(images, name));
Console.WriteLine($"{name}{(errors.Count > before ? $" ({errors.Count - before} errori)" : "")}");
}
}
}
var sheet = Path.Combine(outDir, "confronto.html");
if (File.Exists(sheet))
{
await Navigate(new Uri(sheet).AbsoluteUri);
await Eval("Promise.all([...document.images].map(i => i.decode().catch(() => null))).then(() => true)");
var height = (await Eval("document.documentElement.scrollHeight")).GetInt32();
await Viewport(1600, height);
await Task.Delay(300, ct);
await Capture(Path.Combine(images, "confronto.png"));
Console.WriteLine("confronto.png");
}
await Task.Delay(2500, ct);
await Shot("03-browser", "#/browser", null, 200);
Console.WriteLine(frame ? "Browser del bot: fotogrammi ricevuti" : "Browser del bot: nessun fotogramma");
if (!frame) errors.Add("accesso assistito: nessun fotogramma dal browser del bot");
await Eval("document.querySelector('.browser .url button[title^=\"Chiudi\"]')?.click()");
}
if (args.Contains("--messaggio"))
else
{
// Il messaggio a schermo per un'informazione importante: senza token Telegram il
// messaggio di prova risponde che manca la configurazione.
await Shot("11-messaggio", "#/impostazioni", "[...document.querySelectorAll('.section button')].find(b => b.textContent.startsWith('Invia messaggio'))?.click()");
if ((await Eval("!!document.querySelector('.modal .notice')")).ValueKind != JsonValueKind.True)
errors.Add("messaggio a schermo: nessun avviso dopo «Invia messaggio di prova»");
await Eval("document.querySelector('.modal footer .btn')?.click()");
await Viewport(1600, 1000);
await Navigate(baseUrl + "/accesso");
await Shot("00-accesso-interfaccia", "", null, 500);
await Eval($"document.querySelector('input[type=password]').value = {JsonSerializer.Serialize(password)}; document.querySelector('form').submit();");
await loaded.WaitAsync(TimeSpan.FromSeconds(20), ct);
await Task.Delay(1500, ct);
const string clickFirst = "document.querySelector('.split tbody tr[data-id]')?.click()";
await Shot("01-aste", "#/aste", clickFirst, 4000);
await Shot("12-aste-registro", "#/aste", "document.querySelector('.panel .panel-mode button[data-mode=registro]')?.click()", 500);
await Shot("14-aste-puntate", "#/aste", "document.querySelector('.panel .tabs button[data-tab=puntate]')?.click()", 500);
await Eval("document.querySelector('.panel .tabs button[data-tab=auto]')?.click()");
await Shot("02-apprendimento", "#/apprendimento", null, 3500);
await Shot("03-browser", "#/browser");
if (args.Contains("--accesso-assistito"))
{
// Apre il browser del bot (Chromium dentro il bot) e aspetta il primo fotogramma.
await Eval("document.querySelector('.browser .idle button')?.click()");
var frame = false;
for (var i = 0; i < 40 && !frame; i++)
{
await Task.Delay(500, ct);
frame = (await Eval("!document.querySelector('.browser canvas').hidden")).ValueKind == JsonValueKind.True;
}
await Task.Delay(2500, ct);
await Shot("03-browser", "#/browser", null, 200);
Console.WriteLine(frame ? "Browser del bot: fotogrammi ricevuti" : "Browser del bot: nessun fotogramma");
if (!frame) errors.Add("accesso assistito: nessun fotogramma dal browser del bot");
await Eval("document.querySelector('.browser .url button[title^=\"Chiudi\"]')?.click()");
}
if (args.Contains("--messaggio"))
{
// Il messaggio a schermo per un'informazione importante: senza token Telegram il
// messaggio di prova risponde che manca la configurazione.
await Shot("11-messaggio", "#/impostazioni", "[...document.querySelectorAll('.section button')].find(b => b.textContent.startsWith('Invia messaggio'))?.click()");
if ((await Eval("!!document.querySelector('.modal .notice')")).ValueKind != JsonValueKind.True)
errors.Add("messaggio a schermo: nessun avviso dopo «Invia messaggio di prova»");
await Eval("document.querySelector('.modal footer .btn')?.click()");
}
await Shot("04-prodotti", "#/prodotti", clickFirst);
await Shot("13-prodotti-statistiche", "#/prodotti", "[...document.querySelectorAll('.panel .tabs button')].find(b => b.textContent === 'Statistiche')?.click()", 500);
await Eval("[...document.querySelectorAll('.panel .tabs button')].find(b => b.textContent === 'Paletti e valore')?.click()");
await Shot("05-impostazioni", "#/impostazioni");
await Shot("06-storico", "#/storico", clickFirst);
await Shot("09-cerca", "#/cerca", null, 4000);
await Shot("10-registro", "#/registro");
await Eval("document.documentElement.dataset.theme = 'light'");
await Shot("07-aste-tema-chiaro", "#/aste", clickFirst, 2500);
await Eval("document.documentElement.dataset.theme = 'dark'");
// Una finestra di portatile comune: la colonna Azioni deve restare in vista.
await Viewport(1366, 768);
await Shot("15-aste-1366", "#/aste", clickFirst, 2000);
await Viewport(1000, 900);
await Shot("08-aste-finestra-stretta", "#/aste", clickFirst, 2000);
await Eval("localStorage.removeItem('mimante.theme')");
}
await Shot("04-prodotti", "#/prodotti", clickFirst);
await Shot("13-prodotti-statistiche", "#/prodotti", "[...document.querySelectorAll('.panel .tabs button')].find(b => b.textContent === 'Statistiche')?.click()", 500);
await Eval("[...document.querySelectorAll('.panel .tabs button')].find(b => b.textContent === 'Paletti e valore')?.click()");
await Shot("05-impostazioni", "#/impostazioni");
await Shot("06-storico", "#/storico", clickFirst);
await Shot("09-cerca", "#/cerca", null, 4000);
await Shot("10-registro", "#/registro");
await Eval("document.documentElement.dataset.theme = 'light'");
await Shot("07-aste-tema-chiaro", "#/aste", clickFirst, 2500);
await Eval("document.documentElement.dataset.theme = 'dark'");
// Una finestra di portatile comune: la colonna Azioni deve restare in vista.
await Viewport(1366, 768);
await Shot("15-aste-1366", "#/aste", clickFirst, 2000);
await Viewport(1000, 900);
await Shot("08-aste-finestra-stretta", "#/aste", clickFirst, 2000);
await Eval("localStorage.removeItem('mimante.theme')");
try { await cdp.SendAsync("Browser.close", timeout: TimeSpan.FromSeconds(3)); } catch { }