Skip to content

Commit

Permalink
feat: 1. Add the archived schedule display switch in the settings
Browse files Browse the repository at this point in the history
fix: 1.Fix the issue where the calendar could not load properly due to language settings
  • Loading branch information
hujj committed Sep 25, 2024
1 parent fa612bc commit 3f38f22
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 13 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,10 @@
## v1.3.3
### feat:
1. Merge PR from rishacha (https://github.com/rishacha)
2. 在设置界面中增加日历显示语言的选项,目前支持简体中文和英文 [#47]
2. 在设置界面中增加日历显示语言的选项,目前支持简体中文和英文 [#47]

## v1.3.4
### feat:
1. 在设置中增加是否显示已归档日程的选项
### fix:
1. 修复语言设置导致的日程无法正常加载问题
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<b><font color="#dd0000">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</font></b>

Expand Down
6 changes: 2 additions & 4 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
# 日程管理

## 本次更新
1. 在设置中增加是否显示农历的选项
2. 在设置中增加日历显示语言的选项

<b><font color="#4096ff">最近事情比较多,先更新比较简单的功能吧,正在研究实现跨平台日程提醒,目前的思路是通过iCal、CalDav、Google Calendar等连接第三方日历应用(比如可以连接手机自带日历),将日程添加到这些日历应用中,不知道大家有没有更好的想法,可以在链滴上发帖子讨论,或者到github上提issue</font></b>
1. 在设置中增加是否显示已归档日程的选项
2. 修复语言设置导致的日程无法正常加载问题

## 简介
日程管理插件通过日历的形式管理待办事项,目前支持月、周、日、列表多种视图。
Expand Down
1 change: 1 addition & 0 deletions i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"confirmRemove": "确认删除 ${name} 中的数据?",
"insertEmoji": "插入表情",
"archiveTime": "归档时间",
"showArchivedSchedule": "显示已归档日程",
"hasUpdated": "已更新",
"firstDayOfWeek": "一周开始",
"gregorianCalendar": "公历",
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
5 changes: 5 additions & 0 deletions src/ScheduleCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 22 additions & 3 deletions src/ScheduleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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,
Expand Down Expand Up @@ -154,17 +158,19 @@ 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": {
"custom-checked": checked ? "true" : "false",
"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 => {

Expand Down Expand Up @@ -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", {
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 16 additions & 2 deletions src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
</n-button>
</n-space>
</n-gi>
<n-gi :span="6">
<div class="sm-schedule-item-header" style="margin-top: 3px;">{{ showArchivedScheduleText }}</div>
</n-gi>
<n-gi>
<n-switch v-model:value="isShowArchivedSchedule" @update:value="handleUpdateShowArchivedSchedule"/>
</n-gi>
<n-gi :span="8">
<n-divider />
</n-gi>
Expand Down Expand Up @@ -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: [
Expand All @@ -120,7 +127,8 @@ export default defineComponent({
value: "en-us"
}
],
isShowArchivedSchedule: ref(true),
isShowLunarCalendar: ref(true)
};
},
Expand All @@ -133,6 +141,7 @@ export default defineComponent({
mounted() {
this.archiveTime = globalData.archiveTime;
this.isShowArchivedSchedule = globalData.showArchivedSchedule;
this.isShowLunarCalendar = globalData.showLunarCalendar;
this.selectedLocale = globalData.userLocale;
},
Expand All @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"confirmRemove": "确认删除 ${name} 中的数据?",
"insertEmoji": "插入表情",
"archiveTime": "归档时间",
"showArchivedSchedule": "显示已归档日程",
"hasUpdated": "已更新",
"firstDayOfWeek": "一周开始",
"gregorianCalendar": "公历",
Expand Down
1 change: 1 addition & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const globalData = {
scheduleStatusLogo: ['☕', '🏃‍♂️', '✅', '📦'],
archiveTime: 7,
selectedFirstDayOfWeek: 1,
showArchivedSchedule: true,
showLunarCalendar: true,
userLocale: 'zh-cn'
}
Expand Down

0 comments on commit 3f38f22

Please sign in to comment.