更新记录
1.0(2026-07-05)
第一版 示例项目是uniappx的 有问题联系开发者***
平台兼容性
papil-calendar-s
系统日历日程增删改查 UTS 原生插件,支持 Android / iOS / 鸿蒙 三端。
功能
- 添加日历日程(含提醒、地点、全天事件、每周重复)
- 查询指定时间范围内的日程列表
- 删除指定日程(按事件ID)
- 更新指定日程的标题、描述、地点、时间、提醒
平台支持
| 平台 | 最低版本 | 底层 API |
|---|---|---|
| Android | minSdkVersion 21 | CalendarContract ContentProvider |
| iOS | 12.0+ | EventKit |
| 鸿蒙 Next | — | @ohos.calendarManager |
权限说明
Android
AndroidManifest.xml 已声明 READ_CALENDAR / WRITE_CALENDAR,运行时会自动请求。
iOS
Info.plist 已声明 NSCalendarsUsageDescription / NSCalendarsFullAccessUsageDescription。
鸿蒙
config.json 已声明 ohos.permission.READ_CALENDAR / WRITE_CALENDAR,运行时弹窗授权。
使用方法
import {
calendarAdd,
calendarQuery,
calendarDelete,
calendarUpdate
} from '@/uni_modules/papil-calendar-s'
添加日程
calendarAdd({
title: '团队会议',
description: '季度复盘',
location: '北京会议室A',
startTime: Date.now() + 60 * 60 * 1000, // 1小时后
endTime: Date.now() + 2 * 60 * 60 * 1000, // 2小时后
isAllDay: false,
reminderMinutes: [5, 30], // 提前5分钟和30分钟提醒
weeks: [], // 不重复,[1,3,5] = 每周一三五重复
success: (res) => {
console.log('添加成功,eventId:', res.eventId)
},
fail: (res) => {
console.log('添加失败:', res.message)
}
})
查询日程
calendarQuery({
startTime: Date.now(),
endTime: Date.now() + 30 * 24 * 60 * 60 * 1000, // 未来30天
success: (res) => {
console.log('查询到', res.events.length, '条日程')
res.events.forEach(e => console.log(e.title, e.startTime))
},
fail: (res) => {
console.log('查询失败:', res.message)
}
})
删除日程
calendarDelete({
eventId: '上面添加时返回的ID',
success: (res) => {
console.log('删除成功')
},
fail: (res) => {
console.log('删除失败:', res.message)
}
})
更新日程
calendarUpdate({
eventId: '事件ID',
title: '新标题',
description: '新描述',
startTime: newStartTime,
endTime: newEndTime,
reminderMinutes: [10],
success: (res) => {
console.log('更新成功')
},
fail: (res) => {
console.log('更新失败:', res.message)
}
})
注意事项
- Android 更新:直接使用
ContentResolver.update()修改字段,提醒会先清空再重新添加。 - iOS 更新:通过
eventIdentifier取出事件对象,修改属性后save,效率高。 - 鸿蒙更新:通过
filterById查出事件,修改后调用updateEvent()。 - iOS 重复事件删除:使用
EKSpan.futureEvents,会删除该日程及之后的所有重复实例。 - Android 注意:
eventId为数字字符串(如"42"),来自ContentUris.parseId()。 - iOS 注意:
eventId为 UUID 字符串,来自EKEvent.eventIdentifier。 - 修改
config.json后需重新打自定义基座。

收藏人数:
购买源码授权版(
试用
赞赏(0)
下载 3
赞赏 0
下载 12389171
赞赏 1928
赞赏
京公网安备:11010802035340号