From d784e298127c7525d82800843c6f272f88a52474 Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Wed, 1 Mar 2023 00:48:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20isExternal=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 15c3c68f924f7fed661c2e51f6174bc3715229da --- src/utils/index.ts | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index fee5a09b..72b5b0a1 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -29,19 +29,11 @@ export function removeClass(ele: HTMLElement, cls: string) { } } -export function mix(color1: string, color2: string, weight: number) { - weight = Math.max(Math.min(Number(weight), 1), 0); - const r1 = parseInt(color1.substring(1, 3), 16); - const g1 = parseInt(color1.substring(3, 5), 16); - const b1 = parseInt(color1.substring(5, 7), 16); - const r2 = parseInt(color2.substring(1, 3), 16); - const g2 = parseInt(color2.substring(3, 5), 16); - const b2 = parseInt(color2.substring(5, 7), 16); - const r = Math.round(r1 * (1 - weight) + r2 * weight); - const g = Math.round(g1 * (1 - weight) + g2 * weight); - const b = Math.round(b1 * (1 - weight) + b2 * weight); - const rStr = ('0' + (r || 0).toString(16)).slice(-2); - const gStr = ('0' + (g || 0).toString(16)).slice(-2); - const bStr = ('0' + (b || 0).toString(16)).slice(-2); - return '#' + rStr + gStr + bStr; +/** + * @param {string} path + * @returns {Boolean} + */ +export function isExternal(path: string) { + const isExternal = /^(https?:|http?:|mailto:|tel:)/.test(path); + return isExternal; }