import { PersistedStateOptions } from "pinia-plugin-persistedstate";

/**
 * @description pinia 持久化参数配置
 * @param {String} key 存储到持久化的 name
 * @param {Boolean} islocal 是否永久存储，true,localStorage; false, sessionStorage,关闭标签页时清除。默认：true
 * @param {Array} paths 需要持久化的 state name
 * @return persist
 * */
const piniaPersistConfig = (key: string, islocal: boolean = true, paths?: string[]) => {
  const persist: PersistedStateOptions = {
    key,
    storage: islocal ? localStorage : sessionStorage,
    paths
  };
  return persist;
};

export default piniaPersistConfig;
