fix: crypto.randomUUID 在非安全上下文(非HTTPS)下崩溃
新增 src/lib/uuid.js 提供 genUUID(), 优先使用 crypto.randomUUID, 不可用时回退到 getRandomValues 手动拼装 v4 UUID, 最终回退到 Math.random。 原因: crypto.randomUUID() 仅在安全上下文(HTTPS 或 localhost)可用。 当前站点通过 http://f.zikai.wang:8888 访问, 属于非安全上下文, 导致 event-factory.js 的新增日程和 split.js 的拆分事件功能崩溃。 涉及文件: - src/lib/uuid.js (新增): 带 fallback 的 UUID 生成 - src/lib/event-factory.js: crypto.randomUUID -> genUUID - src/lib/split.js: crypto.randomUUID -> genUUID
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
* and cloning so that useCalendar.js stays focused on state management.
|
||||
*/
|
||||
import { todayISO, nowCompactTimestamp } from './date.js'
|
||||
import { genUUID } from './uuid.js'
|
||||
|
||||
/**
|
||||
* Create a new single-occurrence event with sensible defaults.
|
||||
@@ -14,7 +15,7 @@ import { todayISO, nowCompactTimestamp } from './date.js'
|
||||
*/
|
||||
export function createEvent(overrides = {}) {
|
||||
return {
|
||||
uid: crypto.randomUUID(),
|
||||
uid: genUUID(),
|
||||
summary: '新日程',
|
||||
location: '',
|
||||
description: '',
|
||||
|
||||
Reference in New Issue
Block a user