export default {
  data() {
    return {
      $key: '',
      $params: {}
    }
  },
  created() {
    const { params, name } = this.$route
    const key = `router:${name}`
    this.$key = key
    if (JSON.stringify(params) !== '{}') {
      sessionStorage.setItem(key, JSON.stringify(params))
      this.$params = params
    } else {
      this.$params = JSON.parse(sessionStorage.getItem(key))
    }
  },
  beforeDestroy() {
    sessionStorage.removeItem(this.$key)
  }
}
