/*
 * 一个类似keep-alive的数据缓存功能
 * 比如分页 进入子页面 再返回 还保持原分页
 * 但是类似这种简单的功能 没必要全局做keep-alive
 * 所有用该store进行数据存取来实现
 * */

import { defineStore } from 'pinia'

export const useKeepAliveStore = defineStore('keepAlive', {
  state: () => ({
    keepAlive: {} as Recordable
  }),
  getters: {
    getKeepAlive(): Recordable {
      return this.keepAlive
    }
  },
  actions: {
    setKeepAlive(keepAlive: Recordable) {
      console.log('setKeepAlive', keepAlive)
      this.keepAlive = keepAlive
    }
  }
})
