import{cN as b,cO as h,cP as l,cQ as u}from"./index-9PRMimni.js";const f=["Redirect","Login"];function r(s,e){return s.filter(t=>t.fullPath!=e)}function L(s){return s.filter(e=>e?.meta?.affix??!1)}function c(s,e,t=""){const a=[];for(const i of s)(i?.meta?.affix??!1)||a.push(i.fullPath);return e.filter(i=>i.fullPath===t||!a.includes(i.fullPath))}const m=b("app-tabs-view",{state:()=>({tabsList:[],mystore:[],pageFormCache:{}}),persist:{key:"APP-TABS-VIEW"},getters:{getTabList(){return this.tabsList},getMystore(){return this.mystore},getPageFormCache(){return this.pageFormCache}},actions:{saveSearchParams(s,e){const t=this.tabsList.findIndex(a=>a.fullPath===s);t!==-1&&(this.$patch(a=>{a.tabsList[t].searchParams={...e}}),h.set(l,JSON.stringify(this.tabsList)))},getSearchParams(s){const e=h.get(l);let t=[];if(e)try{t=JSON.parse(e)}catch{}return t.find(i=>i.fullPath===s)?.searchParams},delSearchParams(s){const e=this.tabsList.findIndex(t=>t.fullPath===s);e!==-1&&(this.$patch(t=>{delete t.tabsList[e].searchParams}),h.set(l,JSON.stringify(this.tabsList)))},findKeepAliveNames(s){const e=[];return s.forEach(t=>{t.meta?.keepAlive&&e.push(t.name)}),e},delKeepAliveNames(s){const e=u(),t=this.findKeepAliveNames(s);e.removeKeepAliveComponents(t)},initTabs(s){this.tabsList=s},addMystore(s){if(f.includes(s.name))return!1;if(!this.mystore.some(t=>t.path===s.path))this.mystore.push(s);else{const t=this.mystore.findIndex(a=>a.path===s.path);this.mystore.splice(t,1)}},addTabs(s){if(f.includes(s.name))return!1;if(!this.tabsList.some(t=>t.fullPath==s.fullPath))this.tabsList.push(s);else{const t=this.tabsList.findIndex(o=>o.fullPath==s.fullPath),a=this.tabsList[t].pageFormCache||{},i=this.tabsList[t].formCache||{},n=this.tabsList[t].tableCache||{};this.tabsList[t]={...s,formCache:i,tableCache:n,pageFormCache:a}}return!0},closeLeftTabs(s,e){const t=this.tabsList.findIndex(a=>a.fullPath==s.value.fullPath);if(t>0){const a=this.tabsList.slice(0,t),i=r(a,e);this.delKeepAliveNames(i),this.tabsList=c(i,this.tabsList,e)}},closeRightTabs(s,e){const t=this.tabsList.findIndex(a=>a.fullPath==s.value.fullPath);if(t>=0&&t<this.tabsList.length-1){const a=this.tabsList.slice(t+1,this.tabsList.length),i=r(a,e);this.delKeepAliveNames(i),this.tabsList=c(i,this.tabsList,e)}},closeOtherTabs(s,e){const t=this.tabsList.filter(a=>([s.value.fullPath,e].includes(a.fullPath)||a?.meta?.affix)??!1);this.delKeepAliveNames(t),this.tabsList=t},closeCurrentTab(s){const e=this.tabsList.findIndex(t=>t.fullPath==s.value.fullPath);e!=-1&&(this.delKeepAliveNames([this.tabsList[e]]),this.tabsList.splice(e,1))},closeAllTabs(){this.delKeepAliveNames(this.tabsList),this.tabsList=L(this.tabsList)},async setTabTitle(s,e){this.tabsList.forEach(t=>{t.fullPath===e.fullPath&&(t.meta.title=s)}),h.set(l,JSON.stringify(this.tabsList))},async setTabState(s,e){this.tabsList.forEach(t=>{t.fullPath===e.fullPath&&(t.meta={...t.meta,...s})}),h.set(l,JSON.stringify(this.tabsList))}}});export{m as u};
