From fb925886c5f7959ad3299ed89b18dbbe75aa34f0 Mon Sep 17 00:00:00 2001 From: chuzhongzai Date: Fri, 29 Dec 2023 15:25:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=AE=9A=E6=97=B6=E5=A4=9C?= =?UTF-8?q?=E9=97=B4=E6=A8=A1=E5=BC=8F;=E6=97=A0=E6=B3=95=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=9C=8B=E6=97=B6=E7=BB=99=E5=87=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA;(=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=96=B0)?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=9D=A2=E6=9D=BF=E4=B8=AD=E7=9A=84=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DashBoard.vue | 75 +++--------------------------------- src/components/Side.vue | 2 - src/store/index.js | 15 ++++---- 3 files changed, 12 insertions(+), 80 deletions(-) diff --git a/src/components/DashBoard.vue b/src/components/DashBoard.vue index e7fd0ad..96ca1da 100644 --- a/src/components/DashBoard.vue +++ b/src/components/DashBoard.vue @@ -22,15 +22,6 @@ 夜间模式
重置任务 -
- - {{thumbnailGallery.shortName}} -
- - - -
@@ -95,13 +86,7 @@
夜间模式
夜间模式跟随系统 -
- 自定义起始时间(精确到分) -
- - ~ - - +
在线预览
@@ -306,64 +291,20 @@ function adjustForStyle(){ let darkConfigStr = localStorage.getItem("darkConfig") if(darkConfigStr !== null) { darkConfig.value = JSON.parse(darkConfigStr) - if (darkConfig.value.followSystem) - if (isSystemDark()) { - dark() - isDark.value = true - } - else { - light() - isDark.value = false - } - - if (darkConfig.value.customTime) - if (isDarkTime(darkConfig.value)) { - dark() - isDark.value = true - } - else { - light() - isDark.value = false - } - - if(isDark.value) + if (darkConfig.value.followSystem && isSystemDark()) dark() else light() }else { light() - darkConfig.value = {'followSystem': false, 'customTime': false} + darkConfig.value = {'followSystem': false} } } function isSystemDark(){ return window.matchMedia('(prefers-color-scheme: dark)').matches } -function isDarkTime(darkConfig){ - let date = new Date() - let startTime = darkConfig.startTime - let endTime = darkConfig.endTime - - if(startTime.hour > endTime.hour){ //隔夜 22:00 ~ 8:00 - if(date.getHours() > endTime.getHours() && date.getHours() < startTime.getHours()){ // 大于结束时间且小于起始时间 16:00 - return false - }else if(date.getHours() === endTime.getHours()){ //22:00 ~ 8:30 8:26 - return date.getMinutes() <= endTime.getMinutes(); - }else if(date.getHours() === startTime.getHours()){ //22:30 ~ 8:00 22:46 - return date.getMinutes() > startTime.getMinutes(); - }else - return true - }else{ //不隔夜 00:00 ~ 6:00 22:00 ~ 23:00 - if(date.getHours() > endTime.getHours() || date.getHours() < startTime.getHours()){ - return false - }else if(date.getHours() === startTime.getHours()){ // 01:30 ~ 06:00 01:32 - return date.getMinutes() >= startTime.getMinutes(); - }else if(date.getHours() === endTime.getHours()){ // 01:30 ~ 06:30 06:35 - return date.getMinutes() <= endTime.getMinutes(); - }else - return true - } -} function dark(){ + isDark.value = true let html = document.querySelector("html") if(!html.classList.contains("dark")) html.classList.add('dark') @@ -376,6 +317,7 @@ function dark(){ } function light(){ + isDark.value = false let html = document.querySelector("html") if(html.classList.contains("dark")) html.classList.remove('dark') @@ -389,13 +331,6 @@ function light(){ } } function saveConfig(){ - if(darkConfig.value.customTime) { - if(darkConfig.value.startTime === undefined || darkConfig.value.endTime === undefined){ - ElMessage("请正确选择起始时间") - return - } - } - if(lengthPerPage.value < 0 || lengthPerPage.value > 30) { ElMessage("分页页数设置错误,范围1~30") lengthPerPage.value = 30 diff --git a/src/components/Side.vue b/src/components/Side.vue index 592c863..fa86272 100644 --- a/src/components/Side.vue +++ b/src/components/Side.vue @@ -117,8 +117,6 @@