From b514891bc55967304ac324c9bfb84f239315f72c Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Mon, 21 Dec 2020 20:18:36 +0800 Subject: [PATCH] fix: Auto match dark mode --- data/security/index.ts | 5 +++++ src/utils/index.ts | 10 ++++++++-- tsconfig.json | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/data/security/index.ts b/data/security/index.ts index 29b1a08..103e9fb 100644 --- a/data/security/index.ts +++ b/data/security/index.ts @@ -148,6 +148,11 @@ const nav = { desc: 'Web Pentesting Fuzz 字典', url: 'https://github.com/TheKingOfDuck/fuzzDicts', }, + { + name: 'BurpSuitePro', + desc: '免费的BurpSuitePro版本', + url: 'https://github.com/TrojanAZhen/BurpSuitePro-2.1', + }, ] }, { diff --git a/src/utils/index.ts b/src/utils/index.ts index bf46026..c44f157 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -238,6 +238,12 @@ export function imgErrorInRemove(e) { } export function isDark(): boolean { - const isDark = Boolean(Number(window.localStorage.getItem('IS_DARK'))) - return isDark + const storageVal = window.localStorage.getItem('IS_DARK') + const darkMode = window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches + + if (!storageVal && darkMode) { + return darkMode + } + + return Boolean(Number(storageVal)) } diff --git a/tsconfig.json b/tsconfig.json index a4df54f..28cb9f1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "experimentalDecorators": true, "module": "esnext", "moduleResolution": "node", + "resolveJsonModule": true, "importHelpers": true, "target": "es2015", "typeRoots": [ -- GitLab