From ab367dbf2b5ec41571046c957f24f2fdd9b39aea Mon Sep 17 00:00:00 2001 From: Fine Date: Fri, 16 May 2025 16:14:02 +0800 Subject: [PATCH] refactor --- src/components/DateCalendar.vue | 11 ++++------- src/layout/components/NavBar.vue | 5 ++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/DateCalendar.vue b/src/components/DateCalendar.vue index 6abf6008..293e80a3 100755 --- a/src/components/DateCalendar.vue +++ b/src/components/DateCalendar.vue @@ -376,13 +376,10 @@ limitations under the License. --> flag = tf(props.value, format) === tf(time, format); } classObj[`${state.pre}-date`] = true; - classObj[`${state.pre}-date-disabled`] = - (props.right && (t < start.value || t > maxEnd.value || !props.maxRange?.length)) || - (props.left && t < minStart.value) || - t > end.value || - !props.maxRange?.length || - t > maxEnd.value || - props.disabledDate(time, format); + const rightDisabled = props.right && (t < start.value || t > maxEnd.value || !props.maxRange?.length); + const leftDisabled = + props.left && (t < minStart.value || t > end.value || !props.maxRange?.length || t > maxEnd.value); + classObj[`${state.pre}-date-disabled`] = rightDisabled || leftDisabled || props.disabledDate(time, format); classObj[`${state.pre}-date-on`] = (props.left && t > start.value) || (props.right && t < end.value); classObj[`${state.pre}-date-selected`] = flag; return classObj; diff --git a/src/layout/components/NavBar.vue b/src/layout/components/NavBar.vue index 00e99c41..35e6b53c 100644 --- a/src/layout/components/NavBar.vue +++ b/src/layout/components/NavBar.vue @@ -245,13 +245,16 @@ limitations under the License. --> if (minute === -1 || hour === -1 || day === -1) { return appStore.setMaxRange([]); } + if (!day) { + return appStore.setMaxRange([]); + } const gap = dayToMS(day) + hour * 60 * 60 * 1000 + minute * 60 * 1000; const dates: Date[] = [new Date(new Date().getTime() - gap), new Date()]; appStore.setMaxRange(dates); } function dayToMS(day: number) { - return (day + 1) * 24 * 60 * 60 * 1000; + return day * 24 * 60 * 60 * 1000; } function getNavPaths() {