48 lines
3.1 KiB
JavaScript
48 lines
3.1 KiB
JavaScript
'use strict';
|
|
/**
|
|
* tools/demo-video/capture_app.js: nimmt Bilder des Windows-Programms mit den erfundenen Beispieldaten aus desktop/test/mock.html auf.
|
|
* desktop/node_modules/.bin/electron tools/demo-video/capture_app.js <Bilderordner> [Startnummer]
|
|
*/
|
|
const { app, BrowserWindow } = require('electron');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const OUT = path.resolve(process.argv[2] || path.join(__dirname, 'frames'));
|
|
let n = parseInt(process.argv[3] || '50', 10) - 1;
|
|
fs.mkdirSync(OUT, { recursive: true });
|
|
const MOCK = path.resolve(__dirname, '..', '..', '..', 'desktop', 'test', 'mock.html');
|
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
let win;
|
|
const run = (js) => win.webContents.executeJavaScript(js, true);
|
|
|
|
async function shot(caption, name) {
|
|
n += 1;
|
|
await run(`(() => { const d = document.createElement('div'); d.id = '__cap'; d.textContent = ${JSON.stringify(caption)};
|
|
d.style.cssText = 'position:fixed;left:50%;bottom:26px;transform:translateX(-50%);z-index:2147483647;background:rgba(10,30,45,.92);color:#fff;font:600 21px Segoe UI,Arial,sans-serif;padding:13px 26px;border-radius:40px;box-shadow:0 6px 24px rgba(0,0,0,.35);max-width:1180px;text-align:center';
|
|
document.body.appendChild(d); })()`);
|
|
await sleep(450);
|
|
fs.writeFileSync(path.join(OUT, `${String(n).padStart(2, '0')}_${name}.png`), (await win.webContents.capturePage()).toPNG());
|
|
await run(`document.getElementById('__cap')?.remove()`);
|
|
}
|
|
|
|
app.whenReady().then(async () => {
|
|
win = new BrowserWindow({ width: 1440, height: 900, show: true, useContentSize: true, webPreferences: { contextIsolation: false, nodeIntegration: false, backgroundThrottling: false } });
|
|
try {
|
|
await win.loadFile(MOCK);
|
|
await run(`(() => { const o = window.deskhub.api; window.deskhub.api = async (r) => { const res = await o(r); return res.error && /^Mock:/.test(res.error.message) ? { data: { items: [], rules: [], holidays: [], hours: [], staffOptions: [], departments: [], permissionKeys: [], fieldOptions: [], operatorOptions: [], actionOptions: [] } } : res; }; })()`);
|
|
await sleep(800);
|
|
await run(`go('dashboard')`); await sleep(900);
|
|
await shot('Windows-Programm: Übersicht mit Kennzahlen und priorisierten Tickets', 'app_uebersicht');
|
|
await run(`go('tickets')`); await sleep(900);
|
|
await shot('Windows-Programm: Tickets mit Reitern, Ansichten und Wiedervorlage', 'app_tickets');
|
|
await run(`go('ticket', 1)`); await sleep(1100);
|
|
await shot('Windows-Programm: Ticket bearbeiten, auf später legen, beobachten', 'app_ticket');
|
|
await run(`state.staff.role = 'admin'; go('admin', 'assistant')`); await sleep(900);
|
|
await shot('Windows-Programm: Digitalen Assistenten komplett verwalten', 'app_assistent');
|
|
await run(`[...document.querySelectorAll('#main .tabs button')].find((b) => b.innerText.includes('Fragen-Log')).click()`); await sleep(700);
|
|
await shot('Fragen-Log mit häufigen Fragen ohne Antwort', 'app_assistent_log');
|
|
} catch (e) { console.error('Fehler:', e); process.exitCode = 1; }
|
|
console.log(`${n - (parseInt(process.argv[3] || '50', 10) - 1)} Bilder in ${OUT}`);
|
|
app.quit();
|
|
});
|