1 |
- var l=Object.defineProperty;var n=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;var c=(h,s,e)=>s in h?l(h,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[s]=e,a=(h,s)=>{for(var e in s||(s={}))y.call(s,e)&&c(h,e,s[e]);if(n)for(var e of n(s))u.call(s,e)&&c(h,e,s[e]);return h};var r=(h,s,e)=>(c(h,typeof s!="symbol"?s+"":s,e),e);class f{constructor(s){r(this,"saveKey","searchs");r(this,"initSearch",{form:{},page:{}});r(this,"searchs",{});r(this,"key","");this.key=s,this.searchs=this.parse()}save(){localStorage.setItem(this.saveKey,JSON.stringify(this.searchs))}parse(){let s=a({},o);try{const e=localStorage.getItem(this.saveKey);s=JSON.parse(e)||s}catch(e){}return s}get(s){const e=s||this.key;return this.searchs[e]||(this.searchs[e]=a({},o)),this.searchs[e]}remove(s){return this.searchs&&this.searchs[this.key]&&(s?delete this.searchs[this.key][s]:delete this.searchs[this.key],this.save()),this.searchs}getSearchs(){return this.searchs}removeByKey(s){return console.log("\u771F\u6B63\u7684\u5220",s),delete this.searchs[s],this.save(),this.searchs}removeAll(){return this.searchs={},localStorage.setItem(this.saveKey,JSON.stringify(this.searchs)),this.searchs}removeByRouter(s){var e;this.searchs=this.parse();for(let t in this.searchs)(s===t||s===((e=this.searchs[t])==null?void 0:e.bind))&&(console.log("\u6E05\u9664\u7684\u9875\u9762",t),this.removeByKey(t))}removeByOtherRouter(s){var e;this.searchs=this.parse();for(let t in this.searchs)s===t||s===((e=this.searchs[t])==null?void 0:e.bind)||this.removeByKey(t)}update(s,e,t){this.searchs=this.parse();const i=e||this.key;return this.searchs[i]||(this.searchs[i]=a({},o)),t?this.searchs[i][t]=s:this.searchs[i]=s,this.save(),this.searchs}}const o={form:{},page:{}};export{f as S};
|