From fc0e500e9b41b8e5513531e90e470bb81dd7583b Mon Sep 17 00:00:00 2001 From: pumelotea Date: Tue, 21 Jun 2022 19:00:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=B7=9F=E9=9A=8F?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=88=87=E6=8D=A2=E5=A4=9C=E9=97=B4=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global/config.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/global/config.js b/src/global/config.js index 519a128..b74c844 100644 --- a/src/global/config.js +++ b/src/global/config.js @@ -1,11 +1,13 @@ import {ref, watch} from "vue" -import {darkTheme} from "naive-ui" +import {darkTheme,useOsTheme} from "naive-ui" +const isMenuCollapsed = ref(false) +const osTheme = useOsTheme() const theme = ref(null) const isDark = ref(false) - const isDarkTheme = ref(false) + watch(isDarkTheme, val => { if (val) { theme.value = darkTheme @@ -16,7 +18,11 @@ watch(isDarkTheme, val => { } }) -const isMenuCollapsed = ref(false) +watch(osTheme,val=>{ + isDarkTheme.value = val === 'dark' +}) + +isDarkTheme.value = osTheme.value === 'dark' export { isDarkTheme,