🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

pinia-plugin-data

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pinia-plugin-data

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

latest
npmnpm
Version
0.0.13
Version published
Weekly downloads
17
-15%
Maintainers
1
Weekly downloads
 
Created
Source

pinia 数据持久化

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

Feature

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

快速开始

  • 安装
    • npm i pinia-plugin-data
  • 导入
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);
  • 在 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;
    }

}
)

Keywords

pinia-plugin-data

FAQs

Package last updated on 13 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts