libf 2 anos atrás
pai
commit
a10c47b7b7

+ 17 - 5
src/components/calendar/CalendarData.js

@@ -253,7 +253,13 @@ function defaultEvents() {
     {
       id: '777',
       calendarId: 'work',
-      title: '离中考还有 ' + diffDays(new TZDate('2023-06-18'), today) + " 天",
+      title: '离中考还有 ' + function(){
+        var x=diffDays(new TZDate(today.getFullYear()+'-06-18'), today)
+        if (x<0) {
+          x=diffDays(new TZDate((today.getFullYear()+1)+'-06-18'), today)
+        }
+        return x;
+      }() + " 天",
       category: 'milestone',
       start: today,
       end: today,
@@ -262,7 +268,13 @@ function defaultEvents() {
     {
       id: '888',
       calendarId: 'work',
-      title: '离高考还有 ' + diffDays(new TZDate('2023-06-7'), today) + " 天",
+      title: '离高考还有 ' + function(){
+        var x=diffDays(new TZDate(today.getFullYear()+'-6-7'), today)
+        if (x<0) {
+          x=diffDays(new TZDate((today.getFullYear()+1)+'-6-7'), today)
+        }
+        return x;
+      }() + " 天",
       category: 'milestone',
       start: today,
       end: today,
@@ -306,9 +318,9 @@ var calendars = [
   {
     id: 'rest',
     name: '休息日',
-    backgroundColor: '#00a9ff',
-    borderColor: '#00a9ff',
-    dragBackgroundColor: '#00a9ff',
+    backgroundColor: '#00e9ef',
+    borderColor: '#00e9ef',
+    dragBackgroundColor: '#00e9ef',
   },
   {
     id: 'maintain',

+ 14 - 0
src/components/calendar/utils.js

@@ -18,6 +18,20 @@ export function addDate(d, step) {
   return date;
 }
 
+export function addMonth(d, step) {
+  const date = clone(d);
+  date.setMonth(d.getMonth() + step);
+
+  return date;
+}
+
+export function addYear(d, step) {
+  const date = clone(d);
+  date.setFullYear(d.getFullYear() + step);
+
+  return date;
+}
+
 export function subtractDate(d, steps) {
   const date = clone(d);
   date.setDate(d.getDate() - steps);