fix: WEEKLY 事件的 BYDAY 与 dtstartDate 不一致导致 ICS 输出错误
applyChanges 中 BYDAY 此前取自表单下拉框(默认 'MO'), 与 dtstartDate 的星期可能不一致。expandOccurrences 按 dtstartDate 展开 occurrence, 但序列化的 RRULE 写入表单选择的 BYDAY, 两者不匹配时日历应用会显示 错误的星期。 修复: BYDAY 始终由 dtstartDate 的星期自动推导(bydayFromDate), 下拉框 改为只读展示。确保 RRULE BYDAY 与实际 occurrence 日期始终一致。
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { useCalendar } from '../composables/useCalendar.js'
|
import { useCalendar } from '../composables/useCalendar.js'
|
||||||
import { DOW, DOW_EN } from '../lib/weekday.js'
|
import { DOW, DOW_EN, bydayFromDate } from '../lib/weekday.js'
|
||||||
|
import { toDate } from '../lib/date.js'
|
||||||
import OccurrenceGrid from './OccurrenceGrid.vue'
|
import OccurrenceGrid from './OccurrenceGrid.vue'
|
||||||
|
|
||||||
const { selectedEvent, updateEvent, deleteEvent, splitEvent, toggleOccurrence } = useCalendar()
|
const { selectedEvent, updateEvent, deleteEvent, splitEvent, toggleOccurrence } = useCalendar()
|
||||||
@@ -40,10 +41,16 @@ function applyChanges() {
|
|||||||
dtendTime: form.value.dtend_time,
|
dtendTime: form.value.dtend_time,
|
||||||
}
|
}
|
||||||
if (form.value.is_recurring) {
|
if (form.value.is_recurring) {
|
||||||
|
// BYDAY 必须与 dtstartDate 的星期一致, 否则 ICS 输出的 RRULE BYDAY
|
||||||
|
// 与 expandOccurrences 按 dtstartDate 展开的网格不匹配, 导致日历应用
|
||||||
|
// 显示的日期与应用内网格不一致。
|
||||||
|
const byday = form.value.freq === 'WEEKLY'
|
||||||
|
? bydayFromDate(toDate(ev.dtstartDate))
|
||||||
|
: null
|
||||||
patch.rrule = {
|
patch.rrule = {
|
||||||
freq: form.value.freq,
|
freq: form.value.freq,
|
||||||
interval: Number(form.value.interval) || 1,
|
interval: Number(form.value.interval) || 1,
|
||||||
byday: form.value.freq === 'WEEKLY' ? form.value.byday : null,
|
byday,
|
||||||
untilDate: form.value.until_date || ev.rrule?.untilDate || '',
|
untilDate: form.value.until_date || ev.rrule?.untilDate || '',
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -139,8 +146,8 @@ function onToggleOcc(date) {
|
|||||||
<input type="date" v-model="form.until_date" />
|
<input type="date" v-model="form.until_date" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" v-if="form.freq === 'WEEKLY'">
|
<div class="form-group" v-if="form.freq === 'WEEKLY'">
|
||||||
<label>星期 (BYDAY)</label>
|
<label>星期 (BYDAY, 由开始日期自动确定)</label>
|
||||||
<select v-model="form.byday">
|
<select v-model="form.byday" disabled>
|
||||||
<option v-for="(d, i) in DOW_EN" :key="d" :value="d">
|
<option v-for="(d, i) in DOW_EN" :key="d" :value="d">
|
||||||
{{ DOW[i] }}
|
{{ DOW[i] }}
|
||||||
</option>
|
</option>
|
||||||
|
|||||||
Reference in New Issue
Block a user