var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); import { E as ElMessage } from "./element-plus.CkEW9frc.js"; class QuickStartManager { constructor() { __publicField(this, "storageKey", "quick-start-links"); __publicField(this, "listeners", []); } // 获取所有快速链接 getQuickLinks() { try { const stored = localStorage.getItem(this.storageKey); return stored ? JSON.parse(stored) : this.getDefaultLinks(); } catch (error) { console.error("Failed to load quick links:", error); return this.getDefaultLinks(); } } // 获取默认链接 getDefaultLinks() { return []; } // 保存快速链接 saveQuickLinks(links) { try { localStorage.setItem(this.storageKey, JSON.stringify(links)); this.notifyListeners(links); } catch (error) { console.error("Failed to save quick links:", error); } } // 添加快速链接 addQuickLink(link) { const links = this.getQuickLinks(); const existingIndex = links.findIndex((l) => l.href === link.href); if (existingIndex !== -1) { links[existingIndex] = { ...links[existingIndex], ...link }; ElMessage.success(`已更新快速链接:${link.title}`); } else { links.push(link); } this.saveQuickLinks(links); } // 删除快速链接 removeQuickLink(id) { const links = this.getQuickLinks(); const filteredLinks = links.filter((link) => link.id !== id); if (filteredLinks.length < links.length) { this.saveQuickLinks(filteredLinks); } } // 清空所有快速链接 clearQuickLinks() { this.saveQuickLinks([]); } // 从路由或菜单信息创建快速链接 createQuickLinkFromRoute(route, customTitle) { const finalTitle = customTitle || route.title || route.name || "未命名页面"; return { title: finalTitle, icon: route.icon, href: route.fullPath || route.path, id: `route-${route.path.replace(/\//g, "-")}-${Date.now()}` }; } // 添加监听器 addListener(callback) { this.listeners.push(callback); } // 移除监听器 removeListener(callback) { const index = this.listeners.indexOf(callback); if (index > -1) { this.listeners.splice(index, 1); } } // 通知所有监听器 notifyListeners(links) { this.listeners.forEach((callback) => { try { callback(links); } catch (error) { console.error("Error in quick start listener:", error); } }); } // 检查链接是否已存在 isLinkExists(href) { const links = this.getQuickLinks(); return links.some((link) => link.href === href); } } const quickStartManager = new QuickStartManager(); export { quickStartManager as q };