GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - xiaopingbuxiao/persistence-store

BranchesTags
Open more actions menu

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
dist
dist
 
 
src
src
 
 
.DS_Store
.DS_Store
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
webpack.config.js
webpack.config.js
 
 

Repository files navigation

persistence-store

一个基于 vuex 的数据缓存处理,解决浏览器刷新时,状态管理中数据丢失问题。除阉割掉 modules 之外,其他使用方式和vuex几乎保持一致。

使用

import persistenceStore from 'persistence-store'


Vue.use(persistenceStore, { namespace: 'am' })
const store = persistenceStore.store({
  state: {
    a: 1,
    b: {
      persistence: 'localStorage',
      default: {}
    },
    c: {
      persistence: 'sessionStorage',
      default: {}
    }
  },
  mutations: {
    a(state, payload) {
      console.log(state, payload)
    }
  },
  actions: {
    b(context, payload) {
      console.log(context, payload)
    }
  },
  getters: {
  }
})

new Vue({
  store,
  render: h => h(App)
}).$mount('#app')

namespace为必填参数,persistenceStore.store 接受参数state、mutations、actions、getters。

其中 state中每一项参数如果为对象且对象中包含 persistence 时, persistence 可以支持三种类型 none、localStorage、sessionStorage 。 分别代表不使用缓存,使用 localStorage 和使用 sessionStorage 。如果使用缓存,则刷新浏览器时读取缓存,保留 vuex 中的状态。
mutations、actions、getters 的使用同 vuex 一样。

About

No description, website, or topics provided.

Resources

Readme
MIT license
Activity

Stars

2 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.