fix screenshot script

This commit is contained in:
NhanPT 2022-05-13 21:00:58 +07:00
parent 9a09be4abf
commit 62288e2c70
7 changed files with 39 additions and 20 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View file

@ -0,0 +1,6 @@
:root {
--bgColor: #2d3436;
--bgImage: url("https://images.wallpaperscraft.com/image/single/leaf_plant_green_136967_2560x1440.jpg");
--accentColor: #FFA500;
--foreground: #ffffff;
}

6
sample/leaf/css/core.css Normal file
View file

@ -0,0 +1,6 @@
:root {
--bgColor: #2d3436;
--bgImage: url("https://images.wallpaperscraft.com/image/single/leaf_plant_green_136967_2560x1440.jpg");
--accentColor: #FFA500;
--foreground: #ffffff;
}

View file

@ -64,17 +64,17 @@
<div class="grid gap-4 grid-cols-2">
{{range (index .Contents 1).Columns}}
<div class="box rounded-lg drop-shadow-xl gap-2 p-5 grid grid-flow-row auto-rows-max justify-center">
<div class="icon-container-small mb-4">
<center>
{{if .IsImage}}
<img src="{{.Icon}}" class="icon">
{{else if .IsSVG}}
<svg-file src="{{.Icon}}" class="svg-icon"></svg-file>
{{else}}
<i class="{{.Icon}} fa-xl icon"></i>
{{end}}
</center>
</div>
<center>
<div class="icon-container-small mb-4 w-100">
{{if .IsImage}}
<img src="{{.Icon}}" class="icon">
{{else if .IsSVG}}
<svg-file src="{{.Icon}}" class="svg-icon"></svg-file>
{{else}}
<i class="{{.Icon}} fa-xl icon"></i>
{{end}}
</div>
</center>
{{range .Bookmarks}}
<a href="{{.Url}}" class="text-center">{{.Name}}</a>
{{end}}

View file

@ -1,5 +1,5 @@
const puppeteer = require('puppeteer');
const { readdirSync, copyFileSync } = require('fs');
const { readdirSync, copyFileSync, mkdirSync, existsSync } = require('fs');
const { exec } = require('child_process');
const getDirectories = source =>
@ -9,12 +9,22 @@ const getDirectories = source =>
const replaceFiles = (source, destination) =>
readdirSync(source, { withFileTypes: true })
.filter(dirent => !dirent.isDirectory())
.forEach(file => copyFileSync(`${source}/${file.name}`, `${destination}/${file.name}`));
.forEach(path => {
const srcPath = `${source}/${path.name}`
const desPath = `${destination}/${path.name}`
if (path.isDirectory()) {
if (!existsSync(desPath)) mkdirSync(desPath, { recursive: true });
replaceFiles(srcPath, desPath);
}
else
copyFileSync(srcPath, desPath)
});
const sleep = ms => new Promise(r => setTimeout(r, ms));
(async () => {
exec('cd ../../src/ && go run main.go');
const browser = await puppeteer.launch({
headless: false,
defaultViewport: {
@ -23,22 +33,19 @@ const sleep = ms => new Promise(r => setTimeout(r, ms));
}
});
const themes = ["simplefox"]//getDirectories("./config");
const themes = getDirectories("../../sample");
for (const theme of themes) {
replaceFiles(`../../sample/${theme}`, '../../src/data');
exec('cd ../../src/ && go run main.go');
await sleep(500);
const page = await browser.newPage();
await page.goto('http://localhost:7001');
await page.waitForNetworkIdle();
await sleep(1000);
await sleep(500);
await page.screenshot({ path: `../../docs/screenshots/${theme}.png` });
await page.close();
exec('pkill -f go');
exec('pkill -f main');
await sleep(500);
await sleep(1000);
}
browser.close();