|
1 | 1 | import feishuSnapshot from './generated/feishu.json' |
2 | 2 |
|
3 | 3 | export type TopicKey = 'kernel' | 'comm' | 'serving' | 'rl' |
| 4 | +export type CalendarStatus = 'tentative' | 'confirmed' | 'cancelled' |
4 | 5 |
|
5 | 6 | export interface Topic { |
6 | 7 | key: TopicKey |
@@ -28,7 +29,27 @@ export interface Session { |
28 | 29 | timeLabel?: string |
29 | 30 | location?: string |
30 | 31 | meetingUrl?: string |
31 | | - calendarStatus?: 'tentative' | 'confirmed' | 'cancelled' |
| 32 | + calendarStatus?: CalendarStatus |
| 33 | +} |
| 34 | + |
| 35 | +export interface CalendarEvent { |
| 36 | + eventId: string |
| 37 | + summary: string |
| 38 | + description?: string |
| 39 | + date: string |
| 40 | + endDate: string |
| 41 | + dateLabel: string |
| 42 | + startAt: string |
| 43 | + endAt: string |
| 44 | + allDay: boolean |
| 45 | + timeLabel: string |
| 46 | + timezone: string |
| 47 | + status: CalendarStatus |
| 48 | + location?: string |
| 49 | + sourceUrl?: string |
| 50 | + meetingUrl?: string |
| 51 | + sessionId?: string |
| 52 | + href?: string |
32 | 53 | } |
33 | 54 |
|
34 | 55 | export const topics: Topic[] = [ |
@@ -286,21 +307,78 @@ const staticSessions: Session[] = [ |
286 | 307 |
|
287 | 308 | interface SyncedSession { |
288 | 309 | calendar?: { |
| 310 | + eventId?: string |
289 | 311 | summary?: string |
290 | 312 | date?: string |
291 | 313 | startAt?: string |
292 | 314 | endAt?: string |
293 | 315 | timeLabel?: string |
294 | 316 | location?: string |
295 | 317 | meetingUrl?: string |
296 | | - status?: 'tentative' | 'confirmed' | 'cancelled' |
| 318 | + status?: CalendarStatus |
297 | 319 | } |
298 | 320 | document?: { |
299 | 321 | wikiNodeToken: string |
300 | 322 | } |
301 | 323 | } |
302 | 324 |
|
303 | | -const syncedSessions = feishuSnapshot.sessions as Record<string, SyncedSession> |
| 325 | +interface SyncedCalendarEvent { |
| 326 | + eventId: string |
| 327 | + summary: string |
| 328 | + description?: string |
| 329 | + date: string |
| 330 | + endDate: string |
| 331 | + startAt: string |
| 332 | + endAt: string |
| 333 | + allDay: boolean |
| 334 | + timeLabel: string |
| 335 | + timezone: string |
| 336 | + status: CalendarStatus |
| 337 | + location?: string |
| 338 | + sourceUrl?: string |
| 339 | + meetingUrl?: string |
| 340 | +} |
| 341 | + |
| 342 | +interface SyncedCalendar { |
| 343 | + timezone: string |
| 344 | + range?: { |
| 345 | + start: string |
| 346 | + end: string |
| 347 | + } |
| 348 | + events: SyncedCalendarEvent[] |
| 349 | +} |
| 350 | + |
| 351 | +interface FeishuSnapshot { |
| 352 | + sessions: Record<string, SyncedSession> |
| 353 | + calendar?: SyncedCalendar |
| 354 | +} |
| 355 | + |
| 356 | +const snapshot = feishuSnapshot as FeishuSnapshot |
| 357 | +const syncedSessions = snapshot.sessions |
| 358 | + |
| 359 | +export const calendarTimezone = |
| 360 | + snapshot.calendar?.timezone || 'Asia/Shanghai' |
| 361 | +export const calendarRange = snapshot.calendar?.range |
| 362 | + |
| 363 | +export const calendarEvents: CalendarEvent[] = ( |
| 364 | + snapshot.calendar?.events ?? [] |
| 365 | +).map((event) => { |
| 366 | + const linkedSession = Object.entries(syncedSessions).find( |
| 367 | + ([, session]) => session.calendar?.eventId === event.eventId |
| 368 | + )?.[0] |
| 369 | + |
| 370 | + return { |
| 371 | + ...event, |
| 372 | + summary: event.summary || '未命名活动', |
| 373 | + dateLabel: event.date.slice(5).replace('-', '.'), |
| 374 | + ...(linkedSession |
| 375 | + ? { |
| 376 | + sessionId: linkedSession, |
| 377 | + href: `/sessions/${linkedSession}` |
| 378 | + } |
| 379 | + : {}) |
| 380 | + } |
| 381 | +}) |
304 | 382 |
|
305 | 383 | export const sessions: Session[] = staticSessions.map((session) => { |
306 | 384 | const synced = syncedSessions[session.id] |
|
0 commit comments