Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Commit 5dec40d

Browse files
committed
feat: scripts update
1 parent ac8ded4 commit 5dec40d

File tree

4 files changed

+12
-43
lines changed

4 files changed

+12
-43
lines changed

engine.bin

5.94 MB
Binary file not shown.

pages/index.vue

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@
33
<div class="flex flex-col bg-[#FAFBFB] rounded-md shadow-lg">
44
<input
55
v-if="selectedType != 'multiple-imgs'"
6-
class="
7-
w-full
8-
p-3
9-
transition-all
10-
ease-linear
11-
delay-75
12-
border-2
13-
rounded-md
14-
outline-none
15-
focus:outline-none focus:border-primary-200 focus:border-dashed
16-
"
6+
class="w-full p-3 transition-all ease-linear delay-75 border-2 rounded-md outline-none focus:outline-none focus:border-primary-200 focus:border-dashed"
177
@keyup.enter="generateScreenshot"
188
placeholder="https://github.com/flowko..."
199
type="url"
@@ -22,18 +12,7 @@
2212

2313
<div class="flex items-center justify-center my-4 space-x-10">
2414
<div
25-
class="
26-
flex flex-col
27-
items-center
28-
justify-center
29-
w-32
30-
h-32
31-
text-center
32-
bg-gray-200
33-
cursor-pointer
34-
rounded-2xl
35-
hover:bg-gray-300
36-
"
15+
class="flex flex-col items-center justify-center w-32 h-32 text-center bg-gray-200 cursor-pointer rounded-2xl hover:bg-gray-300"
3716
:class="{
3817
'border-primary-200 border-dashed border-2 shadow-md ':
3918
selectedType == type.value,
@@ -62,17 +41,7 @@
6241
:key="index"
6342
>
6443
<input
65-
class="
66-
w-full
67-
p-3
68-
transition-all
69-
ease-linear
70-
delay-75
71-
border-2
72-
rounded-md
73-
outline-none
74-
focus:outline-none focus:border-primary-200 focus:border-dashed
75-
"
44+
class="w-full p-3 transition-all ease-linear delay-75 border-2 rounded-md outline-none focus:outline-none focus:border-primary-200 focus:border-dashed"
7645
:placeholder="`URL - ${index}`"
7746
type="url"
7847
v-model="url.url"
@@ -548,7 +517,7 @@
548517
v-if="result && result.url"
549518
:src="result.url"
550519
width="100%"
551-
style="height: 50vh;object-fit: cover;"
520+
style="height: 50vh; object-fit: cover"
552521
/>
553522
</div>
554523
</div>
@@ -597,10 +566,8 @@ export default {
597566
format: "resolution",
598567
landscape: false,
599568
},
600-
script: `//console.log('hello world');`,
601-
style: `/* .test {
602-
color: #000;
603-
} */`,
569+
script: "",
570+
style: "",
604571
urls: [
605572
{
606573
url: null,

server-middleware/capture.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,19 @@ const internalCaptureWebsiteCore = async (input, options, page, browser) => {
344344
);
345345
}
346346

347-
if (options.scripts) {
347+
if (options.scripts && options.scripts.length > 0) {
348348
await Promise.all(
349349
options.scripts.map((script) =>
350350
page.addScriptTag({
351351
[getInjectKey("js", script)]: script,
352352
})
353353
)
354354
);
355+
356+
await page.waitForNavigation();
355357
}
356358

357-
if (options.styles) {
359+
if (options.styles && options.styles.length > 0) {
358360
await Promise.all(
359361
options.styles.map((style) =>
360362
page.addStyleTag({

server-middleware/website-shot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ app.post("/screenshot", async (req, res) => {
5959
const styles = [];
6060
const scripts = [];
6161

62-
if (params.style) {
62+
if (params.style && params.style.length > 0) {
6363
styles.push(params.style);
6464
}
6565

66-
if (params.script) {
66+
if (params.script && params.script.length > 0) {
6767
scripts.push(params.script);
6868
}
6969

0 commit comments

Comments
 (0)