From 3f38f22f03fd8324da80d0437051a0481b6904d6 Mon Sep 17 00:00:00 2001 From: hujj Date: Wed, 25 Sep 2024 16:49:39 +0800 Subject: [PATCH] feat: 1. Add the archived schedule display switch in the settings fix: 1.Fix the issue where the calendar could not load properly due to language settings --- CHANGELOG.md | 8 +++++++- README.md | 4 ++-- README_zh_CN.md | 6 ++---- i18n/en_US.json | 1 + i18n/zh_CN.json | 1 + plugin.json | 2 +- src/ScheduleCategories.ts | 5 +++++ src/ScheduleManager.ts | 25 ++++++++++++++++++++++--- src/components/Settings.vue | 18 ++++++++++++++++-- src/i18n/en_US.json | 1 + src/i18n/zh_CN.json | 1 + src/utils/utils.ts | 1 + 12 files changed, 60 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1a100c..badd2e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,4 +140,10 @@ ## v1.3.3 ### feat: 1. Merge PR from rishacha (https://github.com/rishacha) -2. 在设置界面中增加日历显示语言的选项,目前支持简体中文和英文 [#47] \ No newline at end of file +2. 在设置界面中增加日历显示语言的选项,目前支持简体中文和英文 [#47] + +## v1.3.4 +### feat: +1. 在设置中增加是否显示已归档日程的选项 +### fix: +1. 修复语言设置导致的日程无法正常加载问题 \ No newline at end of file diff --git a/README.md b/README.md index 3789908..f97853e 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ # Schedule Manager ## Updates -1. Add the lunar calendar display switch in the settings -2. Add a setting for the calendar local +1. Add the archived schedule display switch in the settings +2. Fix the issue where the calendar could not load properly due to language settings Note: Upgrading from version "1.0. x" to version "1.1. x" may require reopening the plugin to update the format of the schedule records diff --git a/README_zh_CN.md b/README_zh_CN.md index 423914d..809ecf1 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -3,10 +3,8 @@ # 日程管理 ## 本次更新 -1. 在设置中增加是否显示农历的选项 -2. 在设置中增加日历显示语言的选项 - -最近事情比较多,先更新比较简单的功能吧,正在研究实现跨平台日程提醒,目前的思路是通过iCal、CalDav、Google Calendar等连接第三方日历应用(比如可以连接手机自带日历),将日程添加到这些日历应用中,不知道大家有没有更好的想法,可以在链滴上发帖子讨论,或者到github上提issue +1. 在设置中增加是否显示已归档日程的选项 +2. 修复语言设置导致的日程无法正常加载问题 ## 简介 日程管理插件通过日历的形式管理待办事项,目前支持月、周、日、列表多种视图。 diff --git a/i18n/en_US.json b/i18n/en_US.json index aa18825..eb0ce26 100644 --- a/i18n/en_US.json +++ b/i18n/en_US.json @@ -58,6 +58,7 @@ "confirmRemove": "Confirm to delete the data in ${name}?", "insertEmoji": "Insert Emoji", "archiveTime": "Archive time", + "showArchivedSchedule": "Show archived shedule", "hasUpdated": "Has updated", "firstDayOfWeek": "First day of week", "gregorianCalendar": "Gregorian calendar", diff --git a/i18n/zh_CN.json b/i18n/zh_CN.json index c09b93b..4af3584 100644 --- a/i18n/zh_CN.json +++ b/i18n/zh_CN.json @@ -58,6 +58,7 @@ "confirmRemove": "确认删除 ${name} 中的数据?", "insertEmoji": "插入表情", "archiveTime": "归档时间", + "showArchivedSchedule": "显示已归档日程", "hasUpdated": "已更新", "firstDayOfWeek": "一周开始", "gregorianCalendar": "公历", diff --git a/plugin.json b/plugin.json index f4c63b9..d182d63 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.3.3", + "version": "1.3.4", "minAppVersion": "2.10.6", "backends": ["all"], "frontends": ["all"], diff --git a/src/ScheduleCategories.ts b/src/ScheduleCategories.ts index df2c67d..00e8142 100644 --- a/src/ScheduleCategories.ts +++ b/src/ScheduleCategories.ts @@ -43,6 +43,11 @@ export class ScheduleCategories { } let content = JSON.parse(elementS.content); + // 判断是否显示已归档日程 + if(globalData.showArchivedSchedule == false && content.status == 4) { + continue; + } + let schedule = null; let isAllDay = (content.isAllDay === undefined || content.isAllDay === null) ? false : content.isAllDay; diff --git a/src/ScheduleManager.ts b/src/ScheduleManager.ts index 553788c..062449e 100644 --- a/src/ScheduleManager.ts +++ b/src/ScheduleManager.ts @@ -87,6 +87,10 @@ export class ScheduleManager { this.setDocumentArchiveTimeProperty(p); }); + EventAggregator.on('updateShowArchivedSchedule', (p: any) => { + this.setDocumentShowArchivedScheduleProperty(p); + }); + EventAggregator.on('updateFirstDayOfWeek', (p: any) => { this.setDocumentFirstDayOfWeekProperty(p); }); @@ -102,7 +106,7 @@ export class ScheduleManager { async createDocumentAndSetAttributes(notebookId: string, docProp: any) { await this.createDocument(notebookId, docProp); - await this.setDocumentProperty(this.docId, docProp.checked, docProp.color, 7, 1, true,1); + await this.setDocumentProperty(this.docId, docProp.checked, docProp.color, 7, true, 1, true, "zh-cn"); let document = { id: this.docId, name: docProp.name, @@ -154,7 +158,8 @@ export class ScheduleManager { }); } - async setDocumentProperty(docId: string, checked: boolean, color: string, archiveTime: number, firstDayOfWeek: number, showLunarCalendar: boolean,userLocale:number) { + async setDocumentProperty(docId: string, checked: boolean, color: string, archiveTime: number, showArchivedSchedule: boolean, firstDayOfWeek: number, + showLunarCalendar: boolean, userLocale:string) { await fetchSyncPost("/api/attr/setBlockAttrs", { "id": docId, "attrs": { @@ -162,9 +167,10 @@ export class ScheduleManager { "custom-color": color, "custom-version": "1.1.0", "custom-archiveTime": archiveTime.toString(), + "custom-showArchivedSchedule": showArchivedSchedule ? "true" : "false", "custom-firstDayOfWeek": firstDayOfWeek.toString(), "custom-showLunarCalendar": showLunarCalendar ? "true" : "false", - "custom-userLocale": userLocale.toString() + "custom-userLocale": userLocale } }).then(response => { @@ -209,6 +215,17 @@ export class ScheduleManager { } } + async setDocumentShowArchivedScheduleProperty(showArchivedSchedule: boolean) { + for(let document of this.documents) { + await fetchSyncPost("/api/attr/setBlockAttrs", { + "id": document.id, + "attrs": { + "custom-showArchivedSchedule": showArchivedSchedule ? "true" : "false" + } + }); + } + } + async setDocumentFirstDayOfWeekProperty(firstDay: number) { for(let document of this.documents) { await fetchSyncPost("/api/attr/setBlockAttrs", { @@ -268,10 +285,12 @@ export class ScheduleManager { doc.checked = response.data["custom-checked"] === "true" ? true : false; doc.color = response.data["custom-color"]; doc.archiveTime = response.data['custom-archiveTime']; + doc.showArchivedSchedule = response.data['custom-showArchivedSchedule'] == "true" ? true : false; doc.firstDayOfWeek = response.data["custom-firstDayOfWeek"]; doc.showLunarCalendar = response.data["custom-showLunarCalendar"] == "true" ? true : false; doc.userLocale = response.data["custom-userLocale"]; globalData.archiveTime = doc.archiveTime === undefined ? 7 : parseInt(doc.archiveTime, 10); + globalData.showArchivedSchedule = doc.showArchivedSchedule; globalData.selectedFirstDayOfWeek = doc.firstDayOfWeek === undefined ? 0 : doc.firstDayOfWeek; globalData.showLunarCalendar = doc.showLunarCalendar; globalData.userLocale = doc.userLocale === undefined ? "zh-cn" : doc.userLocale; diff --git a/src/components/Settings.vue b/src/components/Settings.vue index a7834c4..83476eb 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -18,6 +18,12 @@ + +
{{ showArchivedScheduleText }}
+
+ + + @@ -92,11 +98,12 @@ export default defineComponent({ firstDayOfWeekText: i18n.firstDayOfWeek, dayText: i18n.day, archiveText: i18n.archive, + showArchivedScheduleText: i18n.showArchivedSchedule, showLunarCalendarText: i18n.showLunarCalendar, selectLocaleText: i18n.selectLocale, archiveTime: ref(7), selectedDay: ref(1), - selectedLocale: ref(0), + selectedLocale: ref("zh-cn"), calDavClient: CalDavClient, firstDaysOfWeek: [ @@ -120,7 +127,8 @@ export default defineComponent({ value: "en-us" } ], - + + isShowArchivedSchedule: ref(true), isShowLunarCalendar: ref(true) }; }, @@ -133,6 +141,7 @@ export default defineComponent({ mounted() { this.archiveTime = globalData.archiveTime; + this.isShowArchivedSchedule = globalData.showArchivedSchedule; this.isShowLunarCalendar = globalData.showLunarCalendar; this.selectedLocale = globalData.userLocale; }, @@ -152,6 +161,11 @@ export default defineComponent({ this.globalData.scheduleCategories.archiveSchedules(this.archiveTime); }, + handleUpdateShowArchivedSchedule() { + EventAggregator.emit('updateShowArchivedSchedule', this.isShowArchivedSchedule); + showMessage(i18n.hasUpdated, 6000, "info"); + }, + handleUpdateShowLunarCalendar() { EventAggregator.emit('updateShowLunarCalendar', this.isShowLunarCalendar); showMessage(i18n.hasUpdated, 6000, "info"); diff --git a/src/i18n/en_US.json b/src/i18n/en_US.json index aa18825..eb0ce26 100644 --- a/src/i18n/en_US.json +++ b/src/i18n/en_US.json @@ -58,6 +58,7 @@ "confirmRemove": "Confirm to delete the data in ${name}?", "insertEmoji": "Insert Emoji", "archiveTime": "Archive time", + "showArchivedSchedule": "Show archived shedule", "hasUpdated": "Has updated", "firstDayOfWeek": "First day of week", "gregorianCalendar": "Gregorian calendar", diff --git a/src/i18n/zh_CN.json b/src/i18n/zh_CN.json index c09b93b..4af3584 100644 --- a/src/i18n/zh_CN.json +++ b/src/i18n/zh_CN.json @@ -58,6 +58,7 @@ "confirmRemove": "确认删除 ${name} 中的数据?", "insertEmoji": "插入表情", "archiveTime": "归档时间", + "showArchivedSchedule": "显示已归档日程", "hasUpdated": "已更新", "firstDayOfWeek": "一周开始", "gregorianCalendar": "公历", diff --git a/src/utils/utils.ts b/src/utils/utils.ts index eab96c3..755857c 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -31,6 +31,7 @@ export const globalData = { scheduleStatusLogo: ['☕', '🏃‍♂️', '✅', '📦'], archiveTime: 7, selectedFirstDayOfWeek: 1, + showArchivedSchedule: true, showLunarCalendar: true, userLocale: 'zh-cn' }