UNPKG

@pisell/pisellos

Version:

一个可扩展的前端模块化SDK框架,支持插件系统

89 lines (87 loc) 3.17 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/server/utils/schedule.ts var schedule_exports = {}; __export(schedule_exports, { extractScheduleIdsFromMenus: () => extractScheduleIdsFromMenus, extractTimePointsFromSchedules: () => extractTimePointsFromSchedules }); module.exports = __toCommonJS(schedule_exports); var import_time = require("./time"); function extractScheduleIdsFromMenus(menus) { const scheduleIds = menus.reduce((ids, menu) => { if (menu.schedule && Array.isArray(menu.schedule)) { return [...ids, ...menu.schedule]; } return ids; }, []); return Array.from(new Set(scheduleIds)); } function extractTimePointsFromSchedules(schedules) { const timePointsSet = /* @__PURE__ */ new Set(); for (const schedule of schedules) { switch (schedule.type) { case "standard": if (schedule.start_time) { const startTime = (0, import_time.extractTimeFromDateTime)(schedule.start_time); if (startTime) timePointsSet.add(startTime); } if (schedule.end_time) { const endTime = (0, import_time.extractTimeFromDateTime)(schedule.end_time); if (endTime) timePointsSet.add(endTime); } break; case "time-slots": if (schedule.time_slot && Array.isArray(schedule.time_slot)) { for (const slot of schedule.time_slot) { if (slot.start_time) { timePointsSet.add(slot.start_time); } if (slot.end_time) { timePointsSet.add(slot.end_time); } } } break; case "designation": if (schedule.designation) { const designations = Array.isArray(schedule.designation) ? schedule.designation : [schedule.designation]; for (const des of designations) { if (des.start_time) { timePointsSet.add(des.start_time); } if (des.end_time) { timePointsSet.add(des.end_time); } } } break; default: console.warn(`[ScheduleUtils] 未知的日程类型: ${schedule.type}`); } } const timePoints = Array.from(timePointsSet); return (0, import_time.sortTimePoints)(timePoints); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { extractScheduleIdsFromMenus, extractTimePointsFromSchedules });