fix: use JSON clone instead of structuredClone for Vue reactive proxies

structuredClone cannot clone Vue reactive Proxy objects (DataCloneError).
EventModel contains only plain data, so JSON round-trip is safe and
lossless. Verified: organize, toggle, undo, download all work correctly.
This commit is contained in:
timeTable2 dev
2026-07-13 20:13:19 +08:00
parent b352c4e116
commit 51461ff5f2

View File

@@ -30,12 +30,13 @@ export function createEvent(overrides = {}) {
} }
/** /**
* Deep-clone an event via structuredClone (available in modern browsers * Deep-clone an event (or any plain-data object).
* and Node 17+). Falls back to JSON round-trip for older environments. *
* Uses JSON round-trip rather than structuredClone because events may be
* wrapped in Vue reactive proxies, which structuredClone cannot handle.
* EventModel contains only plain data (strings, arrays, nested objects),
* so JSON cloning is safe and lossless here.
*/ */
export function cloneEvent(ev) { export function cloneEvent(ev) {
if (typeof structuredClone === 'function') {
return structuredClone(ev)
}
return JSON.parse(JSON.stringify(ev)) return JSON.parse(JSON.stringify(ev))
} }