Browse Source

fix screenshot script

NhanPT 3 years ago
parent
commit
62288e2c70

BIN
docs/screenshots/flame.png


BIN
docs/screenshots/leaf.png


BIN
docs/screenshots/simplefox.png


+ 6 - 0
sample/flame/css/core.css

@@ -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 - 0
sample/leaf/css/core.css

@@ -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;
+}

+ 11 - 11
src/themes/simplefox/index.html

@@ -64,17 +64,17 @@
                     <div class="grid gap-4 grid-cols-2">
                     <div class="grid gap-4 grid-cols-2">
                         {{range (index .Contents 1).Columns}}
                         {{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="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}}
                             {{range .Bookmarks}}
                             <a href="{{.Url}}" class="text-center">{{.Name}}</a>
                             <a href="{{.Url}}" class="text-center">{{.Name}}</a>
                             {{end}}
                             {{end}}

+ 16 - 9
tools/screenshot/app.js

@@ -1,5 +1,5 @@
 const puppeteer = require('puppeteer');
 const puppeteer = require('puppeteer');
-const { readdirSync, copyFileSync } = require('fs');
+const { readdirSync, copyFileSync, mkdirSync, existsSync } = require('fs');
 const { exec } = require('child_process');
 const { exec } = require('child_process');
 
 
 const getDirectories = source =>
 const getDirectories = source =>
@@ -9,12 +9,22 @@ const getDirectories = source =>
 
 
 const replaceFiles = (source, destination) =>
 const replaceFiles = (source, destination) =>
     readdirSync(source, { withFileTypes: true })
     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));
 const sleep = ms => new Promise(r => setTimeout(r, ms));
 
 
 (async () => {
 (async () => {
+    exec('cd ../../src/ && go run main.go');
+
     const browser = await puppeteer.launch({
     const browser = await puppeteer.launch({
         headless: false,
         headless: false,
         defaultViewport: {
         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) {
     for (const theme of themes) {
         replaceFiles(`../../sample/${theme}`, '../../src/data');
         replaceFiles(`../../sample/${theme}`, '../../src/data');
-        exec('cd ../../src/ && go run main.go');
         await sleep(500);
         await sleep(500);
 
 
         const page = await browser.newPage();
         const page = await browser.newPage();
         await page.goto('http://localhost:7001');
         await page.goto('http://localhost:7001');
         await page.waitForNetworkIdle();
         await page.waitForNetworkIdle();
-        await sleep(1000);
+        await sleep(500);
         await page.screenshot({ path: `../../docs/screenshots/${theme}.png` });
         await page.screenshot({ path: `../../docs/screenshots/${theme}.png` });
         await page.close();
         await page.close();
 
 
-        exec('pkill -f go');
-        exec('pkill -f main');
-        await sleep(500);
+        await sleep(1000);
     }
     }
 
 
     browser.close();
     browser.close();