From e816d363a9708d6ea669870eb2bdcd6a165e1cb4 Mon Sep 17 00:00:00 2001 From: roger Date: Wed, 3 Jan 2024 16:42:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E9=87=8D=E5=A4=8D=E6=97=A5=E7=A8=8B?= =?UTF-8?q?=E6=8C=89=E6=9C=88=E3=80=81=E6=8C=89=E5=B9=B4=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E9=80=89=E6=8B=A9=E5=85=B7=E4=BD=93=E7=9A=84?= =?UTF-8?q?=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++- plugin.json | 2 +- src/Schedule.ts | 9 +++- src/ScheduleCategories.ts | 11 +++-- src/ScheduleManager.ts | 4 +- src/ThirdPartyCalendars/CalDav.ts | 13 ++++++ src/components/ScheduleEditor.vue | 74 +++++++++++++++++++++++++------ src/components/Settings.vue | 17 ++++++- 8 files changed, 113 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f662cc..bce0536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,4 +109,8 @@ ## v1.2.6 ### feat: 1. 增加设置标签页,并将一键归档移至该标签页 -2. 支持隐藏日程分类视图 \ No newline at end of file +2. 支持隐藏日程分类视图 + +## v1.2.7 +### fix: +1. 修复重复日程按月、按年时,不能选择具体的天的问题 [#35] \ No newline at end of file diff --git a/plugin.json b/plugin.json index 05c602d..5c71268 100644 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "name": "siyuan-plugin-schedule-manager", "author": "RogerHuHu", "url": "https://github.com/RogerHuHu/siyuan-plugin-schedule-manager", - "version": "1.2.6", + "version": "1.2.7", "minAppVersion": "2.10.6", "backends": ["all"], "frontends": ["all"], diff --git a/src/Schedule.ts b/src/Schedule.ts index abdcdcf..eca6da0 100644 --- a/src/Schedule.ts +++ b/src/Schedule.ts @@ -6,6 +6,8 @@ export class Schedule { isRecurringSchedule: boolean; // 是否为重复性日程 frequency: string; // 重复频率(日、周、月、年) weekdays: string[]; // 如果重复频率为周,则可以选择周几重复 + monthdays: string[]; // 如果重复频率为月,则可以选择当月的哪一天重复 + yeardays: string[]; // 如果重复频率为年,则可以选择当年的哪一天重复 interval: number; // 重复间隔,单位视重复频率 start: string; end: string; @@ -16,8 +18,9 @@ export class Schedule { doneTime: number; constructor(id?: string, title?: string, isAllDay?: boolean, - isRecurringSchedule?: boolean, frequency?: string, weekdays?: string[], interval?: number, - start?: string, end?: string, + isRecurringSchedule?: boolean, frequency?: string, + weekdays?: string[], monthdays?:string[], yeardays?:string[], + interval?: number, start?: string, end?: string, category?: string, refBlockId?:string, content?: string, status?: number) { this.id = id; this.title = title; @@ -25,6 +28,8 @@ export class Schedule { this.isRecurringSchedule = isRecurringSchedule; this.frequency = frequency; this.weekdays = weekdays; + this.monthdays = monthdays; + this.yeardays = yeardays; this.interval = interval; this.start = start; this.end = end; diff --git a/src/ScheduleCategories.ts b/src/ScheduleCategories.ts index 458fda7..32eaeeb 100644 --- a/src/ScheduleCategories.ts +++ b/src/ScheduleCategories.ts @@ -50,13 +50,13 @@ export class ScheduleCategories { if(content.isRecurringSchedule !== null && content.isRecurringSchedule === true) { schedule = new Schedule(content.id, content.title, isAllDay, - true, content.frequency, content.weekdays, content.interval, - content.start, content.end, + true, content.frequency, content.weekdays, content.monthdays, content.yeardays, + content.interval, content.start, content.end, content.category, content.refBlockId, content.content, content.status); schedule.setDoneTime(content.doneTime); } else { schedule = new Schedule(content.id, content.title, isAllDay, - false, '', [], 1, + false, '', [], [], [], 1, content.start, content.end, content.category, content.refBlockId, content.content, content.status); schedule.setDoneTime(content.doneTime); @@ -158,6 +158,7 @@ export class ScheduleCategories { let newEvent = null; if(schedule.isRecurringSchedule) { + console.log("Schedule byyearday: ", schedule.yeardays); newEvent = { id: schedule.id, title: this.getEventName(schedule.title, schedule.status), @@ -166,6 +167,8 @@ export class ScheduleCategories { freq: schedule.frequency, interval: schedule.interval, byweekday: schedule.weekdays, + bymonthday: schedule.monthdays, + byyearday: schedule.yeardays, dtstart: schedule.start, until: schedule.end }, @@ -178,6 +181,8 @@ export class ScheduleCategories { freq: schedule.frequency, interval: schedule.interval, byweekday: schedule.weekdays, + bymonthday: schedule.monthdays, + byyearday: schedule.yeardays, dtstart: schedule.start, until: schedule.end } diff --git a/src/ScheduleManager.ts b/src/ScheduleManager.ts index 2520211..fd7bcbf 100644 --- a/src/ScheduleManager.ts +++ b/src/ScheduleManager.ts @@ -367,8 +367,8 @@ export class ScheduleManager { }) let newSchedule = new Schedule(content.id, content.title, content.isAllDay, - content.isRecurringSchedule, content.frequency, content.weekdays, content.interval, - content.start, content.end, + content.isRecurringSchedule, content.frequency, content.weekdays, content.monthdays, content.yeardays, + content.interval, content.start, content.end, content.extendedProps.category, content.extendedProps.refBlockId, content.extendedProps.content, content.extendedProps.status); //console.log(newSchedule); diff --git a/src/ThirdPartyCalendars/CalDav.ts b/src/ThirdPartyCalendars/CalDav.ts index 4bb889d..9aece7a 100644 --- a/src/ThirdPartyCalendars/CalDav.ts +++ b/src/ThirdPartyCalendars/CalDav.ts @@ -28,8 +28,21 @@ export class CalDavClient { async login() { await this.client.login(); + /* + await this.client.makeCalendar({ + url: 'https://calendar.dingtalk.com/dav/u_oslxrjui/primary/', + props: { + displayname: '工作', + description: '' + } + }); + */ const calendars = await this.client.fetchCalendars(); console.log("=========================calendars==========================="); console.log(calendars); + const calendarObjects = await this.client.fetchCalendarObjects({ + calendar: calendars[0], + }); + console.log(calendarObjects); } } \ No newline at end of file diff --git a/src/components/ScheduleEditor.vue b/src/components/ScheduleEditor.vue index 567fb2b..3cb93f1 100644 --- a/src/components/ScheduleEditor.vue +++ b/src/components/ScheduleEditor.vue @@ -36,10 +36,16 @@
{{ cycleText }}
- + - - + + + + + + + + @@ -199,6 +205,8 @@ export default defineComponent({ isRecurringSchedule: ref(null), scheduleInterval: ref(1), selectedWeekday: ref([]), + selectedMonthday: ref([]), + selectedYearday: ref([]), scheduleStatusList: [ { value: 1, @@ -265,6 +273,8 @@ export default defineComponent({ label: i18n.sunday } ], + monthdays: ref([]), + yeardays: ref([]), selectedFreq: ref(null), selectedEvent: null, }; @@ -280,12 +290,34 @@ export default defineComponent({ }, methods: { + createRecurringDays() { + if(this.selectedFreq === 'monthly') { + this.monthdays = []; + for(let i = 0; i < 31; i++) { + let monthday = { value: i+1, label: (i+1).toString() } + this.monthdays.push(monthday); + } + } + else if(this.selectedFreq === 'yearly') { + this.yeardays = []; + for(let i = 0; i < 366; i++) { + let yearday = { value: i+1, label: (i+1).toString() } + this.yeardays.push(yearday); + } + } + }, + + handleUpdateSelectedFreq() { + this.createRecurringDays(); + }, + newSchedule(param) { if(this.selectedDate !== "" && this.selectedDate === param.startStr) { this.selectedDate = ""; this.selectedScheduleStatus = this.scheduleStatusList[0].value; this.isDeleteButtonVisible = false; this.showEditModal = true; + this.createRecurringDays(); } else { this.selectedDate = param.startStr; } @@ -294,14 +326,14 @@ export default defineComponent({ updateSchedule(param) { if(param.extendedProps.rrule === undefined) { this.updateScheduleInternal(param.id, param.extendedProps.category, param.title.substring(param.title.indexOf(' ') + 1), param.allDay, - false, '', [], 1, + false, '', [], [], [], 1, param.startStr, param.endStr, param.extendedProps.refBlockId, param.extendedProps.content, param.extendedProps.status); } else { this.updateScheduleInternal(param.id, param.extendedProps.category, param.title.substring(param.title.indexOf(' ') + 1), param.allDay, - true, param.extendedProps.rrule.freq, param.extendedProps.rrule.byweekday, param.extendedProps.rrule.interval, - param.extendedProps.rrule.dtstart, param.extendedProps.rrule.until, param.extendedProps.refBlockId, - param.extendedProps.content, param.extendedProps.status); + true, param.extendedProps.rrule.freq, param.extendedProps.rrule.byweekday, param.extendedProps.rrule.bymonthday, + param.extendedProps.rrule.byyearday, param.extendedProps.rrule.interval, param.extendedProps.rrule.dtstart, + param.extendedProps.rrule.until, param.extendedProps.refBlockId, param.extendedProps.content, param.extendedProps.status); } }, @@ -311,13 +343,13 @@ export default defineComponent({ this.sindex = sindex; let schedule = this.globalData.scheduleCategories.categories[cindex].schedules[sindex]; this.updateScheduleInternal(schedule.id, schedule.category, schedule.title, schedule.isAllDay, - schedule.isRecurringSchedule, schedule.frequency, schedule.weekdays, schedule.interval, - schedule.start, schedule.end, + schedule.isRecurringSchedule, schedule.frequency, schedule.weekdays, schedule.monthdays, schedule.yeardays, + schedule.interval, schedule.start, schedule.end, schedule.refBlockId, schedule.content, schedule.status); }, updateScheduleInternal(id, category, title, isAllDay, - isRecurringSchedule, frequency, weekdays, interval, + isRecurringSchedule, frequency, weekdays, monthdays, yeardays, interval, startTime, endTime, refBlockId, content, status) { this.isDeleteButtonVisible = true; this.selectedCategory = category; @@ -343,11 +375,14 @@ export default defineComponent({ this.isRecurringSchedule = isRecurringSchedule; this.selectedFreq = frequency; this.selectedWeekday = weekdays; + this.selectedMonthday = monthdays; + this.selectedYearday = yeardays; this.scheduleInterval = interval; - this.selectedSchedule = new Schedule(id, '', isAllDay, isRecurringSchedule, frequency, weekdays, interval, '', '', category, '', '', 1); + this.selectedSchedule = new Schedule(id, '', isAllDay, isRecurringSchedule, frequency, weekdays, monthdays, yeardays, interval, '', '', category, '', '', 1); this.showEditModal = true; + this.createRecurringDays(); }, handleSubmitSchedule() { @@ -408,9 +443,22 @@ export default defineComponent({ end = format(this.endTime, "yyyy-MM-dd'T'HH:mm:ss"); } + if(this.selectedFreq === 'weekly') { + this.selectedMonthday = []; + this.selectedYearday = []; + } + else if(this.selectedFreq === 'monthly') { + this.selectedWeekday = []; + this.selectedYearday = []; + } + else if(this.selectedFreq === 'yearly') { + this.selectedMonthday = []; + this.selectedWeekday = []; + } + let newSchedule = new Schedule(id, this.scheduleName, this.isAllDaySchedule, - this.isRecurringSchedule, this.selectedFreq, this.selectedWeekday, this.scheduleInterval, - start, end, + this.isRecurringSchedule, this.selectedFreq, this.selectedWeekday, this.selectedMonthday, this.selectedYearday, + this.scheduleInterval, start, end, this.selectedCategory, this.scheduleContentBlockId, this.scheduleContent, this.selectedScheduleStatus ); if(this.selectedScheduleStatus == 3) diff --git a/src/components/Settings.vue b/src/components/Settings.vue index b3f1aea..84d386d 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -21,6 +21,11 @@ + @@ -38,6 +43,7 @@ import { CheckOutlined } from '@vicons/antd' import EventAggregator from "../utils/EventAggregator"; import { showMessage } from "siyuan"; + import { CalDavClient } from "../ThirdPartyCalendars/CalDav"; export default defineComponent({ components: { @@ -51,7 +57,8 @@ export default defineComponent({ dayText: i18n.day, archiveText: i18n.archive, archiveTime: ref(7), - }; + calDavClient: CalDavClient, + }; }, data() { @@ -73,6 +80,14 @@ export default defineComponent({ handleArchive() { this.globalData.scheduleCategories.archiveSchedules(this.archiveTime); }, + + handleTest() { + this.calDavClient = new CalDavClient("https://calendar.dingtalk.com/dav/users/u_oslxrjui", "u_oslxrjui", "ow5kp2zd"); + //this.calDavClient = new CalDavClient("https://dav.qq.com/dav/users/196550051@qq.com", "196550051@qq.com", "ezgcgtzkjkihbiah"); + //this.calDavClient = new CalDavClient("https://caldav.mail.qq.com/", "196550051@qq.com", "dream91722"); + //this.calDavClient = new CalDavClient("https://dida365.com/pub/calendar/feeds/quraph7at8zb/basic.ics", "hujunjie7174@126.com", "hello7109"); + this.calDavClient.login(); + } } }) \ No newline at end of file