Files
----/后端源码/yifan.action-ai.cn/index/js/quickStartManager.B8O8jYqN.js

24 lines
1.6 KiB
JavaScript

var e=Object.defineProperty,t=(t,s,i)=>((t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i)(t,"symbol"!=typeof s?s+"":s,i);import{a as s}from"./element-plus.DhcJM-BD.js";const i=new class{constructor(){t(this,"storageKey","quick-start-links"),t(this,"listeners",[])}
// 获取所有快速链接
getQuickLinks(){try{const e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):this.getDefaultLinks()}catch(e){return this.getDefaultLinks()}}
// 获取默认链接
getDefaultLinks(){return[]}
// 保存快速链接
saveQuickLinks(e){try{localStorage.setItem(this.storageKey,JSON.stringify(e)),this.notifyListeners(e)}catch(t){}}
// 添加快速链接
addQuickLink(e){const t=this.getQuickLinks(),i=t.findIndex(t=>t.href===e.href);-1!==i?(t[i]={...t[i],...e},s.success(`已更新快速链接:${e.title}`)):t.push(e),this.saveQuickLinks(t)}
// 删除快速链接
removeQuickLink(e){const t=this.getQuickLinks(),s=t.filter(t=>t.id!==e);s.length<t.length&&this.saveQuickLinks(s)}
// 清空所有快速链接
clearQuickLinks(){this.saveQuickLinks([])}
// 从路由或菜单信息创建快速链接
createQuickLinkFromRoute(e,t){return{title:t||e.title||e.name||"未命名页面",icon:e.icon,href:e.fullPath||e.path,id:`route-${e.path.replace(/\//g,"-")}-${Date.now()}`}}
// 添加监听器
addListener(e){this.listeners.push(e)}
// 移除监听器
removeListener(e){const t=this.listeners.indexOf(e);t>-1&&this.listeners.splice(t,1)}
// 通知所有监听器
notifyListeners(e){this.listeners.forEach(t=>{try{t(e)}catch(s){}})}
// 检查链接是否已存在
isLinkExists(e){return this.getQuickLinks().some(t=>t.href===e)}};export{i as q};