🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
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
Package version was removed
This package version has been unpublished, mostly likely due to security reasons

pinia-plugin-data

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

unpublished
npmnpm
Version
0.0.10
Version published
Weekly downloads
13
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;
    //在任何地方恢复数据后执行查询是否过期 过期会删除缓存支持异步返回
    onExpire:(store:StateTree):boolean;
    }

}
)

Keywords

pinia-plugin-data

FAQs

Package last updated on 10 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