From eba0456d2fd196ed8ebb61cdc2753990842eea70 Mon Sep 17 00:00:00 2001 From: wanghao Date: Mon, 23 Aug 2021 18:58:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E9=BB=98=E8=AE=A4=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E8=BE=93=E5=85=A5=E5=8C=BA=E5=9F=9F=E5=85=89=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/screenshot-server.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/screenshot-server.ts b/src/screenshot-server.ts index 00b9be7..8bbd6a1 100644 --- a/src/screenshot-server.ts +++ b/src/screenshot-server.ts @@ -112,6 +112,8 @@ export async function createScreenshotServer({ port }: { port: number }) { await page.goto(url, { waitUntil: "networkidle", }); + // 添加样式,隐藏光标 + await page.addStyleTag({content: '* {caret-color: transparent !important;}'}) res.end(); } catch (err) { res.status(400); From 3c8342ff2b8c9cfdefdccc9248f039a9777925bc Mon Sep 17 00:00:00 2001 From: wanghao Date: Sat, 11 Sep 2021 00:02:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=89=93?= =?UTF-8?q?=E5=BC=80=E9=A1=B5=E9=9D=A2=E6=97=B6=EF=BC=8C=E4=B9=9F=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E5=8A=A0=E4=B8=8A=E9=9A=90=E8=97=8F=E5=85=89=E6=A0=87?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/screenshot-server.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/screenshot-server.ts b/src/screenshot-server.ts index 8bbd6a1..52e8564 100644 --- a/src/screenshot-server.ts +++ b/src/screenshot-server.ts @@ -4,6 +4,11 @@ import playwright, { Page } from "playwright"; import { PageCreateBody, PageGotoBody, PageScreenshotBody } from "./interface"; import { logger } from "./logger"; +function hideCaret(page: Page) { + // 添加样式,隐藏光标 + return page.addStyleTag({content: '* {caret-color: transparent !important;}'}); +} + export async function createScreenshotServer({ port }: { port: number }) { // 自增 ID let id = 0; @@ -61,6 +66,7 @@ export async function createScreenshotServer({ port }: { port: number }) { await page.goto(url, { waitUntil: "networkidle", }); + await hideCaret(page); logger.timeEnd("page.goto"); res.send({ id: currentID, @@ -112,8 +118,7 @@ export async function createScreenshotServer({ port }: { port: number }) { await page.goto(url, { waitUntil: "networkidle", }); - // 添加样式,隐藏光标 - await page.addStyleTag({content: '* {caret-color: transparent !important;}'}) + await hideCaret(page); res.end(); } catch (err) { res.status(400);