refactor: high-cohesion low-coupling cleanup across store and components
ical-io.js: - Import pad2/parseISODate from date.js (remove local duplicates) - Rename ICAL.Time helpers to icalTimeTo* for clarity useCalendar.js: - Delegate addEvent to createEvent() factory - Delegate splitEvent to splitRecurringEvent() pure function - Use cloneEvent() instead of JSON.parse(JSON.stringify()) - Add selectEvent() action (components no longer mutate state.selectedUid directly) Components: - EventList: use selectEvent action + toDate() from date.js - HeaderBar: destructure loadFile at top level (was re-calling useCalendar in handler) - EventDetail: import DOW from weekday.js (was inlining the array) - OccurrenceGrid: use toDate() from date.js
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { useCalendar } from '../composables/useCalendar.js'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const { state, canUndo, canRedo, organize, undo, redo, serialize, markSaved } = useCalendar()
|
||||
const { state, canUndo, canRedo, organize, undo, redo, serialize, markSaved, loadFile } = useCalendar()
|
||||
const fileInput = ref(null)
|
||||
|
||||
function onOrganize() {
|
||||
@@ -19,7 +19,6 @@ function onImport() {
|
||||
function onFilePicked(e) {
|
||||
const file = e.target.files[0]
|
||||
if (!file) return
|
||||
const { loadFile } = useCalendar()
|
||||
loadFile(file).catch((err) => alert('解析失败:' + (err.message || err)))
|
||||
e.target.value = ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user