Giter VIP home page Giter VIP logo

umbrella's Introduction

umbrella

umbrella of localStorage & sessionStorage between web apps

codecov travis-ci

说明

一个操作localStorage和sessionStorage的插件,避免同一个域名下部署不同前端web app,本地存储使用同样的key导致的冲突问题。

默认会使用域名+路径作为前缀(适用于hashRouter),对于BrowserRouter可以使用自定义前缀配置。

安装

yarn add umbrella-storage

使用

import umbrella from 'umbrella-storage';

umbrella.setLocalStorage('test', 'test');
umbrella.getLocalStorage('test');

umbrella.setSessionStorage('sessionTest', { name: 'test' });
umbrella.getSessionStorage('sessionTest');

API

// 配置自定义前缀
umbrella.config(prefix: string);

// 操作localStorage,value不需要转成字符串,自动帮忙处理
umbrella.setLocalStorage(key, value);
umbrella.getLocalStorage(key);
umbrella.removeLocalStorage(key);

// 操作localStorage,value不需要转成字符串,自动帮忙处理
umbrella.setSessionStorage(key, value);
umbrella.getSessionStorage(key);
umbrella.removeSessionStorage(key);

umbrella's People

Stargazers

 avatar

Watchers

叶子 avatar

Forkers

pyfundation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.