From bc0c9932c8110dafe118f46d38a7e1b00ce3828b Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 12 Oct 2022 19:21:48 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/TextPage/TextPage.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index ed475cca..ad1a3a40 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -174,7 +174,12 @@ class TextPage { } hex2rgba(hex, alpha = 1) { - const [r, g, b] = hex.match(/\w\w/g).map(x => parseInt(x, 16)); + let [r, g, b] = [0, 0, 0]; + if (hex.length <= 4) { + [r, g, b] = hex.match(/\w/g).map(x => parseInt(x + x, 16)); + } else { + [r, g, b] = hex.match(/\w\w/g).map(x => parseInt(x, 16)); + } return `rgba(${r},${g},${b},${alpha})`; }