| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | /* eslint-disable no-empty */export class Searchs {  saveKey = 'searchs'  initSearch = {    form: {},    page: {},  }  searchs = {}  constructor(key) {    this.key = key    this.searchs = this.parse()  }  save() {    localStorage.setItem(this.saveKey, JSON.stringify(this.searchs))  }  parse() {    let json = {...initSearch}    try {      const val = localStorage.getItem(this.saveKey)      json = JSON.parse(val) || json    } catch (error) {}    return json  }  get(key) {    const k = (key || this.key)    if (!this.searchs[k]) {      this.searchs[k] = {...initSearch}    }    return this.searchs[k]  }  remove(type) {    if (this.searchs && this.searchs[this.key]) {      type ? this.searchs[this.key][type] : this.searchs[this.key]      this.save()    }    return this.searchs  }  getSearchs() {    return this.searchs  }  removeByKey(key) {    delete this.searchs[key]    this.save()    return this.searchs  }  removeAll() {    this.searchs = {}    localStorage.setItem(this.saveKey, JSON.stringify(this.searchs))    return this.searchs  }  update(data, key, type) {    this.searchs = this.parse()    const k = (key || this.key)    if (!this.searchs[k]) {      this.searchs[k] = {...initSearch}    }    if (type) {      this.searchs[k][type] = data    } else {      this.searchs[k] = data    }    this.save()    return this.searchs  }}const initSearch = {  form: {},  page: {},}
 |