0.0.13 • Published 2 years ago

pinia-plugin-data v0.0.13

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

pinia 数据持久化

数据持久化参照 pinia-plugin-persistedstate


Feature

  1. 自定义存储(加密)
  2. 默认序列化是 JSON,可以自定义
  3. 数据过期策略自定义

快速开始

  1. 安装
    • npm i pinia-plugin-data
  2. 导入
import pinaPluginPersistence from "pinia-plugin-data";
import { createPinia } from "pinia";
import { createApp } from "vue";
const app = createApp(xxx);
const pinaAPP = createPinia();
pinaAPP.use(pinaPluginPersistence);
app.use(pinaAPP);
  1. 在 store 配置
import {defineStore}                                      from "pinia";
defineStore( name, {
    persistence:true|{
        readonly key?: string;
    storage?: StorageLike;
    serializer?: Serializer;
    beforeRestore?: (context: PiniaPluginContext) => void;
    afterRestore?: (context: PiniaPluginContext) => void ;
    // 将当前的store恢复托管 到 center的store上
    slave?: string;
    center?: boolean;
    /**
     * 在任何地方恢复数据后执行查询是否过期 过期会删除缓存支持异步返回
     * 在数据恢复之前执行 注意这个只是state的数据没有 getters和action等属性请不要直接调用getter方法
     */
    onExpire:(store:StateTree):boolean;
    }

}
)
0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago