Browse Source

Поправлен баг

Book Pauk 2 years ago
parent
commit
bc0c9932c8
1 changed files with 6 additions and 1 deletions
  1. 6 1
      client/components/Reader/TextPage/TextPage.vue

+ 6 - 1
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})`;
     }